EPICProver 0.1.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.
- epicprover-0.1.0/LICENSE +21 -0
- epicprover-0.1.0/PKG-INFO +327 -0
- epicprover-0.1.0/README.md +311 -0
- epicprover-0.1.0/pyproject.toml +29 -0
- epicprover-0.1.0/setup.cfg +4 -0
- epicprover-0.1.0/src/EPICProver.egg-info/PKG-INFO +327 -0
- epicprover-0.1.0/src/EPICProver.egg-info/SOURCES.txt +18 -0
- epicprover-0.1.0/src/EPICProver.egg-info/dependency_links.txt +1 -0
- epicprover-0.1.0/src/EPICProver.egg-info/top_level.txt +1 -0
- epicprover-0.1.0/src/epiclogic/__init__.py +61 -0
- epicprover-0.1.0/src/epiclogic/kernel/deque.py +153 -0
- epicprover-0.1.0/src/epiclogic/kernel/operators.py +856 -0
- epicprover-0.1.0/src/epiclogic/kernel/opertree.py +614 -0
- epicprover-0.1.0/src/epiclogic/kernel/proofTree.py +306 -0
- epicprover-0.1.0/src/epiclogic/other/metatree.py +148 -0
- epicprover-0.1.0/src/epiclogic/strategy/ssp.py +211 -0
- epicprover-0.1.0/src/epiclogic/utils/consts.py +4 -0
- epicprover-0.1.0/src/epiclogic/utils/derivedFormula.py +93 -0
- epicprover-0.1.0/src/epiclogic/utils/inferenceRule.py +134 -0
- epicprover-0.1.0/src/epiclogic/utils/provenTheorem.py +233 -0
epicprover-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vladislav, Nikita
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: EPICProver
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A proof system for modal logic with cluster moderator architecture
|
|
5
|
+
Author-email: Eberle Vladislav Stanislavovich <eberlad03@gmail.com>, Protsenko Nikita Alexandrovich <nikitaprotsenko2003@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Fivochnik/Eberle-Protsenko-Intuitionistic-Constructive-Prover
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/Fivochnik/Eberle-Protsenko-Intuitionistic-Constructive-Prover/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# EPICLogic — Library for Logical Deduction
|
|
18
|
+
|
|
19
|
+
## Table of Contents
|
|
20
|
+
- [Main Information](#main-information)
|
|
21
|
+
- [Module `operators`](#module-operators)
|
|
22
|
+
- [Class `opertree`](#class-opertree)
|
|
23
|
+
- [Class `derivedFormula`](#class-derivedformula)
|
|
24
|
+
- [Class `inferenceRule`](#class-inferencerule)
|
|
25
|
+
- [Class `provenTheorem`](#class-proventheorem)
|
|
26
|
+
- [Class `proofTree`](#class-prooftree)
|
|
27
|
+
- [Functions `proven_theorems` and `isDerived`](#functions-proven_theorems-and-isderived)
|
|
28
|
+
- [Function `premise_subs`](#function-premise_subs)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
You can install EPICProver using pip:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install epicprover
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or, if you want the latest development version directly from GitHub:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install git+https://github.com/Fivochnik/Eberle-Protsenko-Intuitionistic-Constructive-Prover
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
49
|
+
|
|
50
|
+
## Main Information
|
|
51
|
+
|
|
52
|
+
ProEbLogic provides tools for modal logic with custom operators, axioms, inference rules, and proof verification.
|
|
53
|
+
|
|
54
|
+
All string inputs (formulas, patterns, substitutions) are automatically parsed into `opertree` objects — the user never needs to work with trees directly.
|
|
55
|
+
|
|
56
|
+
**Key modules:**
|
|
57
|
+
- `operators` — operator definitions (names, syntax, types, signatures)
|
|
58
|
+
- `opertree` — internal representation of formulas
|
|
59
|
+
- `derivedFormula`, `inferenceRule`, `provenTheorem`, `proofTree`, `metatree` — proof system
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
64
|
+
|
|
65
|
+
## Module `operators`
|
|
66
|
+
|
|
67
|
+
Contains all operator configuration dictionaries.
|
|
68
|
+
|
|
69
|
+
| Structure | Description |
|
|
70
|
+
|-----------|-------------|
|
|
71
|
+
| `OperatorNameList` | Ordered list of operator names |
|
|
72
|
+
| `OperatorSyntax` | Symbolic notation |
|
|
73
|
+
| `Operator` | name → numeric ID mapping |
|
|
74
|
+
| `OperatorTypeNameList` | Formula type names |
|
|
75
|
+
| `OperatorTypeName` | type name → numeric code |
|
|
76
|
+
| `OperatorArgs` | Context-specific operator signatures `{type_code: {op_id: (arg_types...)}}` |
|
|
77
|
+
| `PrefixOperators`, `InfixOperators`, `PostFixOperators` | Lists of operators of the specified fixity |
|
|
78
|
+
| `OperatorFixity` | A dictionary storing the id of each operation and its fixity |
|
|
79
|
+
| `NullaryOperatorHandler` | Parsing functions for nullary operators |
|
|
80
|
+
| `OperatorDepth` | Temporal depth for fixed-point operators |
|
|
81
|
+
|
|
82
|
+
The module is self-documenting: `print(operators.__doc__)` generates tables of current operators and their signatures.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
87
|
+
|
|
88
|
+
## Class `opertree`
|
|
89
|
+
|
|
90
|
+
Represents a formula as a tree node.
|
|
91
|
+
|
|
92
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
93
|
+
|
|
94
|
+
### Constructor
|
|
95
|
+
|
|
96
|
+
`opertree(type: int, value: list | object = None)`
|
|
97
|
+
|
|
98
|
+
- If `value is None`, `type` is interpreted as a string formula and parsed automatically.
|
|
99
|
+
- Otherwise, `type` is a numeric operator ID, `value` is a list of children (for operators) or a raw value (for nullary operators).
|
|
100
|
+
|
|
101
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
102
|
+
|
|
103
|
+
### Attributes
|
|
104
|
+
|
|
105
|
+
| Attribute | Type | Description |
|
|
106
|
+
|-----------|------|-------------|
|
|
107
|
+
| `type` | `int` | Operator ID (from `Operator` dictionary) |
|
|
108
|
+
| `value` | `list[opertree] \| object` | Children for operators, value for nullary |
|
|
109
|
+
|
|
110
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
111
|
+
|
|
112
|
+
### Methods
|
|
113
|
+
|
|
114
|
+
| Method | Description |
|
|
115
|
+
|--------|-------------|
|
|
116
|
+
| `isCorrectIn(formulaType)` | Checks if node arguments are correct for the given formula type |
|
|
117
|
+
| `isCorrectAllIn(formulaType)` | Recursively checks the entire tree for type correctness |
|
|
118
|
+
| `subs(params)` | In‑place replacement: parameters (`$name`) are replaced by trees from `params` dict |
|
|
119
|
+
| `with_subs(params)` | Returns a new `opertree` with parameters replaced by the given substitutions. The original tree remains unchanged |
|
|
120
|
+
| `paramValuesFor(other)` | Matches tree against `other` (which may contain parameters `$name`), returns dict of substitutions |
|
|
121
|
+
| `copy()` | Returns a shallow copy (nullary values are shared) |
|
|
122
|
+
| `__str__` | String representation of the tree using `OperatorSyntax` and `OperatorFixity` |
|
|
123
|
+
| `__repr__` | Returns `opertree(str(self))` |
|
|
124
|
+
| `__eq__`, `__ne__` | Structural equality comparison |
|
|
125
|
+
|
|
126
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
127
|
+
|
|
128
|
+
### Parameters
|
|
129
|
+
|
|
130
|
+
- Parameters are denoted by `type == 'param'` and `value` is the parameter name (e.g., `'A'`).
|
|
131
|
+
- `paramValuesFor` returns a dictionary `{param_name: opertree}` or `None` if no match.
|
|
132
|
+
|
|
133
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
134
|
+
|
|
135
|
+
### Example
|
|
136
|
+
|
|
137
|
+
`pattern = opertree("$A & ($A -> $B)")` — parsed from string
|
|
138
|
+
`formula = opertree("p & (p -> q)")` — also from string
|
|
139
|
+
`subs = pattern.paramValuesFor(formula)` — returns `{'A': p, 'B': q}`
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
144
|
+
|
|
145
|
+
## Class `derivedFormula`
|
|
146
|
+
|
|
147
|
+
Represents a formula that is derivable under certain conditions.
|
|
148
|
+
|
|
149
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
150
|
+
|
|
151
|
+
### Constructor
|
|
152
|
+
|
|
153
|
+
`derivedFormula(tree: str | opertree, cond: dict[str, Callable | None] = {})`
|
|
154
|
+
|
|
155
|
+
- `tree` — pattern with optional parameters (`$A`, `$B`, ...)
|
|
156
|
+
- `cond` — conditions on parameters:
|
|
157
|
+
- `None` → parameter must be derivable
|
|
158
|
+
- predicate function → parameter must satisfy it
|
|
159
|
+
|
|
160
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
161
|
+
|
|
162
|
+
### String representation
|
|
163
|
+
|
|
164
|
+
`(($A & $B) ← {$A, $B})` — formula derivable if `$A` and `$B` are derivable.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
169
|
+
|
|
170
|
+
## Class `inferenceRule`
|
|
171
|
+
|
|
172
|
+
Defines a rule of inference.
|
|
173
|
+
|
|
174
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
175
|
+
|
|
176
|
+
### Constructor
|
|
177
|
+
|
|
178
|
+
`inferenceRule(premise: list[opertree], conclusion: list[opertree])`
|
|
179
|
+
|
|
180
|
+
- `premise` — list of formulas representing the premise (meta-AND)
|
|
181
|
+
- `conclusion` — list of formulas representing the conclusion (meta-AND)
|
|
182
|
+
|
|
183
|
+
Example: Modus Ponens
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
inferenceRule(
|
|
187
|
+
premise = [opertree('$A'), opertree('$A -> $B')],
|
|
188
|
+
conclusion = [opertree('$B')]
|
|
189
|
+
)
|
|
190
|
+
print(rule)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
194
|
+
|
|
195
|
+
### String representation
|
|
196
|
+
|
|
197
|
+
`[$A, ($A -> $B)] → [$B]`
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
202
|
+
|
|
203
|
+
## Class `provenTheorem`
|
|
204
|
+
|
|
205
|
+
Represents a theorem proven by applying a rule with a substitution.
|
|
206
|
+
|
|
207
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
208
|
+
|
|
209
|
+
### Constructor
|
|
210
|
+
|
|
211
|
+
`provenTheorem(theorem: derivedFormula, rule: inferenceRule, subs: dict[str, str | opertree])`
|
|
212
|
+
|
|
213
|
+
- `theorem` — the proven formula (with conditions)
|
|
214
|
+
- `rule` — inference rule used
|
|
215
|
+
- `subs` — substitution mapping parameters to formulas
|
|
216
|
+
|
|
217
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
218
|
+
|
|
219
|
+
### Properties
|
|
220
|
+
|
|
221
|
+
| Property | Description |
|
|
222
|
+
|----------|-------------|
|
|
223
|
+
| `isCorrect` | Whether `theorem.tree` matches `rule.conclusion` with `subs` applied |
|
|
224
|
+
| `isDerivedIn(axioms)` | Whether the premise is derivable from the given axioms |
|
|
225
|
+
|
|
226
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
227
|
+
|
|
228
|
+
### String representation
|
|
229
|
+
|
|
230
|
+
`(($A|$B) ← {$A}) from [$A, ($A->$B)] → [$B] with {A: $A, B: ($A|$B)}`
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
235
|
+
|
|
236
|
+
## Class `proofTree`
|
|
237
|
+
|
|
238
|
+
Represents a complete proof tree returned by `isDerived`.
|
|
239
|
+
|
|
240
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
241
|
+
|
|
242
|
+
### Constructor
|
|
243
|
+
|
|
244
|
+
`proofTree(target: opertree | provenTheorem, result: bool, reason: str, subproofs: list[proofTree])`
|
|
245
|
+
|
|
246
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
247
|
+
|
|
248
|
+
### Methods
|
|
249
|
+
|
|
250
|
+
| Method | Description |
|
|
251
|
+
|--------|-------------|
|
|
252
|
+
| `toStr(lasts=None, last=False, lvlType: int = 0)` | Returns visual proof tree with branches |
|
|
253
|
+
| `toStrFull(lasts=None, last=False)` | Returns full visual proof tree with branches |
|
|
254
|
+
| `__bool__` | Returns `result` — success or failure |
|
|
255
|
+
| `__str__` | Returns `self.toStr()` |
|
|
256
|
+
|
|
257
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
258
|
+
|
|
259
|
+
### Output format (short mode)
|
|
260
|
+
|
|
261
|
+
```text
|
|
262
|
+
Goal: (A|B) [✔] ⊢ (A|B)
|
|
263
|
+
├─Theorem: ($A|$B) ← {$A} [✔] (($A|$B) ∈ {($A|$B)}), ⊢ {$A, ($A->($A|$B))}
|
|
264
|
+
│ └─Goal: ($A&($A->($A|$B))) [✔] ⊢ (($A&$B) ← {$A, $B})
|
|
265
|
+
│ ├─Goal: $A [✔] [hyp]
|
|
266
|
+
│ └─Goal: ($A->($A|$B)) [✔] ⊢ (($A->($A|$B)) ← {})
|
|
267
|
+
└─Goal: (A|B) [✔] ⊢ (($A|$B) ← {$A})
|
|
268
|
+
├─Goal: A [✔] ⊢ A
|
|
269
|
+
└─Goal: B [✔] [free]
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
273
|
+
|
|
274
|
+
### Symbols
|
|
275
|
+
|
|
276
|
+
- `[✔]` — success
|
|
277
|
+
- `[✘]` — failure
|
|
278
|
+
- `[hyp]` — assumption
|
|
279
|
+
- `[free]` — free parameter (no proof required)
|
|
280
|
+
- `⊢` — "derivable from"
|
|
281
|
+
- `←` — "derivable from" (in theorems)
|
|
282
|
+
- `∈` — "in set"
|
|
283
|
+
- `∉` — "not in set"
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
288
|
+
|
|
289
|
+
## Functions `proven_theorems` and `isDerived`
|
|
290
|
+
|
|
291
|
+
`proven_theorems(theorems: list[provenTheorem], axioms: list[derivedFormula]) -> list[provenTheorem]`
|
|
292
|
+
|
|
293
|
+
Filters the list of theorems, returning only those that can be proven from the given axioms (iteratively, respecting dependencies).
|
|
294
|
+
|
|
295
|
+
`isDerived(main: str | opertree, axioms: list[derivedFormula], theorems: list[provenTheorem] = None) -> proofTree`
|
|
296
|
+
|
|
297
|
+
Checks if `main` is derivable from `axioms` and true theorems from `proven_theorems(theorems, axioms)`.
|
|
298
|
+
|
|
299
|
+
Returns a `proofTree` object representing the complete proof (or failure tree).
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Function `premise_subs`
|
|
304
|
+
|
|
305
|
+
`premise_subs(premise: list[opertree], hypothesis: list[opertree]) -> generator[dict[str, opertree]]`
|
|
306
|
+
|
|
307
|
+
Finds all possible substitutions that make the list of premises match a list of hypotheses.
|
|
308
|
+
|
|
309
|
+
Example:
|
|
310
|
+
|
|
311
|
+
```python
|
|
312
|
+
premise = [opertree('$A'), opertree('$A -> $B')]
|
|
313
|
+
hypothesis = [opertree('A'), opertree('B'), opertree('A -> C'), opertree('A -> D'), opertree('B -> D')]
|
|
314
|
+
|
|
315
|
+
for subs in premise_subs(premise, hypothesis):
|
|
316
|
+
print(subs)
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Output:
|
|
320
|
+
|
|
321
|
+
```text
|
|
322
|
+
{'A': A, 'B': C}
|
|
323
|
+
{'A': A, 'B': D}
|
|
324
|
+
{'A': B, 'B': D}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# EPICLogic — Library for Logical Deduction
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
- [Main Information](#main-information)
|
|
5
|
+
- [Module `operators`](#module-operators)
|
|
6
|
+
- [Class `opertree`](#class-opertree)
|
|
7
|
+
- [Class `derivedFormula`](#class-derivedformula)
|
|
8
|
+
- [Class `inferenceRule`](#class-inferencerule)
|
|
9
|
+
- [Class `provenTheorem`](#class-proventheorem)
|
|
10
|
+
- [Class `proofTree`](#class-prooftree)
|
|
11
|
+
- [Functions `proven_theorems` and `isDerived`](#functions-proven_theorems-and-isderived)
|
|
12
|
+
- [Function `premise_subs`](#function-premise_subs)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
You can install EPICProver using pip:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install epicprover
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or, if you want the latest development version directly from GitHub:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install git+https://github.com/Fivochnik/Eberle-Protsenko-Intuitionistic-Constructive-Prover
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
33
|
+
|
|
34
|
+
## Main Information
|
|
35
|
+
|
|
36
|
+
ProEbLogic provides tools for modal logic with custom operators, axioms, inference rules, and proof verification.
|
|
37
|
+
|
|
38
|
+
All string inputs (formulas, patterns, substitutions) are automatically parsed into `opertree` objects — the user never needs to work with trees directly.
|
|
39
|
+
|
|
40
|
+
**Key modules:**
|
|
41
|
+
- `operators` — operator definitions (names, syntax, types, signatures)
|
|
42
|
+
- `opertree` — internal representation of formulas
|
|
43
|
+
- `derivedFormula`, `inferenceRule`, `provenTheorem`, `proofTree`, `metatree` — proof system
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
48
|
+
|
|
49
|
+
## Module `operators`
|
|
50
|
+
|
|
51
|
+
Contains all operator configuration dictionaries.
|
|
52
|
+
|
|
53
|
+
| Structure | Description |
|
|
54
|
+
|-----------|-------------|
|
|
55
|
+
| `OperatorNameList` | Ordered list of operator names |
|
|
56
|
+
| `OperatorSyntax` | Symbolic notation |
|
|
57
|
+
| `Operator` | name → numeric ID mapping |
|
|
58
|
+
| `OperatorTypeNameList` | Formula type names |
|
|
59
|
+
| `OperatorTypeName` | type name → numeric code |
|
|
60
|
+
| `OperatorArgs` | Context-specific operator signatures `{type_code: {op_id: (arg_types...)}}` |
|
|
61
|
+
| `PrefixOperators`, `InfixOperators`, `PostFixOperators` | Lists of operators of the specified fixity |
|
|
62
|
+
| `OperatorFixity` | A dictionary storing the id of each operation and its fixity |
|
|
63
|
+
| `NullaryOperatorHandler` | Parsing functions for nullary operators |
|
|
64
|
+
| `OperatorDepth` | Temporal depth for fixed-point operators |
|
|
65
|
+
|
|
66
|
+
The module is self-documenting: `print(operators.__doc__)` generates tables of current operators and their signatures.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
71
|
+
|
|
72
|
+
## Class `opertree`
|
|
73
|
+
|
|
74
|
+
Represents a formula as a tree node.
|
|
75
|
+
|
|
76
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
77
|
+
|
|
78
|
+
### Constructor
|
|
79
|
+
|
|
80
|
+
`opertree(type: int, value: list | object = None)`
|
|
81
|
+
|
|
82
|
+
- If `value is None`, `type` is interpreted as a string formula and parsed automatically.
|
|
83
|
+
- Otherwise, `type` is a numeric operator ID, `value` is a list of children (for operators) or a raw value (for nullary operators).
|
|
84
|
+
|
|
85
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
86
|
+
|
|
87
|
+
### Attributes
|
|
88
|
+
|
|
89
|
+
| Attribute | Type | Description |
|
|
90
|
+
|-----------|------|-------------|
|
|
91
|
+
| `type` | `int` | Operator ID (from `Operator` dictionary) |
|
|
92
|
+
| `value` | `list[opertree] \| object` | Children for operators, value for nullary |
|
|
93
|
+
|
|
94
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
95
|
+
|
|
96
|
+
### Methods
|
|
97
|
+
|
|
98
|
+
| Method | Description |
|
|
99
|
+
|--------|-------------|
|
|
100
|
+
| `isCorrectIn(formulaType)` | Checks if node arguments are correct for the given formula type |
|
|
101
|
+
| `isCorrectAllIn(formulaType)` | Recursively checks the entire tree for type correctness |
|
|
102
|
+
| `subs(params)` | In‑place replacement: parameters (`$name`) are replaced by trees from `params` dict |
|
|
103
|
+
| `with_subs(params)` | Returns a new `opertree` with parameters replaced by the given substitutions. The original tree remains unchanged |
|
|
104
|
+
| `paramValuesFor(other)` | Matches tree against `other` (which may contain parameters `$name`), returns dict of substitutions |
|
|
105
|
+
| `copy()` | Returns a shallow copy (nullary values are shared) |
|
|
106
|
+
| `__str__` | String representation of the tree using `OperatorSyntax` and `OperatorFixity` |
|
|
107
|
+
| `__repr__` | Returns `opertree(str(self))` |
|
|
108
|
+
| `__eq__`, `__ne__` | Structural equality comparison |
|
|
109
|
+
|
|
110
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
111
|
+
|
|
112
|
+
### Parameters
|
|
113
|
+
|
|
114
|
+
- Parameters are denoted by `type == 'param'` and `value` is the parameter name (e.g., `'A'`).
|
|
115
|
+
- `paramValuesFor` returns a dictionary `{param_name: opertree}` or `None` if no match.
|
|
116
|
+
|
|
117
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
118
|
+
|
|
119
|
+
### Example
|
|
120
|
+
|
|
121
|
+
`pattern = opertree("$A & ($A -> $B)")` — parsed from string
|
|
122
|
+
`formula = opertree("p & (p -> q)")` — also from string
|
|
123
|
+
`subs = pattern.paramValuesFor(formula)` — returns `{'A': p, 'B': q}`
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
128
|
+
|
|
129
|
+
## Class `derivedFormula`
|
|
130
|
+
|
|
131
|
+
Represents a formula that is derivable under certain conditions.
|
|
132
|
+
|
|
133
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
134
|
+
|
|
135
|
+
### Constructor
|
|
136
|
+
|
|
137
|
+
`derivedFormula(tree: str | opertree, cond: dict[str, Callable | None] = {})`
|
|
138
|
+
|
|
139
|
+
- `tree` — pattern with optional parameters (`$A`, `$B`, ...)
|
|
140
|
+
- `cond` — conditions on parameters:
|
|
141
|
+
- `None` → parameter must be derivable
|
|
142
|
+
- predicate function → parameter must satisfy it
|
|
143
|
+
|
|
144
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
145
|
+
|
|
146
|
+
### String representation
|
|
147
|
+
|
|
148
|
+
`(($A & $B) ← {$A, $B})` — formula derivable if `$A` and `$B` are derivable.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
153
|
+
|
|
154
|
+
## Class `inferenceRule`
|
|
155
|
+
|
|
156
|
+
Defines a rule of inference.
|
|
157
|
+
|
|
158
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
159
|
+
|
|
160
|
+
### Constructor
|
|
161
|
+
|
|
162
|
+
`inferenceRule(premise: list[opertree], conclusion: list[opertree])`
|
|
163
|
+
|
|
164
|
+
- `premise` — list of formulas representing the premise (meta-AND)
|
|
165
|
+
- `conclusion` — list of formulas representing the conclusion (meta-AND)
|
|
166
|
+
|
|
167
|
+
Example: Modus Ponens
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
inferenceRule(
|
|
171
|
+
premise = [opertree('$A'), opertree('$A -> $B')],
|
|
172
|
+
conclusion = [opertree('$B')]
|
|
173
|
+
)
|
|
174
|
+
print(rule)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
178
|
+
|
|
179
|
+
### String representation
|
|
180
|
+
|
|
181
|
+
`[$A, ($A -> $B)] → [$B]`
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
186
|
+
|
|
187
|
+
## Class `provenTheorem`
|
|
188
|
+
|
|
189
|
+
Represents a theorem proven by applying a rule with a substitution.
|
|
190
|
+
|
|
191
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
192
|
+
|
|
193
|
+
### Constructor
|
|
194
|
+
|
|
195
|
+
`provenTheorem(theorem: derivedFormula, rule: inferenceRule, subs: dict[str, str | opertree])`
|
|
196
|
+
|
|
197
|
+
- `theorem` — the proven formula (with conditions)
|
|
198
|
+
- `rule` — inference rule used
|
|
199
|
+
- `subs` — substitution mapping parameters to formulas
|
|
200
|
+
|
|
201
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
202
|
+
|
|
203
|
+
### Properties
|
|
204
|
+
|
|
205
|
+
| Property | Description |
|
|
206
|
+
|----------|-------------|
|
|
207
|
+
| `isCorrect` | Whether `theorem.tree` matches `rule.conclusion` with `subs` applied |
|
|
208
|
+
| `isDerivedIn(axioms)` | Whether the premise is derivable from the given axioms |
|
|
209
|
+
|
|
210
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
211
|
+
|
|
212
|
+
### String representation
|
|
213
|
+
|
|
214
|
+
`(($A|$B) ← {$A}) from [$A, ($A->$B)] → [$B] with {A: $A, B: ($A|$B)}`
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
219
|
+
|
|
220
|
+
## Class `proofTree`
|
|
221
|
+
|
|
222
|
+
Represents a complete proof tree returned by `isDerived`.
|
|
223
|
+
|
|
224
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
225
|
+
|
|
226
|
+
### Constructor
|
|
227
|
+
|
|
228
|
+
`proofTree(target: opertree | provenTheorem, result: bool, reason: str, subproofs: list[proofTree])`
|
|
229
|
+
|
|
230
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
231
|
+
|
|
232
|
+
### Methods
|
|
233
|
+
|
|
234
|
+
| Method | Description |
|
|
235
|
+
|--------|-------------|
|
|
236
|
+
| `toStr(lasts=None, last=False, lvlType: int = 0)` | Returns visual proof tree with branches |
|
|
237
|
+
| `toStrFull(lasts=None, last=False)` | Returns full visual proof tree with branches |
|
|
238
|
+
| `__bool__` | Returns `result` — success or failure |
|
|
239
|
+
| `__str__` | Returns `self.toStr()` |
|
|
240
|
+
|
|
241
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
242
|
+
|
|
243
|
+
### Output format (short mode)
|
|
244
|
+
|
|
245
|
+
```text
|
|
246
|
+
Goal: (A|B) [✔] ⊢ (A|B)
|
|
247
|
+
├─Theorem: ($A|$B) ← {$A} [✔] (($A|$B) ∈ {($A|$B)}), ⊢ {$A, ($A->($A|$B))}
|
|
248
|
+
│ └─Goal: ($A&($A->($A|$B))) [✔] ⊢ (($A&$B) ← {$A, $B})
|
|
249
|
+
│ ├─Goal: $A [✔] [hyp]
|
|
250
|
+
│ └─Goal: ($A->($A|$B)) [✔] ⊢ (($A->($A|$B)) ← {})
|
|
251
|
+
└─Goal: (A|B) [✔] ⊢ (($A|$B) ← {$A})
|
|
252
|
+
├─Goal: A [✔] ⊢ A
|
|
253
|
+
└─Goal: B [✔] [free]
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
257
|
+
|
|
258
|
+
### Symbols
|
|
259
|
+
|
|
260
|
+
- `[✔]` — success
|
|
261
|
+
- `[✘]` — failure
|
|
262
|
+
- `[hyp]` — assumption
|
|
263
|
+
- `[free]` — free parameter (no proof required)
|
|
264
|
+
- `⊢` — "derivable from"
|
|
265
|
+
- `←` — "derivable from" (in theorems)
|
|
266
|
+
- `∈` — "in set"
|
|
267
|
+
- `∉` — "not in set"
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
##### <div align="right">[↑ Back to top](#table-of-contents)</div>
|
|
272
|
+
|
|
273
|
+
## Functions `proven_theorems` and `isDerived`
|
|
274
|
+
|
|
275
|
+
`proven_theorems(theorems: list[provenTheorem], axioms: list[derivedFormula]) -> list[provenTheorem]`
|
|
276
|
+
|
|
277
|
+
Filters the list of theorems, returning only those that can be proven from the given axioms (iteratively, respecting dependencies).
|
|
278
|
+
|
|
279
|
+
`isDerived(main: str | opertree, axioms: list[derivedFormula], theorems: list[provenTheorem] = None) -> proofTree`
|
|
280
|
+
|
|
281
|
+
Checks if `main` is derivable from `axioms` and true theorems from `proven_theorems(theorems, axioms)`.
|
|
282
|
+
|
|
283
|
+
Returns a `proofTree` object representing the complete proof (or failure tree).
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Function `premise_subs`
|
|
288
|
+
|
|
289
|
+
`premise_subs(premise: list[opertree], hypothesis: list[opertree]) -> generator[dict[str, opertree]]`
|
|
290
|
+
|
|
291
|
+
Finds all possible substitutions that make the list of premises match a list of hypotheses.
|
|
292
|
+
|
|
293
|
+
Example:
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
premise = [opertree('$A'), opertree('$A -> $B')]
|
|
297
|
+
hypothesis = [opertree('A'), opertree('B'), opertree('A -> C'), opertree('A -> D'), opertree('B -> D')]
|
|
298
|
+
|
|
299
|
+
for subs in premise_subs(premise, hypothesis):
|
|
300
|
+
print(subs)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Output:
|
|
304
|
+
|
|
305
|
+
```text
|
|
306
|
+
{'A': A, 'B': C}
|
|
307
|
+
{'A': A, 'B': D}
|
|
308
|
+
{'A': B, 'B': D}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
---
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "EPICProver"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A proof system for modal logic with cluster moderator architecture"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Eberle Vladislav Stanislavovich", email = "eberlad03@gmail.com" },
|
|
14
|
+
{ name = "Protsenko Nikita Alexandrovich", email = "nikitaprotsenko2003@gmail.com"}
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
dependencies = []
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/Fivochnik/Eberle-Protsenko-Intuitionistic-Constructive-Prover"
|
|
26
|
+
"Bug Tracker" = "https://github.com/Fivochnik/Eberle-Protsenko-Intuitionistic-Constructive-Prover/issues"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["src"]
|