Draft — mutable and not usable as a dependency; its citation marks the draft state.

Lax58.FormulaExample

Example — structural encoding of propositional formulas

concepts/Lax58/FormulaExample.lean · lax-58

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Concept map

    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    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 derivecertifiedencodingderive_certified_encoding command generates formulaRawformulaRaw, its complete constructor equations formulaRaw.LawsformulaRaw.Laws, and their checked witness formulaRaw.certifiedformulaRaw.certified. Atoms retain their natural indices; negation and conjunction retain their constructor names and recursively encoded children.

    For the sample formula p0¬p1p_0 \land \neg p_1, the structural description is conj(atom(0),neg(atom(1)))conj(atom(0), neg(atom(1))), expressed using the fixed Raw.constructorRaw.constructor vocabulary. sampleInputsampleInput 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

    1import Lax58.CertifiedDerivationElab
    2import Lax58.WordArena
    3
    4/-!
    5---
    6title: Example — structural encoding of propositional formulas
    7type: definition
    8---
    9
    10A propositional formula is finite mathematical data: an atom has a natural
    11number as its name, a negation has one subformula, and a conjunction has two.
    12The example below represents this syntax directly, without evaluating the
    13formula or attaching information about its truth or satisfiability.
    14
    15The single `derive_certified_encoding` command generates `formulaRaw`, its
    16complete constructor equations `formulaRaw.Laws`, and their checked witness
    17`formulaRaw.certified`. Atoms retain their natural indices; negation and
    18conjunction retain their constructor names and recursively encoded children.
    19
    20For the sample formula p0¬p1p_0 \land \neg p_1, the structural description is
    21`conj(atom(0), neg(atom(1)))`, expressed using the fixed `Raw.constructor`
    22vocabulary. `sampleInput` then gives its distinguished word-arena input:
    23the root address followed by the three-word blocks for the structural nodes.
    24The same two-stage construction applies to other supported finite datatypes.
    25-/
    26
    27namespace Lax58.FormulaExample
    28
    29open Lax58.StructuralPresentation Lax58.WordArena
    30
    31/-- Propositional syntax with natural-number atom names. -/
    32inductive 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. -/
    38derive_certified_encoding formulaRaw indexed : Formula
    39
    40/-- The formula p0¬p1p_0 \land \neg p_1. -/
    41def sample : Formula := .conj (.atom 0) (.neg (.atom 1))
    42
    43/-- Constructor structure, before choosing a word-memory layout. -/
    44def sampleStructure : Raw := formulaRaw sample
    45
    46/-- Exact input words, including the root address and no additional data. -/
    47def sampleInput : List Nat := (encodeRaw sampleStructure).toInput
    48
    49end Lax58.FormulaExample
    50

    Used by

    none

    From Mathlib

    none

    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

    Loading discussion…