lean2js

Lean2Js.Eval

source

Imports 2

The reference semantics of the subset, as a fuelled big-step evaluator #

The reference semantics of the subset. Every correctness theorem is stated as agreement between "the result of this eval" and "the result of evaluating the generated JS".

It is a fuelled big-step semantics because partial would make termination an axiom, putting it beyond the reach of proof.

abbrev

Lean2Js.Env

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

      Lean2Js.Env.lookup?

      source
      (env : Env) (name : String) :
      Equations
      Instances For
        Used by
          def

          Lean2Js.litValue

          source
          Equations
          Instances For
            Used by
              def

              Lean2Js.mkInt53

              source

              Int53 traps rather than wraps. JS's Number silently loses precision past 2^53, so failing makes the semantics easier to line up than quietly returning a wrong answer.

              Equations
              Instances For
                Used by
                  def

                  Lean2Js.rangeValues

                  source
                  (n : Int) :

                  The elements of Arr.range n: the whole numbers below n, and none of them when n is not positive. Every element is smaller than n, so an argument that is an Int53 bounds them all and no element of the answer can be out of range.

                  Equations
                  Instances For
                    Used by
                      def

                      Lean2Js.applyUn

                      source
                      Equations
                      Instances For
                        Used by
                          def

                          Lean2Js.applyArith

                          source

                          Integer division is pinned to truncation. Lean's / is floor division (-7 / 2 = -4), which disagrees with JS's Math.trunc(-7 / 2) = -3.

                          Equations
                          Instances For
                            Used by
                              def

                              Lean2Js.compareValues

                              source
                              Equations
                              Instances For
                                Used by
                                  def

                                  Lean2Js.compareValues.orderBy

                                  source
                                  (op : Core.BinOp) (o : Ordering) :
                                  Equations
                                  Instances For
                                    Used by
                                      def

                                      Lean2Js.applyMinMax

                                      source
                                      (op : Core.BinOp) (a b : Value) :

                                      Strings are left out even though they are ordered: JS's < orders them by UTF-16 unit, so a String min would have to route through __strcmp the way the ordering comparisons do.

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

                                          Lean2Js.applyBin

                                          source
                                          (op : Core.BinOp) (a b : Value) :
                                          Equations
                                          Instances For
                                            Used by
                                              def

                                              Lean2Js.isTrimmable

                                              source
                                              (c : Char) :

                                              The whitespace trim strips. Written out rather than delegated to Char.isWhitespace because the generated code has to strip exactly this set, and JS's own trim also takes NBSP, the BOM and the line separators.

                                              Equations
                                              Instances For
                                                Used by
                                                  def

                                                  Lean2Js.asciiUpper

                                                  source
                                                  (c : Char) :

                                                  Case conversion is ASCII only. JS's toUpperCase is neither: it maps ß to SS, which changes the length of the string.

                                                  Equations
                                                  Instances For
                                                    Used by
                                                      def

                                                      Lean2Js.asciiLower

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

                                                          Lean2Js.trimChars

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

                                                              Lean2Js.hasInfix

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

                                                                  Lean2Js.indexOfChars

                                                                  source

                                                                  Where needle first sits in the haystack, counted in code points. The empty needle sits at 0, so this answers some 0 on the empty haystack too.

                                                                  Equations
                                                                  Instances For
                                                                    Used by
                                                                      def

                                                                      Lean2Js.splitStr

                                                                      source
                                                                      (s sep : String) :

                                                                      Splitting on the empty separator gives back the whole string. JS's split("") instead returns the UTF-16 units, which is why the generated code cannot call it unguarded.

                                                                      Equations
                                                                      Instances For
                                                                        Used by
                                                                          def

                                                                          Lean2Js.joinFrom

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

                                                                              Lean2Js.joinStr

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

                                                                                  Lean2Js.repeatStr

                                                                                  source
                                                                                  (s : String) :

                                                                                  s written n times over, one copy at a time. The halving the emitted helper uses is proved equal to this in Correct; this is the shape the docstring claims.

                                                                                  Equations
                                                                                  Instances For
                                                                                    Used by
                                                                                      theorem

                                                                                      Lean2Js.repeatStr_empty

                                                                                      source
                                                                                      (n : Nat) :
                                                                                      repeatStr "" n = ""
                                                                                      Used by
                                                                                        def

                                                                                        Lean2Js.valueStrs

                                                                                        source
                                                                                        Equations
                                                                                        Instances For
                                                                                          Used by
                                                                                            theorem

                                                                                            Lean2Js.valueStrs_map_str

                                                                                            source
                                                                                            Used by
                                                                                              def

                                                                                              Lean2Js.dictLookup

                                                                                              source
                                                                                              (entries : List (String × Value)) (k : String) :
                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                Used by
                                                                                                  def

                                                                                                  Lean2Js.dictWith

                                                                                                  source
                                                                                                  (entries : List (String × Value)) (k : String) (v : Value) :

                                                                                                  Writing an existing key leaves it where it is and writing a new one appends, which is what Map.set does. Iteration order is observable through keys, so the two have to agree on it.

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

                                                                                                      Lean2Js.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, which parseInt53 throws away by printing the answer back.

                                                                                                      Equations
                                                                                                      Instances For
                                                                                                        Used by
                                                                                                          def

                                                                                                          Lean2Js.parseInt53

                                                                                                          source

                                                                                                          Reading an Int53 back from its decimal spelling. The answer has to print as the string it was read from, so what this accepts is exactly what toString prints: "007", "+5", " 5" and "-0" are refused, and so is anything outside the Int53 range.

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

                                                                                                              Lean2Js.parseInt53_range

                                                                                                              source
                                                                                                              {s : String} {n : Int} (h : parseInt53 s = some n) :
                                                                                                              Used by
                                                                                                                def

                                                                                                                Lean2Js.applyStrUn

                                                                                                                source
                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  Used by
                                                                                                                    def

                                                                                                                    Lean2Js.applyStrBin

                                                                                                                    source
                                                                                                                    Equations
                                                                                                                    Instances For
                                                                                                                      Used by
                                                                                                                        def

                                                                                                                        Lean2Js.sliceStr

                                                                                                                        source
                                                                                                                        (s lo hi : Value) :

                                                                                                                        Indices count code points, and one outside the string traps the way an array read does. Clamping is what JS's own substring would do, and silently returning a shorter string is worse than failing.

                                                                                                                        Equations
                                                                                                                        Instances For
                                                                                                                          Used by
                                                                                                                            def

                                                                                                                            Lean2Js.sliceArr

                                                                                                                            source
                                                                                                                            (a lo hi : Value) :

                                                                                                                            Bounds count elements and one outside the array traps, exactly as substring's do on a String.

                                                                                                                            Equations
                                                                                                                            Instances For
                                                                                                                              Used by
                                                                                                                                def

                                                                                                                                Lean2Js.asBool

                                                                                                                                source
                                                                                                                                Equations
                                                                                                                                Instances For
                                                                                                                                  Used by
                                                                                                                                    def

                                                                                                                                    Lean2Js.calleeOf

                                                                                                                                    source
                                                                                                                                    (env : Env) (fn : String) :

                                                                                                                                    A function-typed parameter holds the name of a declaration, so applying it is an ordinary call to that name. Anything else bound to the name is rejected by the compiler, never here.

                                                                                                                                    Equations
                                                                                                                                    Instances For
                                                                                                                                      Used by
                                                                                                                                        def

                                                                                                                                        Lean2Js.bindParams

                                                                                                                                        source
                                                                                                                                        Equations
                                                                                                                                        Instances For
                                                                                                                                          Used by
                                                                                                                                            def

                                                                                                                                            Lean2Js.bindNames

                                                                                                                                            source
                                                                                                                                            Equations
                                                                                                                                            Instances For
                                                                                                                                              Used by
                                                                                                                                                def

                                                                                                                                                Lean2Js.matchPat

                                                                                                                                                source
                                                                                                                                                @[irreducible]

                                                                                                                                                What a pattern binds when it matches the value, and nothing when it does not. Matching needs no evaluation, so Step runs the same function in one transition rather than decomposing the scrutinee across frames.

                                                                                                                                                Equations
                                                                                                                                                Instances For
                                                                                                                                                  Used by
                                                                                                                                                    def

                                                                                                                                                    Lean2Js.matchPats

                                                                                                                                                    source
                                                                                                                                                    @[irreducible]
                                                                                                                                                    Equations
                                                                                                                                                    Instances For
                                                                                                                                                      Used by
                                                                                                                                                        def

                                                                                                                                                        Lean2Js.firstMatch

                                                                                                                                                        source

                                                                                                                                                        The first arm whose pattern matches, with what it bound. Arms are tried in order, so an arm is reached only when every earlier one failed.

                                                                                                                                                        Equations
                                                                                                                                                        Instances For
                                                                                                                                                          Used by
                                                                                                                                                            def

                                                                                                                                                            Lean2Js.keyLe

                                                                                                                                                            source
                                                                                                                                                            :
                                                                                                                                                            Value → Value → Bool

                                                                                                                                                            The order the keys of a sortByKey are compared by. Int53 and String are the only key types the compiler lets through, and both orders are the ones the subset already has: ≤ on Int53, and the code-point order compare gives, which is what < on two strings already means here.

                                                                                                                                                            Equations
                                                                                                                                                            Instances For
                                                                                                                                                              Used by
                                                                                                                                                                def

                                                                                                                                                                Lean2Js.isNumKey

                                                                                                                                                                source
                                                                                                                                                                :
                                                                                                                                                                Equations
                                                                                                                                                                Instances For
                                                                                                                                                                  Used by
                                                                                                                                                                    def

                                                                                                                                                                    Lean2Js.isStrKey

                                                                                                                                                                    source
                                                                                                                                                                    :
                                                                                                                                                                    Equations
                                                                                                                                                                    Instances For
                                                                                                                                                                      Used by
                                                                                                                                                                        def

                                                                                                                                                                        Lean2Js.keysOk

                                                                                                                                                                        source
                                                                                                                                                                        (ps : List (Value × Value)) :

                                                                                                                                                                        The keys are all Int53 or all String. A well-typed program cannot reach the other case: the key type is settled by the compiler before the walk runs.

                                                                                                                                                                        Equations
                                                                                                                                                                        Instances For
                                                                                                                                                                          Used by
                                                                                                                                                                            def

                                                                                                                                                                            Lean2Js.sortPairs

                                                                                                                                                                            source

                                                                                                                                                                            List.mergeSort is the model rather than a sort of our own so that what it already proves — the answer is a permutation of the input, and equal keys keep the order they came in — is what an author reasons with.

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

                                                                                                                                                                                Lean2Js.sortPairs_ne_outOfFuel

                                                                                                                                                                                source
                                                                                                                                                                                Used by
                                                                                                                                                                                  theorem

                                                                                                                                                                                  Lean2Js.sortPairs_mem

                                                                                                                                                                                  source
                                                                                                                                                                                  {ps : List (Value × Value)} {vs : List Value} (h : sortPairs ps = Except.ok vs) {w : Value} (hw : w ∈ vs) :
                                                                                                                                                                                  ∃ (pr : Value × Value), pr ∈ ps ∧ pr.snd = w

                                                                                                                                                                                  Every value the sort answers with came in, which is what carries a property of the elements across it. List.mergeSort gives the permutation; the pairing gives the element back.

                                                                                                                                                                                  Used by
                                                                                                                                                                                    def

                                                                                                                                                                                    Lean2Js.evalExpr

                                                                                                                                                                                    source
                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                    (p : Core.Program) (fuel : Nat) (env : Env) (e : Core.Expr) :

                                                                                                                                                                                    and / or are handled first because JS's && / || short-circuit. Evaluating both sides would make false && (1 / 0) give false in JS and a trap here, splitting the differential test at once.

                                                                                                                                                                                    Equations
                                                                                                                                                                                    Instances For
                                                                                                                                                                                      Used by
                                                                                                                                                                                        def

                                                                                                                                                                                        Lean2Js.evalArgs

                                                                                                                                                                                        source
                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                        (p : Core.Program) (fuel : Nat) (env : Env) (es : List Core.Expr) :
                                                                                                                                                                                        Equations
                                                                                                                                                                                        Instances For
                                                                                                                                                                                          Used by
                                                                                                                                                                                            def

                                                                                                                                                                                            Lean2Js.evalMapItems

                                                                                                                                                                                            source
                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                            (p : Core.Program) (fuel : Nat) (env : Env) (binder : String) (body : Core.Expr) (xs : List Value) :
                                                                                                                                                                                            Equations
                                                                                                                                                                                            Instances For
                                                                                                                                                                                              Used by
                                                                                                                                                                                                def

                                                                                                                                                                                                Lean2Js.evalFilterItems

                                                                                                                                                                                                source
                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                (p : Core.Program) (fuel : Nat) (env : Env) (binder : String) (body : Core.Expr) (xs : List Value) :
                                                                                                                                                                                                Equations
                                                                                                                                                                                                Instances For
                                                                                                                                                                                                  Used by
                                                                                                                                                                                                    def

                                                                                                                                                                                                    Lean2Js.evalFindItems

                                                                                                                                                                                                    source
                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                    (p : Core.Program) (fuel : Nat) (env : Env) (binder : String) (body : Core.Expr) (xs : List Value) :

                                                                                                                                                                                                    Stops at the first element the predicate accepts, so a predicate that would trap on a later element never sees it.

                                                                                                                                                                                                    Equations
                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      Used by
                                                                                                                                                                                                        def

                                                                                                                                                                                                        Lean2Js.evalQuantItems

                                                                                                                                                                                                        source
                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                        (p : Core.Program) (fuel : Nat) (env : Env) (op : Core.QuantOp) (binder : String) (body : Core.Expr) (xs : List Value) :
                                                                                                                                                                                                        Equations
                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          Used by
                                                                                                                                                                                                            def

                                                                                                                                                                                                            Lean2Js.evalFold

                                                                                                                                                                                                            source
                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                            (p : Core.Program) (fuel : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (v : Value) :

                                                                                                                                                                                                            A fold over a value of a declared type, from the leaves up. Each node is rebuilt with every field that came round replaced by the fold's answer for it, and the alternatives then read the rebuilt node exactly as a match's do — so the walk is here and not in the subset.

                                                                                                                                                                                                            The recursion is on the value and not on the fuel, the way evalMapItems walks its list at the fuel it was handed. That is what keeps a fold one expression node however deep the value is, and so what keeps Cost.cost readable off the syntax.

                                                                                                                                                                                                            A value whose constructor the declared type does not name, and a field the declaration names that the value does not carry, are both refused rather than guessed at: a well-typed program reaches neither.

                                                                                                                                                                                                            Equations
                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                def

                                                                                                                                                                                                                Lean2Js.evalFoldList

                                                                                                                                                                                                                source
                                                                                                                                                                                                                @[irreducible]
                                                                                                                                                                                                                (p : Core.Program) (fuel : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (xs : List Value) :
                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                    def

                                                                                                                                                                                                                    Lean2Js.evalFoldListAt

                                                                                                                                                                                                                    source
                                                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                                                    (p : Core.Program) (fuel : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (v : Value) :

                                                                                                                                                                                                                    A field the declaration gives a list of the type coming round. Anything but an array is a value no well-typed program builds, so the walk refuses it rather than folding something else.

                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                        def

                                                                                                                                                                                                                        Lean2Js.evalFoldFields

                                                                                                                                                                                                                        source
                                                                                                                                                                                                                        @[irreducible]
                                                                                                                                                                                                                        (p : Core.Program) (fuel : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (fields : List (String × Value)) :
                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                            def

                                                                                                                                                                                                                            Lean2Js.evalReduceItems

                                                                                                                                                                                                                            source
                                                                                                                                                                                                                            @[irreducible]
                                                                                                                                                                                                                            (p : Core.Program) (fuel : Nat) (env : Env) (accName elemName : String) (body : Core.Expr) (acc : Value) (xs : List Value) :
                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                Lean2Js.defaultFuel

                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                :

                                                                                                                                                                                                                                The upper bound on call depth. Differential test calls are built so as not to exceed it.

                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                    Lean2Js.evalCall

                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                    (p : Core.Program) (fn : String) (args : List Value) :

                                                                                                                                                                                                                                    Calls one exported function. The argument types are checked against the declaration at the entry.

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

                                                                                                                                                                                                                                        Lean2Js.defaultFuel_succ

                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                        :
                                                                                                                                                                                                                                        defaultFuel = 9999 + 1
                                                                                                                                                                                                                                        Used by

                                                                                                                                                                                                                                          Unfolding one step at a time #

                                                                                                                                                                                                                                          evalExpr.eq_def cannot be handed to simp on its own: its right-hand side calls evalExpr again, so rewriting with it does not stop. One lemma per syntactic form fires only where that form actually is, which is what lets a proof about a declaration walk its body.

                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                          Lean2Js.evalExpr_zero

                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                            Lean2Js.evalExpr_lit

                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (l : Core.Lit) :
                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                              Lean2Js.evalExpr_var

                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (name : String) :
                                                                                                                                                                                                                                              evalExpr p (f + 1) env (Core.Expr.var name) = match env.lookup? name with | some v => Except.ok v | none => Except.error (Err.unknownVar name)
                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                Lean2Js.evalExpr_cond

                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                (p : Core.Program) (f : Nat) (env : Env) (c t e : Core.Expr) :
                                                                                                                                                                                                                                                evalExpr p (f + 1) env (c.cond t e) = do let __do_lift ← evalExpr p f env c match __do_lift with | Value.bool true => evalExpr p f env t | Value.bool false => evalExpr p f env e | x => Except.error (Err.typeError "condition expects a Bool")
                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                  Lean2Js.evalExpr_bin

                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                  (p : Core.Program) (f : Nat) (env : Env) (op : Core.BinOp) (lhs rhs : Core.Expr) (hop : op ≠ Core.BinOp.and) (hor : op ≠ Core.BinOp.or) :
                                                                                                                                                                                                                                                  evalExpr p (f + 1) env (Core.Expr.bin op lhs rhs) = do let a ← evalExpr p f env lhs let b ← evalExpr p f env rhs applyBin op a b
                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                    Lean2Js.evalExpr_matchE

                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                    (p : Core.Program) (f : Nat) (env : Env) (scrut : Core.Expr) (alts : List Core.Alt) :
                                                                                                                                                                                                                                                    evalExpr p (f + 1) env (scrut.matchE alts) = do let __do_lift ← evalExpr p f env scrut match firstMatch alts __do_lift with | some (binds, body) => evalExpr p f (binds ++ env) body | none => Except.error Err.noMatchingAlternative
                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                      Lean2Js.evalExpr_foldE

                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                      (p : Core.Program) (f : Nat) (env : Env) (scrut : Core.Expr) (typeName : String) (tyArgs : List Core.Ty) (result : Core.Ty) (alts : List Core.Alt) :
                                                                                                                                                                                                                                                      evalExpr p (f + 1) env (scrut.foldE typeName tyArgs result alts) = do let __do_lift ← evalExpr p f env scrut evalFold p f env typeName tyArgs alts __do_lift
                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                        Lean2Js.evalExpr_okE

                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                        (p : Core.Program) (f : Nat) (env : Env) (err : Core.Ty) (e : Core.Expr) :
                                                                                                                                                                                                                                                        evalExpr p (f + 1) env (Core.Expr.okE err e) = do let __do_lift ← evalExpr p f env e Except.ok (Value.obj "ok" [("value", __do_lift)])
                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                          Lean2Js.evalExpr_errorE

                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                          (p : Core.Program) (f : Nat) (env : Env) (ok : Core.Ty) (e : Core.Expr) :
                                                                                                                                                                                                                                                          evalExpr p (f + 1) env (Core.Expr.errorE ok e) = do let __do_lift ← evalExpr p f env e Except.ok (Value.obj "error" [("error", __do_lift)])
                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                            Lean2Js.evalExpr_ctor

                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (ctorName : String) (args : List Core.Expr) :
                                                                                                                                                                                                                                                            evalExpr p (f + 1) env (Core.Expr.ctor typeName tyArgs ctorName args) = do let vs ← evalArgs p f env args match p.findType? typeName with | none => Except.error (Err.typeError (toString "unknown type: " ++ toString typeName)) | some t => match t.find? ctorName with | none => Except.error (Err.typeError (toString typeName ++ toString " has no constructor " ++ toString ctorName)) | some c => if (c.fields.length != vs.length) = true then Except.error (Err.arity ctorName) else Except.ok (Value.obj ctorName ((List.map (fun (x : Core.Field) => x.name) c.fields).zip vs))
                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                              Lean2Js.evalExpr_proj

                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (e : Core.Expr) (field : String) :
                                                                                                                                                                                                                                                              evalExpr p (f + 1) env (e.proj field) = do let __do_lift ← evalExpr p f env e match __do_lift with | Value.obj ctor fields => match Option.map (fun (x : String × Value) => x.snd) (List.find? (fun (x : String × Value) => x.fst == field) fields) with | some v => Except.ok v | none => Except.error (Err.typeError (toString "no field named " ++ toString field)) | x => Except.error (Err.typeError "field access expects a constructor value")
                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                Lean2Js.evalExpr_fnRef

                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                (p : Core.Program) (f : Nat) (env : Env) (name : String) :
                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                  Lean2Js.evalExpr_un

                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                  (p : Core.Program) (f : Nat) (env : Env) (op : Core.UnOp) (e : Core.Expr) :
                                                                                                                                                                                                                                                                  evalExpr p (f + 1) env (Core.Expr.un op e) = do let __do_lift ← evalExpr p f env e applyUn op __do_lift
                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                    Lean2Js.evalExpr_and

                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                    (p : Core.Program) (f : Nat) (env : Env) (lhs rhs : Core.Expr) :
                                                                                                                                                                                                                                                                    evalExpr p (f + 1) env (Core.Expr.bin Core.BinOp.and lhs rhs) = do let __do_lift ← evalExpr p f env lhs match __do_lift with | Value.bool false => Except.ok (Value.bool false) | Value.bool true => do let __do_lift ← evalExpr p f env rhs asBool __do_lift | x => Except.error (Err.typeError "&& expects Bool operands")
                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                      Lean2Js.evalExpr_or

                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                      (p : Core.Program) (f : Nat) (env : Env) (lhs rhs : Core.Expr) :
                                                                                                                                                                                                                                                                      evalExpr p (f + 1) env (Core.Expr.bin Core.BinOp.or lhs rhs) = do let __do_lift ← evalExpr p f env lhs match __do_lift with | Value.bool true => Except.ok (Value.bool true) | Value.bool false => do let __do_lift ← evalExpr p f env rhs asBool __do_lift | x => Except.error (Err.typeError "|| expects Bool operands")
                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                        Lean2Js.evalExpr_letE

                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                        (p : Core.Program) (f : Nat) (env : Env) (name : String) (ty : Core.Ty) (val body : Core.Expr) :
                                                                                                                                                                                                                                                                        evalExpr p (f + 1) env (Core.Expr.letE name ty val body) = do let v ← evalExpr p f env val evalExpr p f ((name, v) :: env) body
                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                          Lean2Js.evalExpr_call

                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                          (p : Core.Program) (f : Nat) (env : Env) (fn : String) (args : List Core.Expr) :
                                                                                                                                                                                                                                                                          evalExpr p (f + 1) env (Core.Expr.call fn args) = do let vs ← evalArgs p f env args have target : String := calleeOf env fn match p.find? target with | none => Except.error (Err.unknownFn target) | some d => if (d.params.length != vs.length) = true then Except.error (Err.arity target) else evalExpr p f (bindParams d.params vs) d.body
                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                            Lean2Js.evalExpr_noneE

                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (elem : Core.Ty) :
                                                                                                                                                                                                                                                                            evalExpr p (f + 1) env (Core.Expr.noneE elem) = Except.ok (Value.obj "none" [])
                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                              Lean2Js.evalExpr_someE

                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (e : Core.Expr) :
                                                                                                                                                                                                                                                                              evalExpr p (f + 1) env e.someE = do let __do_lift ← evalExpr p f env e Except.ok (Value.obj "some" [("value", __do_lift)])
                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                Lean2Js.evalExpr_arrayLit

                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                (p : Core.Program) (f : Nat) (env : Env) (elem : Core.Ty) (items : List Core.Expr) :
                                                                                                                                                                                                                                                                                evalExpr p (f + 1) env (Core.Expr.arrayLit elem items) = do let __do_lift ← evalArgs p f env items Except.ok (Value.arr __do_lift)
                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                  Lean2Js.evalExpr_index

                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                  (p : Core.Program) (f : Nat) (env : Env) (arr idx : Core.Expr) :
                                                                                                                                                                                                                                                                                  evalExpr p (f + 1) env (arr.index idx) = do let a ← evalExpr p f env arr let i ← evalExpr p f env idx match a, i with | Value.arr xs, Value.int53 n => if (decide (n < 0) || decide (Int.ofNat xs.length ≤ n)) = true then Except.error Err.indexOutOfBounds else match xs[n.toNat]? with | some v => Except.ok v | none => Except.error Err.indexOutOfBounds | x, x_1 => Except.error (Err.typeError "index expects an Array and an Int53")
                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                    Lean2Js.evalExpr_length

                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                    (p : Core.Program) (f : Nat) (env : Env) (arr : Core.Expr) :
                                                                                                                                                                                                                                                                                    evalExpr p (f + 1) env arr.length = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => mkInt53 (Int.ofNat xs.length) | Value.str s => mkInt53 (Int.ofNat s.toList.length) | Value.dict entries => mkInt53 (Int.ofNat entries.length) | x => Except.error (Err.typeError "length expects an Array, a String or a Dict")
                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                      Lean2Js.evalExpr_mapE

                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                      (p : Core.Program) (f : Nat) (env : Env) (arr : Core.Expr) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                      evalExpr p (f + 1) env (arr.mapE binder body) = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => do let __do_lift ← evalMapItems p f env binder body xs Except.ok (Value.arr __do_lift) | x => Except.error (Err.typeError "map expects an Array")
                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                        Lean2Js.evalExpr_filterE

                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                        (p : Core.Program) (f : Nat) (env : Env) (arr : Core.Expr) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                        evalExpr p (f + 1) env (arr.filterE binder body) = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => do let __do_lift ← evalFilterItems p f env binder body xs Except.ok (Value.arr __do_lift) | x => Except.error (Err.typeError "filter expects an Array")
                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                          Lean2Js.evalExpr_findE

                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                          (p : Core.Program) (f : Nat) (env : Env) (arr : Core.Expr) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                          evalExpr p (f + 1) env (arr.findE binder body) = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => evalFindItems p f env binder body xs | x => Except.error (Err.typeError "find expects an Array")
                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                            Lean2Js.evalExpr_quantE

                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (op : Core.QuantOp) (arr : Core.Expr) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                            evalExpr p (f + 1) env (Core.Expr.quantE op arr binder body) = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => evalQuantItems p f env op binder body xs | x => Except.error (Err.typeError (toString op.name ++ toString " expects an Array"))
                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                              Lean2Js.evalExpr_reduceE

                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (arr init : Core.Expr) (accName elemName : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                              evalExpr p (f + 1) env (arr.reduceE init accName elemName body) = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => do let acc ← evalExpr p f env init evalReduceItems p f env accName elemName body acc xs | x => Except.error (Err.typeError "reduce expects an Array")
                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                Lean2Js.evalExpr_sortByKeyE

                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                (p : Core.Program) (f : Nat) (env : Env) (arr : Core.Expr) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                                evalExpr p (f + 1) env (arr.sortByKeyE binder body) = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => do let keys ← evalMapItems p f env binder body xs let __do_lift ← sortPairs (keys.zip xs) Except.ok (Value.arr __do_lift) | x => Except.error (Err.typeError "sortByKey expects an Array")
                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                  Lean2Js.evalExpr_dictLit

                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                  (p : Core.Program) (f : Nat) (env : Env) (value : Core.Ty) (obj : Bool) (entries : List (String × Core.Expr)) :
                                                                                                                                                                                                                                                                                                  evalExpr p (f + 1) env (Core.Expr.dictLit value obj entries) = do let vs ← evalArgs p f env (List.map (fun (x : String × Core.Expr) => x.snd) entries) Except.ok (Value.dict ((List.map (fun (x : String × Core.Expr) => x.fst) entries).zip vs))
                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                    Lean2Js.evalExpr_dictGet

                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                    (p : Core.Program) (f : Nat) (env : Env) (d key : Core.Expr) :
                                                                                                                                                                                                                                                                                                    evalExpr p (f + 1) env (d.dictGet key) = do let dv ← evalExpr p f env d let kv ← evalExpr p f env key match dv, kv with | Value.dict entries, Value.str k => Except.ok (dictLookup entries k) | x, x_1 => Except.error (Err.typeError "get expects a Dict and a String key")
                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                      Lean2Js.evalExpr_dictHas

                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                      (p : Core.Program) (f : Nat) (env : Env) (d key : Core.Expr) :
                                                                                                                                                                                                                                                                                                      evalExpr p (f + 1) env (d.dictHas key) = do let dv ← evalExpr p f env d let kv ← evalExpr p f env key match dv, kv with | Value.dict entries, Value.str k => Except.ok (Value.bool (entries.any fun (x : String × Value) => x.fst == k)) | x, x_1 => Except.error (Err.typeError "has expects a Dict and a String key")
                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                        Lean2Js.evalExpr_dictSet

                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                        (p : Core.Program) (f : Nat) (env : Env) (d key val : Core.Expr) :
                                                                                                                                                                                                                                                                                                        evalExpr p (f + 1) env (d.dictSet key val) = do let dv ← evalExpr p f env d let kv ← evalExpr p f env key let vv ← evalExpr p f env val match dv, kv with | Value.dict entries, Value.str k => Except.ok (Value.dict (dictWith entries k vv)) | x, x_1 => Except.error (Err.typeError "set expects a Dict and a String key")
                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                          Lean2Js.evalExpr_dictKeys

                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                          (p : Core.Program) (f : Nat) (env : Env) (d : Core.Expr) :
                                                                                                                                                                                                                                                                                                          evalExpr p (f + 1) env d.dictKeys = do let __do_lift ← evalExpr p f env d match __do_lift with | Value.dict entries => Except.ok (Value.arr (List.map (fun (e : String × Value) => Value.str e.fst) entries)) | x => Except.error (Err.typeError "keys expects a Dict")
                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                            Lean2Js.evalExpr_dictValues

                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (d : Core.Expr) :
                                                                                                                                                                                                                                                                                                            evalExpr p (f + 1) env d.dictValues = do let __do_lift ← evalExpr p f env d match __do_lift with | Value.dict entries => Except.ok (Value.arr (List.map (fun (e : String × Value) => e.snd) entries)) | x => Except.error (Err.typeError "values expects a Dict")
                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                              Lean2Js.evalExpr_dictDelete

                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (d key : Core.Expr) :
                                                                                                                                                                                                                                                                                                              evalExpr p (f + 1) env (d.dictDelete key) = do let dv ← evalExpr p f env d let kv ← evalExpr p f env key match dv, kv with | Value.dict entries, Value.str k => Except.ok (Value.dict (List.filter (fun (x : String × Value) => x.fst != k) entries)) | x, x_1 => Except.error (Err.typeError "delete expects a Dict and a String key")
                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                Lean2Js.evalExpr_strUn

                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                (p : Core.Program) (f : Nat) (env : Env) (op : Core.StrUnOp) (e : Core.Expr) :
                                                                                                                                                                                                                                                                                                                evalExpr p (f + 1) env (Core.Expr.strUn op e) = do let __do_lift ← evalExpr p f env e applyStrUn op __do_lift
                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                  Lean2Js.evalExpr_strBin

                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                  (p : Core.Program) (f : Nat) (env : Env) (op : Core.StrBinOp) (lhs rhs : Core.Expr) :
                                                                                                                                                                                                                                                                                                                  evalExpr p (f + 1) env (Core.Expr.strBin op lhs rhs) = do let a ← evalExpr p f env lhs let b ← evalExpr p f env rhs applyStrBin op a b
                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                    Lean2Js.evalExpr_arraySlice

                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                    (p : Core.Program) (f : Nat) (env : Env) (arr lo hi : Core.Expr) :
                                                                                                                                                                                                                                                                                                                    evalExpr p (f + 1) env (arr.arraySlice lo hi) = do let a ← evalExpr p f env arr let i ← evalExpr p f env lo let j ← evalExpr p f env hi sliceArr a i j
                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                      Lean2Js.evalExpr_arrayReverse

                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                      (p : Core.Program) (f : Nat) (env : Env) (arr : Core.Expr) :
                                                                                                                                                                                                                                                                                                                      evalExpr p (f + 1) env arr.arrayReverse = do let __do_lift ← evalExpr p f env arr match __do_lift with | Value.arr xs => Except.ok (Value.arr xs.reverse) | x => Except.error (Err.typeError "reverse expects an Array")
                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                        Lean2Js.evalExpr_substring

                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                        (p : Core.Program) (f : Nat) (env : Env) (str lo hi : Core.Expr) :
                                                                                                                                                                                                                                                                                                                        evalExpr p (f + 1) env (str.substring lo hi) = do let s ← evalExpr p f env str let a ← evalExpr p f env lo let b ← evalExpr p f env hi sliceStr s a b
                                                                                                                                                                                                                                                                                                                        Used by

                                                                                                                                                                                                                                                                                                                          The four traversals evalExpr delegates to. A proof about a declaration that uses a combinator walks the list here rather than through evalExpr.

                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                          Lean2Js.evalArgs_nil

                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                          (p : Core.Program) (f : Nat) (env : Env) :
                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                            Lean2Js.evalArgs_cons

                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (e : Core.Expr) (rest : List Core.Expr) :
                                                                                                                                                                                                                                                                                                                            evalArgs p f env (e :: rest) = do let v ← evalExpr p f env e let vs ← evalArgs p f env rest Except.ok (v :: vs)
                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                              Lean2Js.evalMapItems_nil

                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                                                              evalMapItems p f env binder body [] = Except.ok []
                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                Lean2Js.evalMapItems_cons

                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                (p : Core.Program) (f : Nat) (env : Env) (binder : String) (body : Core.Expr) (x : Value) (rest : List Value) :
                                                                                                                                                                                                                                                                                                                                evalMapItems p f env binder body (x :: rest) = do let v ← evalExpr p f ((binder, x) :: env) body let vs ← evalMapItems p f env binder body rest Except.ok (v :: vs)
                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                  Lean2Js.evalFold_obj

                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                  (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (ctor : String) (fields : List (String × Value)) :
                                                                                                                                                                                                                                                                                                                                  evalFold p f env typeName tyArgs alts (Value.obj ctor fields) = match (List.find? (fun (x : Core.TypeDef) => x.name == typeName) p.types).bind fun (td : Core.TypeDef) => td.findAt? tyArgs ctor with | some c => do let fs ← evalFoldFields p f env typeName tyArgs alts fields c.fields match firstMatch alts (Value.obj ctor fs) with | some (binds, body) => evalExpr p f (binds ++ env) body | none => Except.error Err.noMatchingAlternative | none => Except.error (Err.typeError (toString "fold expects a value of " ++ toString typeName))
                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                    Lean2Js.evalFoldList_nil

                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                    (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) :
                                                                                                                                                                                                                                                                                                                                    evalFoldList p f env typeName tyArgs alts [] = Except.ok []
                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                      Lean2Js.evalFoldList_cons

                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                      (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (x : Value) (rest : List Value) :
                                                                                                                                                                                                                                                                                                                                      evalFoldList p f env typeName tyArgs alts (x :: rest) = do let y ← evalFold p f env typeName tyArgs alts x let ys ← evalFoldList p f env typeName tyArgs alts rest Except.ok (y :: ys)
                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                        Lean2Js.evalFoldListAt_arr

                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                        (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (xs : List Value) :
                                                                                                                                                                                                                                                                                                                                        evalFoldListAt p f env typeName tyArgs alts (Value.arr xs) = evalFoldList p f env typeName tyArgs alts xs
                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                          Lean2Js.evalFoldFields_nil

                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                          (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (fields : List (String × Value)) :
                                                                                                                                                                                                                                                                                                                                          evalFoldFields p f env typeName tyArgs alts fields [] = Except.ok []
                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                            Lean2Js.evalFoldFields_cons_none

                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (fields : List (String × Value)) (fd : Core.Field) (rest : List Core.Field) (h : lookupFieldV fields fd.name = none) :
                                                                                                                                                                                                                                                                                                                                            evalFoldFields p f env typeName tyArgs alts fields (fd :: rest) = Except.error (Err.typeError (toString "no field named " ++ toString fd.name))
                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                              Lean2Js.evalFoldFields_cons_some

                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (typeName : String) (tyArgs : List Core.Ty) (alts : List Core.Alt) (fields : List (String × Value)) (fd : Core.Field) (rest : List Core.Field) {v : Value} (h : lookupFieldV fields fd.name = some v) :
                                                                                                                                                                                                                                                                                                                                              evalFoldFields p f env typeName tyArgs alts fields (fd :: rest) = match Core.foldKindOf typeName tyArgs fd.ty with | Core.FoldKind.plain => do let ps ← evalFoldFields p f env typeName tyArgs alts fields rest Except.ok ((fd.name, v) :: ps) | Core.FoldKind.self => do let y ← evalFold p f env typeName tyArgs alts v let ps ← evalFoldFields p f env typeName tyArgs alts fields rest Except.ok ((fd.name, y) :: ps) | Core.FoldKind.list => do let ys ← evalFoldListAt p f env typeName tyArgs alts v let ps ← evalFoldFields p f env typeName tyArgs alts fields rest Except.ok ((fd.name, Value.arr ys) :: ps)
                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                Lean2Js.evalFilterItems_nil

                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                (p : Core.Program) (f : Nat) (env : Env) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                                                                                evalFilterItems p f env binder body [] = Except.ok []
                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                  Lean2Js.evalFilterItems_cons

                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                  (p : Core.Program) (f : Nat) (env : Env) (binder : String) (body : Core.Expr) (x : Value) (rest : List Value) :
                                                                                                                                                                                                                                                                                                                                                  evalFilterItems p f env binder body (x :: rest) = do let __do_lift ← evalExpr p f ((binder, x) :: env) body match __do_lift with | Value.bool true => do let __do_lift ← evalFilterItems p f env binder body rest Except.ok (x :: __do_lift) | Value.bool false => evalFilterItems p f env binder body rest | x => Except.error (Err.typeError "filter expects a Bool predicate")
                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                    Lean2Js.evalFindItems_nil

                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                    (p : Core.Program) (f : Nat) (env : Env) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                                                                                    evalFindItems p f env binder body [] = Except.ok (Value.obj "none" [])
                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                      Lean2Js.evalFindItems_cons

                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                      (p : Core.Program) (f : Nat) (env : Env) (binder : String) (body : Core.Expr) (x : Value) (rest : List Value) :
                                                                                                                                                                                                                                                                                                                                                      evalFindItems p f env binder body (x :: rest) = do let __do_lift ← evalExpr p f ((binder, x) :: env) body match __do_lift with | Value.bool true => Except.ok (Value.obj "some" [("value", x)]) | Value.bool false => evalFindItems p f env binder body rest | x => Except.error (Err.typeError "find expects a Bool predicate")
                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                        Lean2Js.evalQuantItems_nil

                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                        (p : Core.Program) (f : Nat) (env : Env) (op : Core.QuantOp) (binder : String) (body : Core.Expr) :
                                                                                                                                                                                                                                                                                                                                                        evalQuantItems p f env op binder body [] = Except.ok (Value.bool (op == Core.QuantOp.all))
                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                          Lean2Js.evalQuantItems_cons

                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                          (p : Core.Program) (f : Nat) (env : Env) (op : Core.QuantOp) (binder : String) (body : Core.Expr) (x : Value) (rest : List Value) :
                                                                                                                                                                                                                                                                                                                                                          evalQuantItems p f env op binder body (x :: rest) = do let __do_lift ← evalExpr p f ((binder, x) :: env) body match __do_lift with | Value.bool b => match op with | Core.QuantOp.all => if b = true then evalQuantItems p f env op binder body rest else Except.ok (Value.bool false) | Core.QuantOp.any => if b = true then Except.ok (Value.bool true) else evalQuantItems p f env op binder body rest | x => Except.error (Err.typeError (toString op.name ++ toString " expects a Bool predicate"))
                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                            Lean2Js.evalReduceItems_nil

                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                            (p : Core.Program) (f : Nat) (env : Env) (accName elemName : String) (body : Core.Expr) (acc : Value) :
                                                                                                                                                                                                                                                                                                                                                            evalReduceItems p f env accName elemName body acc [] = Except.ok acc
                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                              Lean2Js.evalReduceItems_cons

                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                              (p : Core.Program) (f : Nat) (env : Env) (accName elemName : String) (body : Core.Expr) (acc x : Value) (rest : List Value) :
                                                                                                                                                                                                                                                                                                                                                              evalReduceItems p f env accName elemName body acc (x :: rest) = do let next ← evalExpr p f ((elemName, x) :: (accName, acc) :: env) body evalReduceItems p f env accName elemName body next rest
                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                Lean2Js.evalCall_eq

                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                {p : Core.Program} {fn : String} {args : List Value} {d : Core.Decl} (hfind : p.find? fn = some d) (harity : d.params.length = args.length) (hty : ((d.params.zip args).all fun (x : Core.Param × Value) => match x with | (param, v) => Value.hasTy p v param.ty) = true) :

                                                                                                                                                                                                                                                                                                                                                                Enters the body of an exported function once the entry checks are known to pass. Stating a theorem about a declaration otherwise means unfolding the whole program at the call, which puts every other declaration in front of the tactic.

                                                                                                                                                                                                                                                                                                                                                                Used by