lean2js

Lean2Js.Roundtrip

source

Imports 2

That the reader gives the printer's input back #

That the reader in Parse gives the printer's input back.

Js.Expr.render is not injective, so the statement is about the trees the compiler actually builds. Renderable names the three places two trees share a text — a callee that the reader dispatches on, a unary operator that is not ! or -, a name that is not an identifier — plus a doc comment that closes itself early.

The fuel is bounded by the length of the text being read, so the top level passes the text's own length and no fuel caveat survives.

What the reader needs of a tree #

def

Lean2Js.Parse.dispatchNames

source

The names parseNamed gives a meaning of their own. An identifier or a callee spelled one of these reads back as the form the reader has a constructor for.

Equations
Instances For
    Used by
      def

      Lean2Js.Parse.okCallee

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

          Lean2Js.Parse.okOp

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

              Lean2Js.Parse.RenderableExpr

              source
              @[irreducible]
              Equations
              Instances For
                Used by
                  def

                  Lean2Js.Parse.RenderableList

                  source
                  @[irreducible]
                  Equations
                  Instances For
                    Used by
                      def

                      Lean2Js.Parse.RenderablePairs

                      source
                      @[irreducible]
                      Equations
                      Instances For
                        Used by

                          The printer's equations #

                          Expr.render recurses on a measure, so its equations do not unfold on their own.

                          theorem

                          Lean2Js.Parse.render_num

                          source
                          Used by
                            theorem

                            Lean2Js.Parse.render_bigLit

                            source
                            Used by
                              theorem

                              Lean2Js.Parse.render_str

                              source
                              (s : String) :
                              Used by
                                theorem

                                Lean2Js.Parse.render_bool

                                source
                                (b : Bool) :
                                (Js.Expr.bool b).render = if b = true then "true" else "false"
                                Used by
                                  theorem

                                  Lean2Js.Parse.render_ident

                                  source
                                  (name : String) :
                                  (Js.Expr.ident name).render = name
                                  Used by
                                    theorem

                                    Lean2Js.Parse.render_unary

                                    source
                                    (op : String) (e : Js.Expr) :
                                    (Js.Expr.unary op e).render = "(" ++ op ++ e.render ++ ")"
                                    Used by
                                      theorem

                                      Lean2Js.Parse.render_binary

                                      source
                                      (op : String) (l r : Js.Expr) :
                                      (Js.Expr.binary op l r).render = "(" ++ l.render ++ " " ++ op ++ " " ++ r.render ++ ")"
                                      Used by
                                        theorem

                                        Lean2Js.Parse.render_cond

                                        source
                                        (c t e : Js.Expr) :
                                        (c.cond t e).render = "(" ++ c.render ++ " ? " ++ t.render ++ " : " ++ e.render ++ ")"
                                        Used by
                                          theorem

                                          Lean2Js.Parse.render_call

                                          source
                                          (callee : String) (args : List Js.Expr) :
                                          (Js.Expr.call callee args).render = callee ++ "(" ++ Js.Expr.renderList args ++ ")"
                                          Used by
                                            theorem

                                            Lean2Js.Parse.render_arrowCall

                                            source
                                            (ps : List String) (body : Js.Expr) (args : List Js.Expr) :
                                            (Js.Expr.arrowCall ps body args).render = "((" ++ Js.renderNames ps ++ ") => (" ++ body.render ++ "))(" ++ Js.Expr.renderList args ++ ")"
                                            Used by
                                              theorem

                                              Lean2Js.Parse.render_objLit

                                              source
                                              Used by
                                                theorem

                                                Lean2Js.Parse.render_member

                                                source
                                                (obj : Js.Expr) (field : String) :
                                                (obj.member field).render = "(" ++ obj.render ++ ")." ++ field
                                                Used by
                                                  theorem

                                                  Lean2Js.Parse.render_arrayLit

                                                  source
                                                  (items : List Js.Expr) :
                                                  Used by
                                                    theorem

                                                    Lean2Js.Parse.render_dictLit

                                                    source
                                                    (es : List (String × Js.Expr)) :
                                                    Used by
                                                      theorem

                                                      Lean2Js.Parse.render_check

                                                      source
                                                      (d : Js.TyDesc) (e : Js.Expr) :
                                                      (Js.Expr.check d e).render = "__ck(" ++ e.render ++ ", " ++ d.render ++ ")"
                                                      Used by
                                                        theorem

                                                        Lean2Js.Parse.render_out

                                                        source
                                                        (d : Js.TyDesc) (e : Js.Expr) :
                                                        (Js.Expr.out d e).render = "__out(" ++ e.render ++ ", " ++ d.render ++ ", [])"
                                                        Used by
                                                          theorem

                                                          Lean2Js.Parse.render_mapJs

                                                          source
                                                          (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                          (arr.mapJs b body).render = "__map(" ++ arr.render ++ ", (" ++ b ++ ") => (" ++ body.render ++ "))"
                                                          Used by
                                                            theorem

                                                            Lean2Js.Parse.render_filterJs

                                                            source
                                                            (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                            (arr.filterJs b body).render = "__filter(" ++ arr.render ++ ", (" ++ b ++ ") => (" ++ body.render ++ "))"
                                                            Used by
                                                              theorem

                                                              Lean2Js.Parse.render_sortByJs

                                                              source
                                                              (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                              (arr.sortByJs b body).render = "__sortBy(" ++ arr.render ++ ", (" ++ b ++ ") => (" ++ body.render ++ "))"
                                                              Used by
                                                                theorem

                                                                Lean2Js.Parse.render_findJs

                                                                source
                                                                (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                (arr.findJs b body).render = "__find(" ++ arr.render ++ ", (" ++ b ++ ") => (" ++ body.render ++ "))"
                                                                Used by
                                                                  theorem

                                                                  Lean2Js.Parse.render_quantJs

                                                                  source
                                                                  (op : Core.QuantOp) (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                  (Js.Expr.quantJs op arr b body).render = "__" ++ op.name ++ "(" ++ arr.render ++ ", (" ++ b ++ ") => (" ++ body.render ++ "))"
                                                                  Used by
                                                                    theorem

                                                                    Lean2Js.Parse.render_reduceJs

                                                                    source
                                                                    (arr init : Js.Expr) (a e : String) (body : Js.Expr) :
                                                                    (arr.reduceJs init a e body).render = "__reduce(" ++ arr.render ++ ", " ++ init.render ++ ", (" ++ a ++ ", " ++ e ++ ") => (" ++ body.render ++ "))"
                                                                    Used by
                                                                      theorem

                                                                      Lean2Js.Parse.render_foldJs

                                                                      source
                                                                      (scrut : Js.Expr) (key : String) (spec : Js.FoldSpec) (b : String) (body : Js.Expr) :
                                                                      (scrut.foldJs key spec b body).render = "__fold(" ++ scrut.render ++ ", \"" ++ escapeString key ++ "\", { " ++ Js.renderFoldSpec spec ++ " }, (" ++ b ++ ") => (" ++ body.render ++ "))"
                                                                      Used by

                                                                        Separators #

                                                                        The reader is greedy over names and numerals, it turns a name into a call when a ( follows, and after a ) it looks for a ., so a rendering has to be followed by a character that does none of those.

                                                                        def

                                                                        Lean2Js.Parse.Sep

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

                                                                            Lean2Js.Parse.Sep.nil

                                                                            source
                                                                            Used by
                                                                              theorem

                                                                              Lean2Js.Parse.Sep.cons

                                                                              source
                                                                              {c : Char} (h1 : isIdentPart c = false) (h2 : c ≠ '(') (h3 : c ≠ '.') (r : List Char) :
                                                                              Sep (c :: r)
                                                                              Used by
                                                                                theorem

                                                                                Lean2Js.Parse.Sep.toIdent

                                                                                source
                                                                                {cs : List Char} (h : Sep cs) :
                                                                                Used by
                                                                                  theorem

                                                                                  Lean2Js.Parse.Sep.toDigit

                                                                                  source
                                                                                  {cs : List Char} (h : Sep cs) :
                                                                                  Used by
                                                                                    theorem

                                                                                    Lean2Js.Parse.digit_isIdentPart

                                                                                    source
                                                                                    {c : Char} (h : c.isDigit = true) :
                                                                                    Used by
                                                                                      theorem

                                                                                      Lean2Js.Parse.natDigits_all_identPart

                                                                                      source
                                                                                      Used by

                                                                                        Names #

                                                                                        theorem

                                                                                        Lean2Js.Parse.okName_ne_nil

                                                                                        source
                                                                                        {s : String} (h : okName s = true) :
                                                                                        Used by
                                                                                          theorem

                                                                                          Lean2Js.Parse.okName_all

                                                                                          source
                                                                                          Used by
                                                                                            theorem

                                                                                            Lean2Js.Parse.okName_start

                                                                                            source
                                                                                            {s : String} (h : okName s = true) {c : Char} {cs : List Char} (hm : s.toList = c :: cs) :
                                                                                            Used by
                                                                                              theorem

                                                                                              Lean2Js.Parse.okCallee_name

                                                                                              source
                                                                                              {s : String} (h : okCallee s = true) :
                                                                                              Used by
                                                                                                theorem

                                                                                                Lean2Js.Parse.okCallee_not_dispatch

                                                                                                source
                                                                                                Used by

                                                                                                  Where an identifier list stops #

                                                                                                  parseParen decides between an arrow call and the other parenthesised forms by reading ahead for ( names ) => (. What makes that decision sound is that the lookahead fails on every rendering: the identifier list stops at the first character a name cannot contain, and in a rendering that character is never the ) the arrow head wants.

                                                                                                  theorem

                                                                                                  Lean2Js.Parse.expect_arrow_ne

                                                                                                  source
                                                                                                  {c : Char} (h : c ≠ ')') (cs : List Char) :
                                                                                                  expect [')', ' ', '=', '>', ' ', '('] (c :: cs) = none
                                                                                                  Used by
                                                                                                    structure

                                                                                                    Lean2Js.Parse.AfterHead

                                                                                                    source
                                                                                                    (cs : List Char) :
                                                                                                    Instances For
                                                                                                      Used by
                                                                                                        theorem

                                                                                                        Lean2Js.Parse.AfterHead.close

                                                                                                        source
                                                                                                        (r : List Char) :
                                                                                                        AfterHead (')' :: '.' :: r)
                                                                                                        Used by
                                                                                                          theorem

                                                                                                          Lean2Js.Parse.AfterHead.cons

                                                                                                          source
                                                                                                          {c : Char} (h1 : isIdentPart c = false) (h2 : c ≠ ',') (h3 : c ≠ ')') (r : List Char) :
                                                                                                          Used by
                                                                                                            theorem

                                                                                                            Lean2Js.Parse.parseIdentList_stuck

                                                                                                            source
                                                                                                            (f : Nat) {c : Char} (hc : isIdentPart c = false) (cs : List Char) :
                                                                                                            parseIdentList (f + 1) (c :: cs) = some ([], c :: cs)
                                                                                                            Used by
                                                                                                              theorem

                                                                                                              Lean2Js.Parse.parseIdentList_last

                                                                                                              source
                                                                                                              (f : Nat) (name : List Char) (hne : name ≠ []) (hall : name.all isIdentPart = true) (suffix : List Char) (hsuf : notIdentFirst suffix) (hcomma : expect [',', ' '] suffix = none) :
                                                                                                              parseIdentList (f + 1) (name ++ suffix) = some ([String.ofList name], suffix)
                                                                                                              Used by
                                                                                                                theorem

                                                                                                                Lean2Js.Parse.identList_head

                                                                                                                source
                                                                                                                {c : Char} (hc : isIdentPart c = false) (hne : c ≠ ')') (f : Nat) (tail : List Char) {ns : List String} {r : List Char} (h : parseIdentList (f + 1) (c :: tail) = some (ns, r)) :
                                                                                                                expect [')', ' ', '=', '>', ' ', '('] r = none

                                                                                                                The rendering opens with a character no name can contain, so the list is empty and the lookahead stops on that character.

                                                                                                                Used by
                                                                                                                  theorem

                                                                                                                  Lean2Js.Parse.identList_name_head

                                                                                                                  source
                                                                                                                  (f : Nat) (name : List Char) (hne : name ≠ []) (hall : name.all isIdentPart = true) {c : Char} (hc : isIdentPart c = false) (hcm : c ≠ ',') (hcp : c ≠ ')') (tail : List Char) {ns : List String} {r : List Char} (h : parseIdentList (f + 1) (name ++ c :: tail) = some (ns, r)) :
                                                                                                                  expect [')', ' ', '=', '>', ' ', '('] r = none

                                                                                                                  The rendering opens with a name and then a character no name can contain.

                                                                                                                  Used by
                                                                                                                    theorem

                                                                                                                    Lean2Js.Parse.identList_name_all

                                                                                                                    source
                                                                                                                    (f : Nat) (name : List Char) (hne : name ≠ []) (hall : name.all isIdentPart = true) (suffix : List Char) (hs : AfterHead suffix) {ns : List String} {r : List Char} (h : parseIdentList (f + 1) (name ++ suffix) = some (ns, r)) :
                                                                                                                    expect [')', ' ', '=', '>', ' ', '('] r = none

                                                                                                                    The rendering is a name and nothing else, so the lookahead stops where the rendering ends.

                                                                                                                    Used by

                                                                                                                      The printer's output as characters #

                                                                                                                      Everything below reads the rendering one character at a time, so each printer branch is restated as the list it writes, with the literal chunks spelled out and the recursive parts left as they are.

                                                                                                                      theorem

                                                                                                                      Lean2Js.Parse.render_num_toList

                                                                                                                      source
                                                                                                                      Used by
                                                                                                                        theorem

                                                                                                                        Lean2Js.Parse.render_bigLit_toList

                                                                                                                        source
                                                                                                                        Used by
                                                                                                                          theorem

                                                                                                                          Lean2Js.Parse.render_str_toList

                                                                                                                          source
                                                                                                                          Used by
                                                                                                                            theorem

                                                                                                                            Lean2Js.Parse.render_bool_true_toList

                                                                                                                            source
                                                                                                                            :
                                                                                                                            Used by
                                                                                                                              theorem

                                                                                                                              Lean2Js.Parse.render_bool_false_toList

                                                                                                                              source
                                                                                                                              :
                                                                                                                              (Js.Expr.bool false).render.toList = ['f', 'a', 'l', 's', 'e']
                                                                                                                              Used by
                                                                                                                                theorem

                                                                                                                                Lean2Js.Parse.render_ident_toList

                                                                                                                                source
                                                                                                                                (name : String) :
                                                                                                                                Used by
                                                                                                                                  theorem

                                                                                                                                  Lean2Js.Parse.render_unary_toList

                                                                                                                                  source
                                                                                                                                  (op : String) (e : Js.Expr) :
                                                                                                                                  Used by
                                                                                                                                    theorem

                                                                                                                                    Lean2Js.Parse.render_binary_toList

                                                                                                                                    source
                                                                                                                                    (op : String) (l r : Js.Expr) :
                                                                                                                                    (Js.Expr.binary op l r).render.toList = '(' :: (l.render.toList ++ ' ' :: (op.toList ++ ' ' :: (r.render.toList ++ [')'])))
                                                                                                                                    Used by
                                                                                                                                      theorem

                                                                                                                                      Lean2Js.Parse.render_cond_toList

                                                                                                                                      source
                                                                                                                                      (c t e : Js.Expr) :
                                                                                                                                      (c.cond t e).render.toList = '(' :: (c.render.toList ++ ' ' :: '?' :: ' ' :: (t.render.toList ++ ' ' :: ':' :: ' ' :: (e.render.toList ++ [')'])))
                                                                                                                                      Used by
                                                                                                                                        theorem

                                                                                                                                        Lean2Js.Parse.render_call_toList

                                                                                                                                        source
                                                                                                                                        (callee : String) (args : List Js.Expr) :
                                                                                                                                        (Js.Expr.call callee args).render.toList = callee.toList ++ '(' :: ((Js.Expr.renderList args).toList ++ [')'])
                                                                                                                                        Used by
                                                                                                                                          theorem

                                                                                                                                          Lean2Js.Parse.render_arrowCall_toList

                                                                                                                                          source
                                                                                                                                          (ps : List String) (body : Js.Expr) (args : List Js.Expr) :
                                                                                                                                          (Js.Expr.arrowCall ps body args).render.toList = '(' :: '(' :: ((Js.renderNames ps).toList ++ ')' :: ' ' :: '=' :: '>' :: ' ' :: '(' :: (body.render.toList ++ ')' :: ')' :: '(' :: ((Js.Expr.renderList args).toList ++ [')'])))
                                                                                                                                          Used by
                                                                                                                                            theorem

                                                                                                                                            Lean2Js.Parse.render_objLit_toList

                                                                                                                                            source
                                                                                                                                            Used by
                                                                                                                                              theorem

                                                                                                                                              Lean2Js.Parse.render_member_toList

                                                                                                                                              source
                                                                                                                                              (obj : Js.Expr) (field : String) :
                                                                                                                                              (obj.member field).render.toList = '(' :: (obj.render.toList ++ ')' :: '.' :: field.toList)
                                                                                                                                              Used by
                                                                                                                                                theorem

                                                                                                                                                Lean2Js.Parse.render_arrayLit_toList

                                                                                                                                                source
                                                                                                                                                Used by
                                                                                                                                                  theorem

                                                                                                                                                  Lean2Js.Parse.render_dictLit_toList

                                                                                                                                                  source
                                                                                                                                                  (es : List (String × Js.Expr)) :
                                                                                                                                                  (Js.Expr.dictLit es).render.toList = 'n' :: 'e' :: 'w' :: ' ' :: 'M' :: 'a' :: 'p' :: '(' :: '[' :: ((Js.Expr.renderEntries es).toList ++ [']', ')'])
                                                                                                                                                  Used by
                                                                                                                                                    theorem

                                                                                                                                                    Lean2Js.Parse.render_check_toList

                                                                                                                                                    source
                                                                                                                                                    (d : Js.TyDesc) (e : Js.Expr) :
                                                                                                                                                    (Js.Expr.check d e).render.toList = '_' :: '_' :: 'c' :: 'k' :: '(' :: (e.render.toList ++ ',' :: ' ' :: (d.render.toList ++ [')']))
                                                                                                                                                    Used by
                                                                                                                                                      theorem

                                                                                                                                                      Lean2Js.Parse.render_out_toList

                                                                                                                                                      source
                                                                                                                                                      (d : Js.TyDesc) (e : Js.Expr) :
                                                                                                                                                      (Js.Expr.out d e).render.toList = '_' :: '_' :: 'o' :: 'u' :: 't' :: '(' :: (e.render.toList ++ ',' :: ' ' :: (d.render.toList ++ [',', ' ', '[', ']', ')']))
                                                                                                                                                      Used by
                                                                                                                                                        theorem

                                                                                                                                                        Lean2Js.Parse.render_mapJs_toList

                                                                                                                                                        source
                                                                                                                                                        (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                                                                                                        (arr.mapJs b body).render.toList = '_' :: '_' :: 'm' :: 'a' :: 'p' :: '(' :: Lean2Js.Parse.lambdaTail✝ arr b body
                                                                                                                                                        Used by
                                                                                                                                                          theorem

                                                                                                                                                          Lean2Js.Parse.render_sortByJs_toList

                                                                                                                                                          source
                                                                                                                                                          (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                                                                                                          (arr.sortByJs b body).render.toList = '_' :: '_' :: 's' :: 'o' :: 'r' :: 't' :: 'B' :: 'y' :: '(' :: Lean2Js.Parse.lambdaTail✝ arr b body
                                                                                                                                                          Used by
                                                                                                                                                            theorem

                                                                                                                                                            Lean2Js.Parse.render_filterJs_toList

                                                                                                                                                            source
                                                                                                                                                            (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                                                                                                            (arr.filterJs b body).render.toList = '_' :: '_' :: 'f' :: 'i' :: 'l' :: 't' :: 'e' :: 'r' :: '(' :: Lean2Js.Parse.lambdaTail✝ arr b body
                                                                                                                                                            Used by
                                                                                                                                                              theorem

                                                                                                                                                              Lean2Js.Parse.render_findJs_toList

                                                                                                                                                              source
                                                                                                                                                              (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                                                                                                              (arr.findJs b body).render.toList = '_' :: '_' :: 'f' :: 'i' :: 'n' :: 'd' :: '(' :: Lean2Js.Parse.lambdaTail✝ arr b body
                                                                                                                                                              Used by
                                                                                                                                                                theorem

                                                                                                                                                                Lean2Js.Parse.render_allJs_toList

                                                                                                                                                                source
                                                                                                                                                                (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                                                                                                                (Js.Expr.quantJs Core.QuantOp.all arr b body).render.toList = '_' :: '_' :: 'a' :: 'l' :: 'l' :: '(' :: Lean2Js.Parse.lambdaTail✝ arr b body
                                                                                                                                                                Used by
                                                                                                                                                                  theorem

                                                                                                                                                                  Lean2Js.Parse.render_anyJs_toList

                                                                                                                                                                  source
                                                                                                                                                                  (arr : Js.Expr) (b : String) (body : Js.Expr) :
                                                                                                                                                                  (Js.Expr.quantJs Core.QuantOp.any arr b body).render.toList = '_' :: '_' :: 'a' :: 'n' :: 'y' :: '(' :: Lean2Js.Parse.lambdaTail✝ arr b body
                                                                                                                                                                  Used by
                                                                                                                                                                    theorem

                                                                                                                                                                    Lean2Js.Parse.render_reduceJs_toList

                                                                                                                                                                    source
                                                                                                                                                                    (arr init : Js.Expr) (a e : String) (body : Js.Expr) :
                                                                                                                                                                    (arr.reduceJs init a e body).render.toList = '_' :: '_' :: 'r' :: 'e' :: 'd' :: 'u' :: 'c' :: 'e' :: '(' :: (arr.render.toList ++ ',' :: ' ' :: (init.render.toList ++ ',' :: ' ' :: '(' :: (a.toList ++ ',' :: ' ' :: (e.toList ++ ')' :: ' ' :: '=' :: '>' :: ' ' :: '(' :: (body.render.toList ++ [')', ')'])))))
                                                                                                                                                                    Used by
                                                                                                                                                                      theorem

                                                                                                                                                                      Lean2Js.Parse.render_foldJs_toList

                                                                                                                                                                      source
                                                                                                                                                                      (scrut : Js.Expr) (key : String) (spec : Js.FoldSpec) (b : String) (body : Js.Expr) :
                                                                                                                                                                      (scrut.foldJs key spec b body).render.toList = '_' :: '_' :: 'f' :: 'o' :: 'l' :: 'd' :: '(' :: (scrut.render.toList ++ ',' :: ' ' :: '\"' :: ((escapeString key).toList ++ '\"' :: ',' :: ' ' :: '{' :: ' ' :: ((Js.renderFoldSpec spec).toList ++ ' ' :: '}' :: ',' :: ' ' :: '(' :: (b.toList ++ ')' :: ' ' :: '=' :: '>' :: ' ' :: '(' :: (body.render.toList ++ [')', ')'])))))
                                                                                                                                                                      Used by
                                                                                                                                                                        theorem

                                                                                                                                                                        Lean2Js.Parse.renderList_nil_toList

                                                                                                                                                                        source
                                                                                                                                                                        Used by
                                                                                                                                                                          theorem

                                                                                                                                                                          Lean2Js.Parse.renderList_one_toList

                                                                                                                                                                          source
                                                                                                                                                                          Used by
                                                                                                                                                                            theorem

                                                                                                                                                                            Lean2Js.Parse.renderList_cons_toList

                                                                                                                                                                            source
                                                                                                                                                                            (e a : Js.Expr) (rest : List Js.Expr) :
                                                                                                                                                                            Used by
                                                                                                                                                                              theorem

                                                                                                                                                                              Lean2Js.Parse.renderFields_nil_toList

                                                                                                                                                                              source
                                                                                                                                                                              Used by
                                                                                                                                                                                theorem

                                                                                                                                                                                Lean2Js.Parse.renderFields_one_toList

                                                                                                                                                                                source
                                                                                                                                                                                (k : String) (v : Js.Expr) :
                                                                                                                                                                                Used by
                                                                                                                                                                                  theorem

                                                                                                                                                                                  Lean2Js.Parse.renderFields_cons_toList

                                                                                                                                                                                  source
                                                                                                                                                                                  (k : String) (v : Js.Expr) (a : String × Js.Expr) (rest : List (String × Js.Expr)) :
                                                                                                                                                                                  (Js.Expr.renderFields ((k, v) :: a :: rest)).toList = '\"' :: ((escapeString k).toList ++ '\"' :: ':' :: ' ' :: (v.render.toList ++ ',' :: ' ' :: (Js.Expr.renderFields (a :: rest)).toList))
                                                                                                                                                                                  Used by
                                                                                                                                                                                    theorem

                                                                                                                                                                                    Lean2Js.Parse.renderEntries_nil_toList

                                                                                                                                                                                    source
                                                                                                                                                                                    Used by
                                                                                                                                                                                      theorem

                                                                                                                                                                                      Lean2Js.Parse.renderEntries_one_toList

                                                                                                                                                                                      source
                                                                                                                                                                                      (k : String) (v : Js.Expr) :
                                                                                                                                                                                      (Js.Expr.renderEntries [(k, v)]).toList = '[' :: '\"' :: ((escapeString k).toList ++ '\"' :: ',' :: ' ' :: (v.render.toList ++ [']']))
                                                                                                                                                                                      Used by
                                                                                                                                                                                        theorem

                                                                                                                                                                                        Lean2Js.Parse.renderEntries_cons_toList

                                                                                                                                                                                        source
                                                                                                                                                                                        (k : String) (v : Js.Expr) (a : String × Js.Expr) (rest : List (String × Js.Expr)) :
                                                                                                                                                                                        (Js.Expr.renderEntries ((k, v) :: a :: rest)).toList = '[' :: '\"' :: ((escapeString k).toList ++ '\"' :: ',' :: ' ' :: (v.render.toList ++ ']' :: ',' :: ' ' :: (Js.Expr.renderEntries (a :: rest)).toList))
                                                                                                                                                                                        Used by

                                                                                                                                                                                          The lookahead fails on every rendering but an arrow call #

                                                                                                                                                                                          theorem

                                                                                                                                                                                          Lean2Js.Parse.renderInt_ofNat_toList

                                                                                                                                                                                          source
                                                                                                                                                                                          Used by
                                                                                                                                                                                            theorem

                                                                                                                                                                                            Lean2Js.Parse.renderInt_negSucc_toList

                                                                                                                                                                                            source
                                                                                                                                                                                            (n : Nat) :
                                                                                                                                                                                            Used by
                                                                                                                                                                                              theorem

                                                                                                                                                                                              Lean2Js.Parse.parseIdentList_render

                                                                                                                                                                                              source
                                                                                                                                                                                              (e : Js.Expr) (he : RenderableExpr e = true) (f : Nat) (suffix : List Char) (hs : AfterHead suffix) {ns : List String} {r : List Char} (h : parseIdentList (f + 1) (e.render.toList ++ suffix) = some (ns, r)) :
                                                                                                                                                                                              expect [')', ' ', '=', '>', ' ', '('] r = none
                                                                                                                                                                                              Used by
                                                                                                                                                                                                theorem

                                                                                                                                                                                                Lean2Js.Parse.arrowHead_ne

                                                                                                                                                                                                source
                                                                                                                                                                                                (f : Nat) {c : Char} (hc : c ≠ '(') (cs : List Char) :
                                                                                                                                                                                                Used by
                                                                                                                                                                                                  theorem

                                                                                                                                                                                                  Lean2Js.Parse.arrowHead_stuck

                                                                                                                                                                                                  source
                                                                                                                                                                                                  (f : Nat) (inner : List Char) (hstuck : ∀ (ns : List String) (r : List Char), parseIdentList (f + 1) inner = some (ns, r) → expect [')', ' ', '=', '>', ' ', '('] r = none) :
                                                                                                                                                                                                  parseArrowHead (f + 1) ('(' :: inner) = none
                                                                                                                                                                                                  Used by
                                                                                                                                                                                                    theorem

                                                                                                                                                                                                    Lean2Js.Parse.arrowHead_head

                                                                                                                                                                                                    source
                                                                                                                                                                                                    (f : Nat) {c : Char} (hc : isIdentPart c = false) (hne : c ≠ ')') (inner : List Char) :
                                                                                                                                                                                                    parseArrowHead (f + 1) ('(' :: c :: inner) = none
                                                                                                                                                                                                    Used by
                                                                                                                                                                                                      theorem

                                                                                                                                                                                                      Lean2Js.Parse.parseArrowHead_render

                                                                                                                                                                                                      source
                                                                                                                                                                                                      (e : Js.Expr) (he : RenderableExpr e = true) (f : Nat) (suffix : List Char) (hs : AfterHead suffix) :
                                                                                                                                                                                                      parseArrowHead (f + 1) (e.render.toList ++ suffix) = none

                                                                                                                                                                                                      The lookahead that picks an arrow call fails on every other parenthesised form: member closes with )., and binary and cond put a space where the arrow wants ).

                                                                                                                                                                                                      Used by

                                                                                                                                                                                                        Reaching the reader's branches #

                                                                                                                                                                                                        The reader picks its branch on one character, so each case first has to say which character the rendering opens with.

                                                                                                                                                                                                        theorem

                                                                                                                                                                                                        Lean2Js.Parse.identStart_not_digit

                                                                                                                                                                                                        source
                                                                                                                                                                                                        {c : Char} (h : isIdentStart c = true) :
                                                                                                                                                                                                        Used by
                                                                                                                                                                                                          theorem

                                                                                                                                                                                                          Lean2Js.Parse.head_digit_of_natDigits

                                                                                                                                                                                                          source
                                                                                                                                                                                                          {n : Nat} {d : Char} {ds : List Char} (hn : natDigits n = d :: ds) :
                                                                                                                                                                                                          Used by
                                                                                                                                                                                                            theorem

                                                                                                                                                                                                            Lean2Js.Parse.render_head

                                                                                                                                                                                                            source
                                                                                                                                                                                                            (e : Js.Expr) (he : RenderableExpr e = true) :
                                                                                                                                                                                                            ∃ (c : Char), ∃ (cs : List Char), e.render.toList = c :: cs ∧ (isIdentStart c = true ∨ c.isDigit = true ∨ c = '-' ∨ c = '\"' ∨ c = '(' ∨ c = '[' ∨ c = '{')
                                                                                                                                                                                                            Used by
                                                                                                                                                                                                              theorem

                                                                                                                                                                                                              Lean2Js.Parse.render_head_ne

                                                                                                                                                                                                              source
                                                                                                                                                                                                              (e : Js.Expr) (he : RenderableExpr e = true) {c : Char} {cs : List Char} (h : e.render.toList = c :: cs) :
                                                                                                                                                                                                              c ≠ ')' ∧ c ≠ ']' ∧ c ≠ ' ' ∧ c ≠ '!'

                                                                                                                                                                                                              No rendering opens with a character that closes a list, so a reader looking for the end of one never mistakes an element for it.

                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                Lean2Js.Parse.parseExpr_numHead

                                                                                                                                                                                                                source
                                                                                                                                                                                                                (f : Nat) {c : Char} (hc : (c == '-' || c.isDigit) = true) (cs : List Char) :
                                                                                                                                                                                                                parseExpr (f + 1) (c :: cs) = parseNumeral (c :: cs)
                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                  Lean2Js.Parse.parseExpr_int

                                                                                                                                                                                                                  source
                                                                                                                                                                                                                  (f : Nat) (i : Int) (cs : List Char) :
                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                    Lean2Js.Parse.parseExpr_start

                                                                                                                                                                                                                    source
                                                                                                                                                                                                                    (f : Nat) {c : Char} (hs : isIdentStart c = true) (cs : List Char) :
                                                                                                                                                                                                                    parseExpr (f + 1) (c :: cs) = match parseIdent (c :: cs) with | none => none | some (name, r) => parseNamed f name r
                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                      Lean2Js.Parse.parseNumeral_num

                                                                                                                                                                                                                      source
                                                                                                                                                                                                                      (i : Int) (rest : List Char) (hrest : Sep rest) :
                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                        Lean2Js.Parse.parseNumeral_bigLit

                                                                                                                                                                                                                        source
                                                                                                                                                                                                                        (i : Int) (rest : List Char) :
                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                          Lean2Js.Parse.parseNamed_other

                                                                                                                                                                                                                          source
                                                                                                                                                                                                                          (f : Nat) (name : String) (h : dispatchNames.contains name = false) (cs : List Char) :
                                                                                                                                                                                                                          parseNamed (f + 1) name cs = match expect ['('] cs with | none => some (Js.Expr.ident name, cs) | some cs => do let __x ← parseExprList f ')' cs match __x with | (args, cs) => do let cs ← expect [')'] cs pure (Js.Expr.call name args, cs)
                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                            Lean2Js.Parse.render_head_num

                                                                                                                                                                                                                            source
                                                                                                                                                                                                                            (e : Js.Expr) (he : RenderableExpr e = true) {c : Char} {cs : List Char} (h : e.render.toList = c :: cs) (hc : c.isDigit = true ∨ c = '-') :

                                                                                                                                                                                                                            Only a numeral is written starting with a digit or a minus sign, which is what lets parseParen decide by the character after ( whether a numeral reader should take the sign.

                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                              Lean2Js.Parse.descSize_le

                                                                                                                                                                                                                              source

                                                                                                                                                                                                                              The descriptor reader's budget, read off the text it is handed rather than off the descriptor.

                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                Lean2Js.Parse.foldFieldsSize_le

                                                                                                                                                                                                                                source

                                                                                                                                                                                                                                The spec reader's budget, read off the text the same way the descriptor's is.

                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                  Lean2Js.Parse.specSize_le

                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                    Lean2Js.Parse.parseInt_neg_ofNat

                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                    (n : Nat) (rest : List Char) (hrest : notDigitFirst rest) :
                                                                                                                                                                                                                                    parseInt ('-' :: (natDigits n ++ rest)) = some (-↑n, rest)
                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                      Lean2Js.Parse.parseExprList_step

                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                      (f : Nat) (close : Char) {c : Char} (hne : (c == close) = false) (cs : List Char) :
                                                                                                                                                                                                                                      parseExprList (f + 1) close (c :: cs) = do let __x ← parseExpr f (c :: cs) match __x with | (e, r) => match expect [',', ' '] r with | none => pure ([e], r) | some r => do let __x ← parseExprList f close r match __x with | (es, r) => pure (e :: es, r)
                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                        Name lists and operators #

                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                        Lean2Js.Parse.renderNames_nil_toList

                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                          Lean2Js.Parse.renderNames_one_toList

                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                            Lean2Js.Parse.renderNames_cons_toList

                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                            (n a : String) (rest : List String) :
                                                                                                                                                                                                                                            (Js.renderNames (n :: a :: rest)).toList = n.toList ++ ',' :: ' ' :: (Js.renderNames (a :: rest)).toList
                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                              Lean2Js.Parse.parseIdent_none

                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                              {cs : List Char} (h : notIdentFirst cs) :
                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                Lean2Js.Parse.parseIdentList_names

                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                (ps : List String) (hps : ps.all okName = true) (f : Nat) (hf : ps.length < f) (rest : List Char) (hrest : notIdentFirst rest) (hcomma : expect [',', ' '] rest = none) :
                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                  Lean2Js.Parse.renderNames_length

                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                    Lean2Js.Parse.okOp_ne_nil

                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                    {s : String} (h : okOp s = true) :
                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                      Lean2Js.Parse.okOp_all

                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                      {s : String} (h : okOp s = true) :
                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                        Lean2Js.Parse.okOp_head

                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                        {s : String} (h : okOp s = true) {c : Char} {cs : List Char} (hm : s.toList = c :: cs) :
                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                          Lean2Js.Parse.parseOpChars_append

                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                          (ds : List Char) (hds : ds.all isOpChar = true) (rest : List Char) (hrest : ∀ (c : Char) (r : List Char), rest = c :: r → isOpChar c = false) :
                                                                                                                                                                                                                                                          parseOpChars (ds ++ rest) = (ds, rest)
                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                            Lean2Js.Parse.parseOp_append

                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                            (op : String) (hop : okOp op = true) (rest : List Char) (hrest : ∀ (c : Char) (r : List Char), rest = c :: r → isOpChar c = false) :
                                                                                                                                                                                                                                                            parseOp (op.toList ++ rest) = some (op, rest)
                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                              Lean2Js.Parse.exists_cons_of_ne_nil

                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                              {α : Type u_1} {l : List α} (h : l ≠ []) :
                                                                                                                                                                                                                                                              ∃ (a : α), ∃ (as : List α), l = a :: as
                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                Lean2Js.Parse.parseExpr_name

                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                (f : Nat) (name : String) (hn : okName name = true) (rest : List Char) (hrest : notIdentFirst rest) :
                                                                                                                                                                                                                                                                parseExpr (f + 1) (name.toList ++ rest) = parseNamed f name rest
                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                  Lean2Js.Parse.expect_open_none

                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                  {rest : List Char} (hrest : Sep rest) :
                                                                                                                                                                                                                                                                  expect ['('] rest = none
                                                                                                                                                                                                                                                                  Used by

                                                                                                                                                                                                                                                                    Reaching the parenthesised branches #

                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                    Lean2Js.Parse.parseParen_bang

                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                    (g : Nat) (r : List Char) :
                                                                                                                                                                                                                                                                    parseParen (g + 1 + 1) ('!' :: r) = do let __x ← parseExpr (g + 1) r match __x with | (e, r) => do let r ← expect [')'] r pure (Js.Expr.unary "!" e, r)
                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                      Lean2Js.Parse.parseParen_minusDigit

                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                      (g : Nat) {d : Char} (hd : d.isDigit = true) (r : List Char) :
                                                                                                                                                                                                                                                                      parseParen (g + 1 + 1) ('-' :: d :: r) = do let __x ← parseNumeral ('-' :: d :: r) match __x with | (e, r') => parseAfterHead (g + 1) e r'
                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                        Lean2Js.Parse.parseParen_minusOther

                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                        (g : Nat) {d : Char} (hd : d.isDigit = false) (r : List Char) :
                                                                                                                                                                                                                                                                        parseParen (g + 1 + 1) ('-' :: d :: r) = do let __x ← parseExpr (g + 1) (d :: r) match __x with | (e, r) => do let r ← expect [')'] r pure (Js.Expr.unary "-" e, r)
                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                          Lean2Js.Parse.parseParen_fallback

                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                          (g : Nat) {c : Char} (h1 : c ≠ '!') (h2 : c ≠ '-') (cs : List Char) (harrow : parseArrowHead (g + 1) (c :: cs) = none) :
                                                                                                                                                                                                                                                                          parseParen (g + 1 + 1) (c :: cs) = do let __x ← parseExpr (g + 1) (c :: cs) match __x with | (e, r) => parseAfterHead (g + 1) e r
                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                            Lean2Js.Parse.parseAfterHead_member

                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                            (g : Nat) (e : Js.Expr) (field : String) (hfield : okName field = true) (rest : List Char) (hrest : notIdentFirst rest) :
                                                                                                                                                                                                                                                                            parseAfterHead (g + 1) e (')' :: '.' :: (field.toList ++ rest)) = some (e.member field, rest)
                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                              Lean2Js.Parse.parseAfterHead_negate

                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                              (g : Nat) (e : Js.Expr) {c : Char} (hc : c ≠ '.') (rest : List Char) :
                                                                                                                                                                                                                                                                              parseAfterHead (g + 1) e (')' :: c :: rest) = Option.map (fun (e : Js.Expr) => (Js.Expr.unary "-" e, c :: rest)) (negateNumeral e)
                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                Lean2Js.Parse.parseAfterHead_negate_nil

                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                (g : Nat) (e : Js.Expr) :
                                                                                                                                                                                                                                                                                parseAfterHead (g + 1) e [')'] = Option.map (fun (e : Js.Expr) => (Js.Expr.unary "-" e, [])) (negateNumeral e)
                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                  Lean2Js.Parse.parseAfterHead_neg

                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                  (g : Nat) (e : Js.Expr) (rest : List Char) (hrest : Sep rest) :
                                                                                                                                                                                                                                                                                  parseAfterHead (g + 1) e (')' :: rest) = Option.map (fun (e : Js.Expr) => (Js.Expr.unary "-" e, rest)) (negateNumeral e)
                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                    Lean2Js.Parse.parseAfterHead_binary

                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                    (g : Nat) (e : Js.Expr) {c : Char} (hc : c ≠ '?') (cs : List Char) :
                                                                                                                                                                                                                                                                                    parseAfterHead (g + 1) e (' ' :: c :: cs) = do let __x ← parseOp (c :: cs) match __x with | (op, r) => do let r ← expect [' '] r let __x ← parseExpr g r match __x with | (rhs, r) => do let r ← expect [')'] r pure (Js.Expr.binary op e rhs, r)
                                                                                                                                                                                                                                                                                    Used by

                                                                                                                                                                                                                                                                                      The roundtrip on expressions #

                                                                                                                                                                                                                                                                                      Each case reads back exactly what the matching printer branch wrote. The fuel is bounded by the length of the text, which every recursive call shortens by at least the delimiters around it.

                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                      Lean2Js.Parse.parseExpr_append

                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                      (e : Js.Expr) (he : RenderableExpr e = true) (f : Nat) (hf : e.render.toList.length < f) (rest : List Char) (hrest : Sep rest) :
                                                                                                                                                                                                                                                                                      parseExpr f (e.render.toList ++ rest) = some (e, rest)
                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                        Lean2Js.Parse.parseParen_head

                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                        (h : Js.Expr) (hh : RenderableExpr h = true) (f : Nat) (hf : h.render.toList.length < f) (tail : List Char) (hsep : Sep tail) (hafter : AfterHead tail) :
                                                                                                                                                                                                                                                                                        parseParen (f + 1) (h.render.toList ++ tail) = parseAfterHead f h tail
                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                          Lean2Js.Parse.parseLambdaCall_append

                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                          (arr : Js.Expr) (b : String) (body : Js.Expr) (harr : RenderableExpr arr = true) (hb : okName b = true) (hbody : RenderableExpr body = true) (k : Nat) (hk1 : arr.render.toList.length < k) (hk2 : body.render.toList.length < k) (rest : List Char) (hrest : Sep rest) :
                                                                                                                                                                                                                                                                                          parseLambdaCall (k + 1) ('(' :: (arr.render.toList ++ ',' :: ' ' :: '(' :: (b.toList ++ ')' :: ' ' :: '=' :: '>' :: ' ' :: '(' :: (body.render.toList ++ ')' :: ')' :: rest)))) = some (arr, b, body, rest)
                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                            Lean2Js.Parse.parseExprList_append

                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                            (es : List Js.Expr) (hes : RenderableList es = true) (f : Nat) (hf : (Js.Expr.renderList es).toList.length + 1 < f) (close : Char) (hclose : close = ')' ∨ close = ']') (rest : List Char) :
                                                                                                                                                                                                                                                                                            parseExprList f close ((Js.Expr.renderList es).toList ++ close :: rest) = some (es, close :: rest)
                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                              Lean2Js.Parse.parseObjFields_append

                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                              (fs : List (String × Js.Expr)) (hfs : RenderablePairs fs = true) (f : Nat) (hf : (Js.Expr.renderFields fs).toList.length + 1 < f) (rest : List Char) :
                                                                                                                                                                                                                                                                                              parseObjFields f ((Js.Expr.renderFields fs).toList ++ ' ' :: '}' :: rest) = some (fs, ' ' :: '}' :: rest)
                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                Lean2Js.Parse.parseEntries_append

                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                (es : List (String × Js.Expr)) (hes : RenderablePairs es = true) (f : Nat) (hf : (Js.Expr.renderEntries es).toList.length + 1 < f) (rest : List Char) :
                                                                                                                                                                                                                                                                                                parseEntries f ((Js.Expr.renderEntries es).toList ++ ']' :: rest) = some (es, ']' :: rest)
                                                                                                                                                                                                                                                                                                Used by

                                                                                                                                                                                                                                                                                                  Statements, functions and the module #

                                                                                                                                                                                                                                                                                                  def

                                                                                                                                                                                                                                                                                                  Lean2Js.Parse.RenderableStmt

                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                      def

                                                                                                                                                                                                                                                                                                      Lean2Js.Parse.noCommentClose

                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                      :

                                                                                                                                                                                                                                                                                                      A doc comment goes into /** */ unescaped, so it must not close the comment itself.

                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                          def

                                                                                                                                                                                                                                                                                                          Lean2Js.Parse.RenderableFunc

                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                          (fn : Js.Func) :
                                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                              def

                                                                                                                                                                                                                                                                                                              Lean2Js.Parse.RenderableModule

                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                  Lean2Js.Parse.render_const_toList

                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                  (name : String) (val : Js.Expr) :
                                                                                                                                                                                                                                                                                                                  (Js.Stmt.const name val).render.toList = ' ' :: ' ' :: 'c' :: 'o' :: 'n' :: 's' :: 't' :: ' ' :: (name.toList ++ ' ' :: '=' :: ' ' :: (val.render.toList ++ [';']))
                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                    Lean2Js.Parse.render_ret_toList

                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                    (e : Js.Expr) :
                                                                                                                                                                                                                                                                                                                    (Js.Stmt.ret e).render.toList = ' ' :: ' ' :: 'r' :: 'e' :: 't' :: 'u' :: 'r' :: 'n' :: ' ' :: (e.render.toList ++ [';'])
                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                      Lean2Js.Parse.render_stmt_head

                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                      (st : Js.Stmt) :
                                                                                                                                                                                                                                                                                                                      ∃ (x : List Char), st.render.toList = ' ' :: ' ' :: x
                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                        Lean2Js.Parse.stmtAll_nil_toList

                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                          Lean2Js.Parse.stmtAll_one_toList

                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                            Lean2Js.Parse.stmtAll_cons_toList

                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                            (st a : Js.Stmt) (rest : List Js.Stmt) :
                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                              Lean2Js.Parse.funcAll_nil_toList

                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                Lean2Js.Parse.funcAll_cons_toList

                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                (fn : Js.Func) (rest : List Js.Func) :
                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                  Lean2Js.Parse.render_func_toList

                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                  (fn : Js.Func) :
                                                                                                                                                                                                                                                                                                                                  fn.render.toList = (if fn.doc.isEmpty = true then [] else '/' :: '*' :: '*' :: ' ' :: (fn.doc.toList ++ [' ', '*', '/', '\n'])) ++ ((if fn.exported = true then ['e', 'x', 'p', 'o', 'r', 't', ' '] else []) ++ 'f' :: 'u' :: 'n' :: 'c' :: 't' :: 'i' :: 'o' :: 'n' :: ' ' :: (fn.name.toList ++ '(' :: ((Js.renderNames fn.params).toList ++ ')' :: ' ' :: '{' :: '\n' :: ((Js.Stmt.renderAll fn.body).toList ++ ['\n', '}']))))
                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                    Lean2Js.Parse.render_func_split

                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                    (fn : Js.Func) (rest : List Char) :
                                                                                                                                                                                                                                                                                                                                    fn.render.toList ++ rest = (if fn.doc.isEmpty = true then [] else '/' :: '*' :: '*' :: ' ' :: (fn.doc.toList ++ [' ', '*', '/', '\n'])) ++ ((if fn.exported = true then ['e', 'x', 'p', 'o', 'r', 't', ' '] else []) ++ 'f' :: 'u' :: 'n' :: 'c' :: 't' :: 'i' :: 'o' :: 'n' :: ' ' :: (fn.name.toList ++ '(' :: ((Js.renderNames fn.params).toList ++ ')' :: ' ' :: '{' :: '\n' :: ((Js.Stmt.renderAll fn.body).toList ++ '\n' :: '}' :: rest))))
                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                      Lean2Js.Parse.render_func_length

                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                                        Reading a doc comment back #

                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                        Lean2Js.Parse.takeUntil_close

                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                        (rest : List Char) :
                                                                                                                                                                                                                                                                                                                                        takeUntil [' ', '*', '/', '\n'] ([' ', '*', '/', '\n'] ++ rest) = some ([], [' ', '*', '/', '\n'] ++ rest)
                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                          Lean2Js.Parse.noCommentClose_tail

                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                          {a : Char} {d : List Char} (h : noCommentClose (a :: d) = true) :
                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                            Lean2Js.Parse.takeUntil_doc

                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                            (d : List Char) (h : noCommentClose d = true) (rest : List Char) :
                                                                                                                                                                                                                                                                                                                                            takeUntil [' ', '*', '/', '\n'] (d ++ ([' ', '*', '/', '\n'] ++ rest)) = some (d, [' ', '*', '/', '\n'] ++ rest)
                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                              Lean2Js.Parse.expect_docOpen

                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                              (Y : List Char) :
                                                                                                                                                                                                                                                                                                                                              expect ['/', '*', '*', ' '] ('/' :: '*' :: '*' :: ' ' :: Y) = some Y
                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                Lean2Js.Parse.expect_docClose

                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                (Y : List Char) :
                                                                                                                                                                                                                                                                                                                                                expect [' ', '*', '/', '\n'] (' ' :: '*' :: '/' :: '\n' :: Y) = some Y
                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Parse.takeUntil_doc'

                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                  (d : List Char) (h : noCommentClose d = true) (rest : List Char) :
                                                                                                                                                                                                                                                                                                                                                  takeUntil [' ', '*', '/', '\n'] (d ++ ' ' :: '*' :: '/' :: '\n' :: rest) = some (d, ' ' :: '*' :: '/' :: '\n' :: rest)

                                                                                                                                                                                                                                                                                                                                                  The shape a doc comment takes inside a rendering, where the closing marker is spelled out.

                                                                                                                                                                                                                                                                                                                                                  Used by

                                                                                                                                                                                                                                                                                                                                                    The roundtrip on statements, functions and the module #

                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Parse.parseStmt_append

                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                    (st : Js.Stmt) (hst : RenderableStmt st = true) (f : Nat) (hf : st.render.toList.length < f) (rest : List Char) :
                                                                                                                                                                                                                                                                                                                                                    parseStmt f (st.render.toList ++ rest) = some (st, rest)
                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Parse.stmtAll_head

                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                      (ss : List Js.Stmt) (h : ss ≠ []) :
                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Parse.parseStmts_step

                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                        (f : Nat) (cs x : List Char) (h : cs = ' ' :: ' ' :: x) :
                                                                                                                                                                                                                                                                                                                                                        parseStmts (f + 1) cs = do let __x ← parseStmt f cs match __x with | (st, r) => match r with | '\n' :: '}' :: tail => pure ([st], r) | '\n' :: r' => do let __x ← parseStmts f r' match __x with | (ss, r') => pure (st :: ss, r') | x => none
                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Parse.parseStmts_append

                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                          (ss : List Js.Stmt) (hss : ss.all RenderableStmt = true) (f : Nat) (hf : (Js.Stmt.renderAll ss).toList.length + 1 < f) (rest : List Char) :
                                                                                                                                                                                                                                                                                                                                                          parseStmts f ((Js.Stmt.renderAll ss).toList ++ '\n' :: '}' :: rest) = some (ss, '\n' :: '}' :: rest)
                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Parse.parseFunc_append

                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                            (fn : Js.Func) (hfn : RenderableFunc fn = true) (f : Nat) (hf : fn.render.toList.length + 1 < f) (rest : List Char) :
                                                                                                                                                                                                                                                                                                                                                            parseFunc f (fn.render.toList ++ rest) = some (fn, rest)
                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Parse.parseFuncs_step

                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                              (f : Nat) (cs : List Char) (c : Char) (x : List Char) (h : cs = c :: x) :
                                                                                                                                                                                                                                                                                                                                                              parseFuncs (f + 1) cs = do let __x ← parseFunc f cs match __x with | (fn, r) => do let r ← expect ['\n', '\n'] r let __x ← parseFuncs f r match __x with | (fs, r) => pure (fn :: fs, r)
                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Parse.expect_self

                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                (l : List Char) :
                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Parse.render_func_head

                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Parse.parseFuncs_append

                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Parse.parseModule_of

                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                      (P : List Char) (hP : 1 < P.length) (fs : List Js.Func) (hfs : fs.all RenderableFunc = true) :
                                                                                                                                                                                                                                                                                                                                                                      (do let r ← expect P (P ++ (Js.Func.renderAll fs).toList) let __x ← parseFuncs (P ++ (Js.Func.renderAll fs).toList).length r match __x with | (fs', r) => if r.isEmpty = true then some { funcs := fs' } else none) = some { funcs := fs }

                                                                                                                                                                                                                                                                                                                                                                      The prelude is a long literal, so it is kept opaque here: nothing about the roundtrip depends on what it says, only on its being the same text on both sides and on its leaving the reader more fuel than the functions after it need.

                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Parse.preamble_length

                                                                                                                                                                                                                                                                                                                                                                        source

                                                                                                                                                                                                                                                                                                                                                                        The prelude opens with a comment, so it leaves the reader more fuel than the functions after it need.

                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Parse.parseModule_render

                                                                                                                                                                                                                                                                                                                                                                          source

                                                                                                                                                                                                                                                                                                                                                                          The file the compiler writes reads back as the module it was compiled from.

                                                                                                                                                                                                                                                                                                                                                                          Used by