Skip to content

Commit 0671452

Browse files
committed
rework proof printing
1 parent 4c516c7 commit 0671452

File tree

5 files changed

+73
-61
lines changed

5 files changed

+73
-61
lines changed

README.md

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ Select logic (TFL, FOL, MLK, MLT, MLS4, MLS5): TFL
3838
Enter premises (separated by "," or ";"), or "NA" if none: P -> Q, P
3939
Enter conclusion: Q
4040
41-
1 | P → Q PR
42-
2 | P PR
43-
|---
41+
1 │ P → Q PR
42+
43+
2 │ P PR
44+
├───
4445
4546
1 - Add a new line
4647
2 - Begin a new subproof
@@ -51,10 +52,11 @@ Enter conclusion: Q
5152
Select action: 1
5253
Enter line: Q ; ->E, 1,2
5354
54-
1 | P → Q PR
55-
2 | P PR
56-
|---
57-
3 | Q →E, 1,2
55+
1 │ P → Q PR
56+
57+
2 │ P PR
58+
├───
59+
3 │ Q →E, 1,2
5860
5961
Proof complete! 🎉
6062
```
@@ -63,18 +65,23 @@ A proof of the law of excluded middle (LEM) using ND-Prover:
6365

6466
```
6567
Proof of ∴ P ∨ ¬P
66-
------------------
67-
68-
1 | | ¬(P ∨ ¬P) AS
69-
| |-----------
70-
2 | | | P AS
71-
| | |---
72-
3 | | | P ∨ ¬P ∨I, 2
73-
4 | | | ⊥ ¬E, 1,3
74-
5 | | ¬P ¬I, 2-4
75-
6 | | P ∨ ¬P ∨I, 5
76-
7 | | ⊥ ¬E, 1,6
77-
8 | P ∨ ¬P IP, 1-7
68+
──────────────────
69+
70+
1 │ │ ¬(P ∨ ¬P) AS
71+
│ ├───────────
72+
2 │ │ │ P AS
73+
│ │ ├───
74+
3 │ │ │ P ∨ ¬P ∨I, 2
75+
│ │ │
76+
4 │ │ │ ⊥ ¬E, 1,3
77+
│ │
78+
5 │ │ ¬P ¬I, 2-4
79+
│ │
80+
6 │ │ P ∨ ¬P ∨I, 5
81+
│ │
82+
7 │ │ ⊥ ¬E, 1,6
83+
84+
8 │ P ∨ ¬P IP, 1-7
7885
7986
Proof complete! 🎉
8087
```
@@ -83,15 +90,19 @@ A proof that identity is symmetric:
8390

8491
```
8592
Proof of ∴ ∀x∀y(x = y → y = x)
86-
-------------------------------
87-
88-
1 | | a = b AS
89-
| |-------
90-
2 | | a = a =I
91-
3 | | b = a =E, 1,2
92-
4 | a = b → b = a →I, 1-3
93-
5 | ∀y(a = y → y = a) ∀I, 4
94-
6 | ∀x∀y(x = y → y = x) ∀I, 5
93+
───────────────────────────────
94+
95+
1 │ │ a = b AS
96+
│ ├───────
97+
2 │ │ a = a =I
98+
│ │
99+
3 │ │ b = a =E, 1,2
100+
101+
4 │ a = b → b = a →I, 1-3
102+
103+
5 │ ∀y(a = y → y = a) ∀I, 4
104+
105+
6 │ ∀x∀y(x = y → y = x) ∀I, 5
95106
96107
Proof complete! 🎉
97108
```
@@ -100,19 +111,23 @@ A proof in modal logic S5:
100111

101112
```
102113
Proof of ♢□A ∴ □A
103-
-----------------
104-
105-
1 | ♢□A PR
106-
|-----
107-
2 | ¬□¬□A Def♢, 1
108-
3 | | ¬□A AS
109-
| |-----
110-
4 | | | □ AS
111-
| | |---
112-
5 | | | ¬□A R5, 3
113-
6 | | □¬□A □I, 4-5
114-
7 | | ⊥ ¬E, 2,6
115-
8 | □A IP, 3-7
114+
─────────────────
115+
116+
1 │ ♢□A PR
117+
├─────
118+
2 │ ¬□¬□A Def♢, 1
119+
120+
3 │ │ ¬□A AS
121+
│ ├─────
122+
4 │ │ │ □ AS
123+
│ │ ├───
124+
5 │ │ │ ¬□A R5, 3
125+
│ │
126+
6 │ │ □¬□A □I, 4-5
127+
│ │
128+
7 │ │ ⊥ ¬E, 2,6
129+
130+
8 │ □A IP, 3-7
116131
117132
Proof complete! 🎉
118133
```

interactive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ async def send_proof_msg(ctx, session):
242242
"""
243243
premises = ', '.join(str(p) for p in session.premises)
244244
first_line = f'Proof of {premises}{session.conclusion}'
245-
content = f'{first_line}\n{'-' * len(first_line)}\n\n{session.proof}'
245+
content = f'{first_line}\n{'' * len(first_line)}\n\n{session.proof}'
246246

247247
# Delete previous proof message, if it exists
248248
if session.proof_msg:

nd_prover/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.1.0'
1+
__version__ = '1.0.0'
22
__author__ = 'Daniyal Akif'
33
__email__ = '[email protected]'
44
__license__ = 'MIT'

nd_prover/logic.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -824,27 +824,24 @@ def _begin_subproof_current(self, assumption):
824824
self.seq.append(subproof)
825825

826826
def _collect_lines(self, depth=0):
827-
indent = ' '.join('|' * (depth + 1))
828-
assumptions = self.seq[:1] if self.assumption else self.context
829-
lines = []
830-
831-
for a in assumptions:
832-
line = (a.idx, f'{indent} {a.formula}', a.justification)
833-
lines.append(line)
834-
835-
if assumptions:
836-
bar_len = len(str(assumptions[-1].formula)) + 2
837-
line = ('', f'{indent}{'-' * bar_len}', '')
838-
lines.append(line)
827+
indent = '│ ' * depth
828+
seq = self.seq if self.assumption else self.context + self.seq
829+
bar_idx = 0 if self.assumption else len(self.context) - 1
839830

840-
i = 1 if self.assumption else 0
841-
for obj in self.seq[i:]:
831+
lines = []
832+
for idx, obj in enumerate(seq):
842833
if obj.is_line():
834+
formula = str(obj.formula)
843835
j = obj.justification
844-
line = (obj.idx, f'{indent} {obj.formula}', j)
845-
lines.append(line)
836+
lines.append((obj.idx, f'{indent}{formula}', j))
846837
else:
847838
lines.extend(obj._collect_lines(depth + 1))
839+
840+
if idx == bar_idx:
841+
bar = f'{indent}{'─' * (len(formula) + 2)}'
842+
lines.append(('', bar, ''))
843+
elif idx != len(seq) - 1:
844+
lines.append(('', f'{indent}│', ''))
848845
return lines
849846

850847

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "nd-prover"
7-
version = "0.1.0"
7+
version = "1.0.0"
88
description = "An interactive Fitch-style proof checker"
99
authors = [{ name = "Daniyal Akif", email = "[email protected]" }]
1010
readme = "README.md"
@@ -22,7 +22,7 @@ keywords = [
2222
]
2323

2424
classifiers = [
25-
"Development Status :: 3 - Alpha",
25+
"Development Status :: 5 - Production/Stable",
2626
"Intended Audience :: Science/Research",
2727
"License :: OSI Approved :: MIT License",
2828
"Programming Language :: Python :: 3",

0 commit comments

Comments
 (0)