Lax58.FormulaExample
Example — structural encoding of propositional formulas
concepts/Lax58/FormulaExample.lean · lax-58
No public endorsements yet.
Loading review…
Sign in with ORCIDConcept map
Definition
A propositional formula is finite mathematical data: an atom has a natural number as its name, a negation has one subformula, and a conjunction has two. The example below represents this syntax directly, without evaluating the formula or attaching information about its truth or satisfiability.
The single command generates , its complete constructor equations , and their checked witness . Atoms retain their natural indices; negation and conjunction retain their constructor names and recursively encoded children.
For the sample formula , the structural description is , expressed using the fixed vocabulary. then gives its distinguished word-arena input: the root address followed by the three-word blocks for the structural nodes. The same two-stage construction applies to other supported finite datatypes.
Lean source view on GitHub
| 1 | import Lax58.CertifiedDerivationElab |
| 2 | import Lax58.WordArena |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Example — structural encoding of propositional formulas |
| 7 | type: definition |
| 8 | --- |
| 9 | |
| 10 | A propositional formula is finite mathematical data: an atom has a natural |
| 11 | number as its name, a negation has one subformula, and a conjunction has two. |
| 12 | The example below represents this syntax directly, without evaluating the |
| 13 | formula or attaching information about its truth or satisfiability. |
| 14 | |
| 15 | The single `derive_certified_encoding` command generates `formulaRaw`, its |
| 16 | complete constructor equations `formulaRaw.Laws`, and their checked witness |
| 17 | `formulaRaw.certified`. Atoms retain their natural indices; negation and |
| 18 | conjunction retain their constructor names and recursively encoded children. |
| 19 | |
| 20 | For the sample formula , the structural description is |
| 21 | `conj(atom(0), neg(atom(1)))`, expressed using the fixed `Raw.constructor` |
| 22 | vocabulary. `sampleInput` then gives its distinguished word-arena input: |
| 23 | the root address followed by the three-word blocks for the structural nodes. |
| 24 | The same two-stage construction applies to other supported finite datatypes. |
| 25 | -/ |
| 26 | |
| 27 | namespace Lax58.FormulaExample |
| 28 | |
| 29 | open Lax58.StructuralPresentation Lax58.WordArena |
| 30 | |
| 31 | /-- Propositional syntax with natural-number atom names. -/ |
| 32 | inductive Formula where |
| 33 | | atom (index : Nat) |
| 34 | | neg (body : Formula) |
| 35 | | conj (left right : Formula) |
| 36 | |
| 37 | /-- Derive the structural encoder and its complete certificate together. -/ |
| 38 | derive_certified_encoding formulaRaw indexed : Formula |
| 39 | |
| 40 | /-- The formula . -/ |
| 41 | def sample : Formula := .conj (.atom 0) (.neg (.atom 1)) |
| 42 | |
| 43 | /-- Constructor structure, before choosing a word-memory layout. -/ |
| 44 | def sampleStructure : Raw := formulaRaw sample |
| 45 | |
| 46 | /-- Exact input words, including the root address and no additional data. -/ |
| 47 | def sampleInput : List Nat := (encodeRaw sampleStructure).toInput |
| 48 | |
| 49 | end Lax58.FormulaExample |
| 50 |
Community review
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.
0 comments