Project

EarthSciAST

The EarthSciML Abstract Syntax Tree format: schema, operators, coupling, and five language bindings.

Contents

The token-level round trip, by induction over the expression

Lean module Esm.Document.Math.Induct, formal/Esm/Document/Math/Induct.lean at 29ec73bddfdc
Imports Esm.Document.Math.Makearray

theorem M_all proved source
theorem M_all (c : Ctx) : ∀ n e, sizeOf e < n → isE e = true → M c e

Every well-formed expression carries the round-trip facts.

def parseToks (sf : Sf) (S : Sym) (ts : List Tok) : Option Json

Read a whole token list as one expression: an expression, or an equation in its defining form (x_s = …, s ∈ S, unlift ).

theorem parseToks_pa proved source
theorem parseToks_pa (sf : Sf) (S : Sym) (e : Json) (he : isE e = true) :
    parseToks sf S (pa ⟨sf, S⟩ 1 e) = some e

An expression printed whole reads back.

theorem pTail_tail proved source
theorem pTail_tail (c : Ctx) (rows : List (String × Json)) (hne : rows ≠ [])
    (hrows : rows.all (fun kv => nameOK kv.1 && rangeOK kv.2 &&
      match kv.2 with | .arr [a, b] => isE a && isE b | _ => true) = true)
    (f : Nat) (hf : 30 * (defRowsToks c rows).length + 12 ≤ f) :
    pTail c (f + 1) (defRowsToks c rows) = some (rows.map fun kv => Row.rng kv.1 kv.2)

The range rows after a defining equation read back.

theorem parseToks_print proved source
theorem parseToks_print (sf : Sf) (S : Sym) (e : Json) (he : isE e = true) :
    parseToks sf S (print sf S e) = some e

The token-level round trip: every well-formed expression reads back from its printed tokens, on both surfaces and under every symbol table.

This module also proves 7 lemmas without doc comments; they are in the source.