Skip to content

Commit

Permalink
Quick Tweaks and Final Upload
Browse files Browse the repository at this point in the history
Added the custom start functionality, in order to allow the user to decide what type of proof they want to try. The initial values must now be denoted with + (true) or = (false)
  • Loading branch information
Bnml committed May 5, 2021
1 parent 9f6947b commit b519f39
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 42 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,33 @@ If you wish to make a new executable use pyinstaller -F STTSolver.py in a window
Check the Gurl Help button for instructions. They are repeated below for convenience:

Valid Input Symbols:

NOT : ~

AND : &

OR : |

CONDITIONAL : ->

BICONDITIONAL : <->

Possible literals are any capital letter
Possible literals are any capital letter.
Separate premises with newline characters.
The final line will always be assumed to be the conclusion.
Denote starting truth values using + for true and = for false. Put these at the start of each expression.
Use the scrollwheel to see next steps that go beyond the box.

FILE IMPORT: Select a txt file to put in the entry box

GURL HELP: Finds this window (you already did it!)

START: Press start after inputing premises and conclusion to begin.

NEXT: Procedes to the next step.

AUTO-COMPLETE: Automatically displays all steps.

RESET: Sets the program to its default state, removing any current text.
Do this especially when in the middle of a proof.

SAVE: Saves anything in the text box to a desired location as a txt file.
Binary file modified STTSolver.exe
Binary file not shown.
31 changes: 23 additions & 8 deletions STTSolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,25 @@ def getStatement(self, line, i):
#Parses each line, translating it into a Statement and adds it to a statement list.
def parseInput(self, f):
self.statements = []
self.starting_truth_vars = ''
for line in f:
s, temp = self.getStatement(line.strip(), 0)
input_line = line.strip()
if input_line == '' or input_line == '\n' or input_line == ' ': #Skips new lines
continue
if input_line[0] == '=':
self.starting_truth_vars = False
input_line = input_line[1:]
elif input_line[0] == '+':
self.starting_truth_vars = True
input_line = input_line[1:]
else:
tk.messagebox.showerror("error", "Invalid input. Please include initial truth values.")
self.error.set(1)
break
s, temp = self.getStatement(input_line, 0)
if self.error.get() == 1:
break
s.starting_value = self.starting_truth_vars
self.statements.append(s)
return self.statements

Expand Down Expand Up @@ -195,9 +210,8 @@ def solveTable(self, statements):
changedLiterals = dict()

#Setting the final statement as false, and the premises as true
for statement in statements[:-1]:
statement.assignment = True
statements[-1].assignment = True
for statement in statements:
statement.assignment = statement.starting_value

#Print opening statement
self.entry.config(state='normal')
Expand All @@ -219,7 +233,7 @@ def solveTable(self, statements):
for statement in range(len(statements)):
if not statements[statement].isValid():
self.entry.config(state='normal')
self.entry.insert(tk.END, 'Contradiction found in Statement ' + str(statement + 1) + '! Therefore, this is valid.\n')
self.entry.insert(tk.END, 'Contradiction found in Statement ' + str(statement + 1) + '\n')
self.entry.config(state='disabled')
self.start.config(state='disabled')
self.auto.config(state='disabled')
Expand All @@ -241,13 +255,13 @@ def solveTable(self, statements):
else:
statement = self.forceAssignment(statements)
if statement != -1:
toPrint = 'Forced assignment in Statement ' + str(statement + 1)
toPrint = 'Forced assignment in Statement ' + str(statement + 1) + '\n'

# no assignment was forced. check if the statements are complete
else:
if self.isComplete(statements):
self.entry.config(state='normal')
self.entry.insert(tk.END,'\nNo contradiction found! Therefore, this is invalid.\n')
self.entry.insert(tk.END,'\nNo contradiction found!\n')
self.entry.config(state='disabled')
self.start.config(state='disabled')
self.auto.config(state='disabled')
Expand Down Expand Up @@ -342,7 +356,7 @@ def girl_help(self):
self.help_text.grid()
self.help_text.insert("1.0", '''Valid Input Symbols:\nNOT : ~\nAND : &\nOR : |\nCONDITIONAL : ->\nBICONDITIONAL : <->\n
Possible literals are any capital letter\nSeparate premises with newline characters.
The final line will always be assumed to be the conclusion.\nUse the scrollwheel to see next steps that go beyond the box.\n\nFILE IMPORT: Select a txt file to put in the entry box\nGURL HELP: Finds this window (you already did it!)
Denote starting truth values using + for true and = for false. Put these at the start of each expression.\nUse the scrollwheel to see next steps that go beyond the box.\n\nFILE IMPORT: Select a txt file to put in the entry box\nGURL HELP: Finds this window (you already did it!)
START: Press start after inputing premises and conclusion to begin.\nNEXT: Procedes to the next step.\nAUTO-COMPLETE: Automatically displays all steps.
RESET: Sets the program to its default state, removing any current text.\nDo this especially when in the middle of a proof.\nSAVE: Saves anything in the text box to a desired location as a txt file.''')
self.help_text.config(state="disabled")
Expand Down Expand Up @@ -394,6 +408,7 @@ def __init__(self, first=''):
self.second = ''
self.operation = ''
self._assignment = ''
self.starting_value = ''

@property
def assignment(self):
Expand Down
8 changes: 4 additions & 4 deletions inputs/3premises-2.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A & (B & C)
A -> (D | E)
B -> (D | F)
D | (E & F)
+A & (B & C)
+A -> (D | E)
+B -> (D | F)
=D | (E & F)
8 changes: 4 additions & 4 deletions inputs/3premises.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A | (B & C)
A -> D
D -> C
C
+A | (B & C)
+A -> D
+D -> C
=C
6 changes: 3 additions & 3 deletions inputs/error.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
~M
~~~C
V & m
+~M
=~~~C
+V & m
L ~|
4 changes: 2 additions & 2 deletions inputs/invalid.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(B -> A)
A -> B
+(B -> A)
+A -> B
4 changes: 2 additions & 2 deletions inputs/noforcedmove.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(A & B) | C
C -> (A <-> B)
+(A & B) | C
=C -> (A <-> B)
8 changes: 4 additions & 4 deletions inputs/not.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
~(A | B) -> ~(C & D)
(A & C) -> E
A & ~E
~(D | E)
+~(A | B) -> ~(C & D)
+(A & C) -> E
+A & ~E
+~(D | E)
6 changes: 3 additions & 3 deletions inputs/not2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
~(A | ~B) <-> ~C
C
B -> (A | D)
=~(A | ~B) <-> ~C
=C
=B -> (A | D)
4 changes: 2 additions & 2 deletions inputs/simpleinput.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
A & B
A | B
+A & B
=A | B
8 changes: 4 additions & 4 deletions inputs/simplenot.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
~A | B
A | C
~D -> ~C
B | D
=~A | B
=A | C
=~D -> ~C
+B | D
4 changes: 2 additions & 2 deletions inputs/test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
A & B
A | C
=A & B
=A | C
4 changes: 2 additions & 2 deletions inputs/test2.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(B -> C)
A -> B
+(B -> C)
+A -> B

0 comments on commit b519f39

Please sign in to comment.