Two engines

The same Lean code, compiled to WebAssembly for the browser, and the full elaborator on a local server.

In the browser, an engine compiled from Lean answers the pages' requests, with no server. With GraviTrax's local server, proofs go through Lean's real elaborator and kernel. Tests compare the two engines, and Lean with each game's JavaScript.

The games share one logic (`LeanGames.Core`): a checker proved sound, deductions that lose no solution, checked proof trees.

The games with a design system (GraviTrax, Tubulax) also share one definition of the workshop (`LeanGames.Design.Workshop`): a rule and what the assembly is for, each decided by a checker proved sound, and a checked catalogue of pieces.

In Lean

These statements are read from the games' Lean code when the site is built: if one of them disappears or changes, the site does not build.

LeanGames.Api.Protocol (C : Type) : Type 1
The commands of a game: each one's name, documentation, request and answer types. source →
LeanGames.Api.EngineT (m : Type → Type) (C : Type) [Protocol C] : Type
An engine for a protocol, in a monad `m`: an answer of the right type for every command, in the language of the request. source →
LeanGames.Api.handle {C : Type} [Protocol C] (engine : Engine C) (request : J) : J
`handleM` for a pure engine. source →
LeanGames.Core.Checker (P B : Type) [Problem P B] : Type
A checker for the rule: what it accepts is solved. source →
LeanGames.Core.Follows {P B : Type} [Partial P B] (p : P) (g g' : B) : Prop
Going from `g` to `g'` loses no solution. source →
LeanGames.Core.Interp.run_sound {G R : Type} [Inhabited G] [Inhabited R] {game : Interp.Game G R}
  {config : Script.Config (Interp.Atom R)} {root : G} {script : String} {l : Lang}
  (h : (Interp.run game config root script l).complete = true) : game.rules.holds root
A complete run proves the root goal. source →
LeanGames.Design.Workshop : Type 1
A workshop: where and what it builds, its rule, what the assembly is for, the pieces. source →
LeanGames.Design.Workshop.check_sound {D : Design.Workshop} {s : D.Site} {a : D.Assembly}
  (h : D.check s a = true) : D.Built s a
source →
Gravitrax.built_iff (s : Stock) (p : Plan) : systeme.Built s p ↔ Circuit s p
Built, for the design system, is the workshop's theorem. source →
LeanGames.Core.ProofTree.valid_sound {G R : Type} {rs : Rules G R} {n : Nat} {g : G}
  {t : ProofTree R} : ProofTree.valid rs n g t = true → rs.holds g
A tree the checker accepts proves its goal. source →