lean2js

Lean2Js.JsSem

source

Imports 3

The semantics of the generated JavaScript, held inside Lean #

Holds the semantics of the generated JavaScript inside Lean.

What this model assumes #

Numbers are held as Int, with no Number rounding. That is legitimate because the generated code never handles a bare Number: integer addition, subtraction and multiplication always go through __i53 or >>> 0, and division goes through BigInt. On top of that we assume the following about IEEE double precision.

  • If the true result is a safe integer, the double-precision result agrees with it
  • If the true result is not a safe integer, the double-precision result is not a safe integer either

So "exact integer arithmetic + a range check" returns the same result as real JS's "double-precision arithmetic + Number.isSafeInteger".

-0 cannot be represented in this model. Agreement on negative zero is the differential test's job.

The guarantee therefore comes in two layers. On the Lean side we check that this model and the reference semantics agree; the differential test on Node checks that the model and the real JS agree.

inductive

Lean2Js.Js.JsValue

source
Instances For
    Used by
      instance

      Lean2Js.Js.instReprJsValue

      source
      @[instance_reducible]
      Equations
      Used by
        partial def

        Lean2Js.Js.instReprJsValue.repr

        source
        Used by
          instance

          Lean2Js.Js.instInhabitedJsValue

          source
          @[instance_reducible]
          Equations
          Used by
            abbrev

            Lean2Js.Js.JsEnv

            source
            @[reducible, inline]
            Equations
            Instances For
              Used by
                abbrev

                Lean2Js.Js.JsResult

                source
                @[reducible, inline]

                Only the code of a thrown exception is observed. The generated code throws from nowhere but __fail.

                Equations
                Instances For
                  Used by
                    def

                    Lean2Js.Js.JsValue.beq

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

                        Lean2Js.Js.JsValue.beqFields

                        source
                        @[irreducible]
                        Equations
                        Instances For
                          Used by
                            def

                            Lean2Js.Js.JsValue.beqList

                            source
                            @[irreducible]
                            Equations
                            Instances For
                              Used by
                                instance

                                Lean2Js.Js.instBEqJsValue

                                source
                                @[instance_reducible]
                                Equations
                                Used by
                                  def

                                  Lean2Js.Js.Runtime.safeMax

                                  source
                                  :
                                  Equations
                                  Instances For
                                    Used by
                                      def

                                      Lean2Js.Js.Runtime.safeMin

                                      source
                                      :
                                      Equations
                                      Instances For
                                        Used by
                                          def

                                          Lean2Js.Js.Runtime.wrap32

                                          source
                                          :
                                          Equations
                                          Instances For
                                            Used by
                                              def

                                              Lean2Js.Js.Runtime.fail

                                              source
                                              (code : String) :
                                              Equations
                                              Instances For
                                                Used by
                                                  def

                                                  Lean2Js.Js.Runtime.i53

                                                  source
                                                  (i : Int) :
                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    Used by
                                                      def

                                                      Lean2Js.Js.Runtime.i53div

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

                                                          Lean2Js.Js.Runtime.i53mod

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

                                                              Lean2Js.Js.Runtime.u32

                                                              source
                                                              (i : Int) :

                                                              >>> 0 is ToUint32: the non-negative representative modulo 2^32.

                                                              Equations
                                                              Instances For
                                                                Used by
                                                                  def

                                                                  Lean2Js.Js.Runtime.u32mul

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

                                                                      Lean2Js.Js.Runtime.u32div

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

                                                                          Lean2Js.Js.Runtime.u32mod

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

                                                                              Lean2Js.Js.Runtime.bigdiv

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

                                                                                  Lean2Js.Js.Runtime.bigmod

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

                                                                                      Lean2Js.Js.Runtime.strcmp

                                                                                      source
                                                                                      (a b : String) :

                                                                                      Array.from splits by code point, not by the UTF-16 units JS's < uses.

                                                                                      Equations
                                                                                      Instances For
                                                                                        Used by
                                                                                          def

                                                                                          Lean2Js.Js.Runtime.isSpace

                                                                                          source
                                                                                          (c : Char) :
                                                                                          Equations
                                                                                          Instances For
                                                                                            Used by
                                                                                              def

                                                                                              Lean2Js.Js.Runtime.strTrim

                                                                                              source
                                                                                              (s : String) :
                                                                                              Equations
                                                                                              Instances For
                                                                                                Used by
                                                                                                  def

                                                                                                  Lean2Js.Js.Runtime.strUpper

                                                                                                  source
                                                                                                  (s : String) :
                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    Used by
                                                                                                      def

                                                                                                      Lean2Js.Js.Runtime.strLower

                                                                                                      source
                                                                                                      (s : String) :
                                                                                                      Equations
                                                                                                      Instances For
                                                                                                        Used by
                                                                                                          def

                                                                                                          Lean2Js.Js.Runtime.digitsValue

                                                                                                          source
                                                                                                          (cs : List Char) :

                                                                                                          The digits read as a number, with no bound on the answer. A character that is not a digit contributes its code point less 48; strToInt throws that away by printing the answer back.

                                                                                                          Equations
                                                                                                          Instances For
                                                                                                            Used by
                                                                                                              def

                                                                                                              Lean2Js.Js.Runtime.strToInt

                                                                                                              source

                                                                                                              What __toInt answers: the value, read back and printed again, has to be the string it was handed. That admits exactly the strings String(n) prints for an Int53, so "007", "+5", " 5" and "-0" are all refused.

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

                                                                                                                  Lean2Js.Js.Runtime.strIncludes

                                                                                                                  source
                                                                                                                  (needle : List Char) :
                                                                                                                  Equations
                                                                                                                  Instances For
                                                                                                                    Used by
                                                                                                                      def

                                                                                                                      Lean2Js.Js.Runtime.strIndexOfChars

                                                                                                                      source

                                                                                                                      Where needle first sits in the haystack, counted in code points. The empty needle sits at 0.

                                                                                                                      Equations
                                                                                                                      Instances For
                                                                                                                        Used by
                                                                                                                          def

                                                                                                                          Lean2Js.Js.Runtime.strIndexOf

                                                                                                                          source
                                                                                                                          (s t : String) :

                                                                                                                          A position past the safe integers is what __i53 refuses, exactly as a length is.

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

                                                                                                                              Lean2Js.Js.Runtime.strJoinFrom

                                                                                                                              source
                                                                                                                              (sep acc : String) :
                                                                                                                              Equations
                                                                                                                              Instances For
                                                                                                                                Used by
                                                                                                                                  def

                                                                                                                                  Lean2Js.Js.Runtime.strJoin

                                                                                                                                  source
                                                                                                                                  (xs : List String) (sep : String) :
                                                                                                                                  Equations
                                                                                                                                  Instances For
                                                                                                                                    Used by
                                                                                                                                      def

                                                                                                                                      Lean2Js.Js.Runtime.strRepeatFrom

                                                                                                                                      source
                                                                                                                                      (s : String) :

                                                                                                                                      s written n times over, one copy at a time.

                                                                                                                                      Equations
                                                                                                                                      Instances For
                                                                                                                                        Used by
                                                                                                                                          def

                                                                                                                                          Lean2Js.Js.Runtime.strRepeat

                                                                                                                                          source
                                                                                                                                          (s : String) (n : Int) :

                                                                                                                                          A result longer than the safe integers is what __i53 refuses, exactly as a length is. An empty string answers before the bound is consulted, because no count makes it longer.

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

                                                                                                                                              Lean2Js.Js.Runtime.strsOf

                                                                                                                                              source

                                                                                                                                              An array holding anything but Strings is past what the compiler builds, so the table leaves it unanswered rather than modelling what JS would print for it.

                                                                                                                                              Equations
                                                                                                                                              Instances For
                                                                                                                                                Used by
                                                                                                                                                  theorem

                                                                                                                                                  Lean2Js.Js.Runtime.strsOf_map_str

                                                                                                                                                  source
                                                                                                                                                  Used by
                                                                                                                                                    theorem

                                                                                                                                                    Lean2Js.Js.Runtime.strsOf_eq

                                                                                                                                                    source
                                                                                                                                                    {xs : List JsValue} {ss : List String} (h : strsOf xs = some ss) :
                                                                                                                                                    Used by
                                                                                                                                                      def

                                                                                                                                                      Lean2Js.Js.Runtime.strSplit

                                                                                                                                                      source
                                                                                                                                                      (s sep : String) :
                                                                                                                                                      Equations
                                                                                                                                                      Instances For
                                                                                                                                                        Used by
                                                                                                                                                          def

                                                                                                                                                          Lean2Js.Js.Runtime.strSlice

                                                                                                                                                          source
                                                                                                                                                          (s : String) (lo hi : Int) :
                                                                                                                                                          Equations
                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                          Instances For
                                                                                                                                                            Used by
                                                                                                                                                              def

                                                                                                                                                              Lean2Js.Js.Runtime.mapSet

                                                                                                                                                              source
                                                                                                                                                              (entries : List (String × JsValue)) (key : String) (v : JsValue) :

                                                                                                                                                              Map.set overwrites in place and appends a key it has not seen, so iteration order survives both.

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

                                                                                                                                                                  Lean2Js.Js.Runtime.mapSetAll

                                                                                                                                                                  source

                                                                                                                                                                  What a Map filled from a list of entries holds: each one set in the order the list carries them. This model holds an object as an association list, which can carry a key twice where a real object cannot; a Map keeps the last of such a pair, at the place the first took, and saying so here is what lets a dictionary rebuilt out of an object need nothing of the object's keys.

                                                                                                                                                                  Equations
                                                                                                                                                                  Instances For
                                                                                                                                                                    Used by
                                                                                                                                                                      def

                                                                                                                                                                      Lean2Js.Js.Runtime.arrSlice

                                                                                                                                                                      source
                                                                                                                                                                      (xs : List JsValue) (lo hi : Int) :
                                                                                                                                                                      Equations
                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                      Instances For
                                                                                                                                                                        Used by
                                                                                                                                                                          def

                                                                                                                                                                          Lean2Js.Js.Runtime.at?

                                                                                                                                                                          source
                                                                                                                                                                          (xs : List JsValue) (i : Int) :
                                                                                                                                                                          Equations
                                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                                          Instances For
                                                                                                                                                                            Used by
                                                                                                                                                                              def

                                                                                                                                                                              Lean2Js.Js.Runtime.rangeNums

                                                                                                                                                                              source

                                                                                                                                                                              The whole numbers below n, as the model's numbers.

                                                                                                                                                                              Equations
                                                                                                                                                                              Instances For
                                                                                                                                                                                Used by
                                                                                                                                                                                  def

                                                                                                                                                                                  Lean2Js.Js.helper

                                                                                                                                                                                  source
                                                                                                                                                                                  (name : String) (args : List JsValue) :

                                                                                                                                                                                  The runtime helpers the generated code calls. Guarded by the reserved prefix every helper name carries, which is what tells a call to a declaration apart from a call to a helper.

                                                                                                                                                                                  The raised budget is what lets a proof case-split on this table: split builds the splitter with the options this declaration was elaborated under, not the ones in force where it is called.

                                                                                                                                                                                  Equations
                                                                                                                                                                                  Instances For
                                                                                                                                                                                    Used by
                                                                                                                                                                                      theorem

                                                                                                                                                                                      Lean2Js.Js.helper_join

                                                                                                                                                                                      source
                                                                                                                                                                                      Used by
                                                                                                                                                                                        inductive

                                                                                                                                                                                        Lean2Js.Js.HelperRow

                                                                                                                                                                                        source

                                                                                                                                                                                        The calls the table above answers. Stated as an inductive rather than read off helper at the use site because split builds its splitter in whatever module asks, under options that module cannot raise, and this table is past what they allow; here the matcher is at hand. A row added to helper without a constructor here fails helper_row.

                                                                                                                                                                                        Instances For
                                                                                                                                                                                          Used by
                                                                                                                                                                                            theorem

                                                                                                                                                                                            Lean2Js.Js.helper_row

                                                                                                                                                                                            source
                                                                                                                                                                                            {name : String} {args : List JsValue} {r : JsResult} (h : helper name args = some r) :
                                                                                                                                                                                            HelperRow name args
                                                                                                                                                                                            Used by
                                                                                                                                                                                              theorem

                                                                                                                                                                                              Lean2Js.Js.helper_of_isBodyName

                                                                                                                                                                                              source
                                                                                                                                                                                              {name : String} (h : isBodyName name = true) (args : List JsValue) :
                                                                                                                                                                                              helper name args = none

                                                                                                                                                                                              A declaration's body function is no runtime helper. Every row of the table names a literal, and none of them carries _ where the body prefix does, so a call the compiler redirects to a body reaches the module's own function and not the table. Read off HelperRow rather than off helper, for the reason HelperRow exists.

                                                                                                                                                                                              Used by
                                                                                                                                                                                                def

                                                                                                                                                                                                Lean2Js.Js.arith

                                                                                                                                                                                                source
                                                                                                                                                                                                (op : String) (a b : JsValue) :
                                                                                                                                                                                                Equations
                                                                                                                                                                                                Instances For
                                                                                                                                                                                                  Used by
                                                                                                                                                                                                    def

                                                                                                                                                                                                    Lean2Js.Js.arith.sameValue

                                                                                                                                                                                                    source
                                                                                                                                                                                                    :

                                                                                                                                                                                                    === compares values on scalars and references on everything else. The generated code calls __eq in the latter case, so the model admits only the former.

                                                                                                                                                                                                    Equations
                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      Used by
                                                                                                                                                                                                        def

                                                                                                                                                                                                        Lean2Js.Js.arith.order

                                                                                                                                                                                                        source
                                                                                                                                                                                                        (x y : JsValue) (keep : Ordering → Bool) :
                                                                                                                                                                                                        Equations
                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          Used by

                                                                                                                                                                                                            Reading a field by name #

                                                                                                                                                                                                            Everything below asks an object for a key rather than for a position: the order a JavaScript object carries its keys in is not something a caller can be held to.

                                                                                                                                                                                                            def

                                                                                                                                                                                                            Lean2Js.Js.lookupField

                                                                                                                                                                                                            source
                                                                                                                                                                                                            (fields : List (String × JsValue)) (k : String) :
                                                                                                                                                                                                            Equations
                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                Lean2Js.Js.sizeOf_lookupField

                                                                                                                                                                                                                source
                                                                                                                                                                                                                (fields : List (String × JsValue)) (k : String) {v : JsValue} (h : lookupField fields k = some v) :
                                                                                                                                                                                                                sizeOf v < sizeOf fields
                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                  def

                                                                                                                                                                                                                  Lean2Js.Js.descRank

                                                                                                                                                                                                                  source
                                                                                                                                                                                                                  @[reducible]
                                                                                                                                                                                                                  :

                                                                                                                                                                                                                  What a step that does not descend into the value shrinks instead. Entering a mu lands on the ctors node it binds, and resolving a ref lands on the one its binder holds, so both reach rank one and every step after that is measured by the value.

                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                      def

                                                                                                                                                                                                                      Lean2Js.Js.checkTy

                                                                                                                                                                                                                      source
                                                                                                                                                                                                                      @[irreducible]
                                                                                                                                                                                                                      (env : TyEnv) :

                                                                                                                                                                                                                      Whether a value matches the type its declaration promised. This mirrors Value.hasTy on every value a caller can hand over; the two are held together by the vectors that call an exported function with an argument of the wrong shape. The one value they disagree on is a dictionary holding the same key twice, which hasTy refuses and this accepts — a Map cannot hold one, and dictKeysDistinctList is the hypothesis that fences it out of the statements that need the two to coincide.

                                                                                                                                                                                                                      A constructor's fields are read by name, so the order they arrive in does not matter and a key the descriptor does not name is ignored. normTy below is what puts such a value back into the shape encodeValue writes.

                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                          def

                                                                                                                                                                                                                          Lean2Js.Js.checkFields

                                                                                                                                                                                                                          source
                                                                                                                                                                                                                          @[irreducible]
                                                                                                                                                                                                                          (env : TyEnv) (fields : List (String × JsValue)) :
                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                              def

                                                                                                                                                                                                                              Lean2Js.Js.checkList

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

                                                                                                                                                                                                                                  Lean2Js.Js.checkEntries

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

                                                                                                                                                                                                                                      Descriptors a compiled type renders #

                                                                                                                                                                                                                                      Field names a constructor may carry: distinct, and none of them the key the constructor's own name is carried under. Compile.lean rejects a field named that key, and Decl.lean proves the names distinct for a well-formed type. Without both, the object this reads by name and the Value the reference semantics reads by position are different readings.

                                                                                                                                                                                                                                      def

                                                                                                                                                                                                                                      Lean2Js.Js.namesOk

                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                      (key : String) :
                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                          def

                                                                                                                                                                                                                                          Lean2Js.Js.descOk

                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                          @[irreducible]
                                                                                                                                                                                                                                          (depth : Nat) :
                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                              def

                                                                                                                                                                                                                                              Lean2Js.Js.fieldsOk

                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                              @[irreducible]
                                                                                                                                                                                                                                              (depth : Nat) :
                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                  def

                                                                                                                                                                                                                                                  Lean2Js.Js.altsOk

                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                  @[irreducible]
                                                                                                                                                                                                                                                  (depth : Nat) (key : String) :
                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                      def

                                                                                                                                                                                                                                                      Lean2Js.Js.envOk

                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                      :

                                                                                                                                                                                                                                                      What an environment a ref may be resolved in has to be: each binder's alternatives well formed at the depth that binder sits at, which is its own plus everything outside it.

                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                          Lean2Js.Js.envOk_drop

                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                          {env : TyEnv} (k : Nat) :
                                                                                                                                                                                                                                                          envOk env = true → envOk (List.drop k env) = true

                                                                                                                                                                                                                                                          The environment from a binder outwards is an environment: a ref resolved in it is resolved in one whose entries are still well formed at the depth they sit at.

                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                            Lean2Js.Js.envOk_getElem

                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                            {env : TyEnv} {k : Nat} {b : String × TyAlts} :
                                                                                                                                                                                                                                                            envOk env = true → env[k]? = some b → altsOk (List.drop k env).length b.fst b.snd = true

                                                                                                                                                                                                                                                            What a binder holds is well formed at the depth of the environment it opens.

                                                                                                                                                                                                                                                            Used by

                                                                                                                                                                                                                                                              Descriptors that reach no dictionary crossing as an object #

                                                                                                                                                                                                                                                              The predicates themselves are in Js.lean, beside the descriptor they read, because the compiler consults them to decide whether a declaration's entry needs a walk out at all. What is here is what a proof needs of them.

                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                              Lean2Js.Js.envNoDictObj_drop

                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                              {env : TyEnv} (k : Nat) :
                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                Lean2Js.Js.envNoDictObj_getElem

                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                {env : TyEnv} {k : Nat} {b : String × TyAlts} :
                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                  Lean2Js.Js.altsNoDictObj_find

                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                  {alts : List (String × List (String × TyDesc))} {ctor : String} {alt : String × List (String × TyDesc)} (h : altsNoDictObj alts = true) (hf : List.find? (fun (x : String × List (String × TyDesc)) => x.fst == ctor) alts = some alt) :
                                                                                                                                                                                                                                                                  Used by

                                                                                                                                                                                                                                                                    The canonical shape #

                                                                                                                                                                                                                                                                    checkTy reads a constructor's fields by name, so a value it accepts may carry them in any order and may carry keys the descriptor does not name. normTy rebuilds it with the key the constructor's name is carried under first and the constructor's fields in declared order, dropping the keys the descriptor does not name, so what reaches the body is the value encodeValue writes.

                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                    Lean2Js.Js.normTy

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

                                                                                                                                                                                                                                                                        Lean2Js.Js.normList

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

                                                                                                                                                                                                                                                                            Lean2Js.Js.normEntries

                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                Lean2Js.Js.normFields

                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                (env : TyEnv) (fields : List (String × JsValue)) :
                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                  Used by

                                                                                                                                                                                                                                                                                    The shape a result leaves in #

                                                                                                                                                                                                                                                                                    A dictionary is a Map everywhere inside the module, whatever its declared type says it crosses the boundary as. outTy is what the entry reads its result through: the walk normTy does, differing at exactly one node — a dictObj becomes the plain object a consumer can stringify, where normTy on the way in made the Map the body runs on.

                                                                                                                                                                                                                                                                                    Everywhere else the two agree, so a return type reaching no dictObj is handed back untouched and the entry emits no wrapper at all.

                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                    Lean2Js.Js.outTy

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

                                                                                                                                                                                                                                                                                        Lean2Js.Js.outList

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

                                                                                                                                                                                                                                                                                            Lean2Js.Js.outEntries

                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                Lean2Js.Js.outFields

                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                (env : TyEnv) (fields : List (String × JsValue)) :
                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                  Used by

                                                                                                                                                                                                                                                                                                    Dictionaries a Map could have produced #

                                                                                                                                                                                                                                                                                                    checkTy never looks at a dictionary's keys, because the value it is handed is a Map and a Map cannot hold one key twice. This model holds a dictionary as an association list, which can carry what no Map can, so a claim about what the generated code accepts has to say it is looking at the values the runtime actually hands it.

                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                    Lean2Js.Js.keysDistinct

                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                        Lean2Js.Js.dictKeysDistinct

                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                            Lean2Js.Js.dictKeysDistinctFields

                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                Lean2Js.Js.dictKeysDistinctList

                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                    Lean2Js.Js.bindAll

                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                        Lean2Js.Js.calleeName

                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                        (env : JsEnv) (name : String) :

                                                                                                                                                                                                                                                                                                                        The function a call lands on. A binding holding a function shadows the module's own, the way a local name shadows a function declaration in real JavaScript; anything else bound to the name is not something the compiler emits a call through.

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

                                                                                                                                                                                                                                                                                                                            Lean2Js.Js.keyLe

                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                            :

                                                                                                                                                                                                                                                                                                                            The order __sortBy puts its keys in. A number is compared with <= and a string through __strcmp, which is the code-point order the rest of the model already uses for < on two strings.

                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                Lean2Js.Js.isNumKey

                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                    Lean2Js.Js.isStrKey

                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                        Lean2Js.Js.keysOk

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

                                                                                                                                                                                                                                                                                                                                            Lean2Js.Js.sortPairs

                                                                                                                                                                                                                                                                                                                                            source

                                                                                                                                                                                                                                                                                                                                            The keys are asked to be all numbers or all strings, which is more than the helper asks and exactly what the key type gives. Mixing them would put __strcmp on a number, which the model has no answer for.

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

                                                                                                                                                                                                                                                                                                                                                Lean2Js.Js.eval

                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                (m : Module) (fuel : Nat) (env : JsEnv) (e : Expr) :

                                                                                                                                                                                                                                                                                                                                                Evaluation of the generated code. && and || short-circuit as they do in JS.

                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Js.evalList

                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                    (m : Module) (fuel : Nat) (env : JsEnv) (es : List Expr) :
                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Js.evalMapJs

                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                        (m : Module) (fuel : Nat) (env : JsEnv) (binder : String) (body : Expr) (xs : List JsValue) :

                                                                                                                                                                                                                                                                                                                                                        The combinators are walked here rather than modelled as a function value handed to a helper, so that nothing in the model is ever a closure.

                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Js.evalFilterJs

                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                            (m : Module) (fuel : Nat) (env : JsEnv) (binder : String) (body : Expr) (xs : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Js.evalFindJs

                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                (m : Module) (fuel : Nat) (env : JsEnv) (binder : String) (body : Expr) (xs : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Js.evalQuantJs

                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                    (m : Module) (fuel : Nat) (env : JsEnv) (op : Core.QuantOp) (binder : String) (body : Expr) (xs : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Js.evalReduceJs

                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                        (m : Module) (fuel : Nat) (env : JsEnv) (accName elemName : String) (body : Expr) (acc : JsValue) (xs : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Js.evalFoldJs

                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                            (m : Module) (fuel : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (v : JsValue) :

                                                                                                                                                                                                                                                                                                                                                                            What __fold computes, walked here rather than reached as a call to the helper, the way mapJs is: the node is rebuilt out of the fields the spec names, with each field that came round replaced by the answer for it, and body runs on the rebuilt node with binder bound to it.

                                                                                                                                                                                                                                                                                                                                                                            A field the spec names and the node does not carry is a missing property read, which this model refuses exactly as member does — real JavaScript reads undefined there, and a node the entry check accepted carries every field its constructor declares.

                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Js.evalFoldList

                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                (m : Module) (fuel : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (xs : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Js.evalFoldListAt

                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                    (m : Module) (fuel : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (v : JsValue) :

                                                                                                                                                                                                                                                                                                                                                                                    A field the spec says holds a list of the type coming round. Anything but an array is a value the entry check would not have let through, so the walk refuses it rather than guessing.

                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Js.evalFoldPairs

                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                        (m : Module) (fuel : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (es : List (String × JsValue)) :
                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Js.evalStmts

                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                                                                                                                                                                                            (m : Module) (fuel : Nat) (env : JsEnv) (stmts : List Stmt) :
                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                              Used by

                                                                                                                                                                                                                                                                                                                                                                                                Unfolding the fold walk #

                                                                                                                                                                                                                                                                                                                                                                                                The fold family recurses on the value rather than on the fuel, under the same five-component measure eval is defined by, so Lean does not hand back its equations as definitional unfoldings the way it does for a definition structural in its argument like evalMapJs. These state them once, so the agreement proof rewrites with a lemma where the map proofs rewrite with Js.evalMapJs itself.

                                                                                                                                                                                                                                                                                                                                                                                                They are the twins of Eval.evalFold_obj and the five under it, against JsValue rather than Value and reading the spec the compiler emitted rather than the declaration the spec came from.

                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Js.evalFoldJs_obj

                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                (m : Module) (f : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (es : List (String × JsValue)) :
                                                                                                                                                                                                                                                                                                                                                                                                evalFoldJs m f env key spec binder body (JsValue.obj es) = match lookupField es key with | some (JsValue.str tag) => match Option.map (fun (x : String × FoldFields) => x.snd) (List.find? (fun (x : String × FoldFields) => x.fst == tag) spec) with | some fs => do let ps ← evalFoldPairs m f env key spec binder body es fs eval m f ((binder, JsValue.obj (Runtime.mapSetAll [(key, JsValue.str tag)] ps)) :: env) body | none => Except.error "typeError" | x => Except.error "typeError"
                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Js.evalFoldList_nil

                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                  (m : Module) (f : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                  evalFoldList m f env key spec binder body [] = Except.ok []
                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Js.evalFoldList_cons

                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                    (m : Module) (f : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (x : JsValue) (rest : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                                                                    evalFoldList m f env key spec binder body (x :: rest) = do let y ← evalFoldJs m f env key spec binder body x let ys ← evalFoldList m f env key spec binder body rest Except.ok (y :: ys)
                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Js.evalFoldListAt_arr

                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                      (m : Module) (f : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (xs : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                                                                      evalFoldListAt m f env key spec binder body (JsValue.arr xs) = evalFoldList m f env key spec binder body xs
                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Js.evalFoldPairs_nil

                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                        (m : Module) (f : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (es : List (String × JsValue)) :
                                                                                                                                                                                                                                                                                                                                                                                                        evalFoldPairs m f env key spec binder body es [] = Except.ok []
                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Js.evalFoldPairs_cons_none

                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                          (m : Module) (f : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (es : List (String × JsValue)) (n : String) (k : FoldKind) (rest : FoldFields) (h : lookupField es n = none) :
                                                                                                                                                                                                                                                                                                                                                                                                          evalFoldPairs m f env key spec binder body es ((n, k) :: rest) = Except.error "typeError"
                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Js.evalFoldPairs_cons_some

                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                            (m : Module) (f : Nat) (env : JsEnv) (key : String) (spec : FoldSpec) (binder : String) (body : Expr) (es : List (String × JsValue)) (n : String) (k : FoldKind) (rest : FoldFields) {v : JsValue} (h : lookupField es n = some v) :
                                                                                                                                                                                                                                                                                                                                                                                                            evalFoldPairs m f env key spec binder body es ((n, k) :: rest) = match k with | FoldKind.plain => do let ps ← evalFoldPairs m f env key spec binder body es rest Except.ok ((n, v) :: ps) | FoldKind.self => do let y ← evalFoldJs m f env key spec binder body v let ps ← evalFoldPairs m f env key spec binder body es rest Except.ok ((n, y) :: ps) | FoldKind.list => do let ys ← evalFoldListAt m f env key spec binder body v let ps ← evalFoldPairs m f env key spec binder body es rest Except.ok ((n, JsValue.arr ys) :: ps)
                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                              def

                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Js.callFunctionAt

                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                              (m : Module) (fuel : Nat) (name : String) (args : List JsValue) :

                                                                                                                                                                                                                                                                                                                                                                                                              Calling an exported function at a stated amount of fuel. The model's fuel is what makes eval total; real JavaScript has none, so a claim about the generated code is stated for every large enough amount and callFunction fixes the one the shipped artifact is checked at.

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

                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Js.eval_call

                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                  (m : Module) (f : Nat) (env : JsEnv) (name : String) (args : List Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                  eval m (f + 1) env (Expr.call name args) = do let vs ← evalList m f env args match helper name vs with | some r => r | none => callFunctionAt m f (calleeName env name) vs

                                                                                                                                                                                                                                                                                                                                                                                                                  A call evaluates its arguments and then runs the callee, which is what callFunctionAt does.

                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Js.callFunction

                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                    (m : Module) (name : String) (args : List JsValue) :
                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                      Used by