unicode_fol_kit.semantics.matrix¶
Finite-valued logical matrices: a generalisation of the K3 / LP three-valued layer.
A logical matrix is a finite set of truth values, a distinguished subset of
designated values (those that count as assertible), and a truth table for each
connective. Validity is “designated under every assignment”, satisfiability is
“designated under some assignment”, and Γ ⊨ φ is “every assignment that designates
all of Γ designates φ”. This module makes that schema first-class so any finite
many-valued logic — not just the hard-wired {0, ½, 1} of
unicode_fol_kit.semantics.manyvalued — can be evaluated and decided.
Three matrices ship built in:
K3_MATRIX— Kleene’s strong three-valued logic (designate{1});LP_MATRIX— Priest’s Logic of Paradox (designate{½, 1});FDE_MATRIX— the Belnap–Dunn four-valued logic FDE (first-degree entailment), valuesT/F/N(neither)/B(both), designate the true-containing values{T, B}. FDE is both paraconsistent (p ∧ ¬p ⊭ q) and paracomplete (p ⊭ q ∨ ¬q), and — unlike K3/LP — has no logical truths at all (evenp → pfails, taking valueNatN).
K3 and LP are re-expressed here as matrices, so this layer reproduces the existing
three-valued decisions exactly (cross-checked in the tests). Build your own with
TruthMatrix.from_functions().
Public API: TruthMatrix, matrix_value(), matrix_is_valid(),
matrix_is_satisfiable(), matrix_entails(), and the matrices
K3_MATRIX, LP_MATRIX, FDE_MATRIX. MATRICES maps the
names "K3" / "LP" / "FDE" to them.
Functions
|
True iff every assignment designating all |
|
True iff |
|
True iff |
|
Evaluate |
Classes
|
A finite logical matrix: values, designated values, and connective tables. |
- class unicode_fol_kit.semantics.matrix.TruthMatrix(name, values, designated, neg, conj, disj, impl, iff, xor)[source]¶
Bases:
objectA finite logical matrix: values, designated values, and connective tables.
The connective tables are plain dicts (
neg[v],conj[(a, b)], …) so a matrix is fully data-driven; build one directly, or — more conveniently — withfrom_functions()from value-level operations.∀/∃are read as the iteratedconj/disjover a finite domain (a generalised min / max), so the matrix needs no separate quantifier tables.- Parameters:
name (str)
- static from_functions(name, values, designated, neg, conj, disj, impl=None)[source]¶
Materialise a matrix from value-level operations.
impldefaults to the material conditional¬a ∨ b; the biconditional is(a→b) ∧ (b→a)and exclusive-or is¬(a↔b). Every operation is checked to land back invalues(a closed matrix), and every designated value to be a value, so a malformed table is caught at build time.
- unicode_fol_kit.semantics.matrix.matrix_value(formula, valuation, matrix, domain=None)[source]¶
Evaluate
formulato a matrix value undervaluation.valuationmaps each ground atom’sto_unicode_str()key to a value ofmatrix. Quantifiers foldconj(∀) /disj(∃) overdomain(a set of constant names), generalising min/max. A missing atom key raisesKeyError; a value outside the matrix raisesValueError; a modal/fuzzy/sorted/lambda node is rejected with the same messagekleene_value()uses.
- unicode_fol_kit.semantics.matrix.matrix_is_valid(formula, matrix, domain=None)[source]¶
True iff
formulais designated under every assignment overmatrix.Enumerates
len(matrix.values) ** nassignments of thendistinct ground atoms (after grounding quantifiers overdomain). Exponential inn; capped atmanyvalued.MAX_MODELS.- Parameters:
formula (Node)
matrix (TruthMatrix)
- Return type:
- unicode_fol_kit.semantics.matrix.matrix_is_satisfiable(formula, matrix, domain=None)[source]¶
True iff
formulais designated under some assignment overmatrix.- Parameters:
formula (Node)
matrix (TruthMatrix)
- Return type:
- unicode_fol_kit.semantics.matrix.matrix_entails(premises, conclusion, matrix, domain=None)[source]¶
True iff every assignment designating all
premisesdesignatesconclusion.Matrix consequence:
Γ ⊨ φholds when no assignment overmatrixmakes every premise designated yet the conclusion undesignated.