lean2js

Lean2Js.HelperProof

source

What each runtime helper computes, read off the tree the printer writes #

What each runtime helper computes, read off the tree the printer writes rather than assumed.

The claims are stated at f + k rather than "for all f at least k" because the evaluator spends one fuel per node: an offset reduces where an inequality would have to be transported first. Eventually below turns one into the other.

theorem

Lean2Js.HelperSem.bindEq

source
@[simp]
{α β : Type} (r : Res α) (k : α → Res β) :
r >>= k = r.bind k
Used by
    theorem

    Lean2Js.HelperSem.bind_stuck

    source
    @[simp]
    {α β : Type} (k : α → Res β) :
    Used by
      theorem

      Lean2Js.HelperSem.bind_thrown

      source
      @[simp]
      {α β : Type} (c : String) (k : α → Res β) :
      Used by
        theorem

        Lean2Js.HelperSem.bind_ok

        source
        @[simp]
        {α β : Type} (v : α) (k : α → Res β) :
        (Res.ok v).bind k = k v
        Used by
          def

          Lean2Js.HelperSem.ofRes

          source
          Equations
          Instances For
            Used by
              theorem

              Lean2Js.HelperSem.eventually_of_offset

              source
              {ext : Ext} {name : String} {args : List Val} {r : Res Val} (k : Nat) (h : ∀ (f : Nat), callDef ext (f + k) name args = r) :
              Helper.Calls ext name args r
              Used by
                theorem

                Lean2Js.HelperSem.ofJs_num

                source
                @[simp]
                Used by
                  theorem

                  Lean2Js.HelperSem.ofJs_bigint

                  source
                  @[simp]
                  Used by
                    theorem

                    Lean2Js.HelperSem.ofJs_str

                    source
                    @[simp]
                    Used by
                      theorem

                      Lean2Js.HelperSem.ofJs_bool

                      source
                      @[simp]
                      Used by
                        theorem

                        Lean2Js.HelperSem.ofRes_ok

                        source
                        @[simp]
                        Used by
                          theorem

                          Lean2Js.HelperSem.ofRes_error

                          source
                          @[simp]
                          Used by
                            theorem

                            Lean2Js.HelperSem.applyVal_ext

                            source
                            @[simp]
                            (ext : Ext) (f i : Nat) (args : List Val) :
                            applyVal ext (f + 1) (Val.ext i) args = ext i args

                            Applying a function the caller supplied. walk reduces this rather than applyVal itself, so that a call to a closure — which is what __has hands __all and __find — stays folded until a lemma about that closure is available.

                            Used by
                              theorem

                              Lean2Js.HelperSem.applyVal_lam

                              source
                              (ext : Ext) (f : Nat) (ps : List String) (body : Helper.Expr) (cenv : Env) (args : List Val) (h : ps.length = args.length) :
                              applyVal ext (f + 1) (Val.lam ps body cenv) args = evalExpr ext f (bindAll ps args ++ cenv) body
                              Used by
                                def

                                Lean2Js.HelperSem.tacticWalk

                                source

                                Walks the evaluator down a concrete tree. Everything it unfolds is either the evaluator itself or a table the evaluator consults; nothing about a helper's meaning is in here.

                                Equations
                                Instances For
                                  Used by
                                    theorem

                                    Lean2Js.HelperSem.callDef_expr

                                    source
                                    {ext : Ext} {f : Nat} {name : String} {args : List Val} {d : Helper.Def} {e : Helper.Expr} (hd : List.find? (fun (x : Helper.Def) => x.name == name) Helper.defs = some d) (hb : d.body = Helper.Body.expr e) (hn : d.params.length = args.length) :
                                    callDef ext (f + 1) name args = evalExpr ext f (bindAll d.params args) e
                                    Used by
                                      theorem

                                      Lean2Js.HelperSem.callDef_block

                                      source
                                      {ext : Ext} {f : Nat} {name : String} {args : List Val} {d : Helper.Def} {ss : List Helper.Stmt} (hd : List.find? (fun (x : Helper.Def) => x.name == name) Helper.defs = some d) (hb : d.body = Helper.Body.block ss) (hn : d.params.length = args.length) :
                                      callDef ext (f + 1) name args = match evalStmts ext f (bindAll d.params args) ss with | Res.ok (Outcome.ret v) => Res.ok v | Res.ok v => Res.stuck | Res.thrown c => Res.thrown c | Res.stuck => Res.stuck
                                      Used by

                                        Arithmetic #

                                        Each theorem says what the helper computes, in plain Lean, with no hypothesis about its arguments. Relating that to what JsSem.helper says is a separate step: the model range-checks a quotient the helper does not, and the two meet only on the numbers the generated code can actually produce.

                                        theorem

                                        Lean2Js.HelperSem.find_fail

                                        source
                                        Used by
                                          theorem

                                          Lean2Js.HelperSem.find_i53

                                          source
                                          Used by
                                            theorem

                                            Lean2Js.HelperSem.find_i53div

                                            source
                                            :
                                            Used by
                                              theorem

                                              Lean2Js.HelperSem.find_i53mod

                                              source
                                              :
                                              Used by
                                                theorem

                                                Lean2Js.HelperSem.find_u32mul

                                                source
                                                :
                                                Used by
                                                  theorem

                                                  Lean2Js.HelperSem.find_u32div

                                                  source
                                                  :
                                                  Used by
                                                    theorem

                                                    Lean2Js.HelperSem.find_u32mod

                                                    source
                                                    :
                                                    Used by
                                                      theorem

                                                      Lean2Js.HelperSem.find_bigdiv

                                                      source
                                                      :
                                                      Used by
                                                        theorem

                                                        Lean2Js.HelperSem.find_bigmod

                                                        source
                                                        :
                                                        Used by
                                                          theorem

                                                          Lean2Js.HelperSem.find_abs

                                                          source
                                                          Used by
                                                            theorem

                                                            Lean2Js.HelperSem.find_min

                                                            source
                                                            Used by
                                                              theorem

                                                              Lean2Js.HelperSem.find_max

                                                              source
                                                              Used by
                                                                theorem

                                                                Lean2Js.HelperSem.calls_fail

                                                                source
                                                                (ext : Ext) (code : String) (f : Nat) :
                                                                callDef ext (f + 5) "__fail" [Val.str code] = Res.thrown code
                                                                Used by
                                                                  theorem

                                                                  Lean2Js.HelperSem.calls_i53

                                                                  source
                                                                  (ext : Ext) (a : Int) (f : Nat) :
                                                                  callDef ext (f + 8) "__i53" [Val.num a] = ofRes (Js.Runtime.i53 a)
                                                                  Used by
                                                                    theorem

                                                                    Lean2Js.HelperSem.calls_i53div

                                                                    source
                                                                    (ext : Ext) (a b : Int) (f : Nat) :
                                                                    callDef ext (f + 9) "__i53div" [Val.num a, Val.num b] = if b = 0 then Res.thrown "divByZero" else Res.ok (Val.num (a.tdiv b))
                                                                    Used by
                                                                      theorem

                                                                      Lean2Js.HelperSem.calls_u32div

                                                                      source
                                                                      (ext : Ext) (a b : Int) (f : Nat) :
                                                                      callDef ext (f + 9) "__u32div" [Val.num a, Val.num b] = if b = 0 then Res.thrown "divByZero" else Res.ok (Val.num (Js.Runtime.u32 (a.tdiv b)))
                                                                      Used by
                                                                        theorem

                                                                        Lean2Js.HelperSem.calls_u32mod

                                                                        source
                                                                        (ext : Ext) (a b : Int) (f : Nat) :
                                                                        callDef ext (f + 8) "__u32mod" [Val.num a, Val.num b] = if b = 0 then Res.thrown "divByZero" else Res.ok (Val.num (Js.Runtime.u32 (a.tmod b)))
                                                                        Used by
                                                                          theorem

                                                                          Lean2Js.HelperSem.calls_bigdiv

                                                                          source
                                                                          (ext : Ext) (a b : Int) (f : Nat) :
                                                                          callDef ext (f + 8) "__bigdiv" [Val.bigint a, Val.bigint b] = if b = 0 then Res.thrown "divByZero" else Res.ok (Val.bigint (a.tdiv b))
                                                                          Used by
                                                                            theorem

                                                                            Lean2Js.HelperSem.calls_bigmod

                                                                            source
                                                                            (ext : Ext) (a b : Int) (f : Nat) :
                                                                            callDef ext (f + 8) "__bigmod" [Val.bigint a, Val.bigint b] = if b = 0 then Res.thrown "divByZero" else Res.ok (Val.bigint (a.tmod b))
                                                                            Used by
                                                                              theorem

                                                                              Lean2Js.HelperSem.calls_i53mod

                                                                              source
                                                                              (ext : Ext) (a b : Int) (f : Nat) :
                                                                              callDef ext (f + 12) "__i53mod" [Val.num a, Val.num b] = if b = 0 then Res.thrown "divByZero" else ofRes (Js.Runtime.i53 (a.tmod b))
                                                                              Used by
                                                                                theorem

                                                                                Lean2Js.HelperSem.calls_u32mul

                                                                                source
                                                                                (ext : Ext) (a b : Int) (f : Nat) :
                                                                                callDef ext (f + 6) "__u32mul" [Val.num a, Val.num b] = Res.ok (Val.num (Js.Runtime.u32 (imul a b)))
                                                                                Used by
                                                                                  theorem

                                                                                  Lean2Js.HelperSem.calls_abs_num

                                                                                  source
                                                                                  (ext : Ext) (a : Int) (f : Nat) :
                                                                                  callDef ext (f + 5) "__abs" [Val.num a] = Res.ok (Val.num (if a < 0 then -a else a))
                                                                                  Used by
                                                                                    theorem

                                                                                    Lean2Js.HelperSem.calls_abs_big

                                                                                    source
                                                                                    (ext : Ext) (a : Int) (f : Nat) :
                                                                                    callDef ext (f + 5) "__abs" [Val.bigint a] = Res.ok (Val.bigint (if a < 0 then -a else a))
                                                                                    Used by
                                                                                      theorem

                                                                                      Lean2Js.HelperSem.calls_min_num

                                                                                      source
                                                                                      (ext : Ext) (a b : Int) (f : Nat) :
                                                                                      callDef ext (f + 4) "__min" [Val.num a, Val.num b] = Res.ok (Val.num (if a ≤ b then a else b))
                                                                                      Used by
                                                                                        theorem

                                                                                        Lean2Js.HelperSem.calls_min_big

                                                                                        source
                                                                                        (ext : Ext) (a b : Int) (f : Nat) :
                                                                                        callDef ext (f + 4) "__min" [Val.bigint a, Val.bigint b] = Res.ok (Val.bigint (if a ≤ b then a else b))
                                                                                        Used by
                                                                                          theorem

                                                                                          Lean2Js.HelperSem.calls_max_num

                                                                                          source
                                                                                          (ext : Ext) (a b : Int) (f : Nat) :
                                                                                          callDef ext (f + 4) "__max" [Val.num a, Val.num b] = Res.ok (Val.num (if a ≤ b then b else a))
                                                                                          Used by
                                                                                            theorem

                                                                                            Lean2Js.HelperSem.calls_max_big

                                                                                            source
                                                                                            (ext : Ext) (a b : Int) (f : Nat) :
                                                                                            callDef ext (f + 4) "__max" [Val.bigint a, Val.bigint b] = Res.ok (Val.bigint (if a ≤ b then b else a))
                                                                                            Used by

                                                                                              Strings, arrays and dictionaries without a loop #

                                                                                              theorem

                                                                                              Lean2Js.HelperSem.find_chars

                                                                                              source
                                                                                              :
                                                                                              Used by
                                                                                                theorem

                                                                                                Lean2Js.HelperSem.find_cp

                                                                                                source
                                                                                                Used by
                                                                                                  theorem

                                                                                                  Lean2Js.HelperSem.find_strlen

                                                                                                  source
                                                                                                  :
                                                                                                  Used by
                                                                                                    theorem

                                                                                                    Lean2Js.HelperSem.find_ws

                                                                                                    source
                                                                                                    Used by
                                                                                                      theorem

                                                                                                      Lean2Js.HelperSem.find_startsWith

                                                                                                      source
                                                                                                      :
                                                                                                      Used by
                                                                                                        theorem

                                                                                                        Lean2Js.HelperSem.find_endsWith

                                                                                                        source
                                                                                                        :
                                                                                                        Used by
                                                                                                          theorem

                                                                                                          Lean2Js.HelperSem.find_includes

                                                                                                          source
                                                                                                          :
                                                                                                          Used by
                                                                                                            theorem

                                                                                                            Lean2Js.HelperSem.find_split

                                                                                                            source
                                                                                                            :
                                                                                                            Used by
                                                                                                              theorem

                                                                                                              Lean2Js.HelperSem.find_substring

                                                                                                              source
                                                                                                              :
                                                                                                              Used by
                                                                                                                theorem

                                                                                                                Lean2Js.HelperSem.find_aslice

                                                                                                                source
                                                                                                                :
                                                                                                                Used by
                                                                                                                  theorem

                                                                                                                  Lean2Js.HelperSem.find_atIdx

                                                                                                                  source
                                                                                                                  Used by
                                                                                                                    theorem

                                                                                                                    Lean2Js.HelperSem.find_dget

                                                                                                                    source
                                                                                                                    Used by
                                                                                                                      theorem

                                                                                                                      Lean2Js.HelperSem.find_dhas

                                                                                                                      source
                                                                                                                      Used by
                                                                                                                        theorem

                                                                                                                        Lean2Js.HelperSem.find_dset

                                                                                                                        source
                                                                                                                        Used by
                                                                                                                          theorem

                                                                                                                          Lean2Js.HelperSem.find_dkeys

                                                                                                                          source
                                                                                                                          :
                                                                                                                          Used by
                                                                                                                            theorem

                                                                                                                            Lean2Js.HelperSem.find_dvalues

                                                                                                                            source
                                                                                                                            :
                                                                                                                            Used by
                                                                                                                              theorem

                                                                                                                              Lean2Js.HelperSem.find_isObj

                                                                                                                              source
                                                                                                                              :
                                                                                                                              Used by
                                                                                                                                theorem

                                                                                                                                Lean2Js.HelperSem.calls_chars

                                                                                                                                source
                                                                                                                                (ext : Ext) (x : String) (f : Nat) :
                                                                                                                                callDef ext (f + 5) "__chars" [Val.str x] = Res.ok (Val.arr (List.map (fun (c : Char) => Val.str c.toString) x.toList))
                                                                                                                                Used by
                                                                                                                                  theorem

                                                                                                                                  Lean2Js.HelperSem.calls_cp

                                                                                                                                  source
                                                                                                                                  (ext : Ext) (c : Char) (f : Nat) :
                                                                                                                                  callDef ext (f + 5) "__cp" [Val.str c.toString] = Res.ok (Val.num ↑c.toNat)
                                                                                                                                  Used by
                                                                                                                                    theorem

                                                                                                                                    Lean2Js.HelperSem.find_str

                                                                                                                                    source
                                                                                                                                    Used by
                                                                                                                                      theorem

                                                                                                                                      Lean2Js.HelperSem.calls_str

                                                                                                                                      source
                                                                                                                                      (ext : Ext) (a : Int) (f : Nat) (hlo : Js.Runtime.safeMin ≤ a) (hhi : a ≤ Js.Runtime.safeMax) :
                                                                                                                                      callDef ext (f + 5) "__str" [Val.num a] = Res.ok (Val.str (toString a))
                                                                                                                                      Used by
                                                                                                                                        theorem

                                                                                                                                        Lean2Js.HelperSem.find_toInt

                                                                                                                                        source
                                                                                                                                        :
                                                                                                                                        Used by
                                                                                                                                          theorem

                                                                                                                                          Lean2Js.HelperSem.toInt_loop

                                                                                                                                          source
                                                                                                                                          (ext : Ext) (cs : List Char) (k : Int) (D N X S : Val) (f : Nat) :
                                                                                                                                          evalFor ext (f + cs.length + 11) [("v", Val.bigint k), ("ds", D), ("neg", N), ("xs", X), ("s", S)] "c" (List.map (fun (c : Char) => Val.str c.toString) cs) [Helper.Stmt.setVar "v" (Helper.Expr.bin "+" (Helper.Expr.bin "*" (Helper.Expr.var "v") (Helper.Expr.big 10)) (Helper.Expr.prim "BigInt" [Helper.Expr.bin "-" (Helper.Expr.call "__cp" [Helper.Expr.var "c"]) (Helper.Expr.num 48)]))] = Res.ok (Outcome.next [("v", Val.bigint (List.foldl (fun (acc : Int) (c : Char) => acc * 10 + (↑c.toNat - 48)) k cs)), ("ds", D), ("neg", N), ("xs", X), ("s", S)])
                                                                                                                                          Used by
                                                                                                                                            theorem

                                                                                                                                            Lean2Js.HelperSem.slice1

                                                                                                                                            source
                                                                                                                                            {α β : Type} (g : α → β) (xs : List α) :
                                                                                                                                            List.take (↑xs.length - 1).toNat (List.drop 1 (List.map g xs)) = List.map g (List.drop 1 xs)
                                                                                                                                            Used by
                                                                                                                                              theorem

                                                                                                                                              Lean2Js.HelperSem.calls_toInt

                                                                                                                                              source
                                                                                                                                              (ext : Ext) (x : String) (f : Nat) :
                                                                                                                                              callDef ext (f + x.toList.length + 40) "__toInt" [Val.str x] = Res.ok (match Js.Runtime.strToInt x with | some n => Val.obj [("tag", Val.str "some"), ("value", Val.num n)] | none => Val.obj [("tag", Val.str "none")])
                                                                                                                                              Used by
                                                                                                                                                theorem

                                                                                                                                                Lean2Js.HelperSem.calls_strlen

                                                                                                                                                source
                                                                                                                                                (ext : Ext) (x : String) (f : Nat) :
                                                                                                                                                callDef ext (f + 9) "__strlen" [Val.str x] = Res.ok (Val.num ↑x.toList.length)
                                                                                                                                                Used by
                                                                                                                                                  theorem

                                                                                                                                                  Lean2Js.HelperSem.calls_ws

                                                                                                                                                  source
                                                                                                                                                  (ext : Ext) (x : String) (f : Nat) :
                                                                                                                                                  callDef ext (f + 8) "__ws" [Val.str x] = Res.ok (Val.bool (x == " " || x == "\t" || x == "\n" || x == "\x0d"))
                                                                                                                                                  Used by
                                                                                                                                                    theorem

                                                                                                                                                    Lean2Js.HelperSem.calls_startsWith

                                                                                                                                                    source
                                                                                                                                                    (ext : Ext) (x t : String) (f : Nat) :
                                                                                                                                                    callDef ext (f + 5) "__startsWith" [Val.str x, Val.str t] = Res.ok (Val.bool (t.toList.isPrefixOf x.toList))
                                                                                                                                                    Used by
                                                                                                                                                      theorem

                                                                                                                                                      Lean2Js.HelperSem.calls_endsWith

                                                                                                                                                      source
                                                                                                                                                      (ext : Ext) (x t : String) (f : Nat) :
                                                                                                                                                      Used by
                                                                                                                                                        theorem

                                                                                                                                                        Lean2Js.HelperSem.calls_includes

                                                                                                                                                        source
                                                                                                                                                        (ext : Ext) (x t : String) (f : Nat) :
                                                                                                                                                        Used by
                                                                                                                                                          theorem

                                                                                                                                                          Lean2Js.HelperSem.calls_split

                                                                                                                                                          source
                                                                                                                                                          (ext : Ext) (x sep : String) (f : Nat) :
                                                                                                                                                          callDef ext (f + 6) "__split" [Val.str x, Val.str sep] = Res.ok (Val.arr (List.map Val.str (if sep.isEmpty = true then [x] else x.splitOn sep)))
                                                                                                                                                          Used by
                                                                                                                                                            theorem

                                                                                                                                                            Lean2Js.HelperSem.calls_dhas

                                                                                                                                                            source
                                                                                                                                                            (ext : Ext) (es : List (String × Val)) (key : String) (f : Nat) :
                                                                                                                                                            callDef ext (f + 5) "__dhas" [Val.dict es, Val.str key] = Res.ok (Val.bool (es.any fun (x : String × Val) => x.fst == key))
                                                                                                                                                            Used by
                                                                                                                                                              theorem

                                                                                                                                                              Lean2Js.HelperSem.calls_dkeys

                                                                                                                                                              source
                                                                                                                                                              (ext : Ext) (es : List (String × Val)) (f : Nat) :
                                                                                                                                                              callDef ext (f + 5) "__dkeys" [Val.dict es] = Res.ok (Val.arr (List.map (fun (e : String × Val) => Val.str e.fst) es))
                                                                                                                                                              Used by
                                                                                                                                                                theorem

                                                                                                                                                                Lean2Js.HelperSem.calls_dvalues

                                                                                                                                                                source
                                                                                                                                                                (ext : Ext) (es : List (String × Val)) (f : Nat) :
                                                                                                                                                                callDef ext (f + 5) "__dvalues" [Val.dict es] = Res.ok (Val.arr (List.map (fun (x : String × Val) => x.snd) es))
                                                                                                                                                                Used by
                                                                                                                                                                  theorem

                                                                                                                                                                  Lean2Js.HelperSem.calls_dget

                                                                                                                                                                  source
                                                                                                                                                                  (ext : Ext) (es : List (String × Val)) (key : String) (f : Nat) :
                                                                                                                                                                  callDef ext (f + 10) "__dget" [Val.dict es, Val.str key] = Res.ok (if (es.any fun (x : String × Val) => x.fst == key) = true then Val.obj [("tag", Val.str "some"), ("value", lookupV es key)] else Val.obj [("tag", Val.str "none")])
                                                                                                                                                                  Used by
                                                                                                                                                                    theorem

                                                                                                                                                                    Lean2Js.HelperSem.calls_dset

                                                                                                                                                                    source
                                                                                                                                                                    (ext : Ext) (es : List (String × Val)) (key : String) (v : Val) (f : Nat) :
                                                                                                                                                                    callDef ext (f + 8) "__dset" [Val.dict es, Val.str key, v] = Res.ok (Val.dict (mapSet es key v))
                                                                                                                                                                    Used by
                                                                                                                                                                      theorem

                                                                                                                                                                      Lean2Js.HelperSem.calls_isObj

                                                                                                                                                                      source
                                                                                                                                                                      (ext : Ext) (v : Val) (f : Nat) :
                                                                                                                                                                      callDef ext (f + 8) "__isObj" [v] = Res.ok (Val.bool (match v with | Val.obj fields => true | Val.dict entries => true | x => false))
                                                                                                                                                                      Used by

                                                                                                                                                                        Loops #

                                                                                                                                                                        A loop's fuel is one per element plus a constant, so a claim about a forOf is stated at f + xs.length + k and proved by induction on the list. The environment is written out rather than left generic: restore reads every name the enclosing scope binds, and only a concrete list of names lets it reduce.

                                                                                                                                                                        theorem

                                                                                                                                                                        Lean2Js.HelperSem.find_aconcat

                                                                                                                                                                        source
                                                                                                                                                                        :
                                                                                                                                                                        Used by
                                                                                                                                                                          theorem

                                                                                                                                                                          Lean2Js.HelperSem.find_areverse

                                                                                                                                                                          source
                                                                                                                                                                          :
                                                                                                                                                                          Used by
                                                                                                                                                                            theorem

                                                                                                                                                                            Lean2Js.HelperSem.find_lead

                                                                                                                                                                            source
                                                                                                                                                                            Used by
                                                                                                                                                                              theorem

                                                                                                                                                                              Lean2Js.HelperSem.aconcat_loop

                                                                                                                                                                              source
                                                                                                                                                                              (ext : Ext) (xs acc : List Val) (A B : Val) (f : Nat) :
                                                                                                                                                                              evalFor ext (f + xs.length + 3) [("out", Val.arr acc), ("a", A), ("b", B)] "v" xs [Helper.Stmt.push "out" (Helper.Expr.var "v")] = Res.ok (Outcome.next [("out", Val.arr (acc ++ xs)), ("a", A), ("b", B)])
                                                                                                                                                                              Used by
                                                                                                                                                                                theorem

                                                                                                                                                                                Lean2Js.HelperSem.calls_aconcat

                                                                                                                                                                                source
                                                                                                                                                                                (ext : Ext) (a b : List Val) (f : Nat) :
                                                                                                                                                                                callDef ext (f + a.length + b.length + 8) "__aconcat" [Val.arr a, Val.arr b] = Res.ok (Val.arr (a ++ b))
                                                                                                                                                                                Used by
                                                                                                                                                                                  theorem

                                                                                                                                                                                  Lean2Js.HelperSem.areverse_loop

                                                                                                                                                                                  source
                                                                                                                                                                                  (ext : Ext) (xs ys acc : List Val) (f : Nat) (h : ys.length ≤ xs.length) :

                                                                                                                                                                                  The loop reads xs[i - 1] while iterating over xs itself, so the induction runs on a second list that only carries the count still to go, and ys.length ≤ xs.length is what keeps that index in range.

                                                                                                                                                                                  Used by
                                                                                                                                                                                    theorem

                                                                                                                                                                                    Lean2Js.HelperSem.calls_areverse

                                                                                                                                                                                    source
                                                                                                                                                                                    (ext : Ext) (xs : List Val) (f : Nat) :
                                                                                                                                                                                    callDef ext (f + xs.length + 9) "__areverse" [Val.arr xs] = Res.ok (Val.arr xs.reverse)
                                                                                                                                                                                    Used by
                                                                                                                                                                                      def

                                                                                                                                                                                      Lean2Js.HelperSem.isSpaceStr

                                                                                                                                                                                      source
                                                                                                                                                                                      (s : String) :

                                                                                                                                                                                      The four strings __ws accepts. __lead counts them off the front of an array of strings; that the array is one string per code point is what __chars supplies, and calls_trim is where the two meet.

                                                                                                                                                                                      Equations
                                                                                                                                                                                      Instances For
                                                                                                                                                                                        Used by
                                                                                                                                                                                          theorem

                                                                                                                                                                                          Lean2Js.HelperSem.lead_loop

                                                                                                                                                                                          source
                                                                                                                                                                                          Used by
                                                                                                                                                                                            theorem

                                                                                                                                                                                            Lean2Js.HelperSem.calls_lead

                                                                                                                                                                                            source
                                                                                                                                                                                            (ext : Ext) (ss : List String) (f : Nat) :
                                                                                                                                                                                            Used by
                                                                                                                                                                                              theorem

                                                                                                                                                                                              Lean2Js.HelperSem.compare_singleton

                                                                                                                                                                                              source
                                                                                                                                                                                              (c d : Char) :
                                                                                                                                                                                              Used by
                                                                                                                                                                                                theorem

                                                                                                                                                                                                Lean2Js.HelperSem.cmp_char_ge

                                                                                                                                                                                                source
                                                                                                                                                                                                (c d : Char) :
                                                                                                                                                                                                Used by
                                                                                                                                                                                                  theorem

                                                                                                                                                                                                  Lean2Js.HelperSem.cmp_char_le

                                                                                                                                                                                                  source
                                                                                                                                                                                                  (c d : Char) :
                                                                                                                                                                                                  Used by
                                                                                                                                                                                                    theorem

                                                                                                                                                                                                    Lean2Js.HelperSem.append_ofList_cons

                                                                                                                                                                                                    source
                                                                                                                                                                                                    (a : String) (x : Char) (l : List Char) :
                                                                                                                                                                                                    Used by
                                                                                                                                                                                                      theorem

                                                                                                                                                                                                      Lean2Js.HelperSem.find_upper

                                                                                                                                                                                                      source
                                                                                                                                                                                                      :
                                                                                                                                                                                                      Used by
                                                                                                                                                                                                        theorem

                                                                                                                                                                                                        Lean2Js.HelperSem.upper_loop

                                                                                                                                                                                                        source
                                                                                                                                                                                                        (ext : Ext) (cs : List Char) (acc : String) (S : Val) (f : Nat) :
                                                                                                                                                                                                        evalFor ext (f + cs.length + 6) [("out", Val.str acc), ("s", S)] "c" (List.map (fun (c : Char) => Val.str c.toString) cs) [Helper.Stmt.setVar "out" (Helper.Expr.bin "+" (Helper.Expr.var "out") (((Helper.Expr.bin ">=" (Helper.Expr.var "c") (Helper.Expr.str "a")).andAlso (Helper.Expr.bin "<=" (Helper.Expr.var "c") (Helper.Expr.str "z"))).cond ((Helper.Expr.var "c").method "toUpperCase" []) (Helper.Expr.var "c")))] = Res.ok (Outcome.next [("out", Val.str (acc ++ String.ofList (List.map (fun (c : Char) => if (decide ('a' ≤ c) && decide (c ≤ 'z')) = true then Char.ofNat (c.toNat - 32) else c) cs))), ("s", S)])
                                                                                                                                                                                                        Used by
                                                                                                                                                                                                          theorem

                                                                                                                                                                                                          Lean2Js.HelperSem.calls_upper

                                                                                                                                                                                                          source
                                                                                                                                                                                                          (ext : Ext) (x : String) (f : Nat) :
                                                                                                                                                                                                          Used by
                                                                                                                                                                                                            theorem

                                                                                                                                                                                                            Lean2Js.HelperSem.find_lower

                                                                                                                                                                                                            source
                                                                                                                                                                                                            :
                                                                                                                                                                                                            Used by
                                                                                                                                                                                                              theorem

                                                                                                                                                                                                              Lean2Js.HelperSem.lower_loop

                                                                                                                                                                                                              source
                                                                                                                                                                                                              (ext : Ext) (cs : List Char) (acc : String) (S : Val) (f : Nat) :
                                                                                                                                                                                                              evalFor ext (f + cs.length + 6) [("out", Val.str acc), ("s", S)] "c" (List.map (fun (c : Char) => Val.str c.toString) cs) [Helper.Stmt.setVar "out" (Helper.Expr.bin "+" (Helper.Expr.var "out") (((Helper.Expr.bin ">=" (Helper.Expr.var "c") (Helper.Expr.str "A")).andAlso (Helper.Expr.bin "<=" (Helper.Expr.var "c") (Helper.Expr.str "Z"))).cond ((Helper.Expr.var "c").method "toLowerCase" []) (Helper.Expr.var "c")))] = Res.ok (Outcome.next [("out", Val.str (acc ++ String.ofList (List.map (fun (c : Char) => if (decide ('A' ≤ c) && decide (c ≤ 'Z')) = true then Char.ofNat (c.toNat + 32) else c) cs))), ("s", S)])
                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                Lean2Js.HelperSem.calls_lower

                                                                                                                                                                                                                source
                                                                                                                                                                                                                (ext : Ext) (x : String) (f : Nat) :
                                                                                                                                                                                                                Used by

                                                                                                                                                                                                                  Indices and slices #

                                                                                                                                                                                                                  The guard each of these writes out is what stands between the model's index and slice — both of which have a shape they decline to answer for — and the answer the helper returns.

                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                  Lean2Js.HelperSem.calls_atIdx

                                                                                                                                                                                                                  source
                                                                                                                                                                                                                  (ext : Ext) (xs : List Val) (i : Int) (f : Nat) :
                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_aslice

                                                                                                                                                                                                                    source
                                                                                                                                                                                                                    (ext : Ext) (xs : List Val) (lo hi : Int) (f : Nat) :
                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                      Lean2Js.HelperSem.ofList_cons

                                                                                                                                                                                                                      source
                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                        Lean2Js.HelperSem.joinStrs_chars

                                                                                                                                                                                                                        source
                                                                                                                                                                                                                        (cs : List Char) :
                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                          Lean2Js.HelperSem.calls_substring

                                                                                                                                                                                                                          source
                                                                                                                                                                                                                          (ext : Ext) (x : String) (lo hi : Int) (f : Nat) :
                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                            Lean2Js.HelperSem.find_startsAt

                                                                                                                                                                                                                            source
                                                                                                                                                                                                                            :
                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                              Lean2Js.HelperSem.find_indexOf

                                                                                                                                                                                                                              source
                                                                                                                                                                                                                              :
                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                Lean2Js.HelperSem.find_join

                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                  Lean2Js.HelperSem.calls_startsAt

                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                  (ext : Ext) (cs : List Char) (t : String) (f : Nat) :
                                                                                                                                                                                                                                  callDef ext (f + 8) "__startsAt" [Val.arr (List.map (fun (c : Char) => Val.str c.toString) cs), Val.str t] = Res.ok (Val.bool (t.toList.isPrefixOf cs))
                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                    Lean2Js.HelperSem.scanSteps

                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                    (t : List Char) :

                                                                                                                                                                                                                                    How far the loop in __indexOf walks: to the first position the needle sits at, or off the end.

                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                        Lean2Js.HelperSem.strIndexOfChars_eq

                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                          Lean2Js.HelperSem.dropTake1

                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                          (a : Val) (l : List Val) :
                                                                                                                                                                                                                                          List.take (↑(a :: l).length - 1).toNat (List.drop 1 (a :: l)) = l
                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                            Lean2Js.HelperSem.indexOf_loop

                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                            (ext : Ext) (cs : List Char) (t : String) (k : Int) (X S : Val) (f : Nat) :
                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                              Lean2Js.HelperSem.calls_indexOf

                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                              (ext : Ext) (x t : String) (f : Nat) :
                                                                                                                                                                                                                                              callDef ext (f + x.toList.length + 40) "__indexOf" [Val.str x, Val.str t] = match Js.Runtime.strIndexOfChars x.toList t.toList with | some n => if Js.Runtime.safeMax < ↑n then Res.thrown "int53Overflow" else Res.ok (Val.obj [("tag", Val.str "some"), ("value", Val.num ↑n)]) | none => Res.ok (Val.obj [("tag", Val.str "none")])
                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                Lean2Js.HelperSem.join_loop

                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                (ext : Ext) (ss : List String) (sep acc : String) (XS : Val) (f : Nat) :
                                                                                                                                                                                                                                                evalFor ext (f + ss.length + 6) [("out", Val.str acc), ("xs", XS), ("sep", Val.str sep)] "x" (List.map Val.str ss) [Helper.Stmt.setVar "out" (Helper.Expr.bin "+" (Helper.Expr.bin "+" (Helper.Expr.var "out") (Helper.Expr.var "sep")) (Helper.Expr.var "x"))] = Res.ok (Outcome.next [("out", Val.str (Js.Runtime.strJoinFrom sep acc ss)), ("xs", XS), ("sep", Val.str sep)])
                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                  Lean2Js.HelperSem.calls_join

                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                  (ext : Ext) (ss : List String) (sep : String) (f : Nat) :
                                                                                                                                                                                                                                                  callDef ext (f + ss.length + 20) "__join" [Val.arr (List.map Val.str ss), Val.str sep] = Res.ok (Val.str (Js.Runtime.strJoin ss sep))
                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                    Lean2Js.HelperSem.find_rep

                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                      Lean2Js.HelperSem.find_repeat

                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                      :
                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                        Lean2Js.HelperSem.calls_rep

                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                        (ext : Ext) (s : String) (n : Int) (f : Nat) :
                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                          Lean2Js.HelperSem.find_range

                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                          :
                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                            Lean2Js.HelperSem.range_loop

                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                            (ext : Ext) (xs acc : List Val) (N : Val) (f : Nat) :
                                                                                                                                                                                                                                                            evalFor ext (f + xs.length + 3) [("out", Val.arr acc), ("n", N)] "c" xs [Helper.Stmt.push "out" ((Helper.Expr.var "out").field "length")] = Res.ok (Outcome.next [("out", Val.arr (acc ++ List.map (fun (k : Nat) => Val.num (Int.ofNat k)) (List.range' acc.length xs.length))), ("n", N)])

                                                                                                                                                                                                                                                            The loop keeps no counter of its own: it pushes the length the array has reached, so the element it adds is the index it is at. That is why the induction runs on the accumulator as well as on what is left to walk, and why the numbers start where the accumulator ends rather than at zero.

                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                              Lean2Js.HelperSem.calls_range

                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                              (ext : Ext) (n : Int) (f : Nat) :
                                                                                                                                                                                                                                                              callDef ext (f + 5 * n.toNat + 30) "__range" [Val.num n] = Res.ok (Val.arr (List.map (fun (k : Nat) => Val.num (Int.ofNat k)) (List.range n.toNat)))
                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                Lean2Js.HelperSem.calls_repeat

                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                (ext : Ext) (s : String) (n : Int) (f : Nat) :
                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.strcmp_loop

                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.find_strcmp

                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                    :
                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.calls_strcmp

                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                      (ext : Ext) (x y : String) (f : Nat) :
                                                                                                                                                                                                                                                                      callDef ext (f + x.toList.length + 17) "__strcmp" [Val.str x, Val.str y] = Res.ok (Val.num (Js.Runtime.strcmp x y))
                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                        Deleting a key #

                                                                                                                                                                                                                                                                        The loop is stated as the foldl it runs, with no hypothesis about the dictionary. That it agrees with dropping the key — JsSem's filter — needs the keys to be distinct, which is a fact about the values the generated code hands over rather than about this helper, so it is a separate lemma.

                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.find_ddelete

                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                        :
                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                          def

                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.dropStep

                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                          (es : List (String × Val)) (k : String) (a : List (String × Val)) (key : String) :
                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.ddelete_loop

                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                              (ext : Ext) (es acc : List (String × Val)) (k : String) (ks : List String) (f : Nat) :
                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.calls_ddelete

                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                (ext : Ext) (es : List (String × Val)) (k : String) (f : Nat) :
                                                                                                                                                                                                                                                                                callDef ext (f + es.length + 12) "__ddelete" [Val.dict es, Val.str k] = Res.ok (Val.dict (List.foldl (dropStep es k) [] (List.map (fun (x : String × Val) => x.fst) es)))
                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.ddelete_fold

                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                  (es : List (String × Val)) (k : String) (h : Js.keysDistinct (List.map (fun (x : String × Val) => x.fst) es) = true) :
                                                                                                                                                                                                                                                                                  List.foldl (dropStep es k) [] (List.map (fun (x : String × Val) => x.fst) es) = List.filter (fun (x : String × Val) => x.fst != k) es
                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_ddelete_distinct

                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                    (ext : Ext) (es : List (String × Val)) (k : String) (f : Nat) (h : Js.keysDistinct (List.map (fun (x : String × Val) => x.fst) es) = true) :
                                                                                                                                                                                                                                                                                    callDef ext (f + es.length + 12) "__ddelete" [Val.dict es, Val.str k] = Res.ok (Val.dict (List.filter (fun (x : String × Val) => x.fst != k) es))

                                                                                                                                                                                                                                                                                    What JsSem.helper says, for the dictionaries a Map can actually hold.

                                                                                                                                                                                                                                                                                    Used by

                                                                                                                                                                                                                                                                                      Trimming #

                                                                                                                                                                                                                                                                                      __trim slices between two counts, where strTrim drops from both ends. The two agree, and the only place they could come apart is a string that is whitespace throughout: there the slice is empty because its bounds cross, not because the counts line up, so the proof splits that case off first.

                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.find_trim

                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.calls_lead_chars

                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                        (ext : Ext) (cs : List Char) (f : Nat) :
                                                                                                                                                                                                                                                                                        callDef ext (f + cs.length + 18) "__lead" [Val.arr (List.map (fun (c : Char) => Val.str c.toString) cs)] = Res.ok (Val.num ↑(List.takeWhile Js.Runtime.isSpace cs).length)
                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.calls_trim

                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                          (ext : Ext) (x : String) (f : Nat) :
                                                                                                                                                                                                                                                                                          Used by

                                                                                                                                                                                                                                                                                            Traversals #

                                                                                                                                                                                                                                                                                            The callback is ext, so what these compute is stated as a walk of the list that calls it once per element and stops at the first thrown. That is the shape JsSem's evalMapJs and its siblings already have, which is what lets the two be put side by side.

                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.find_map

                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                              def

                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.extMap

                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                              (ext : Ext) (i : Nat) :
                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.map_loop

                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                  (ext : Ext) (i : Nat) (xs acc : List Val) (X : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                  evalFor ext (f + xs.length + 4) [("out", Val.arr acc), ("xs", X), ("f", Val.ext i)] "v" xs [Helper.Stmt.push "out" ((Helper.Expr.var "f").apply [Helper.Expr.var "v"])] = (extMap ext i xs).bind fun (ys : List Val) => Res.ok (Outcome.next [("out", Val.arr (acc ++ ys)), ("xs", X), ("f", Val.ext i)])
                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_map

                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                    (ext : Ext) (i : Nat) (xs : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                    callDef ext (f + xs.length + 9) "__map" [Val.arr xs, Val.ext i] = (extMap ext i xs).bind fun (ys : List Val) => Res.ok (Val.arr ys)
                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.find_filter

                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                      :
                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.extFilter

                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                        (ext : Ext) (i : Nat) :
                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.filter_loop

                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                            (ext : Ext) (i : Nat) (xs acc : List Val) (X : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                            evalFor ext (f + xs.length + 5) [("out", Val.arr acc), ("xs", X), ("f", Val.ext i)] "v" xs [Helper.Stmt.ifThen ((Helper.Expr.var "f").apply [Helper.Expr.var "v"]) [Helper.Stmt.push "out" (Helper.Expr.var "v")]] = (extFilter ext i xs).bind fun (ys : List Val) => Res.ok (Outcome.next [("out", Val.arr (acc ++ ys)), ("xs", X), ("f", Val.ext i)])
                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.calls_filter

                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                              (ext : Ext) (i : Nat) (xs : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                              callDef ext (f + xs.length + 10) "__filter" [Val.arr xs, Val.ext i] = (extFilter ext i xs).bind fun (ys : List Val) => Res.ok (Val.arr ys)
                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.find_find

                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.find_all

                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.find_any

                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.find_reduce

                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                      :
                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                        Callbacks #

                                                                                                                                                                                                                                                                                                                        __all and __find take a function value. The generated code hands them a function it defined, and __has hands them a closure of its own; the loops below are stated for either, with the fuel a sum over the elements rather than a length, because a closure that recurses does not cost a constant.

                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.valAll

                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                        (P : Val → Res Val) :

                                                                                                                                                                                                                                                                                                                        The walk __all performs: the function value is applied to each element, and the first false stops it. An answer that is not a boolean is a shape the model declines to read.

                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.valFind

                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                            (P : Val → Res Val) :
                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.sumCost

                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                (cost : Val → Nat) :

                                                                                                                                                                                                                                                                                                                                One element's fuel, plus one for the step.

                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.Answers

                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                    (ext : Ext) (F : Val) (P : Val → Res Val) (cost : Val → Nat) (xs : List Val) :

                                                                                                                                                                                                                                                                                                                                    What a loop needs of the function value it was handed: on the elements it will actually see, past its cost there, applying it answers P. An inequality rather than an offset, because the loop applies it with whatever fuel it has left; restricted to the list because the closure __has builds only answers for values smaller than the one it was called on.

                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.extAll

                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                        (ext : Ext) (i : Nat) :
                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.extFind

                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (i : Nat) :
                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.answers_ext

                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                (ext : Ext) (i : Nat) (xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                Answers ext (Val.ext i) (fun (v : Val) => ext i [v]) (fun (x : Val) => 0) xs
                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.sumCost_zero

                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                  (xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                  sumCost (fun (x : Val) => 0) xs = xs.length
                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.find_loop

                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                    (ext : Ext) (F : Val) (P : Val → Res Val) (cost : Val → Nat) (X : Val) (xs : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                    Answers ext F P cost xs → evalFor ext (f + sumCost cost xs + 6) [("xs", X), ("f", F)] "v" xs [Helper.Stmt.ifThen ((Helper.Expr.var "f").apply [Helper.Expr.var "v"]) [Helper.Stmt.ret (Helper.Expr.objLit [("tag", Helper.Expr.str "some"), ("value", Helper.Expr.var "v")])]] = (valFind P xs).bind fun (r : Option Val) => match r with | some v => Res.ok (Outcome.ret (Val.obj [("tag", Val.str "some"), ("value", v)])) | none => Res.ok (Outcome.next [("xs", X), ("f", F)])
                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.all_loop

                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                      (ext : Ext) (F : Val) (P : Val → Res Val) (cost : Val → Nat) (X : Val) (xs : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.calls_find_gen

                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                        (ext : Ext) (F : Val) (P : Val → Res Val) (cost : Val → Nat) (xs : List Val) (hF : Answers ext F P cost xs) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                        callDef ext (f + sumCost cost xs + 8) "__find" [Val.arr xs, F] = (valFind P xs).bind fun (r : Option Val) => Res.ok (match r with | some v => Val.obj [("tag", Val.str "some"), ("value", v)] | none => Val.obj [("tag", Val.str "none")])
                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.calls_all_gen

                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                          (ext : Ext) (F : Val) (P : Val → Res Val) (cost : Val → Nat) (xs : List Val) (hF : Answers ext F P cost xs) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                          callDef ext (f + sumCost cost xs + 8) "__all" [Val.arr xs, F] = (valAll P xs).bind fun (r : Bool) => Res.ok (Val.bool r)
                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.calls_find

                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (i : Nat) (xs : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                            callDef ext (f + xs.length + 8) "__find" [Val.arr xs, Val.ext i] = (extFind ext i xs).bind fun (r : Option Val) => Res.ok (match r with | some v => Val.obj [("tag", Val.str "some"), ("value", v)] | none => Val.obj [("tag", Val.str "none")])
                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.calls_all

                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                              (ext : Ext) (i : Nat) (xs : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                              callDef ext (f + xs.length + 8) "__all" [Val.arr xs, Val.ext i] = (extAll ext i xs).bind fun (r : Bool) => Res.ok (Val.bool r)
                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.extAny

                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                (ext : Ext) (i : Nat) :
                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.any_loop

                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                    (ext : Ext) (i : Nat) (xs : List Val) (X : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.calls_any

                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                      (ext : Ext) (i : Nat) (xs : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                      callDef ext (f + xs.length + 8) "__any" [Val.arr xs, Val.ext i] = (extAny ext i xs).bind fun (r : Bool) => Res.ok (Val.bool r)
                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.extReduce

                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                        (ext : Ext) (i : Nat) :
                                                                                                                                                                                                                                                                                                                                                                        Val → List Val → Res Val
                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.reduce_loop

                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (i : Nat) (xs : List Val) (a X I : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                            evalFor ext (f + xs.length + 5) [("acc", a), ("xs", X), ("init", I), ("f", Val.ext i)] "v" xs [Helper.Stmt.setVar "acc" ((Helper.Expr.var "f").apply [Helper.Expr.var "acc", Helper.Expr.var "v"])] = (extReduce ext i a xs).bind fun (r : Val) => Res.ok (Outcome.next [("acc", r), ("xs", X), ("init", I), ("f", Val.ext i)])
                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.calls_reduce

                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                              (ext : Ext) (i : Nat) (xs : List Val) (a : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                              callDef ext (f + xs.length + 8) "__reduce" [Val.arr xs, a, Val.ext i] = (extReduce ext i a xs).bind fun (r : Val) => Res.ok r
                                                                                                                                                                                                                                                                                                                                                                              Used by

                                                                                                                                                                                                                                                                                                                                                                                The sort #

                                                                                                                                                                                                                                                                                                                                                                                __sortBy pairs every element with its key, orders the pairs and reads the elements back out, so the three helpers under it are proved in that order: the comparison of two keys, the merge of two ordered runs, and the split that feeds it.

                                                                                                                                                                                                                                                                                                                                                                                Compares is what keeps a call away from the one case __keyle has no answer for. A number and a string compared together would reach __strcmp on a number; the key type the compiler insists on is what says the keys of one call are all numbers or all strings, and this is where that arrives.

                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.find_keyle

                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                :
                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.find_merge

                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                  :
                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.find_msort

                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                    :
                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.find_sortBy

                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                      :
                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.valLe

                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                        :
                                                                                                                                                                                                                                                                                                                                                                                        Val → Val → Bool

                                                                                                                                                                                                                                                                                                                                                                                        The order __keyle puts two keys in.

                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.compare_ne_gt

                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                            (a b : Int) :
                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.compare_strcmp

                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.calls_keyle_num

                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                (ext : Ext) (a b : Int) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                callDef ext (f + 5) "__keyle" [Val.num a, Val.num b] = Res.ok (Val.bool (valLe (Val.num a) (Val.num b)))
                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.calls_keyle_str

                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                  (ext : Ext) (x y : String) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                  callDef ext (f + x.toList.length + 22) "__keyle" [Val.str x, Val.str y] = Res.ok (Val.bool (valLe (Val.str x) (Val.str y)))
                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.keyOf

                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                    :
                                                                                                                                                                                                                                                                                                                                                                                                    Val → Val

                                                                                                                                                                                                                                                                                                                                                                                                    The key a pair carries. __sortBy builds every pair, so the shape is always [key, element].

                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.pairLe

                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                        (a b : Val) :
                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.Compares

                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (kcost : Nat) (vs : List Val) :

                                                                                                                                                                                                                                                                                                                                                                                                            What __merge and __msort need of the pairs they are handed: past a cost of its own, __keyle answers valLe on any two of their keys.

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

                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.mergeCost

                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                (kcost : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.IsPair

                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                    (v : Val) :

                                                                                                                                                                                                                                                                                                                                                                                                                    Every value the sort moves is a pair __sortBy built.

                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.index_pair

                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                        {v : Val} (h : IsPair v) :
                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.index_get

                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                          {vs : List Val} {i : Nat} (h : i < vs.length) :
                                                                                                                                                                                                                                                                                                                                                                                                                          index (Val.arr vs) (Val.num ↑i) = Res.ok vs[i]
                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.compare_nat_lt

                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                            {a b : Nat} (h : a < b) :
                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.compare_nat_self

                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                              (a : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.at_nat

                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                {vs : List Val} {i : Nat} (h : i < vs.length) :
                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.merge_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                  (ext : Ext) (kcost : Nat) (xs ys : List Val) (hpair : ∀ (v : Val), v ∈ xs ++ ys → IsPair v) (hcmp : Compares ext kcost (xs ++ ys)) (loop : List Val) (i j : Nat) (acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                  loop.length = xs.length - i + (ys.length - j) → i ≤ xs.length → j ≤ ys.length → evalFor ext (f + mergeCost kcost loop) [("j", Val.num ↑j), ("i", Val.num ↑i), ("out", Val.arr acc), ("xs", Val.arr xs), ("ys", Val.arr ys)] "_pair" loop Helper.mergeBody = Res.ok (Outcome.next [("j", Val.num ↑ys.length), ("i", Val.num ↑xs.length), ("out", Val.arr (acc ++ (List.drop i xs).merge (List.drop j ys) pairLe)), ("xs", Val.arr xs), ("ys", Val.arr ys)])
                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_merge

                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                    (ext : Ext) (kcost : Nat) (xs ys : List Val) (hpair : ∀ (v : Val), v ∈ xs ++ ys → IsPair v) (hcmp : Compares ext kcost (xs ++ ys)) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                    callDef ext (f + xs.length + ys.length + mergeCost kcost (xs ++ ys) + 20) "__merge" [Val.arr xs, Val.arr ys] = Res.ok (Val.arr (xs.merge ys pairLe))
                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.compare_gt_one

                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                      {n : Nat} (h : 2 ≤ n) :
                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.half_cast

                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                        (n : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                        (↑n + 1).tdiv 2 = ↑((n + 1) / 2)
                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.mergeSort_split

                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                          {α : Type} {le : α → α → Bool} {l : List α} (h : 2 ≤ l.length) :
                                                                                                                                                                                                                                                                                                                                                                                                                                          l.mergeSort le = ((List.take ((l.length + 1) / 2) l).mergeSort le).merge ((List.drop ((l.length + 1) / 2) l).mergeSort le) le
                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.calls_msort_small

                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (xs : List Val) (h : xs.length ≤ 1) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                            callDef ext (f + 5) "__msort" [Val.arr xs] = Res.ok (Val.arr (xs.mergeSort pairLe))
                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.calls_msort

                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                              (ext : Ext) (kcost n : Nat) (xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                              xs.length ≤ n → (∀ (v : Val), v ∈ xs → IsPair v) → Compares ext kcost xs → ∃ (c : Nat), ∀ (f : Nat), callDef ext (f + c) "__msort" [Val.arr xs] = Res.ok (Val.arr (xs.mergeSort pairLe))
                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.elemOf

                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                :
                                                                                                                                                                                                                                                                                                                                                                                                                                                Val → Val
                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.pairsOf

                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                    :

                                                                                                                                                                                                                                                                                                                                                                                                                                                    The pairs __sortBy builds: each key in front of the element it was worked out from.

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.mem_pairsOf

                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                        {ks xs : List Val} {v : Val} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                        v ∈ pairsOf ks xs → ∃ (k : Val), k ∈ ks ∧ ∃ (x : Val), v = Val.arr [k, x]
                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.isPair_pairsOf

                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                          {ks xs : List Val} {v : Val} (h : v ∈ pairsOf ks xs) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.elemOf_pairsOf

                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                            (ks xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                            ks.length = xs.length → List.map elemOf (pairsOf ks xs) = xs
                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.pairs_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                              (ext : Ext) (i : Nat) (xs acc : List Val) (X : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                              evalFor ext (f + xs.length + 6) [("pairs", Val.arr acc), ("xs", X), ("f", Val.ext i)] "v" xs [Helper.Stmt.push "pairs" (Helper.Expr.arrayLit [(Helper.Expr.var "f").apply [Helper.Expr.var "v"], Helper.Expr.var "v"])] = (extMap ext i xs).bind fun (ks : List Val) => Res.ok (Outcome.next [("pairs", Val.arr (acc ++ pairsOf ks xs)), ("xs", X), ("f", Val.ext i)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.elems_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                (ext : Ext) (S P X F : Val) (ps acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                (∀ (v : Val), v ∈ ps → IsPair v) → evalFor ext (f + ps.length + 4) [("out", Val.arr acc), ("sorted", S), ("pairs", P), ("xs", X), ("f", F)] "pr" ps [Helper.Stmt.push "out" ((Helper.Expr.var "pr").index (Helper.Expr.num 1))] = Res.ok (Outcome.next [("out", Val.arr (acc ++ List.map elemOf ps)), ("sorted", S), ("pairs", P), ("xs", X), ("f", F)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.isNumV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Val → Bool
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.isStrV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Val → Bool
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.strLens

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          One cost for every comparison of one call, taken over all the keys at once: __strcmp walks the left string, and a bound that holds of each key separately is what the loop needs.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.strLens_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {keys : List Val} {s : String} (h : Val.str s ∈ keys) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.compares_num

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (ext : Ext) {ks xs : List Val} (h : ∀ (k : Val), k ∈ ks → isNumV k = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Compares ext 5 (pairsOf ks xs)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.compares_str

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (ext : Ext) {ks xs : List Val} (h : ∀ (k : Val), k ∈ ks → isStrV k = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Compares ext (strLens ks + 22) (pairsOf ks xs)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_sortBy

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (ext : Ext) (i : Nat) (xs ks : List Val) (hks : extMap ext i xs = Res.ok ks) (hhomo : (∀ (k : Val), k ∈ ks → isNumV k = true) ∨ ∀ (k : Val), k ∈ ks → isStrV k = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.pairsOf_eq_zip

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (ks xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      pairsOf ks xs = List.map (fun (p : Val × Val) => Val.arr [p.fst, p.snd]) (ks.zip xs)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.sortBy_answer

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (ks xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        List.map elemOf ((pairsOf ks xs).mergeSort pairLe) = List.map (fun (x : Val × Val) => x.snd) ((ks.zip xs).mergeSort fun (a b : Val × Val) => valLe a.fst b.fst)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        What __sortBy answers, read in the shape the model of the generated code assumes: the pairs of key and element, ordered by key, with the elements read back out.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.valLe_ofJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (a b : Js.JsValue) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          valLe (ofJs a) (ofJs b) = Js.keyLe a b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          The order the helpers put two keys in is the order JsSem assumes. Stated for every pair of values rather than for the keys of one call: neither side orders anything but two numbers or two strings.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Structural equality #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            __eq decides a notion of its own, stated below as eqVal, not JsValue.beq. Two divergences, both real and both about values the compiler can produce:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • objects are walked key by key with Object.hasOwn, so {a:1,b:2} and {b:2,a:1} are equal here and unequal under beq, which compares the field lists in order;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • functions never reach the structural path — typeof says "function", not "object" — so the helper answers false where beq compares the names.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Dictionaries, unlike objects, are compared positionally: the loop checks __dkeys(b)[i] against the key it is on. Both walks look their values up by key in both operands, so the recursion is on lookupV, which is not structurally smaller — hence the well-founded definitions, and the fuel a call needs is a function of the values rather than a constant.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.sizeOf_lookupV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (es : List (String × Val)) (k : String) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.sizeOf_lookupV_pair

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (es fs : List (String × Val)) (k : String) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              sizeOf (lookupV es k) + sizeOf (lookupV fs k) < 1 + sizeOf es + (1 + sizeOf fs)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.eqVal

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Val → Val → Bool
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.eqList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    List Val → List Val → Bool
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.eqKeys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (es fs : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.eqObj

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (es fs : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.eqFuel

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Val → Val → Nat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.eqFuelList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    List Val → List Val → Nat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.eqFuelKeys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (es fs : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.eq_dict_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.eq_arr_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (ext : Ext) (A : Val) (xs ys pre : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              xs.length = ys.length → (∀ (x : Val), x ∈ xs → ∀ (y : Val), y ∈ ys → ∀ (g : Nat), callDef ext (g + eqFuel x y) "__eq" [x, y] = Res.ok (Val.bool (eqVal x y))) → evalFor ext (f + eqFuelList xs ys + 8) [("i", Val.num ↑pre.length), ("a", A), ("b", Val.arr (pre ++ ys))] "v" xs [Helper.Stmt.ifThen (Helper.Expr.call "__eq" [Helper.Expr.var "v", (Helper.Expr.var "b").index (Helper.Expr.var "i")]).not [Helper.Stmt.ret (Helper.Expr.bool false)], Helper.Stmt.setVar "i" (Helper.Expr.bin "+" (Helper.Expr.var "i") (Helper.Expr.num 1))] = if eqList xs ys = true then Res.ok (Outcome.next [("i", Val.num (↑pre.length + ↑xs.length)), ("a", A), ("b", Val.arr (pre ++ ys))]) else Res.ok (Outcome.ret (Val.bool false))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.eq_obj_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.find_eq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_eq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (ext : Ext) (a b : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    callDef ext (f + eqFuel a b) "__eq" [a, b] = Res.ok (Val.bool (eqVal a b))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.sizeOf_lookupV_lt

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (es : List (String × Val)) (k : String) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      sizeOf (lookupV es k) < 1 + sizeOf es
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Entry checks #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.tyVal

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        The value the descriptor the compiler renders denotes. Js.TyDesc.render writes the text; that the text reads back to this value is the parser's question, not this one.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.tyValFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.tyValAlts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.envVals

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (env : Js.TyEnv) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    One entry per mu the walk is inside, nearest first, holding what that node bound.

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.envVal

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (env : Js.TyEnv) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        The array those entries reach the helpers as.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.envVals_cons

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.envVals_length

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (env : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.envVals_drop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (env : Js.TyEnv) (k : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.envVals_getElem?

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (env : Js.TyEnv) (k : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.hasV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (env : Js.TyEnv) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    What __has decides. An object's field is read by name, with lookupV, exactly as Js.checkTy reads it; has_checkTy below is where the two meet.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.hasList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (env : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.hasEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (env : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.hasFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (env : Js.TyEnv) (es : List (String × Val)) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                __hasFields asks the object for each declared field by name. A key the descriptor does not name is never looked at, which is how an object carrying more than the type declares still passes.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.hasFuel

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (env : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Val → Js.TyDesc → Nat

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Enough fuel for __has, by the same recursion as hasV. A generous constant per level: the claims are stated for every larger amount, so an upper bound is all a proof needs.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.hasFuelList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (env : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.hasFuelEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (env : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.hasFuelAlts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.hasFuelFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (env : Js.TyEnv) (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Reading the object path off the tree #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.find_has

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.find_hasFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.find_ck

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.tyValFields_length

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (fields : List (String × Js.TyDesc)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (tyValFields fields).length = fields.length
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.getElem?_eq_head?_drop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {α : Type u_1} (l : List α) (m : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.hasFields_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (ext : Ext) (es : List (String × Val)) (F : Val) (hsub : ∀ (name : String) (d : Js.TyDesc) (g : Nat), callDef ext (g + hasFuel tenv (lookupV es name) d) "__has" [lookupV es name, tyVal d, envVal tenv] = Res.ok (Val.bool (hasV tenv (lookupV es name) d))) (fields : List (String × Js.TyDesc)) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_hasFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {tenv : Js.TyEnv} (ext : Ext) (es : List (String × Val)) (hsub : ∀ (name : String) (d : Js.TyDesc) (g : Nat), callDef ext (g + hasFuel tenv (lookupV es name) d) "__has" [lookupV es name, tyVal d, envVal tenv] = Res.ok (Val.bool (hasV tenv (lookupV es name) d))) (fields : List (String × Js.TyDesc)) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    callDef ext (f + hasFuelFields tenv es fields + 16) "__hasFields" [Val.obj es, Val.arr (tyValFields fields), envVal tenv] = Res.ok (Val.bool (hasFields tenv es fields))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Stepping the dispatch #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      __has is a chain of if (k === "…") guards. walk would normalise every guard below the one that fires — simp rewrites a subterm before it reduces the match that made it unreachable — and on a body this size that is the whole cost of the proof. The two lemmas below step the chain by rewriting instead, so a branch pays only for itself.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.evalStmts_const

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (ext : Ext) (f : Nat) (env : Env) (name : String) (val : Helper.Expr) (rest : List Helper.Stmt) (v : Val) (h : evalExpr ext f env val = Res.ok v) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      evalStmts ext (f + 1) env (Helper.Stmt.const name val :: rest) = evalStmts ext f ((name, v) :: env) rest
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.has_skip

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (ext : Ext) (f : Nat) (env : Env) (k s : String) (yes rest : List Helper.Stmt) (hk : lookup env "k" = some (Val.str k)) (hne : (k == s) = false) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        evalStmts ext (f + 3) env (Helper.Stmt.ifThen (Helper.Expr.bin "===" (Helper.Expr.var "k") (Helper.Expr.str s)) yes :: rest) = evalStmts ext (f + 2) env rest
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.has_take

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (ext : Ext) (f : Nat) (env : Env) (k : String) (yes rest : List Helper.Stmt) (r : Val) (hk : lookup env "k" = some (Val.str k)) (hy : evalStmts ext (f + 2) env yes = Res.ok (Outcome.ret r)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.cmp_int_ge

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (a b : Int) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.cmp_int_le

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (a b : Int) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.headName

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                The head the compiler renders for a descriptor: what __has dispatches on.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.has_head

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {tenv : Js.TyEnv} (ext : Ext) (f : Nat) (v : Val) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.lookup_k

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {tenv : Js.TyEnv} (t : Js.TyDesc) (v : Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      lookup [("k", Val.str (headName t)), ("x", v), ("t", tyVal t), ("e", envVal tenv)] "k" = some (Val.str (headName t))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.sumCost_hasFuelList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {tenv : Js.TyEnv} (te : Js.TyDesc) (xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        sumCost (fun (w : Val) => hasFuel tenv w te + 7) xs = hasFuelList tenv xs te
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.valAll_hasList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {tenv : Js.TyEnv} (te : Js.TyDesc) (xs : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          valAll (fun (w : Val) => Res.ok (Val.bool (hasV tenv w te))) xs = Res.ok (hasList tenv xs te)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.answers_element

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {tenv : Js.TyEnv} (ext : Ext) (n : Nat) (ih : ∀ (w : Val) (te : Js.TyDesc), sizeOf w < n → ∀ (g : Nat), callDef ext (g + hasFuel tenv w te) "__has" [w, tyVal te, envVal tenv] = Res.ok (Val.bool (hasV tenv w te))) (te : Js.TyDesc) (head : String) (x : Val) (xs : List Val) (hsz : ∀ (w : Val), w ∈ xs → sizeOf w < n) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Answers ext (Val.lam ["y"] (Helper.Expr.call "__has" [Helper.Expr.var "y", (Helper.Expr.var "t").index (Helper.Expr.num 1), Helper.Expr.var "e"]) [("k", Val.str head), ("x", x), ("t", Val.arr [Val.str head, tyVal te]), ("e", envVal tenv)]) (fun (w : Val) => Res.ok (Val.bool (hasV tenv w te))) (fun (w : Val) => hasFuel tenv w te + 7) xs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The closure __has hands to __all: it asks __has about the element, at the descriptor sitting one along from the one it is checking. Its cost is not a constant — the call recurses — so the loop is given a cost per element rather than a length.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.hasEntries_eq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} (te : Js.TyDesc) (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              hasEntries tenv es te = hasList tenv (List.map (fun (x : String × Val) => x.snd) es) te
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.hasFuelEntries_eq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} (te : Js.TyDesc) (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                hasFuelEntries tenv es te = hasFuelList tenv (List.map (fun (x : String × Val) => x.snd) es) te
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.answers_keyString

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (ext : Ext) (cenv : Env) (ks : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Answers ext (Val.lam ["key"] (Helper.Expr.bin "===" (Helper.Expr.var "key").typeOf (Helper.Expr.str "string")) cenv) (fun (w : Val) => Res.ok (Val.bool (typeOf w == "string"))) (fun (x : Val) => 3) ks

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  The other closure __has builds: the one that reads a dictionary's keys back as strings. It is vacuous on the model's side — __dkeys yields .str — but the helper still walks it.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.sumCost_three

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (ks : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    sumCost (fun (x : Val) => 3) ks = 4 * ks.length
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.sumCost_four

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (ks : List Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      sumCost (fun (x : Val) => 4) ks = 5 * ks.length
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.valAll_keyString

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        valAll (fun (w : Val) => Res.ok (Val.bool (typeOf w == "string"))) (List.map (fun (e : String × Val) => Val.str e.fst) es) = Res.ok true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.sizeOf_snd_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {es : List (String × Val)} {w : Val} (h : w ∈ List.map (fun (x : String × Val) => x.snd) es) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.altVal

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            One rendered constructor: its name and its fields.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.tyValAlts_eq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.altMatch

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (tag c : Val) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  What the closure __has hands __find computes: the alternative's name against the object's tag.

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.valFind_alts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.find_alts_notStr

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {v : Val} (hv : ∀ (s : String), v ≠ Val.str s) (alts : List (String × List (String × Js.TyDesc))) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        No alternative matches a key the value does not carry as a string — which is what a Map answers, since the key a declared type is told apart by is never one of a Map's own.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.dict_index_notStr

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (es : List (String × Val)) (key : String) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ∃ (v : Val), index (Val.dict es) (Val.str key) = Res.ok v ∧ ∀ (s : String), v ≠ Val.str s

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          What indexing a Map with a declared type's key answers: never a string, whatever the key is, so no alternative can match it.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.answers_alt

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (x key tag tv ev : Val) (xs : List Val) (hkey : index tv (Val.num 1) = Res.ok key) (htag : index x key = Res.ok tag) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Answers ext (Val.lam ["c"] (Helper.Expr.bin "===" ((Helper.Expr.var "c").index (Helper.Expr.num 0)) ((Helper.Expr.var "x").index ((Helper.Expr.var "t").index (Helper.Expr.num 1)))) [("k", Val.str "ctors"), ("x", x), ("t", tv), ("e", ev)]) (altMatch tag) (fun (x : Val) => 4) xs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.hasFuelFields_le_alts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} (es : List (String × Val)) (alts : List (String × List (String × Js.TyDesc))) (alt : String × List (String × Js.TyDesc)) (h : alt ∈ alts) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              hasFuelFields tenv es alt.snd ≤ hasFuelAlts tenv es alts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.drop_take_all

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (xs : List Val) (k : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                List.take (↑xs.length - ↑k).toNat (List.drop k xs) = List.drop k xs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Everything slice(k, length) leaves behind.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.calls_has

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (ext : Ext) (v : Val) (t : Js.TyDesc) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  callDef ext (f + hasFuel tenv v t) "__has" [v, tyVal t, envVal tenv] = Res.ok (Val.bool (hasV tenv v t))

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  What __has decides, for every value and every descriptor the compiler renders.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.find_norm

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.find_normFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.normV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Val → Js.TyDesc → Val

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        What __norm builds. The tag keeps the slot the object handed it; the constructor's fields follow in the order the descriptor names them, and a name the object does not carry is dropped.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.normVList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.normVEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.normVFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.normFuel

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Val → Js.TyDesc → Nat

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Enough fuel for __norm, by the same recursion as normV and for the reason hasFuel is generous: the claims are stated for every larger amount.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.normFuelList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.normFuelEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.normFuelAlts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.normFuelFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.normPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (tenv : Js.TyEnv) (es : List (String × Val)) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The pairs __normFields pushes, in the order it pushes them.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.fromPairs_normPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} (es : List (String × Val)) {key : String} (fields : List (String × Js.TyDesc)) (acc : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Js.namesOk key fields = true → (∀ (n : String), n ∈ List.map (fun (x : String × Js.TyDesc) => x.fst) fields → (acc.any fun (x : String × Val) => x.fst == n) = false) → fromPairs acc (normPairs tenv es fields) = some (acc ++ normVFields tenv es fields)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Object.fromEntries over what the loop pushed. It appends rather than replaces because the names are distinct and none of them is the tag the accumulator already carries.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.normFields_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (ext : Ext) (es : List (String × Val)) (K F : Val) (fields : List (String × Js.TyDesc)) (acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (∀ (name : String) (d : Js.TyDesc), (name, d) ∈ fields → ∀ (g : Nat), callDef ext (g + normFuel tenv (lookupV es name) d) "__norm" [lookupV es name, tyVal d, envVal tenv] = Res.ok (normV tenv (lookupV es name) d)) → evalFor ext (f + normFuelFields tenv es fields + 8) [("out", Val.arr acc), ("x", Val.obj es), ("key", K), ("fields", F), ("e", envVal tenv)] "f" (tyValFields fields) [Helper.Stmt.ifThen (Helper.Expr.prim "Object.hasOwn" [Helper.Expr.var "x", (Helper.Expr.var "f").index (Helper.Expr.num 0)]) [Helper.Stmt.push "out" (Helper.Expr.arrayLit [(Helper.Expr.var "f").index (Helper.Expr.num 0), Helper.Expr.call "__norm" [(Helper.Expr.var "x").index ((Helper.Expr.var "f").index (Helper.Expr.num 0)), (Helper.Expr.var "f").index (Helper.Expr.num 1), Helper.Expr.var "e"]])]] = Res.ok (Outcome.next [("out", Val.arr (acc ++ normPairs tenv es fields)), ("x", Val.obj es), ("key", K), ("fields", F), ("e", envVal tenv)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.calls_normFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {tenv : Js.TyEnv} (ext : Ext) (es : List (String × Val)) (key : String) (fields : List (String × Js.TyDesc)) (hsub : ∀ (name : String) (d : Js.TyDesc), (name, d) ∈ fields → ∀ (g : Nat), callDef ext (g + normFuel tenv (lookupV es name) d) "__norm" [lookupV es name, tyVal d, envVal tenv] = Res.ok (normV tenv (lookupV es name) d)) (hnames : Js.namesOk key fields = true) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    callDef ext (f + normFuelFields tenv es fields + 16) "__normFields" [Val.obj es, Val.str key, Val.arr (tyValFields fields), envVal tenv] = Res.ok (Val.obj ((key, lookupV es key) :: normVFields tenv es fields))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.normArray_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {tenv : Js.TyEnv} (ext : Ext) (te : Js.TyDesc) (K : Val) (xs : List Val) (X : Val) (acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (∀ (y : Val), y ∈ xs → ∀ (g : Nat), callDef ext (g + normFuel tenv y te) "__norm" [y, tyVal te, envVal tenv] = Res.ok (normV tenv y te)) → evalFor ext (f + normFuelList tenv xs te + 8) [("out", Val.arr acc), ("k", K), ("x", X), ("t", Val.arr [Val.str "array", tyVal te]), ("e", envVal tenv)] "y" xs [Helper.Stmt.push "out" (Helper.Expr.call "__norm" [Helper.Expr.var "y", (Helper.Expr.var "t").index (Helper.Expr.num 1), Helper.Expr.var "e"])] = Res.ok (Outcome.next [("out", Val.arr (acc ++ normVList tenv xs te)), ("k", K), ("x", X), ("t", Val.arr [Val.str "array", tyVal te]), ("e", envVal tenv)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.keysDistinctV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        What no Map can hold: the same key twice. Js.dictKeysDistinct says this of a JsValue; the source semantics needs it of the Val the helper is handed, because __norm rebuilds a dictionary by walking its keys.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.mapsOk

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Val → Bool
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.mapsOkFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.mapsOkList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.normSet

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) (es : List (String × Val)) (t : Js.TyDesc) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        What the dictionary loop leaves in out: each key set, in the order __dkeys hands them over.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.normFuelKeys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (tenv : Js.TyEnv) (es : List (String × Val)) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.normVEntries_keys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} (es : List (String × Val)) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                List.map (fun (x : String × Val) => x.fst) (normVEntries tenv es t) = List.map (fun (x : String × Val) => x.fst) es
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.mapSetAll_normVEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (es : List (String × Val)) (t : Js.TyDesc) (h : keysDistinctV (List.map (fun (x : String × Val) => x.fst) es) = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  mapSetAll [] (normVEntries tenv es t) = normVEntries tenv es t
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.normDictObj_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {tenv : Js.TyEnv} (ext : Ext) (te : Js.TyDesc) (K X : Val) (es acc : List (String × Val)) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (∀ (w : Val), w ∈ List.map (fun (x : String × Val) => x.snd) es → ∀ (g : Nat), callDef ext (g + normFuel tenv w te) "__norm" [w, tyVal te, envVal tenv] = Res.ok (normV tenv w te)) → evalFor ext (f + normFuelEntries tenv es te + 8 * es.length + 8) [("out", Val.dict acc), ("k", K), ("x", X), ("t", Val.arr [Val.str "dictObj", tyVal te]), ("e", envVal tenv)] "en" (List.map (fun (e : String × Val) => Val.arr [Val.str e.fst, e.snd]) es) [Helper.Stmt.setKey "out" ((Helper.Expr.var "en").index (Helper.Expr.num 0)) (Helper.Expr.call "__norm" [(Helper.Expr.var "en").index (Helper.Expr.num 1), (Helper.Expr.var "t").index (Helper.Expr.num 1), Helper.Expr.var "e"])] = Res.ok (Outcome.next [("out", Val.dict (mapSetAll acc (normVEntries tenv es te))), ("k", K), ("x", X), ("t", Val.arr [Val.str "dictObj", tyVal te]), ("e", envVal tenv)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.normDict_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {tenv : Js.TyEnv} (ext : Ext) (te : Js.TyDesc) (es : List (String × Val)) (K : Val) (ks : List String) (acc : List (String × Val)) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (∀ (k : String), k ∈ ks → ∀ (g : Nat), callDef ext (g + normFuel tenv (lookupV es k) te) "__norm" [lookupV es k, tyVal te, envVal tenv] = Res.ok (normV tenv (lookupV es k) te)) → evalFor ext (f + normFuelKeys tenv es te ks + 8) [("out", Val.dict acc), ("k", K), ("x", Val.dict es), ("t", Val.arr [Val.str "dict", tyVal te]), ("e", envVal tenv)] "key" (List.map Val.str ks) [Helper.Stmt.setKey "out" (Helper.Expr.var "key") (Helper.Expr.call "__norm" [(Helper.Expr.var "x").method "get" [Helper.Expr.var "key"], (Helper.Expr.var "t").index (Helper.Expr.num 1), Helper.Expr.var "e"])] = Res.ok (Outcome.next [("out", Val.dict (normSet tenv es te acc ks)), ("k", K), ("x", Val.dict es), ("t", Val.arr [Val.str "dict", tyVal te]), ("e", envVal tenv)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.mapsOkList_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {xs : List Val} {y : Val} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        mapsOkList xs = true → y ∈ xs → mapsOk y = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.mapsOkFields_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {es : List (String × Val)} {y : Val} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          mapsOkFields es = true → y ∈ List.map (fun (x : String × Val) => x.snd) es → mapsOk y = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.mapsOk_lookupV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {es : List (String × Val)} (h : mapsOkFields es = true) (k : String) (hmem : (es.any fun (x : String × Val) => x.fst == k) = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.hasList_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} {xs : List Val} {te : Js.TyDesc} {y : Val} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              hasList tenv xs te = true → y ∈ xs → hasV tenv y te = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.hasEntries_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} {es : List (String × Val)} {te : Js.TyDesc} {y : Val} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                hasEntries tenv es te = true → y ∈ List.map (fun (x : String × Val) => x.snd) es → hasV tenv y te = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.lookupV_skipV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (pre suf : List (String × Val)) (k : String) (h : ∀ (e : String × Val), e ∈ pre → e.fst ≠ k) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  lookupV (pre ++ suf) k = lookupV suf k
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.keysDistinctV_append

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {pre suf : List (String × Val)} (h : keysDistinctV (List.map (fun (x : String × Val) => x.fst) (pre ++ suf)) = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (∀ (k : String), k ∈ List.map (fun (x : String × Val) => x.fst) suf → ∀ (e : String × Val), e ∈ pre → e.fst ≠ k) ∧ keysDistinctV (List.map (fun (x : String × Val) => x.fst) suf) = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.normSet_split

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {tenv : Js.TyEnv} (full : List (String × Val)) (t : Js.TyDesc) (pre suf acc : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      full = pre ++ suf → keysDistinctV (List.map (fun (x : String × Val) => x.fst) full) = true → (∀ (k : String), k ∈ List.map (fun (x : String × Val) => x.fst) suf → (acc.any fun (x : String × Val) => x.fst == k) = false) → normSet tenv full t acc (List.map (fun (x : String × Val) => x.fst) suf) = acc ++ normVEntries tenv suf t

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Walking a dictionary's keys and looking each one up hands back the entries in order, because a Map cannot carry the same key twice.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.normFuelKeys_split

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {tenv : Js.TyEnv} (full : List (String × Val)) (t : Js.TyDesc) (pre suf : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        full = pre ++ suf → keysDistinctV (List.map (fun (x : String × Val) => x.fst) full) = true → normFuelKeys tenv full t (List.map (fun (x : String × Val) => x.fst) suf) = normFuelEntries tenv suf t + 4 * suf.length
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.lookupV_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {es : List (String × Val)} {k : String} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (es.any fun (x : String × Val) => x.fst == k) = true → lookupV es k ∈ List.map (fun (x : String × Val) => x.snd) es
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.mapsOk_lookupV'

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {es : List (String × Val)} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            mapsOkFields es = true → ∀ (k : String), mapsOk (lookupV es k) = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.hasFields_field

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} {fields : List (String × Js.TyDesc)} {es : List (String × Val)} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              hasFields tenv es fields = true → ∀ {n : String} {d : Js.TyDesc}, (n, d) ∈ fields → (es.any fun (x : String × Val) => x.fst == n) = true ∧ hasV tenv (lookupV es n) d = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.altsOk_findV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {depth : Nat} {alts : List (String × List (String × Js.TyDesc))} {key : String} {tag : Val} {alt : String × List (String × Js.TyDesc)} (h : Js.altsOk depth key alts = true) (hf : List.find? (fun (c : String × List (String × Js.TyDesc)) => strictEq (Val.str c.fst) tag) alts = some alt) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.normFuelFields_le_alts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (es : List (String × Val)) (alts : List (String × List (String × Js.TyDesc))) (alt : String × List (String × Js.TyDesc)) (h : alt ∈ alts) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  normFuelFields tenv es alt.snd ≤ normFuelAlts tenv es alts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.fieldsOk_mem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {depth : Nat} {fields : List (String × Js.TyDesc)} {n : String} {d : Js.TyDesc} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Js.fieldsOk depth fields = true → (n, d) ∈ fields → Js.descOk depth d = true
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.lookup_k_norm

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {tenv : Js.TyEnv} (t : Js.TyDesc) (v : Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      lookup [("k", Val.str (headName t)), ("x", v), ("t", tyVal t), ("e", envVal tenv)] "k" = some (Val.str (headName t))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.normV_scalar

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {tenv : Js.TyEnv} (v : Val) (t : Js.TyDesc) (h : headName t = "bool" ∨ headName t = "int53" ∨ headName t = "uint32" ∨ headName t = "string" ∨ headName t = "bigint") :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        normV tenv v t = v
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.calls_norm

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {tenv : Js.TyEnv} (ext : Ext) (v : Val) (t : Js.TyDesc) (hd : Js.descOk (List.length tenv) t = true) (he : Js.envOk tenv = true) (hmo : mapsOk v = true) (hh : hasV tenv v t = true) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          callDef ext (f + normFuel tenv v t) "__norm" [v, tyVal t, envVal tenv] = Res.ok (normV tenv v t)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          What __norm builds, for every value the entry check accepts and every descriptor the compiler renders.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.envVal_nil

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.calls_ck

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (ext : Ext) (v : Val) (t : Js.TyDesc) (hd : Js.descOk 0 t = true) (hmo : mapsOk v = true) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              callDef ext (f + hasFuel [] v t + normFuel [] v t + 9) "__ck" [v, tyVal t] = if hasV [] v t = true then Res.ok (normV [] v t) else Res.thrown "typeError"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              __ck is __has with a throw: what the check accepts comes back rebuilt in the shape the descriptor names, and what it refuses raises typeError. The environment it starts at is empty.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                The walk back out #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                __out is __norm read the other way, and so is everything below: the same recursion, the same fuel arithmetic, the same branch-by-branch proof. The one node they disagree at is the one the helper exists for — a dictionary declared to cross as a plain object leaves as one, where __norm on the way in made the Map the body ran on. Nothing here calls __out yet; what it is here to say is that the JavaScript Helper.out writes out is the walk Js.outTy describes.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.find_out

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.find_outFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.outV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Val → Js.TyDesc → Val

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    What __out builds. The tag keeps the slot the object handed it; the constructor's fields follow in the order the descriptor names them, and a name the object does not carry is dropped.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.outVList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.outVEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.outVFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.outFuel

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Val → Js.TyDesc → Nat

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Enough fuel for __out, by the same recursion as outV and for the reason hasFuel is generous: the claims are stated for every larger amount.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.outFuelList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.outFuelEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (tenv : Js.TyEnv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.outFuelAlts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.outFuelFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (tenv : Js.TyEnv) (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.outPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) (es : List (String × Val)) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        The pairs __outFields pushes, in the order it pushes them.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.fromPairs_outPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {tenv : Js.TyEnv} (es : List (String × Val)) {key : String} (fields : List (String × Js.TyDesc)) (acc : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Js.namesOk key fields = true → (∀ (n : String), n ∈ List.map (fun (x : String × Js.TyDesc) => x.fst) fields → (acc.any fun (x : String × Val) => x.fst == n) = false) → fromPairs acc (outPairs tenv es fields) = some (acc ++ outVFields tenv es fields)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Object.fromEntries over what the loop pushed. It appends rather than replaces because the names are distinct and none of them is the tag the accumulator already carries.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.outFields_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} (ext : Ext) (es : List (String × Val)) (K F : Val) (fields : List (String × Js.TyDesc)) (acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (∀ (name : String) (d : Js.TyDesc), (name, d) ∈ fields → ∀ (g : Nat), callDef ext (g + outFuel tenv (lookupV es name) d) "__out" [lookupV es name, tyVal d, envVal tenv] = Res.ok (outV tenv (lookupV es name) d)) → evalFor ext (f + outFuelFields tenv es fields + 8) [("out", Val.arr acc), ("x", Val.obj es), ("key", K), ("fields", F), ("e", envVal tenv)] "f" (tyValFields fields) [Helper.Stmt.ifThen (Helper.Expr.prim "Object.hasOwn" [Helper.Expr.var "x", (Helper.Expr.var "f").index (Helper.Expr.num 0)]) [Helper.Stmt.push "out" (Helper.Expr.arrayLit [(Helper.Expr.var "f").index (Helper.Expr.num 0), Helper.Expr.call "__out" [(Helper.Expr.var "x").index ((Helper.Expr.var "f").index (Helper.Expr.num 0)), (Helper.Expr.var "f").index (Helper.Expr.num 1), Helper.Expr.var "e"]])]] = Res.ok (Outcome.next [("out", Val.arr (acc ++ outPairs tenv es fields)), ("x", Val.obj es), ("key", K), ("fields", F), ("e", envVal tenv)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.calls_outFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} (ext : Ext) (es : List (String × Val)) (key : String) (fields : List (String × Js.TyDesc)) (hsub : ∀ (name : String) (d : Js.TyDesc), (name, d) ∈ fields → ∀ (g : Nat), callDef ext (g + outFuel tenv (lookupV es name) d) "__out" [lookupV es name, tyVal d, envVal tenv] = Res.ok (outV tenv (lookupV es name) d)) (hnames : Js.namesOk key fields = true) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                callDef ext (f + outFuelFields tenv es fields + 16) "__outFields" [Val.obj es, Val.str key, Val.arr (tyValFields fields), envVal tenv] = Res.ok (Val.obj ((key, lookupV es key) :: outVFields tenv es fields))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.outArray_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (ext : Ext) (te : Js.TyDesc) (K : Val) (xs : List Val) (X : Val) (acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (∀ (y : Val), y ∈ xs → ∀ (g : Nat), callDef ext (g + outFuel tenv y te) "__out" [y, tyVal te, envVal tenv] = Res.ok (outV tenv y te)) → evalFor ext (f + outFuelList tenv xs te + 8) [("out", Val.arr acc), ("k", K), ("x", X), ("t", Val.arr [Val.str "array", tyVal te]), ("e", envVal tenv)] "y" xs [Helper.Stmt.push "out" (Helper.Expr.call "__out" [Helper.Expr.var "y", (Helper.Expr.var "t").index (Helper.Expr.num 1), Helper.Expr.var "e"])] = Res.ok (Outcome.next [("out", Val.arr (acc ++ outVList tenv xs te)), ("k", K), ("x", X), ("t", Val.arr [Val.str "array", tyVal te]), ("e", envVal tenv)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.outSet

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (tenv : Js.TyEnv) (es : List (String × Val)) (t : Js.TyDesc) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    What the dictionary loop leaves in out: each key set, in the order __dkeys hands them over.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.outFuelKeys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) (es : List (String × Val)) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.outVEntries_keys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {tenv : Js.TyEnv} (es : List (String × Val)) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            List.map (fun (x : String × Val) => x.fst) (outVEntries tenv es t) = List.map (fun (x : String × Val) => x.fst) es
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.outEntryPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (tenv : Js.TyEnv) (t : Js.TyDesc) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              The pairs __out pushes for a dictionary leaving as a plain object, in the order the Map's iterator hands them over.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.fromPairs_outEntryPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (t : Js.TyDesc) (es acc : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  keysDistinctV (List.map (fun (x : String × Val) => x.fst) es) = true → (∀ (k : String), k ∈ List.map (fun (x : String × Val) => x.fst) es → (acc.any fun (x : String × Val) => x.fst == k) = false) → fromPairs acc (outEntryPairs tenv t es) = some (acc ++ outVEntries tenv es t)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Object.fromEntries over what that loop pushed. It appends rather than replaces because a Map cannot have handed the same key over twice.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.outDictObj_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {tenv : Js.TyEnv} (ext : Ext) (te : Js.TyDesc) (K X : Val) (es : List (String × Val)) (acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (∀ (w : Val), w ∈ List.map (fun (x : String × Val) => x.snd) es → ∀ (g : Nat), callDef ext (g + outFuel tenv w te) "__out" [w, tyVal te, envVal tenv] = Res.ok (outV tenv w te)) → evalFor ext (f + outFuelEntries tenv es te + 8 * es.length + 8) [("out", Val.arr acc), ("k", K), ("x", X), ("t", Val.arr [Val.str "dictObj", tyVal te]), ("e", envVal tenv)] "en" (List.map (fun (e : String × Val) => Val.arr [Val.str e.fst, e.snd]) es) [Helper.Stmt.push "out" (Helper.Expr.arrayLit [(Helper.Expr.var "en").index (Helper.Expr.num 0), Helper.Expr.call "__out" [(Helper.Expr.var "en").index (Helper.Expr.num 1), (Helper.Expr.var "t").index (Helper.Expr.num 1), Helper.Expr.var "e"]])] = Res.ok (Outcome.next [("out", Val.arr (acc ++ outEntryPairs tenv te es)), ("k", K), ("x", X), ("t", Val.arr [Val.str "dictObj", tyVal te]), ("e", envVal tenv)])

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    The loop __out runs over a dictionary leaving as a plain object. It walks the entries the Map's iterator hands over and pushes each one, so the object is built in the order the dictionary held.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.outDict_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {tenv : Js.TyEnv} (ext : Ext) (te : Js.TyDesc) (es : List (String × Val)) (K : Val) (ks : List String) (acc : List (String × Val)) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (∀ (k : String), k ∈ ks → ∀ (g : Nat), callDef ext (g + outFuel tenv (lookupV es k) te) "__out" [lookupV es k, tyVal te, envVal tenv] = Res.ok (outV tenv (lookupV es k) te)) → evalFor ext (f + outFuelKeys tenv es te ks + 8) [("out", Val.dict acc), ("k", K), ("x", Val.dict es), ("t", Val.arr [Val.str "dict", tyVal te]), ("e", envVal tenv)] "key" (List.map Val.str ks) [Helper.Stmt.setKey "out" (Helper.Expr.var "key") (Helper.Expr.call "__out" [(Helper.Expr.var "x").method "get" [Helper.Expr.var "key"], (Helper.Expr.var "t").index (Helper.Expr.num 1), Helper.Expr.var "e"])] = Res.ok (Outcome.next [("out", Val.dict (outSet tenv es te acc ks)), ("k", K), ("x", Val.dict es), ("t", Val.arr [Val.str "dict", tyVal te]), ("e", envVal tenv)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.outSet_split

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {tenv : Js.TyEnv} (full : List (String × Val)) (t : Js.TyDesc) (pre suf acc : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        full = pre ++ suf → keysDistinctV (List.map (fun (x : String × Val) => x.fst) full) = true → (∀ (k : String), k ∈ List.map (fun (x : String × Val) => x.fst) suf → (acc.any fun (x : String × Val) => x.fst == k) = false) → outSet tenv full t acc (List.map (fun (x : String × Val) => x.fst) suf) = acc ++ outVEntries tenv suf t

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Walking a dictionary's keys and looking each one up hands back the entries in order, because a Map cannot carry the same key twice.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.outFuelKeys_split

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {tenv : Js.TyEnv} (full : List (String × Val)) (t : Js.TyDesc) (pre suf : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          full = pre ++ suf → keysDistinctV (List.map (fun (x : String × Val) => x.fst) full) = true → outFuelKeys tenv full t (List.map (fun (x : String × Val) => x.fst) suf) = outFuelEntries tenv suf t + 4 * suf.length
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.outFuelFields_le_alts

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {tenv : Js.TyEnv} (es : List (String × Val)) (alts : List (String × List (String × Js.TyDesc))) (alt : String × List (String × Js.TyDesc)) (h : alt ∈ alts) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            outFuelFields tenv es alt.snd ≤ outFuelAlts tenv es alts
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.lookup_k_out

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} (t : Js.TyDesc) (v : Val) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              lookup [("k", Val.str (headName t)), ("x", v), ("t", tyVal t), ("e", envVal tenv)] "k" = some (Val.str (headName t))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.outV_scalar

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} (v : Val) (t : Js.TyDesc) (h : headName t = "bool" ∨ headName t = "int53" ∨ headName t = "uint32" ∨ headName t = "string" ∨ headName t = "bigint") :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                outV tenv v t = v
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.calls_out

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} (ext : Ext) (v : Val) (t : Js.TyDesc) (hd : Js.descOk (List.length tenv) t = true) (he : Js.envOk tenv = true) (hmo : mapsOk v = true) (hh : hasV tenv v t = true) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  callDef ext (f + outFuel tenv v t) "__out" [v, tyVal t, envVal tenv] = Res.ok (outV tenv v t)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  What __out builds, for every value the entry check accepts and every descriptor the compiler renders.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    The model of the generated code, read off the source semantics #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.ofJsFields_any

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (es : List (String × Js.JsValue)) (n : String) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ((ofJsFields es).any fun (x : String × Val) => x.fst == n) = (Js.lookupField es n).isSome
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.lookupV_ofJsFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {es : List (String × Js.JsValue)} {n : String} {v : Js.JsValue} (h : Js.lookupField es n = some v) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.lookupV_ofJsFields_none

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.ofJsFields_mapSet

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.ofJsFields_mapSetAll

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.ofJsFields_keys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              (es : List (String × Js.JsValue)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              List.map (fun (x : String × Val) => x.fst) (ofJsFields es) = List.map (fun (x : String × Js.JsValue) => x.fst) es
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.keysDistinctV_eq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.mapsOk_ofJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.lookupV_ofJsFields_str

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.strictEq_lookupV_str_false

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.checkTy_option_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {t : Js.TyDesc} (h1 : Js.lookupField fields "tag" = some (Js.JsValue.str "none") → False) (h2 : Js.lookupField fields "tag" = some (Js.JsValue.str "some") → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.checkTy_result_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {ok err : Js.TyDesc} (h1 : Js.lookupField fields "tag" = some (Js.JsValue.str "ok") → False) (h2 : Js.lookupField fields "tag" = some (Js.JsValue.str "error") → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Js.checkTy tenv (Js.JsValue.obj fields) (ok.result err) = false
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.checkTy_ctors_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {key : String} {alts : List (String × List (String × Js.TyDesc))} (h : ∀ (ctor : String), Js.lookupField fields key = some (Js.JsValue.str ctor) → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.normTy_option_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {t : Js.TyDesc} (h1 : Js.lookupField fields "tag" = some (Js.JsValue.str "none") → False) (h2 : Js.lookupField fields "tag" = some (Js.JsValue.str "some") → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.normTy_result_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {ok err : Js.TyDesc} (h1 : Js.lookupField fields "tag" = some (Js.JsValue.str "ok") → False) (h2 : Js.lookupField fields "tag" = some (Js.JsValue.str "error") → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Js.normTy tenv (Js.JsValue.obj fields) (ok.result err) = Js.JsValue.obj fields
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.strictEq_str_lookupV_false

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {fields : List (String × Js.JsValue)} {key : String} (h : ∀ (ctor : String), Js.lookupField fields key = some (Js.JsValue.str ctor) → False) (s : String) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.normTy_ctors_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {key : String} {alts : List (String × List (String × Js.TyDesc))} (h : ∀ (ctor : String), Js.lookupField fields key = some (Js.JsValue.str ctor) → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Js.normTy tenv (Js.JsValue.obj fields) (Js.TyDesc.ctors key alts) = Js.JsValue.obj fields
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.normV_ofJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (tenv : Js.TyEnv) (x : Js.JsValue) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      normV tenv (ofJs x) t = ofJs (Js.normTy tenv x t)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        The entry check the model runs #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        __has and Js.checkTy both read an object's fields by name, so they are the same predicate on every value and every descriptor, with no side condition on the descriptor at all.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.has_checkTy

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (tenv : Js.TyEnv) (x : Js.JsValue) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        hasV tenv (ofJs x) t = Js.checkTy tenv x t
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.calls_has_checkTy

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {tenv : Js.TyEnv} (ext : Ext) (x : Js.JsValue) (t : Js.TyDesc) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          callDef ext (f + hasFuel tenv (ofJs x) t) "__has" [ofJs x, tyVal t, envVal tenv] = Res.ok (Val.bool (Js.checkTy tenv x t))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.calls_ck_checkTy

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (x : Js.JsValue) (t : Js.TyDesc) (h : Js.descOk 0 t = true) (hk : Js.dictKeysDistinct x = true) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            callDef ext (f + hasFuel [] (ofJs x) t + normFuel [] (ofJs x) t + 9) "__ck" [ofJs x, tyVal t] = ofRes (if Js.checkTy [] x t = true then Except.ok (Js.normTy [] x t) else Except.error "typeError")

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            What the generated code's entry check does to an argument: hand back the value the model's check normalises to, or throw typeError.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              The walk back out the model runs #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Js.outTy is Js.normTy at every node but the one, and outV is normV at every node but the same one, so the bridge between them is normV_ofJs with one name substituted and one case fewer: an object met at a dictObj is no longer an arm of its own on either side.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.HelperSem.outTy_option_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {t : Js.TyDesc} (h1 : Js.lookupField fields "tag" = some (Js.JsValue.str "none") → False) (h2 : Js.lookupField fields "tag" = some (Js.JsValue.str "some") → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.outTy_result_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {ok err : Js.TyDesc} (h1 : Js.lookupField fields "tag" = some (Js.JsValue.str "ok") → False) (h2 : Js.lookupField fields "tag" = some (Js.JsValue.str "error") → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Js.outTy tenv (Js.JsValue.obj fields) (ok.result err) = Js.JsValue.obj fields
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.outTy_ctors_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {tenv : Js.TyEnv} {fields : List (String × Js.JsValue)} {key : String} {alts : List (String × List (String × Js.TyDesc))} (h : ∀ (ctor : String), Js.lookupField fields key = some (Js.JsValue.str ctor) → False) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Js.outTy tenv (Js.JsValue.obj fields) (Js.TyDesc.ctors key alts) = Js.JsValue.obj fields
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.outV_ofJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (tenv : Js.TyEnv) (x : Js.JsValue) (t : Js.TyDesc) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    outV tenv (ofJs x) t = ofJs (Js.outTy tenv x t)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.calls_out_outTy

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (ext : Ext) (x : Js.JsValue) (t : Js.TyDesc) (h : Js.descOk 0 t = true) (hk : Js.dictKeysDistinct x = true) (hh : Js.checkTy [] x t = true) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      callDef ext (f + outFuel [] (ofJs x) t) "__out" [ofJs x, tyVal t, Val.arr []] = ofRes (Except.ok (Js.outTy [] x t))

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      What the generated code's walk back out does to a result: hand it back as the model's walk out leaves it. Nothing is refused and nothing needs to be, which is what the hypothesis says — the value __out is handed is one the declared type accepts, and decl_correct is what gives that at the one place the compiler writes this call.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Walking a value of a type that names itself #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        __fold is the helper a fold in the subset compiles to. It walks a value from the leaves up and hands each node to the one callback the compiler passed, with each field that came round already replaced by what the callback answered for it — so the callback reads a node of the shape the type declares and dispatches on the tag, which is what a match does.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Nothing emits a call to it yet: the Core.Expr form and its compilation are the commit after this one. What is here is the helper and the statement that it computes what the model says, which is the expensive half and the one this repository requires before a helper may ship.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.specValFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.specValEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The spec as the object __fold reads it: one entry per constructor, holding that constructor's fields in declared order. Written as a recursion rather than through List.map, and reached through an abbrev, so that the walk can see the obj constructor and step into the read.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.specVal

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (spec : Js.FoldSpec) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.foldV

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (ext : Ext) (i : Nat) (key : String) (spec : Js.FoldSpec) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Val → Res Val

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    What __fold computes: the callback's answer for the node, with each field that came round already replaced by the callback's answer for it.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.foldList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (ext : Ext) (i : Nat) (key : String) (spec : Js.FoldSpec) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.foldListAt

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (ext : Ext) (i : Nat) (key : String) (spec : Js.FoldSpec) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Val → Res (List Val)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            A field the spec says holds a list of the type coming round. A value that is not an array is one the entry check would not have let through, so the walk declines to answer for it rather than guessing.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Written apart from foldPairs so that the match is on a value and not on a proof: an arm matching on lookupV es n in place makes that arm depend on the equation, and nothing can then case on the field.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.foldPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (ext : Ext) (i : Nat) (key : String) (spec : Js.FoldSpec) (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.foldFuel

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (key : String) (spec : Js.FoldSpec) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Val → Nat

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Enough fuel for __fold, by the same recursion as foldV. A generous constant per level: the claim is stated for every larger amount, so an upper bound is all a proof needs.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.HelperSem.foldFuelList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (key : String) (spec : Js.FoldSpec) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.foldFuelListAt

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (key : String) (spec : Js.FoldSpec) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Val → Nat
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.foldFuelPairs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (key : String) (spec : Js.FoldSpec) (es : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.find_fold

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.pairVals

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      The pairs the loop pushes, as the array literals it pushes them as.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.HelperSem.foldList_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (ext : Ext) (i : Nat) (key : String) (spec : Js.FoldSpec) (G O X : Val) (xs acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (∀ (x : Val), x ∈ xs → ∀ (g : Nat), callDef ext (g + foldFuel key spec x) "__fold" [x, Val.str key, specVal spec, Val.ext i] = foldV ext i key spec x) → evalFor ext (f + foldFuelList key spec xs + 6) [("ys", Val.arr acc), ("g", G), ("out", O), ("x", X), ("key", Val.str key), ("spec", specVal spec), ("f", Val.ext i)] "c" xs [Helper.Stmt.push "ys" (Helper.Expr.call "__fold" [Helper.Expr.var "c", Helper.Expr.var "key", Helper.Expr.var "spec", Helper.Expr.var "f"])] = (foldList ext i key spec xs).bind fun (ys : List Val) => Res.ok (Outcome.next [("ys", Val.arr (acc ++ ys)), ("g", G), ("out", O), ("x", X), ("key", Val.str key), ("spec", specVal spec), ("f", Val.ext i)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.HelperSem.foldBody

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The body of the loop __fold runs over a constructor's fields. Named so that the lemma below and the helper read the same text.

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.HelperSem.foldPairs_loop

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                (ext : Ext) (i : Nat) (key : String) (spec : Js.FoldSpec) (es : List (String × Val)) (hsub : ∀ (w : Val), sizeOf w < sizeOf (Val.obj es) → ∀ (g : Nat), callDef ext (g + foldFuel key spec w) "__fold" [w, Val.str key, specVal spec, Val.ext i] = foldV ext i key spec w) (fs : Js.FoldFields) (acc : List Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                evalFor ext (f + foldFuelPairs key spec es fs + 6) [("out", Val.arr acc), ("x", Val.obj es), ("key", Val.str key), ("spec", specVal spec), ("f", Val.ext i)] "g" (specValFields fs) foldBody = (foldPairs ext i key spec es fs).bind fun (ps : List (String × Val)) => Res.ok (Outcome.next [("out", Val.arr (acc ++ pairVals ps)), ("x", Val.obj es), ("key", Val.str key), ("spec", specVal spec), ("f", Val.ext i)])
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.HelperSem.fromPairs_pairVals

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (ps acc : List (String × Val)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  fromPairs acc (pairVals ps) = some (mapSetAll acc ps)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Object.fromEntries over the pairs the loop pushed. No side condition: what it builds is what mapSetAll builds, a later pair carrying the same name replacing an earlier one, and that is what the walk says it builds rather than a list the names have to be distinct for.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.HelperSem.lookupV_specValEntries

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (spec : Js.FoldSpec) (tag : String) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    lookupV (specValEntries spec) tag = match Option.map (fun (x : String × Js.FoldFields) => x.snd) (List.find? (fun (x : String × Js.FoldFields) => x.fst == tag) spec) with | some fs => Val.arr (specValFields fs) | none => Val.undef

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    The spec is read by the constructor's name, so a name the spec does not carry reads as undefined and the loop the walk runs over it is one the model declines to answer for.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.HelperSem.calls_fold

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (ext : Ext) (i : Nat) (key : String) (spec : Js.FoldSpec) (v : Val) (f : Nat) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      callDef ext (f + foldFuel key spec v) "__fold" [v, Val.str key, specVal spec, Val.ext i] = foldV ext i key spec v

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      __fold computes what foldV says, at every value and every callback. The value is walked from the leaves up and each node is handed to the callback once, so a callback that throws stops the walk where the helper stops it.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by