Repository navigation
Metalogic
As of v1.0.0
This section presents the mechanized Lean 4 formalization (lean/, pinned at leanprover/lean4:v4.36.0) for a facts-only declaration-line fragment of Typify v1, together with the page-to-proof verification gate (scripts/metalogic-check.py).
- Formality — equivalence of the declarative line-denotation judgment and the executable recognizer, uniqueness of emitted fact terms, and decidable line acceptance.
- Conservative language extension — preservation of every accepted program's ordered fact terms under a fresh, verb-disjoint Typify declaration extension, together with a strict extension witness.
- Ontology representation — exact round-trip decoding and second-order satisfaction preservation and reflection for ground unary class assertions and directed binary relation assertions across every nonempty domain and interpretation, together with an asymmetric relation model.
The Lean model operates directly on raw source lines (SourceLine := String) and ordered lists of raw source lines (SourceProgram := List SourceLine), rather than pre-tokenized syntax trees:
-
Characters and line classification (
src/syntax.rkt:blank?,trim,classify; see Language): a legal fragment line uses printable ASCII code points (0x20..0x7E) and horizontal tabs (0x09), with no carriage returns (\r), embedded newlines (\n), or other control characters (isLegalChar). Leading and trailing spaces and tabs are stripped (trimChars). Blank lines and#-prefixed lines (isBlankOrCommentLine) emit no term; reserved?-prefixed question lines (isQuestionChars; see Questions) are outside the modeled facts-only fragment; every other legal line is a content line (FragmentLine) and is split at its first:into a trimmed non-empty verb and a trimmed right-hand side (splitColonLineandHasColonShape). -
Object-language declarations as Typify declaration data (
DeclandDeclData := List MetaLine, corresponding todeclare-class,declare-constructor,declare-form, anddeclare-meaninginsrc/meta.rkt, and the checks insrc/language.rktandsrc/classes.rkt; see Classes and Terms and counts):-
is : <name> = "<lit_1>" | ... | "<lit_k>"(MetaLine.isClass): unreserved identifier<name>(isNameToken, excluding reserved meta, built-in class, and library names) over a non-empty duplicate-free finite list of outer-trimmed non-comment printable ASCII tokens free of horizontal tabs,", and\(isLegalToken); -
term : <ctor> : <c_1>andterm : <ctor> : <c_1> <c_2>(MetaLine.termUnary,MetaLine.termBinary): first-order fact constructors of arity 1 or 2 over declared classes; -
form : <verb> : <<slot>>withdoes : <ctor> <<slot>>(unary) andform : <verb> : <<slot_1>><sep><<slot_2>>withdoes : <ctor> <<d_1>> <<d_2>>(binary): distinct verb-headed forms (noDupKeys FormDecl.verb, preventingE_FORM_SHADOW), distinct placeholder names (slot_1 != slot_2) naming declared classes, capture-onlydoesmatching the declared constructor parameter classes (E_TERM_CLASS), printable ASCII non-empty separator<sep>free of horizontal tabs,<, and>(isLegalSeparator), and the syntactic delimiter-unambiguity conditionnoEarlySepMatchrequiring that for every literaluof<slot_1>'s class,<sep>does not match insideu ++ sepprior to|u|(E_CLASS_OVERLAPinsrc/classes.rkt:class-delimiter-witness).
-
-
Observation scope: declaration well-formedness (
compileMeta/WellFormedDecl), line and program acceptance (recognizeLine,readProgram), and the exact ordered list of emittedFactTermrecords. Concrete declarations (witnessBaseDeclandwitnessExtDecl/ontologyDecl) are included directly in the statements so no universal claim is vacuous.
Every law page displays a single complete many-sorted second-order formula mechanically reflected from the kernel Expr of its designated Lean Prop definition.
| Displayed sort | Qualified Lean type | Quantifier domain |
|---|---|---|
TypifyMetalogic.Decl |
Compiled object-language declarations (classes, terms, forms) |
|
TypifyMetalogic.DeclData |
Finite sequences of Typify meta-language clauses (List MetaLine) |
|
TypifyMetalogic.SourceLine |
Raw source lines (String) |
|
TypifyMetalogic.SourceProgram |
Ordered lists of raw source lines (List SourceLine) |
|
TypifyMetalogic.FactTerm |
Ground first-order emitted fact terms (ctor and args) |
|
TypifyMetalogic.TermList |
Ordered lists of emitted fact terms (List FactTerm) |
|
TypifyMetalogic.IndName |
Individual constant names (String) |
|
TypifyMetalogic.AssertionList |
Finite lists of ground unary and directed binary assertions (List Assertion) |
|
Type (Sort 1) |
Arbitrary carrier types |
|
TypifyMetalogic.IndName -> D |
Interpretations |
|
D -> Prop |
Second-order unary predicates |
|
D -> D -> Prop |
Second-order directed binary relations |
No project-specific axiom or opaque declarations exist anywhere in lean/. Every proved law depends exclusively on Lean's standard foundational axioms (propext, Classical.choice, Quot.sound).
| Symbol / Entry | Kind | Qualified Lean declaration & argument order | Meaning |
|---|---|---|---|
| Primitive definition |
TypifyMetalogic.witnessBaseDecl (0-ary) |
Concrete base declaration (person, peer, unary member) |
|
| Primitive definition |
TypifyMetalogic.ontologyDecl (0-ary) |
Concrete ontology dialect extending knows (=) |
|
| Primitive definition |
TypifyMetalogic.witnessKnowsTerm (0-ary) |
Ground fact term ["knows", "ada", "ben"]
|
|
| Primitive definitions |
TypifyMetalogic.nameAda, TypifyMetalogic.nameBen (0-ary) |
Admissible individual names "ada" and "ben"
|
|
| Primitive definition | TypifyMetalogic.WellFormedDecl d |
Checkable syntactic well-formedness of declaration |
|
| Primitive definition | TypifyMetalogic.FragmentLine l |
Legal non-blank, non-comment raw source line |
|
| Primitive definition | TypifyMetalogic.recognizeLine d l |
Deterministic executable line recognizer returning Option FactTerm
|
|
| Primitive definition | TypifyMetalogic.DerivesLine d l t |
Inductive line-denotation judgment built from colon shape, form capture, class membership, and constructor typing | |
| Primitive definition | TypifyMetalogic.AcceptsLine d l |
Executable boolean line-acceptance predicate | |
| Primitive definition | TypifyMetalogic.compileMeta m |
Compiles Typify meta-language clause list Option Decl
|
|
| Primitive definition | TypifyMetalogic.appendDeclData m1 m2 |
Concatenates base declaration clauses |
|
| Primitive definition | TypifyMetalogic.FreshExtension m1 m2 |
Checkable freshness of extension classes, constructors, and form verbs | |
| Primitive definition | TypifyMetalogic.readProgram d p |
Evaluates program Option TermList
|
|
| Primitive definition | TypifyMetalogic.AdmissibleAssertions A |
Every individual name in assertion list |
|
| Primitive definition | TypifyMetalogic.encodeAssertions A |
Encodes assertion list member : x, knows : x = y) |
|
| Primitive definition | TypifyMetalogic.decodeTerms T |
Partial inverse decoding emitted fact terms Option AssertionList
|
|
| Primitive definition | TypifyMetalogic.singleBinary x y |
Singleton assertion list [Assertion.binary x y]
|
|
| Primitive definition | TypifyMetalogic.SatisfiesSource D val P R A |
Independent model-theoretic satisfaction of source assertions |
|
| Primitive definition | TypifyMetalogic.SatisfiesOutput D val P R O |
Independent model-theoretic satisfaction of reader output |
|
| External assumptions | Assumption inventory | (none) | Zero unchecked axiom or opaque declarations |
formality_law |
Proved law | TypifyMetalogic.formality_law : TypifyMetalogic.FormalityLaw |
Inhabits FormalityLaw
|
extension_law |
Proved law | TypifyMetalogic.extension_law : TypifyMetalogic.ExtensionLaw |
Inhabits ExtensionLaw
|
ontology_law |
Proved law | TypifyMetalogic.ontology_law : TypifyMetalogic.OntologyLaw |
Inhabits OntologyLaw
|
-
$\mathsf{WFDecl}(d)$ requires duplicate-free class, constructor, and form-verb tables, non-empty legal literal sets, declared parameter classes, distinct binary placeholder names, andnoEarlySepMatchseparator non-overlap (E_CLASS_OVERLAPandE_FORM_SHADOWfail closed when violated). -
$\mathsf{FragLine}(\ell)$ restricts single-lineFormalityclaims to legal facts-only content lines (blank and#-comment lines are handled at the program level by$\mathsf{readProg}$ , and?-prefixed question lines are outside the modeled fragment). -
$\mathsf{compileMeta}(\mathit{base}) = \mathsf{some}(d_{\mathsf{base}})$ ,$\mathsf{compileMeta}(\mathsf{extend}(\mathit{base}, \mathit{ext})) = \mathsf{some}(d_{\mathsf{ext}})$ , and$\mathsf{FreshExt}(\mathit{base}, \mathit{ext})$ require both the base declaration data and the extended declaration data to compile cleanly while keeping old classes, constructors, and form verbs disjoint from the extension's additions, with no new program-level count obligations. -
$\mathsf{Nonempty}(D)$ and$\mathsf{Admissible}(A)$ restrict ontology satisfaction equivalence to nonempty interpretation domains and assertion lists over the dialect's declared individual vocabulary ({"ada", "ben"}; out-of-vocabulary lines such asmember : unknownare rejected withE_CLASS).
With Racket 9.3 CS and Lean v4.36.0 on PATH:
cd lean && lake build
cd ..
python3 -B scripts/metalogic-check.py --mode ci --repo-dir .To verify the full page-to-proof correspondence and link inventory against a checkout of this wiki:
python3 -B scripts/metalogic-check.py --mode full --repo-dir . --wiki-dir ../typify-wikiIn CI, the release-blocking job Lean / zero sorry runs scripts/metalogic-check.py --mode ci on pull requests, on main, and on the packaged release candidate before tag attestation.
A passing run establishes:
-
Inventory bijection: the three frozen v1 law identifiers match the four
Metalogicwiki pages (N + 1) and the six tracked.leanfiles (2N), with no orphan files, reused paths, or unindexed section pages. -
Kernel-checked proofs without placeholders: every tracked
.leanfile compiles underleanprover/lean4:v4.36.0with zero comments, zerosorry/admittokens (including unused helpers), zero user axioms, and no transitive kernel dependencies outsidepropext,Classical.choice, andQuot.sound; each proof module directly imports its paired statement module and proves that exact namedProp. -
Mechanical formula correspondence: each law page's
$$ ... $$display-math formula equals the canonical TeX mechanically reflected from the elaborated LeanPropover the symbol table above, and itsStatementandProoflinks resolve to the exact verified source commit. -
Finite cross-reader conformance: all positive and negative declaration and program fixtures in
test/metalogic-conformance.jsonproduce identical verdicts and ordered fact terms in both the Lean executable model and the Typify reader.
Passing does not establish a formal verification of the Racket reader implementation beyond the finite conformance suite, ontology entailment or OWL compatibility, unrestricted reflection outside the admissible ground vocabulary, or tautologicity under arbitrary reinterpretations of the Typify-specific definitions.