Project

EarthSciAST

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

Contents

This is the documentation for the older version v0.16.0. For the latest release, see v0.17.0.

The Typst printer writes only Typst tokens, in lexable order

Lean module Esm.Document.Math.TokTypst, formal/Esm/Document/Math/TokTypst.lean at ed59cfa2b070
Imports Esm.Document.Math.LexTypst, Esm.Document.Math.TokLatex

Every token of a printed well-formed expression is a Typst token (tokOK ), every call parenthesis follows a name-like token, and no unit block follows a unit block (Adj ), so the Typst lexer lemma applies to the printer’s output.

def Nice (ts : List Tok) : Prop

A list that may follow anything: it does not start with a call parenthesis or a unit block.

theorem good_times proved source
theorem good_times {B : List Tok} (hB : Good (.kw .lbk :: B)) : Good (.kw .times :: .kw .lbk :: B)

times and the bracket after it.

theorem good_times_tok proved source
theorem good_times_tok {u : Tok} {B : List Tok} (hB : Good (u :: B)) (hu : startsNum [u] = false)
    (hlp : u ≠ .kw .lp) : Good (.kw .times :: u :: B)

times before a list that does not start with a number (the operand of a curl).

macro source
macro "gok" : tactic

Close Good, Nice and fact goals about a printed template from the pieces in the context.

Names

Printer pieces

macro source
macro "fixed" : tactic

The fixed tokens of a printed template.

Reductions

theorem good_close proved source
theorem good_close {A : List Tok} {k : Kw} (hk : kwOK k = true) (hl : k ≠ .lp) (hA : Good A) (hn : Nice A) :
    Good (A ++ [.kw k]) ∧ Nice (A ++ [.kw k])

The list toks ++ [closer] for a list that is good and nice.

Block assembly

The induction

theorem good_at proved source
theorem good_at (S : Sym) (x : Json) (hx : isE x = true) (L : Nat) :
    Good ((pr ⟨.typst, S⟩ x).at .typst L) ∧ Nice ((pr ⟨.typst, S⟩ x).at .typst L) ∧
      (pr ⟨.typst, S⟩ x).at .typst L ≠ []

A well-formed expression’s tokens at any level are good, nice and not empty.

theorem good_rowToks proved source
theorem good_rowToks (c : Ctx) (hc : c.sf = .typst) (P : Json → Out) (kv : String × Json)
    (hQ : ∀ a b, kv.2 = .arr [a, b] →
      (Good ((P a).at .typst 4) ∧ Nice ((P a).at .typst 4) ∧ (P a).at .typst 4 ≠ []) ∧
      (Good ((P b).at .typst 4) ∧ Nice ((P b).at .typst 4) ∧ (P b).at .typst 4 ≠ [])) :
    Good (rowToks c P kv) ∧ Nice (rowToks c P kv)

A range row’s tokens are good and nice.

theorem print_ok proved source
theorem print_ok (S : Sym) (e : Json) (he : isE e = true) :
    (∀ t ∈ print .typst S e, tokOK t ∨ t = .kw .times) ∧ Adj (print .typst S e) ∧
      ∀ r, print .typst S e ≠ .kw .lp :: r

Every token the Typst printer writes for a well-formed expression is a Typst token, in an order the Typst lexer reads back.

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