Version: dev

This is the documentation for the development version. For the latest release, see v0.12.1.

Document formats

The Markdown and Typst source formats of an ESM document, as the commented Lean model that defines them.

An ESM document can be written as a Markdown (.md) or Typst (.typ) source file as well as .esm JSON. This chapter specifies those source formats: the notation tables, the LaTeX and Typst math grammars, the value codecs (JSON, the strict YAML subset, Typst dictionaries) and the unit spellings. It is not a description of a Lean model; it is the Lean model, formal/ in the EarthSciAST repository, rendered page by page.

The Esm.Document modules, with Esm.Units.Canonical and Esm.Units.Typeset for the unit spellings, are the authority for these formats: esm-spec.md only points here, and a change to the notation is a change to the modules first. The other Esm.Units modules are included as the supporting model of units and dimensional analysis, which esm-spec.md §4.8 still defines. Every proof is checked by Lean in EarthSciAST’s CI (the formal workflow; formal/README.md explains how to build it locally).

Generated from the Lean source at commit 184aa13d35e5 , without running Lean. Module comments are the prose; each documented declaration shows its statement, its doc comment and a link to its source. 74 modules, 265 documented theorems. Every theorem marked proved has no sorry or admit in its proof, and no file of the Lean package contains either or declares an axiom.

Esm.Document

Esm.Document.Math

Esm.Document.Source

  • Lines of text (Esm.Document.Source.Lines): Containers are line-oriented: a fenced block ends at the first line that starts with its closing fence.
  • Objects in canonical form: sorting entries, and splitting an object between surfaces (Esm.Document.Source.Keys): A canonical ESM document has the keys of every object in strictly increasing order (the sorted-key canonical serialization).
  • The document skeleton (Esm.Document.Source.Skeleton): The document layer maps an ESM document (a JSON object in canonical form) to a skeleton: the front matter, the description, the path blocks, and one section per model or reaction system with its description, its declarations, its equations and its own path blocks.
  • The document layer round trip (Esm.Document.Source.SkeletonRT): ofDoc_toDoc: a canonical document is rebuilt exactly from its skeleton, for every choice of container predicates Caps.
  • The skeleton as a sequence of constructs (Esm.Document.Source.Items): A container spells a skeleton as a sequence of constructs: description blocks, path blocks, component directives, declarations, equations (model, initialization and constraint) and reactions.
  • What the skeleton of a canonical document satisfies (Esm.Document.Source.Facts): toDoc_ok: the skeleton of a canonical document only holds what its container can spell (Caps), and only well-formed JSON values; the containers’ round trips assume exactly this.
  • Text scanning shared by the containers (Esm.Document.Source.Text): Prefixes, lines, fenced bodies ended by a closing line, and the facts the containers’ round trips use about them.
  • Line heads of the YAML spelling (Esm.Document.Source.YamlLines): Facts about which characters start a line of Yaml.encode v, used to show a YAML block can sit inside a Markdown code fence (yaml_heads_tick) or between front-matter --- delimiters (yaml_heads_dash), and that it ends at the start of a line (yaml_ends).
  • Reaction sides, shared by the containers (Esm.Document.Source.Reaction): A reaction prints as one line in the chemistry notation of its container (mhchem \ce{…} in Markdown, typsium #ce[…] in Typst), the rate over the arrow (Notation.reactionLatex).
  • An equation as math (Esm.Document.Source.Equation): An equation lhs = rhs is printed as the math of the expression ==(lhs, rhs): the = is the comparison’s sign at the loosest comparison level.
  • Multi-line equations (accepted input variants) (Esm.Document.Source.MultiLine): The printer writes one equation per display.
  • The Markdown container (Esm.Document.Source.Markdown): An ESM document in Markdown is CommonMark with $…$ / $$…$$ math (LaTeX), fenced blocks, YAML front matter and directives.
  • Markdown documents: printing, parsing, and the round trip (Esm.Document.Source.MarkdownDoc): printMd spells a canonical ESM document as Markdown, parseMd reads it back, and parseMd_printMd is the round trip.
  • The Typst container (Esm.Document.Source.Typst): An ESM document in Typst is markup plus the functions of an esm Typst package.
  • Typst documents: printing, parsing, and the round trip (Esm.Document.Source.TypstDoc): printTyp spells a canonical ESM document as Typst, parseTyp reads it back, and parseTyp_printTyp is the round trip, composed exactly as for Markdown (Esm.Document.Source.MarkdownDoc) with the Typst math theorem parseTypst_printTypst.

Esm.Units