sublation 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sublation-0.3.0/src/sublation.egg-info → sublation-0.4.0}/PKG-INFO +14 -14
- {sublation-0.3.0 → sublation-0.4.0}/README.md +13 -13
- {sublation-0.3.0 → sublation-0.4.0}/pyproject.toml +1 -1
- {sublation-0.3.0 → sublation-0.4.0}/src/sublation/__init__.py +7 -1
- sublation-0.4.0/src/sublation/core.py +161 -0
- sublation-0.4.0/src/sublation/operators.py +95 -0
- sublation-0.4.0/src/sublation/truths.py +168 -0
- {sublation-0.3.0 → sublation-0.4.0/src/sublation.egg-info}/PKG-INFO +14 -14
- {sublation-0.3.0 → sublation-0.4.0}/src/sublation.egg-info/SOURCES.txt +1 -0
- {sublation-0.3.0 → sublation-0.4.0}/tests/test_core.py +31 -0
- {sublation-0.3.0 → sublation-0.4.0}/tests/test_properties.py +0 -7
- {sublation-0.3.0 → sublation-0.4.0}/tests/test_truths.py +57 -0
- {sublation-0.3.0 → sublation-0.4.0}/tests/test_validation.py +0 -27
- sublation-0.3.0/src/sublation/core.py +0 -100
- sublation-0.3.0/src/sublation/truths.py +0 -129
- {sublation-0.3.0 → sublation-0.4.0}/LICENSE +0 -0
- {sublation-0.3.0 → sublation-0.4.0}/MANIFEST.in +0 -0
- {sublation-0.3.0 → sublation-0.4.0}/setup.cfg +0 -0
- {sublation-0.3.0 → sublation-0.4.0}/src/sublation/py.typed +0 -0
- {sublation-0.3.0 → sublation-0.4.0}/src/sublation.egg-info/dependency_links.txt +0 -0
- {sublation-0.3.0 → sublation-0.4.0}/src/sublation.egg-info/requires.txt +0 -0
- {sublation-0.3.0 → sublation-0.4.0}/src/sublation.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sublation
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Non-boolean truth structures for dialectical reasoning, an alternative to boolean binarism, inspired by Hegelian logic.
|
|
5
5
|
Author-email: Germano Castanho <germanocastanho@proton.me>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,7 +24,10 @@ Dynamic: license-file
|
|
|
24
24
|
|
|
25
25
|
# 🧠 Sublation
|
|
26
26
|
|
|
27
|
-
Inspired by Hegel's dialectical logic, this library formalizes dialectical logic as a
|
|
27
|
+
Inspired by Hegel's dialectical logic, this library formalizes dialectical logic as a
|
|
28
|
+
case of four-valued reasoning (true / false / contradictory / indeterminate), grounded
|
|
29
|
+
in Belnap–Dunn logic (FDE) and the bilattice structure behind paraconsistent annotated
|
|
30
|
+
logics such as Eτ.
|
|
28
31
|
|
|
29
32
|
# ✨ Main Features
|
|
30
33
|
|
|
@@ -36,7 +39,7 @@ Inspired by Hegel's dialectical logic, this library formalizes dialectical logic
|
|
|
36
39
|
# ✅ Prerequisites
|
|
37
40
|
|
|
38
41
|
- Python 3.12+ installed on your machine
|
|
39
|
-
-
|
|
42
|
+
- No runtime dependencies; dev extras declared in `pyproject.toml`
|
|
40
43
|
|
|
41
44
|
# ⚙️ Local Installation
|
|
42
45
|
|
|
@@ -51,9 +54,6 @@ cd sublation-lib/
|
|
|
51
54
|
python3 -m venv .venv
|
|
52
55
|
source .venv/bin/activate
|
|
53
56
|
|
|
54
|
-
# Install dependencies
|
|
55
|
-
pip install -r requirements.txt
|
|
56
|
-
|
|
57
57
|
# Install sublation package
|
|
58
58
|
pip install -e .
|
|
59
59
|
```
|
|
@@ -71,10 +71,7 @@ cd sublation-lib/
|
|
|
71
71
|
python3 -m venv .venv
|
|
72
72
|
source .venv/bin/activate
|
|
73
73
|
|
|
74
|
-
# Install
|
|
75
|
-
pip install -r requirements.txt
|
|
76
|
-
|
|
77
|
-
# Install sublation package
|
|
74
|
+
# Install sublation package with dev extras
|
|
78
75
|
pip install -e ".[dev]"
|
|
79
76
|
|
|
80
77
|
# Run full test suite
|
|
@@ -90,9 +87,9 @@ t = Thesis(True)
|
|
|
90
87
|
a = Antithesis(True)
|
|
91
88
|
s = Synthesis(t, a)
|
|
92
89
|
|
|
93
|
-
s.contradiction()
|
|
94
|
-
s.becoming()
|
|
95
|
-
s.sublation()
|
|
90
|
+
s.contradiction() # True — the tension is real and detectable
|
|
91
|
+
s.becoming() # False — this is not a quiet resolution
|
|
92
|
+
s.sublation() # True — it doesn't collapse into falsehood
|
|
96
93
|
|
|
97
94
|
# The next round
|
|
98
95
|
t2 = s.as_thesis()
|
|
@@ -100,4 +97,7 @@ t2 = s.as_thesis()
|
|
|
100
97
|
|
|
101
98
|
# 📜 Libre Software
|
|
102
99
|
|
|
103
|
-
If you have ideas for improvements or new features, please open an issue or submit a
|
|
100
|
+
If you have ideas for improvements or new features, please open an issue or submit a
|
|
101
|
+
pull request. Make sure to follow the existing code style and include tests for any new
|
|
102
|
+
functionality. Licensed under the MIT License, so you are free to use, modify, and
|
|
103
|
+
distribute this software. Please refer to the [LICENSE](LICENSE) for more!
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# 🧠 Sublation
|
|
2
2
|
|
|
3
|
-
Inspired by Hegel's dialectical logic, this library formalizes dialectical logic as a
|
|
3
|
+
Inspired by Hegel's dialectical logic, this library formalizes dialectical logic as a
|
|
4
|
+
case of four-valued reasoning (true / false / contradictory / indeterminate), grounded
|
|
5
|
+
in Belnap–Dunn logic (FDE) and the bilattice structure behind paraconsistent annotated
|
|
6
|
+
logics such as Eτ.
|
|
4
7
|
|
|
5
8
|
# ✨ Main Features
|
|
6
9
|
|
|
@@ -12,7 +15,7 @@ Inspired by Hegel's dialectical logic, this library formalizes dialectical logic
|
|
|
12
15
|
# ✅ Prerequisites
|
|
13
16
|
|
|
14
17
|
- Python 3.12+ installed on your machine
|
|
15
|
-
-
|
|
18
|
+
- No runtime dependencies; dev extras declared in `pyproject.toml`
|
|
16
19
|
|
|
17
20
|
# ⚙️ Local Installation
|
|
18
21
|
|
|
@@ -27,9 +30,6 @@ cd sublation-lib/
|
|
|
27
30
|
python3 -m venv .venv
|
|
28
31
|
source .venv/bin/activate
|
|
29
32
|
|
|
30
|
-
# Install dependencies
|
|
31
|
-
pip install -r requirements.txt
|
|
32
|
-
|
|
33
33
|
# Install sublation package
|
|
34
34
|
pip install -e .
|
|
35
35
|
```
|
|
@@ -47,10 +47,7 @@ cd sublation-lib/
|
|
|
47
47
|
python3 -m venv .venv
|
|
48
48
|
source .venv/bin/activate
|
|
49
49
|
|
|
50
|
-
# Install
|
|
51
|
-
pip install -r requirements.txt
|
|
52
|
-
|
|
53
|
-
# Install sublation package
|
|
50
|
+
# Install sublation package with dev extras
|
|
54
51
|
pip install -e ".[dev]"
|
|
55
52
|
|
|
56
53
|
# Run full test suite
|
|
@@ -66,9 +63,9 @@ t = Thesis(True)
|
|
|
66
63
|
a = Antithesis(True)
|
|
67
64
|
s = Synthesis(t, a)
|
|
68
65
|
|
|
69
|
-
s.contradiction()
|
|
70
|
-
s.becoming()
|
|
71
|
-
s.sublation()
|
|
66
|
+
s.contradiction() # True — the tension is real and detectable
|
|
67
|
+
s.becoming() # False — this is not a quiet resolution
|
|
68
|
+
s.sublation() # True — it doesn't collapse into falsehood
|
|
72
69
|
|
|
73
70
|
# The next round
|
|
74
71
|
t2 = s.as_thesis()
|
|
@@ -76,4 +73,7 @@ t2 = s.as_thesis()
|
|
|
76
73
|
|
|
77
74
|
# 📜 Libre Software
|
|
78
75
|
|
|
79
|
-
If you have ideas for improvements or new features, please open an issue or submit a
|
|
76
|
+
If you have ideas for improvements or new features, please open an issue or submit a
|
|
77
|
+
pull request. Make sure to follow the existing code style and include tests for any new
|
|
78
|
+
functionality. Licensed under the MIT License, so you are free to use, modify, and
|
|
79
|
+
distribute this software. Please refer to the [LICENSE](LICENSE) for more!
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sublation"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Non-boolean truth structures for dialectical reasoning, an alternative to boolean binarism, inspired by Hegelian logic."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyleft 2026, Germano Castanho
|
|
3
|
+
Licensed under the MIT License
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from . import operators # noqa: F401
|
|
1
7
|
from .core import Antithesis, Synthesis, Thesis
|
|
2
8
|
from .truths import TruthValue
|
|
3
9
|
|
|
4
10
|
__all__ = ["Antithesis", "Synthesis", "Thesis", "TruthValue"]
|
|
5
|
-
__version__ = "0.
|
|
11
|
+
__version__ = "0.4.0"
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyleft 2026, Germano Castanho
|
|
3
|
+
Licensed under the MIT License
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .truths import THRESHOLD, TruthValue
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Dialectical:
|
|
10
|
+
"""
|
|
11
|
+
Shared behavior for Thesis, Antithesis, and Synthesis. Each subclass only
|
|
12
|
+
builds self.value, self.thesis, and self.antithesis in its own __init__;
|
|
13
|
+
the four inherited methods read those fields identically regardless of
|
|
14
|
+
which subclass produced the instance.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
value: TruthValue
|
|
18
|
+
thesis: bool
|
|
19
|
+
antithesis: bool
|
|
20
|
+
|
|
21
|
+
def negation(self, threshold: float = THRESHOLD) -> bool:
|
|
22
|
+
"""
|
|
23
|
+
Whether the negation of this value holds cleanly true — inverts mu and
|
|
24
|
+
lam and checks the result. Equivalent to asking whether the original is
|
|
25
|
+
false; at contradictory and indeterminate corners it is a fixed point.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
negation = self.value.invert().is_true(threshold=threshold)
|
|
29
|
+
return negation
|
|
30
|
+
|
|
31
|
+
def contradiction(self, threshold: float = THRESHOLD) -> bool:
|
|
32
|
+
"""
|
|
33
|
+
Whether evidence for and against are both strong at once. A plain bool
|
|
34
|
+
can never represent this state — it forces True or False — but
|
|
35
|
+
TruthValue can: both degrees crossing the threshold is contradiction,
|
|
36
|
+
the state that motivates the whole library and the one a dialectical
|
|
37
|
+
round must be able to name without collapsing.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
contradiction = self.value.is_contradictory(threshold=threshold)
|
|
41
|
+
return contradiction
|
|
42
|
+
|
|
43
|
+
def becoming(self, threshold: float = THRESHOLD) -> bool:
|
|
44
|
+
"""
|
|
45
|
+
Whether this value is a clean, uncontested affirmation — evidence FOR
|
|
46
|
+
has crossed the threshold and evidence AGAINST has not. A plain bool
|
|
47
|
+
can represent this, and so can TruthValue; the method exists as a
|
|
48
|
+
convenience for the simplest case, the one classical logic mistakes
|
|
49
|
+
for the only case.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
becoming = self.value.is_true(threshold=threshold)
|
|
53
|
+
return becoming
|
|
54
|
+
|
|
55
|
+
def sublation(self, threshold: float = THRESHOLD) -> bool:
|
|
56
|
+
"""
|
|
57
|
+
Whether this value has been determined at all, either way — Hegelian
|
|
58
|
+
Aufhebung: the TruthValue has crossed the threshold in either
|
|
59
|
+
direction, so it is no longer indeterminate and has been sublated.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
sublation = not self.value.is_indeterminate(threshold=threshold)
|
|
63
|
+
return sublation
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class Thesis(Dialectical):
|
|
67
|
+
"""
|
|
68
|
+
A proposition asserted as posited. A bool thesis infers its classical
|
|
69
|
+
complement; a continuous degree infers nothing. Either inference can be
|
|
70
|
+
overridden by passing antithesis explicitly.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
thesis: bool | float = True,
|
|
76
|
+
antithesis: bool | float | None = None,
|
|
77
|
+
) -> None:
|
|
78
|
+
"""Builds a thesis from a proposition and its negation degree. A bool
|
|
79
|
+
infers the classical complement (lam becomes 1.0 when thesis is False,
|
|
80
|
+
0.0 when True). A float infers nothing — it asserts only what it
|
|
81
|
+
states and leaves lam at 0.0 unless overridden. Passing antithesis
|
|
82
|
+
explicitly breaks the inference, reaching the non-classical corners.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
if antithesis is None:
|
|
86
|
+
antithesis = (not thesis) if isinstance(thesis, bool) else 0.0
|
|
87
|
+
|
|
88
|
+
self.value = TruthValue(mu=float(thesis), lam=float(antithesis))
|
|
89
|
+
self.thesis = self.value.mu >= THRESHOLD
|
|
90
|
+
self.antithesis = self.value.lam >= THRESHOLD
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class Antithesis(Dialectical):
|
|
94
|
+
"""
|
|
95
|
+
A proposition asserted as the negation of a thesis. A bool antithesis
|
|
96
|
+
infers its classical complement; a continuous degree infers nothing.
|
|
97
|
+
Either inference can be overridden by passing thesis explicitly.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def __init__(
|
|
101
|
+
self,
|
|
102
|
+
antithesis: bool | float = False,
|
|
103
|
+
thesis: bool | float | None = None,
|
|
104
|
+
) -> None:
|
|
105
|
+
"""Builds an antithesis from a negated proposition and its affirmation
|
|
106
|
+
degree. Mirrors Thesis in the opposite direction: a bool infers its
|
|
107
|
+
classical complement on the thesis side; a float infers nothing,
|
|
108
|
+
leaving mu at 0.0 unless overridden. Passing thesis explicitly breaks
|
|
109
|
+
the inference.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
if thesis is None:
|
|
113
|
+
thesis = (not antithesis) if isinstance(antithesis, bool) else 0.0
|
|
114
|
+
|
|
115
|
+
self.value = TruthValue(mu=float(thesis), lam=float(antithesis))
|
|
116
|
+
self.thesis = self.value.mu >= THRESHOLD
|
|
117
|
+
self.antithesis = self.value.lam >= THRESHOLD
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class Synthesis(Dialectical):
|
|
121
|
+
"""
|
|
122
|
+
Combines a Thesis and an Antithesis, trusting the thesis only on its own
|
|
123
|
+
claim (mu) and the antithesis only on its own claim (lam), rather than
|
|
124
|
+
pooling everything either side carries.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
def __init__(self, thesis: Thesis, antithesis: Antithesis) -> None:
|
|
128
|
+
"""
|
|
129
|
+
Combines a thesis and an antithesis, taking mu from the thesis and
|
|
130
|
+
lam from the antithesis, discarding each side's other degree. Each
|
|
131
|
+
side is trusted only about its own claim — the inferred complement is
|
|
132
|
+
invisible here. Pooling both sides with `accumulate` would manufacture
|
|
133
|
+
spurious contradiction; projection stays the rule.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
self.value = TruthValue(mu=thesis.value.mu, lam=antithesis.value.lam)
|
|
137
|
+
|
|
138
|
+
self.thesis = self.value.mu >= THRESHOLD
|
|
139
|
+
self.antithesis = self.value.lam >= THRESHOLD
|
|
140
|
+
self.synthesis = self.sublation()
|
|
141
|
+
|
|
142
|
+
def as_thesis(self) -> Thesis:
|
|
143
|
+
"""
|
|
144
|
+
Re-posits this synthesis as the thesis of the next round. Both degrees
|
|
145
|
+
are passed explicitly, so the new thesis carries the exact mu/lam
|
|
146
|
+
rather than a thresholded bool — intermediate certainty survives the
|
|
147
|
+
chaining into a fresh antithesis.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
next_round = Thesis(thesis=self.value.mu, antithesis=self.value.lam)
|
|
151
|
+
return next_round
|
|
152
|
+
|
|
153
|
+
@classmethod
|
|
154
|
+
def from_values(cls, mu: float, lam: float) -> "Synthesis":
|
|
155
|
+
"""
|
|
156
|
+
Builds a Synthesis directly from evidence degrees, without fabricating
|
|
157
|
+
disposable Thesis/Antithesis instances. Equivalent to
|
|
158
|
+
Synthesis(Thesis(mu), Antithesis(lam)).
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
return cls(Thesis(mu), Antithesis(lam))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyleft 2026, Germano Castanho
|
|
3
|
+
Licensed under the MIT License
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .truths import TruthValue
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def conjunction(self, other: "TruthValue") -> "TruthValue":
|
|
10
|
+
"""
|
|
11
|
+
Combines two values as logical AND: only as favorably evidenced as the
|
|
12
|
+
weaker half (min mu), and only as free of doubt as the most doubted half
|
|
13
|
+
(max lam). Supported as far as the weakest conjunct is supported; reduces
|
|
14
|
+
to classical conjunction on the classical corners.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
return TruthValue(
|
|
18
|
+
min(self.mu, other.mu),
|
|
19
|
+
max(self.lam, other.lam),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def disjunction(self, other: "TruthValue") -> "TruthValue":
|
|
24
|
+
"""
|
|
25
|
+
The mirror of conjunction: OR takes the stronger mu and the milder lam,
|
|
26
|
+
since a disjunction only needs one side to hold up. Evidence for the
|
|
27
|
+
disjunction is as strong as its best-supported disjunct, and evidence
|
|
28
|
+
against it only as strong as the weakest objection to either side.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
return TruthValue(
|
|
32
|
+
max(self.mu, other.mu),
|
|
33
|
+
min(self.lam, other.lam),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def implication(self, other: "TruthValue") -> "TruthValue":
|
|
38
|
+
"""
|
|
39
|
+
Material implication in FDE: ¬A ∨ B, computed as disjunction(self.invert(), other).
|
|
40
|
+
Unlike classical implication this is not a truth-function of a single
|
|
41
|
+
degree; it inverts the antecedent and disjoins it with the consequent, so
|
|
42
|
+
the resulting mu reflects both how strongly A fails and how strongly B
|
|
43
|
+
holds. Reflexive implication need not yield the true corner.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
return self.invert().disjunction(other)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def equivalence(self, other: "TruthValue") -> "TruthValue":
|
|
50
|
+
"""
|
|
51
|
+
Logical equivalence in FDE: (A → B) ∧ (B → A), the conjunction of both
|
|
52
|
+
material implications. Symmetric by construction, and reflexive equivalence
|
|
53
|
+
need not collapse to the true corner — two identical non-classical values
|
|
54
|
+
remain exactly as they are.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
return self.implication(other).conjunction(other.implication(self))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def consensus(self, other: "TruthValue") -> "TruthValue":
|
|
61
|
+
"""
|
|
62
|
+
Keeps only the evidence both operands agree on (min mu, min lam) — a
|
|
63
|
+
skeptical combination where anything one side claims but the other does
|
|
64
|
+
not corroborate gets dropped. It is the meet of the knowledge order:
|
|
65
|
+
demanding joint warrant from a claim and its denial leaves nothing
|
|
66
|
+
standing, which is the point, not a defect.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
return TruthValue(
|
|
70
|
+
min(self.mu, other.mu),
|
|
71
|
+
min(self.lam, other.lam),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def accumulate(self, other: "TruthValue") -> "TruthValue":
|
|
76
|
+
"""
|
|
77
|
+
Pools all evidence from both operands, FOR and AGAINST alike (max mu, max
|
|
78
|
+
lam), without discarding anything either side claims. Credulous
|
|
79
|
+
combination: pooling a strong case for with a strong case against yields a
|
|
80
|
+
contradictory value rather than resolving the conflict, which is Belnap's
|
|
81
|
+
gullibility and the substance of the knowledge order's join.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
return TruthValue(
|
|
85
|
+
max(self.mu, other.mu),
|
|
86
|
+
max(self.lam, other.lam),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
TruthValue.conjunction = conjunction
|
|
91
|
+
TruthValue.disjunction = disjunction
|
|
92
|
+
TruthValue.implication = implication
|
|
93
|
+
TruthValue.equivalence = equivalence
|
|
94
|
+
TruthValue.consensus = consensus
|
|
95
|
+
TruthValue.accumulate = accumulate
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyleft 2026, Germano Castanho
|
|
3
|
+
Licensed under the MIT License
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
THRESHOLD = 0.5
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TruthValue:
|
|
10
|
+
"""
|
|
11
|
+
Evidential state of a proposition as a pair of independent degrees: `mu`
|
|
12
|
+
(evidence for) and `lam` (evidence against), both in [0.0, 1.0]. The four
|
|
13
|
+
corners are true (1,0), false (0,1), contradictory (1,1), indeterminate
|
|
14
|
+
(0,0).
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, mu: float, lam: float) -> None:
|
|
18
|
+
"""
|
|
19
|
+
Builds a TruthValue from its two evidence degrees, both required to
|
|
20
|
+
fall within [0.0, 1.0]. Out-of-range input raises ValueError right
|
|
21
|
+
away, rather than producing a value that misbehaves later.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
if not (0 <= mu <= 1):
|
|
25
|
+
raise ValueError(f"mu must be within [0.0, 1.0], got {mu}")
|
|
26
|
+
|
|
27
|
+
if not (0 <= lam <= 1):
|
|
28
|
+
raise ValueError(f"lam must be within [0.0, 1.0], got {lam}")
|
|
29
|
+
|
|
30
|
+
self._mu = mu
|
|
31
|
+
self._lam = lam
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def mu(self) -> float:
|
|
35
|
+
"""
|
|
36
|
+
Degree of evidence in favor of the proposition, independent of lam.
|
|
37
|
+
This is the supporting side of the evidential pair. It is never derived
|
|
38
|
+
from lam, and changing one never touches the other; that independence is
|
|
39
|
+
what keeps contradiction and indeterminacy expressible. Read-only after
|
|
40
|
+
construction.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
return self._mu
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def lam(self) -> float:
|
|
47
|
+
"""
|
|
48
|
+
Degree of evidence against the proposition, independent of mu.
|
|
49
|
+
This is the opposing side of the evidential pair. It is never derived
|
|
50
|
+
from mu, and changing one never touches the other; that independence is
|
|
51
|
+
what keeps contradiction and indeterminacy expressible. Read-only after
|
|
52
|
+
construction.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
return self._lam
|
|
56
|
+
|
|
57
|
+
def invert(self) -> "TruthValue":
|
|
58
|
+
"""
|
|
59
|
+
Returns this value's negation by swapping the two kinds of evidence:
|
|
60
|
+
what argued FOR now argues AGAINST, and vice versa. Involutive by
|
|
61
|
+
construction, so inverting twice restores the original value, and it
|
|
62
|
+
leaves the knowledge-order operations (consensus, accumulate) untouched
|
|
63
|
+
while exchanging the truth-order connectives under De Morgan's laws.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
truth_value = TruthValue(self.lam, self.mu)
|
|
67
|
+
return truth_value
|
|
68
|
+
|
|
69
|
+
def to_bool(self) -> bool:
|
|
70
|
+
"""
|
|
71
|
+
Collapses this value to a plain bool by checking which evidence degree
|
|
72
|
+
is larger — a relative comparison (mu > lam), not the same question as
|
|
73
|
+
`is_true`. Always returns an answer, but discards exactly the
|
|
74
|
+
information the type exists to carry: thin, thick, or both ways.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
conversion = self.mu > self.lam
|
|
78
|
+
return conversion
|
|
79
|
+
|
|
80
|
+
def __eq__(self, other: object) -> bool:
|
|
81
|
+
"""
|
|
82
|
+
Equality of evidence: two values are equal when both degrees match.
|
|
83
|
+
Compares the full (mu, lam) pair rather than object identity, so two
|
|
84
|
+
separately constructed values carrying the same evidence compare equal.
|
|
85
|
+
Returns NotImplemented for non-TruthValue operands so Python falls
|
|
86
|
+
back to the other side's comparison.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
if not isinstance(other, TruthValue):
|
|
90
|
+
return NotImplemented
|
|
91
|
+
return (self.mu, self.lam) == (other.mu, other.lam)
|
|
92
|
+
|
|
93
|
+
def __repr__(self) -> str:
|
|
94
|
+
"""
|
|
95
|
+
A representation that shows both evidence degrees, useful for debugging
|
|
96
|
+
and logging. Renders as TruthValue(mu=..., lam=...), making the pair
|
|
97
|
+
visible at a glance without inspecting attributes individually.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
return f"TruthValue(mu={self.mu!r}, lam={self.lam!r})"
|
|
101
|
+
|
|
102
|
+
@classmethod
|
|
103
|
+
def from_bool(cls, value: bool) -> "TruthValue":
|
|
104
|
+
"""
|
|
105
|
+
Lifts a plain bool to a TruthValue on one of the two classical corners:
|
|
106
|
+
true -> (1.0, 0.0), false -> (0.0, 1.0). Total but not surjective —
|
|
107
|
+
contradictory and indeterminate have no classical preimage. Alias for
|
|
108
|
+
the module-level `truth_value_from_bool` helper.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
return truth_value_from_bool(value)
|
|
112
|
+
|
|
113
|
+
def is_true(self, threshold: float = THRESHOLD) -> bool:
|
|
114
|
+
"""
|
|
115
|
+
Reports whether this value sits in the "true" corner: evidence FOR has
|
|
116
|
+
crossed the threshold while evidence AGAINST has not. A value can be
|
|
117
|
+
neither true nor false (indeterminate) or both at once
|
|
118
|
+
(contradictory); this predicate answers only the true question.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
response = (self.mu >= threshold) and (self.lam < threshold)
|
|
122
|
+
return response
|
|
123
|
+
|
|
124
|
+
def is_false(self, threshold: float = THRESHOLD) -> bool:
|
|
125
|
+
"""
|
|
126
|
+
Reports whether this value sits in the "false" corner: evidence AGAINST
|
|
127
|
+
has crossed the threshold while evidence FOR has not. The mirror of
|
|
128
|
+
`is_true`, so a false reading means the proposition is opposed, not
|
|
129
|
+
merely unsupported (that would be indeterminate).
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
response = (self.lam >= threshold) and (self.mu < threshold)
|
|
133
|
+
return response
|
|
134
|
+
|
|
135
|
+
def is_contradictory(self, threshold: float = THRESHOLD) -> bool:
|
|
136
|
+
"""
|
|
137
|
+
Reports whether both evidence FOR and evidence AGAINST have crossed the
|
|
138
|
+
threshold at once. A plain bool can never represent this state — it
|
|
139
|
+
forces a choice — which is exactly why TruthValue exists: contradiction
|
|
140
|
+
is a legitimate, determinate evidential state, not an error.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
response = (self.mu >= threshold) and (self.lam >= threshold)
|
|
144
|
+
return response
|
|
145
|
+
|
|
146
|
+
def is_indeterminate(self, threshold: float = THRESHOLD) -> bool:
|
|
147
|
+
"""
|
|
148
|
+
Reports whether neither evidence FOR nor evidence AGAINST has crossed
|
|
149
|
+
the threshold — "we simply don't know yet". A plain bool forces every
|
|
150
|
+
proposition to a side, so it cannot express this state; TruthValue can,
|
|
151
|
+
and indeterminacy is as much a verdict as true or false.
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
response = (self.mu < threshold) and (self.lam < threshold)
|
|
155
|
+
return response
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def truth_value_from_bool(value: bool) -> TruthValue:
|
|
159
|
+
"""
|
|
160
|
+
Builds a TruthValue from a plain bool, landing on one of the two classical
|
|
161
|
+
corners. Convenience helper because the constructor requires two evidence
|
|
162
|
+
degrees while a bool carries only one. The lifted value infers the
|
|
163
|
+
classical complement: asserting true denies false, and vice versa, which is
|
|
164
|
+
exactly the structural commitment TruthValue exists to relax.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
conversion = TruthValue(1.0, 0.0) if value else TruthValue(0.0, 1.0)
|
|
168
|
+
return conversion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sublation
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Non-boolean truth structures for dialectical reasoning, an alternative to boolean binarism, inspired by Hegelian logic.
|
|
5
5
|
Author-email: Germano Castanho <germanocastanho@proton.me>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,7 +24,10 @@ Dynamic: license-file
|
|
|
24
24
|
|
|
25
25
|
# 🧠 Sublation
|
|
26
26
|
|
|
27
|
-
Inspired by Hegel's dialectical logic, this library formalizes dialectical logic as a
|
|
27
|
+
Inspired by Hegel's dialectical logic, this library formalizes dialectical logic as a
|
|
28
|
+
case of four-valued reasoning (true / false / contradictory / indeterminate), grounded
|
|
29
|
+
in Belnap–Dunn logic (FDE) and the bilattice structure behind paraconsistent annotated
|
|
30
|
+
logics such as Eτ.
|
|
28
31
|
|
|
29
32
|
# ✨ Main Features
|
|
30
33
|
|
|
@@ -36,7 +39,7 @@ Inspired by Hegel's dialectical logic, this library formalizes dialectical logic
|
|
|
36
39
|
# ✅ Prerequisites
|
|
37
40
|
|
|
38
41
|
- Python 3.12+ installed on your machine
|
|
39
|
-
-
|
|
42
|
+
- No runtime dependencies; dev extras declared in `pyproject.toml`
|
|
40
43
|
|
|
41
44
|
# ⚙️ Local Installation
|
|
42
45
|
|
|
@@ -51,9 +54,6 @@ cd sublation-lib/
|
|
|
51
54
|
python3 -m venv .venv
|
|
52
55
|
source .venv/bin/activate
|
|
53
56
|
|
|
54
|
-
# Install dependencies
|
|
55
|
-
pip install -r requirements.txt
|
|
56
|
-
|
|
57
57
|
# Install sublation package
|
|
58
58
|
pip install -e .
|
|
59
59
|
```
|
|
@@ -71,10 +71,7 @@ cd sublation-lib/
|
|
|
71
71
|
python3 -m venv .venv
|
|
72
72
|
source .venv/bin/activate
|
|
73
73
|
|
|
74
|
-
# Install
|
|
75
|
-
pip install -r requirements.txt
|
|
76
|
-
|
|
77
|
-
# Install sublation package
|
|
74
|
+
# Install sublation package with dev extras
|
|
78
75
|
pip install -e ".[dev]"
|
|
79
76
|
|
|
80
77
|
# Run full test suite
|
|
@@ -90,9 +87,9 @@ t = Thesis(True)
|
|
|
90
87
|
a = Antithesis(True)
|
|
91
88
|
s = Synthesis(t, a)
|
|
92
89
|
|
|
93
|
-
s.contradiction()
|
|
94
|
-
s.becoming()
|
|
95
|
-
s.sublation()
|
|
90
|
+
s.contradiction() # True — the tension is real and detectable
|
|
91
|
+
s.becoming() # False — this is not a quiet resolution
|
|
92
|
+
s.sublation() # True — it doesn't collapse into falsehood
|
|
96
93
|
|
|
97
94
|
# The next round
|
|
98
95
|
t2 = s.as_thesis()
|
|
@@ -100,4 +97,7 @@ t2 = s.as_thesis()
|
|
|
100
97
|
|
|
101
98
|
# 📜 Libre Software
|
|
102
99
|
|
|
103
|
-
If you have ideas for improvements or new features, please open an issue or submit a
|
|
100
|
+
If you have ideas for improvements or new features, please open an issue or submit a
|
|
101
|
+
pull request. Make sure to follow the existing code style and include tests for any new
|
|
102
|
+
functionality. Licensed under the MIT License, so you are free to use, modify, and
|
|
103
|
+
distribute this software. Please refer to the [LICENSE](LICENSE) for more!
|
|
@@ -62,3 +62,34 @@ def test_as_thesis_preserves_continuous_degrees():
|
|
|
62
62
|
s = Synthesis(Thesis(0.7), Antithesis(0.2))
|
|
63
63
|
t = s.as_thesis()
|
|
64
64
|
assert (t.value.mu, t.value.lam) == (0.7, 0.2)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_dialectical_methods_accept_threshold():
|
|
68
|
+
# becoming: is_true on the underlying value
|
|
69
|
+
s = Synthesis(Thesis(0.6), Antithesis(0.2))
|
|
70
|
+
assert s.becoming() is True
|
|
71
|
+
assert s.becoming(threshold=0.8) is False
|
|
72
|
+
|
|
73
|
+
# contradiction: is_contradictory on the underlying value
|
|
74
|
+
s = Synthesis(Thesis(0.8), Antithesis(0.8))
|
|
75
|
+
assert s.contradiction() is True
|
|
76
|
+
assert s.contradiction(threshold=0.9) is False
|
|
77
|
+
|
|
78
|
+
# sublation: not is_indeterminate on the underlying value
|
|
79
|
+
s = Synthesis(Thesis(0.6), Antithesis(0.2))
|
|
80
|
+
assert s.sublation() is True
|
|
81
|
+
assert s.sublation(threshold=0.8) is False
|
|
82
|
+
|
|
83
|
+
# negation: invert().is_true() on the underlying value
|
|
84
|
+
s = Synthesis(Thesis(0.2), Antithesis(0.6))
|
|
85
|
+
assert s.negation() is True
|
|
86
|
+
assert s.negation(threshold=0.8) is False
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_synthesis_from_values_matches_thesis_antithesis_flow():
|
|
90
|
+
s = Synthesis.from_values(0.7, 0.2)
|
|
91
|
+
assert s.value.mu == 0.7
|
|
92
|
+
assert s.value.lam == 0.2
|
|
93
|
+
|
|
94
|
+
reference = Synthesis(Thesis(0.7), Antithesis(0.2))
|
|
95
|
+
assert (s.value.mu, s.value.lam) == (reference.value.mu, reference.value.lam)
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Property-based invariants for TruthValue. The four combining operations are
|
|
3
|
-
defined by min/max alone, so results are exact degrees of the inputs and can
|
|
4
|
-
be compared without float tolerance. Values are compared as (mu, lam) tuples,
|
|
5
|
-
since TruthValue defines no __eq__.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
1
|
from hypothesis import given
|
|
9
2
|
from hypothesis import strategies as st
|
|
10
3
|
|
|
@@ -60,3 +60,60 @@ def test_rejects_out_of_range_evidence():
|
|
|
60
60
|
TruthValue(mu=1.5, lam=0.0)
|
|
61
61
|
with pytest.raises(ValueError):
|
|
62
62
|
TruthValue(mu=0.0, lam=-0.1)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_eq_compares_evidence_not_identity():
|
|
66
|
+
assert TruthValue(1.0, 0.0) == TruthValue(1.0, 0.0)
|
|
67
|
+
assert TruthValue(0.0, 1.0) == TruthValue(0.0, 1.0)
|
|
68
|
+
assert TruthValue(1.0, 0.0) != TruthValue(0.0, 1.0)
|
|
69
|
+
assert TruthValue(0.7, 0.2) == TruthValue(0.7, 0.2)
|
|
70
|
+
assert TruthValue(0.7, 0.2) != TruthValue(0.7, 0.3)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_repr_shows_both_degrees():
|
|
74
|
+
value = TruthValue(mu=0.8, lam=0.3)
|
|
75
|
+
rendered = repr(value)
|
|
76
|
+
assert "mu=0.8" in rendered
|
|
77
|
+
assert "lam=0.3" in rendered
|
|
78
|
+
assert "TruthValue" in rendered
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_degrees_are_read_only_after_construction():
|
|
82
|
+
value = TruthValue(mu=0.9, lam=0.1)
|
|
83
|
+
assert value.mu == 0.9
|
|
84
|
+
assert value.lam == 0.1
|
|
85
|
+
with pytest.raises(AttributeError):
|
|
86
|
+
value.mu = 5.0
|
|
87
|
+
with pytest.raises(AttributeError):
|
|
88
|
+
value.lam = 5.0
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_implication_is_not_a_or_b():
|
|
92
|
+
result = TruthValue(0.9, 0.1).implication(TruthValue(0.3, 0.6))
|
|
93
|
+
assert result.mu == 0.3
|
|
94
|
+
assert result.lam == 0.6
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_implication_reflexive_is_not_necessarily_true():
|
|
98
|
+
# In FDE, A -> A need not be (1, 0); it keeps its own degrees.
|
|
99
|
+
value = TruthValue(0.9, 0.1)
|
|
100
|
+
result = value.implication(value)
|
|
101
|
+
assert result.mu == 0.9
|
|
102
|
+
assert result.lam == 0.1
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_equivalence_is_conjunction_of_both_implications():
|
|
106
|
+
result = TruthValue(1.0, 0.0).equivalence(TruthValue(0.0, 1.0))
|
|
107
|
+
assert result.mu == 0.0
|
|
108
|
+
assert result.lam == 1.0
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_equivalence_is_symmetric():
|
|
112
|
+
a = TruthValue(0.9, 0.1)
|
|
113
|
+
b = TruthValue(0.3, 0.6)
|
|
114
|
+
assert a.equivalence(b) == b.equivalence(a)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_from_bool_lifts_to_classical_corners():
|
|
118
|
+
assert TruthValue.from_bool(True) == TruthValue(1.0, 0.0)
|
|
119
|
+
assert TruthValue.from_bool(False) == TruthValue(0.0, 1.0)
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Validation against three canonical cases: the liar paradox, the sorites,
|
|
3
|
-
and Hegel's Being/Nothing/Becoming triad. Each test encodes only what the
|
|
4
|
-
library actually models, and comments where the mapping is interpretive.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
1
|
from itertools import pairwise
|
|
8
2
|
|
|
9
3
|
from sublation import Antithesis, Synthesis, Thesis, TruthValue
|
|
10
4
|
|
|
11
5
|
|
|
12
6
|
def test_liar_is_a_stable_contradiction_not_an_explosion():
|
|
13
|
-
"""
|
|
14
|
-
"This sentence is false": its truth entails its falsity and vice versa,
|
|
15
|
-
so evidence lands on both sides at once. That is the contradictory corner,
|
|
16
|
-
and `invert` (its own negation) is a fixed point there — the paradox is
|
|
17
|
-
recorded as a determinate state instead of blowing the logic up.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
7
|
liar = TruthValue(mu=1.0, lam=1.0)
|
|
21
8
|
assert liar.is_contradictory() is True
|
|
22
9
|
|
|
@@ -27,13 +14,6 @@ def test_liar_is_a_stable_contradiction_not_an_explosion():
|
|
|
27
14
|
|
|
28
15
|
|
|
29
16
|
def test_sorites_passes_through_indeterminacy_without_a_sharp_cutoff():
|
|
30
|
-
"""
|
|
31
|
-
Removing grains one at a time: as evidence-for a heap fades from 1.0 to
|
|
32
|
-
0.0, the verdict does not flip crisply true -> false. A middle band reads
|
|
33
|
-
indeterminate, which is the sorites' point — there is no single grain at
|
|
34
|
-
which "heap" becomes "not a heap".
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
17
|
gradient = [i / 10 for i in range(10, -1, -1)]
|
|
38
18
|
verdicts = [Thesis(mu).becoming() for mu in gradient]
|
|
39
19
|
|
|
@@ -48,13 +28,6 @@ def test_sorites_passes_through_indeterminacy_without_a_sharp_cutoff():
|
|
|
48
28
|
|
|
49
29
|
|
|
50
30
|
def test_being_and_nothing_are_indeterminate_becoming_is_their_unity():
|
|
51
|
-
"""
|
|
52
|
-
Being and Nothing are each pure and empty — nothing determinate is
|
|
53
|
-
asserted either way — which is the indeterminate corner. Their unity as
|
|
54
|
-
a synthesis is likewise undetermined: the movement is real, but no side
|
|
55
|
-
has yet settled it. (Interpretive mapping of Hegel's opening triad.)
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
31
|
being = Thesis(0.0)
|
|
59
32
|
nothing = Antithesis(0.0)
|
|
60
33
|
assert being.value.is_indeterminate() is True
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
from .truths import THRESHOLD, TruthValue
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Dialectical:
|
|
5
|
-
"""
|
|
6
|
-
Shared behavior for Thesis, Antithesis, and Synthesis. Each subclass is only responsible for building self.value, self.thesis, and self.antithesis in its own __init__ — the four methods below read those fields the same way regardless of which subclass created them.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
value: TruthValue
|
|
10
|
-
thesis: bool
|
|
11
|
-
antithesis: bool
|
|
12
|
-
|
|
13
|
-
def negation(self) -> bool:
|
|
14
|
-
"""
|
|
15
|
-
Whether the negation of this value holds cleanly true. Inverts the `mu` and `lam` of the underlying TruthValue and checks whether that inverted value is true.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
negation = self.value.invert().is_true()
|
|
19
|
-
return negation
|
|
20
|
-
|
|
21
|
-
def contradiction(self) -> bool:
|
|
22
|
-
"""
|
|
23
|
-
Whether evidence for and against are both strong at once. State that a plain bool can never represent - True and False at the same time -, but that TruthValue can.
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
contradiction = self.value.is_contradictory()
|
|
27
|
-
return contradiction
|
|
28
|
-
|
|
29
|
-
def becoming(self) -> bool:
|
|
30
|
-
"""
|
|
31
|
-
Whether this value is a clean, uncontested affirmation. State that a plain bool can represent, but that TruthValue can also represent. This method is just a convenience for when you want to check for the simplest case.
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
becoming = self.value.is_true()
|
|
35
|
-
return becoming
|
|
36
|
-
|
|
37
|
-
def sublation(self) -> bool:
|
|
38
|
-
"""
|
|
39
|
-
Whether this value has been determined at all, either way. Corresponds to the Hegelian notion of `Aufhebung`. In this case, it means that the TruthValue has crossed the threshold in either direction, so it is no longer indeterminate and has been "sublated" (Aufgehoben).
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
sublation = not self.value.is_indeterminate()
|
|
43
|
-
return sublation
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class Thesis(Dialectical):
|
|
47
|
-
"""
|
|
48
|
-
Thesis: a proposition asserted as posited. A bool thesis infers its complement (asserting the thesis denies its antithesis), a continuous degree does not (it asserts nothing against). Either inference can be overridden by passing antithesis explicitly.
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
def __init__(
|
|
52
|
-
self,
|
|
53
|
-
thesis: bool | float = True,
|
|
54
|
-
antithesis: bool | float | None = None,
|
|
55
|
-
) -> None:
|
|
56
|
-
if antithesis is None:
|
|
57
|
-
antithesis = (not thesis) if isinstance(thesis, bool) else 0.0
|
|
58
|
-
|
|
59
|
-
self.value = TruthValue(mu=float(thesis), lam=float(antithesis))
|
|
60
|
-
self.thesis = self.value.mu >= THRESHOLD
|
|
61
|
-
self.antithesis = self.value.lam >= THRESHOLD
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class Antithesis(Dialectical):
|
|
65
|
-
"""
|
|
66
|
-
Antithesis: a proposition asserted as the negation of a thesis. A bool antithesis infers its complement (asserting the antithesis denies the thesis), a continuous degree does not (it asserts nothing for). Either inference can be overridden by passing thesis explicitly.
|
|
67
|
-
"""
|
|
68
|
-
|
|
69
|
-
def __init__(
|
|
70
|
-
self,
|
|
71
|
-
antithesis: bool | float = False,
|
|
72
|
-
thesis: bool | float | None = None,
|
|
73
|
-
) -> None:
|
|
74
|
-
if thesis is None:
|
|
75
|
-
thesis = (not antithesis) if isinstance(antithesis, bool) else 0.0
|
|
76
|
-
|
|
77
|
-
self.value = TruthValue(mu=float(thesis), lam=float(antithesis))
|
|
78
|
-
self.thesis = self.value.mu >= THRESHOLD
|
|
79
|
-
self.antithesis = self.value.lam >= THRESHOLD
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class Synthesis(Dialectical):
|
|
83
|
-
"""
|
|
84
|
-
Synthesis: combines a Thesis and an Antithesis - it trusts the thesis only on its own claim (mu) and the antithesis only on its own claim (lam), rather than pooling everything either side happens to carry.
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
def __init__(self, thesis: Thesis, antithesis: Antithesis) -> None:
|
|
88
|
-
self.value = TruthValue(mu=thesis.value.mu, lam=antithesis.value.lam)
|
|
89
|
-
|
|
90
|
-
self.thesis = self.value.mu >= THRESHOLD
|
|
91
|
-
self.antithesis = self.value.lam >= THRESHOLD
|
|
92
|
-
self.synthesis = self.sublation()
|
|
93
|
-
|
|
94
|
-
def as_thesis(self) -> Thesis:
|
|
95
|
-
"""
|
|
96
|
-
Re-posits this synthesis as the thesis of the next round. Both degrees are passed explicitly, so the new thesis carries the synthesis's exact `mu`/`lam` rather than a thresholded bool — intermediate certainty survives the chaining. The next round evaluates it against a fresh antithesis.
|
|
97
|
-
"""
|
|
98
|
-
|
|
99
|
-
next_round = Thesis(thesis=self.value.mu, antithesis=self.value.lam)
|
|
100
|
-
return next_round
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
THRESHOLD = 0.5
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class TruthValue:
|
|
5
|
-
"""
|
|
6
|
-
This class represents a proposition's evidential state as a pair of independent degrees: `mu`, how much evidence favors it, and `lam`, how much evidence opposes it, both ranging from 0.0 to 1.0. The four values are:
|
|
7
|
-
|
|
8
|
-
(mu=1.0, lam=0.0) <-> True (bool);
|
|
9
|
-
(mu=0.0, lam=1.0) <-> False (bool);
|
|
10
|
-
(mu=1.0, lam=1.0) <-> Contradiction
|
|
11
|
-
(mu=0.0, lam=0.0) <-> Indeterminacy
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
def __init__(self, mu: float, lam: float) -> None:
|
|
15
|
-
"""
|
|
16
|
-
Builds a TruthValue from its two evidence degrees, both required to
|
|
17
|
-
fall within [0.0, 1.0]. Out-of-range input raises ValueError right
|
|
18
|
-
away, rather than producing a value that misbehaves later.
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
if not (0 <= mu <= 1):
|
|
22
|
-
raise ValueError(f"mu must be within [0.0, 1.0], got {mu}")
|
|
23
|
-
|
|
24
|
-
if not (0 <= lam <= 1):
|
|
25
|
-
raise ValueError(f"lam must be within [0.0, 1.0], got {lam}")
|
|
26
|
-
|
|
27
|
-
self.mu = mu
|
|
28
|
-
self.lam = lam
|
|
29
|
-
|
|
30
|
-
def invert(self) -> "TruthValue":
|
|
31
|
-
"""
|
|
32
|
-
Returns this value's negation by swapping the two kinds of evidence: what argued FOR now argues AGAINST, and vice versa.
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
|
-
truth_value = TruthValue(self.lam, self.mu)
|
|
36
|
-
return truth_value
|
|
37
|
-
|
|
38
|
-
def conjunction(self, other: "TruthValue") -> "TruthValue":
|
|
39
|
-
"""
|
|
40
|
-
Combines two values as logical AND: only as favorably evidenced as the weaker half (min of the two mu), and only as free of doubt as the most doubted half (max of the two lam).
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
truth_value = TruthValue(
|
|
44
|
-
min(self.mu, other.mu),
|
|
45
|
-
max(self.lam, other.lam),
|
|
46
|
-
)
|
|
47
|
-
return truth_value
|
|
48
|
-
|
|
49
|
-
def disjunction(self, other: "TruthValue") -> "TruthValue":
|
|
50
|
-
"""
|
|
51
|
-
The mirror of conjunction: OR takes the stronger mu and the milder lam, since a disjunction only needs one side to hold up.
|
|
52
|
-
"""
|
|
53
|
-
|
|
54
|
-
truth_value = TruthValue(
|
|
55
|
-
max(self.mu, other.mu),
|
|
56
|
-
min(self.lam, other.lam),
|
|
57
|
-
)
|
|
58
|
-
return truth_value
|
|
59
|
-
|
|
60
|
-
def consensus(self, other: "TruthValue") -> "TruthValue":
|
|
61
|
-
"""
|
|
62
|
-
Keeps only the evidence both operands agree on (min mu, min lam) - a skeptical combination where anything one side claims but the other doesn't corroborate gets dropped.
|
|
63
|
-
"""
|
|
64
|
-
|
|
65
|
-
truth_value = TruthValue(
|
|
66
|
-
min(self.mu, other.mu),
|
|
67
|
-
min(self.lam, other.lam),
|
|
68
|
-
)
|
|
69
|
-
return truth_value
|
|
70
|
-
|
|
71
|
-
def accumulate(self, other: "TruthValue") -> "TruthValue":
|
|
72
|
-
"""
|
|
73
|
-
Pools all evidence from both operands, FOR and AGAINST alike (max mu, max lam), without discarding anything either side claims.
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
truth_value = TruthValue(
|
|
77
|
-
max(self.mu, other.mu),
|
|
78
|
-
max(self.lam, other.lam),
|
|
79
|
-
)
|
|
80
|
-
return truth_value
|
|
81
|
-
|
|
82
|
-
def to_bool(self) -> bool:
|
|
83
|
-
"""
|
|
84
|
-
Collapses this value to a plain bool by checking which evidence degree is larger — a relative comparison, **not** the same question as `is_true ()` below.
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
conversion = self.mu > self.lam
|
|
88
|
-
return conversion
|
|
89
|
-
|
|
90
|
-
def is_true(self, threshold: float = THRESHOLD) -> bool:
|
|
91
|
-
"""
|
|
92
|
-
Reports whether this value sits in the "true" corner: evidence FOR has crossed the threshold and evidence AGAINST has not.
|
|
93
|
-
"""
|
|
94
|
-
|
|
95
|
-
response = (self.mu >= threshold) and (self.lam < threshold)
|
|
96
|
-
return response
|
|
97
|
-
|
|
98
|
-
def is_false(self, threshold: float = THRESHOLD) -> bool:
|
|
99
|
-
"""
|
|
100
|
-
The mirror of `is_true`: evidence AGAINST has crossed the threshold and evidence FOR has not.
|
|
101
|
-
"""
|
|
102
|
-
|
|
103
|
-
response = (self.lam >= threshold) and (self.mu < threshold)
|
|
104
|
-
return response
|
|
105
|
-
|
|
106
|
-
def is_contradictory(self, threshold: float = THRESHOLD) -> bool:
|
|
107
|
-
"""
|
|
108
|
-
Reports whether both evidence FOR and evidence AGAINST have crossed the threshold at once — the state a plain bool can never represent, and the reason TruthValue exists.
|
|
109
|
-
"""
|
|
110
|
-
|
|
111
|
-
response = (self.mu >= threshold) and (self.lam >= threshold)
|
|
112
|
-
return response
|
|
113
|
-
|
|
114
|
-
def is_indeterminate(self, threshold: float = THRESHOLD) -> bool:
|
|
115
|
-
"""
|
|
116
|
-
Reports whether neither evidence FOR nor evidence AGAINST has crossed the threshold — "we simply don't know yet", a legitimate state that plain bool forces away.
|
|
117
|
-
"""
|
|
118
|
-
|
|
119
|
-
response = (self.mu < threshold) and (self.lam < threshold)
|
|
120
|
-
return response
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def truth_value_from_bool(value: bool) -> TruthValue:
|
|
124
|
-
"""
|
|
125
|
-
Builds a TruthValue from a plain bool, landing on one of the two classical corners. Utility function for convenience, since the constructor requires two evidence degrees and a bool only has one.
|
|
126
|
-
"""
|
|
127
|
-
|
|
128
|
-
conversion = TruthValue(1.0, 0.0) if value else TruthValue(0.0, 1.0)
|
|
129
|
-
return conversion
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|