from logic import TruthTable prop1, prop2 = input("Enter proposition 1: "), input("Enter proposition 2: ") table1 = TruthTable([prop1]) table2 = TruthTable([prop2]) if table1.table == table2.table: print("The propositions are equivalent") else: print("The propositions are not equivalent")
from logic import TruthTable tables = input("Enter a proposition: ") cont = False #get all of the inputs while input("\nWould you like to enter more (Y/N): ") in ['y', 'Y']: tables = tables + " and " + input("\nEnter a proposition: ") table = TruthTable([tables]) print("\nYour propositions contain the following variables: ", table.vars) meanings = [] for i in range(len(table.vars)): print("\nEnter the meaning of", table.vars[i], ":", end=" ") meanings.append(input()) count = 0 for i in range(len(table.table)): if table.table[i][len(table.table[0]) - 1][0] == 1: cont = True break count = count + 1 #table.display() #print("consistant on index : ", count) #print(table.table[count][0]) if cont == True: print("\nYour description is consistent when: \n")
from logic import TruthTable myTable = TruthTable(['p', 'q', 'r']['p -> q', 'q -> r', ' p -> r']) myTable.display() myTable.latex()
while i == 1: more = input("Would you like to enter more (Y/N): ") if more == "N" or more == "n": i = 0 else: if more == "Y" or more == "y": proposition2 = input("Enter a proposition: ") proposition.append(proposition2) i = 1 check = len(proposition) if check == 5: myTable = TruthTable([ proposition[0], proposition[1], proposition[2], proposition[3], proposition[4] ]) if check == 4: myTable = TruthTable( [proposition[0], proposition[1], proposition[2], proposition[3]]) if check == 3: myTable = TruthTable([proposition[0], proposition[1], proposition[2]]) if check == 2: myTable = TruthTable([proposition[0], proposition[1]]) if check == 1: myTable = TruthTable([proposition[0]]) #myTable.display() #print(myTable.table) result = 0 for row in myTable.table:
from logic import TruthTable meaningList = [] List = [] end = False while not end: propVar = raw_input("Enter a proposition:") List.append(propVar) more = raw_input("Would you like to enter more?(Y/N):") if more == 'N': end = True propTable = TruthTable(List) consistent = False for i in range(len(propTable.table)): if propTable.table[i][1] == [1] * len(List): # double check it consistent = True break if consistent: print("Your program uses propositional variable " + str(propTable.vars)) for i in range(len(propTable.vars)): meaning = raw_input("Enter the meaning of " + propTable.vars[i] + ": ") meaningList.append(meaning) print('Your description is consistent') for i in meaningList: for j in i: if (propTable.table[0][0][0] != propTable.table[0][0][1]):
from logic import TruthTable yesTable = TruthTable(['p', 'q', 'r'], ['a -> b']) yesTable.display() print ""
from logic import TruthTable modusPonens = TruthTable(['p', 'q'], ['((p -> q) and p) -> q']) modusTollens = TruthTable(['p', 'q'], ['(-q and (p -> q)) -> -p']) hypoSyllogism = TruthTable(['p', 'q', 'r'], ['((p -> q) and (q -> r)) -> (p -> r)']) disSyllogism = TruthTable(['p', 'q'], ['((p or q) and -p) -> q']) addition = TruthTable(['p', 'q'], ['p -> (p or q)']) simplification = TruthTable(['p', 'q'], ['(p and q) -> p']) conjunction = TruthTable(['p', 'q'], ['((p) and (q)) -> (p and q)']) resolution = TruthTable(['p', 'q', 'r'], ['((p or q) and (-p or r)) -> (q or r)']) print("Modus Ponens verification:") modusPonens.display() print("\nModus Tollens verification:") modusTollens.display() print("\nHypothetical Syllogism verification:") hypoSyllogism.display() print("\nDisjunctive Syllogism verification:") disSyllogism.display() print("\nAddition verification:") addition.display() print("\nSimplification verification:") simplification.display() print("\nConjunction verification:") conjunction.display() print("\nResolution verification:") resolution.display()
from logic import TruthTable NextTable = TruthTable(['q -> r' ,'p -> (q -> r)']) NextTable.display() NextTable.latex() TheTable = TruthTable(['p and q','(p and q) -> r']) TheTable.display() TheTable.latex() NoTable = TruthTable(['q -> r', 'p -> (q -> r)']) NoTable.display() NoTable.latex() YesTable = TruthTable(['p -> q', '(p -> q) -> r']) YesTable.display() YesTable.latex()
#Recieved help from roommate from logic import TruthTable myTable = TruthTable(['p', 'q'], ['-p']) myTable.display() myTable = TruthTable(['p', 'q'], ['p and q']) myTable.display() myTable = TruthTable(['p', 'q'], ['p or q']) myTable.display() myTable = TruthTable(['p', 'q'], ['p -> q']) myTable.display() myTable = TruthTable(['p', 'q'], ['p <-> q']) myTable.display()
from logic import TruthTable myTable = TruthTable(["a"], ["-a"]) myTable.display() myTable = TruthTable(["a", "b"], ["a and b"]) myTable.display() myTable = TruthTable(["a", "b"], ["a or b"]) myTable.display() myTable = TruthTable(["a", "b"], ["a <-> b"]) myTable.display() myTable = TruthTable(["a", "b"], ["a -> b"]) myTable.display()
from logic import TruthTable FourTable = TruthTable(['p', 'q'], ['p and q', 'p or -q']) FourTable.display() print "" FourTable.latex() print "" FiveTable = TruthTable(['p', 'q'], ['p or q', '-p or -q']) FiveTable.display() print "" FiveTable.latex() print "" SixTable = TruthTable(['p', 'q'], ['p -> q', '-q -> -p']) SixTable.display() print "" SixTable.latex() print "" SevenTable = TruthTable(['p', 'q'], ['p -> q', '-p or q']) SevenTable.display()
from logic import TruthTable proposition1 = input("Enter Proposition 1:\n") proposition2 = input("Enter Proposition 2:\n") myTable1 = TruthTable(['p', 'q'], [proposition1]) myTable2 = TruthTable(['p', 'q'], [proposition2]) print(myTable1.table) print(myTable2.table) if myTable1.table == myTable2.table: print("The Propositions are equivalent.") else: print("The Propositions are not equivalent.")
from logic import TruthTable propOne = input("Enter proposition 1:") propTwo = input("Enter proposition 2:") myTable1 = TruthTable([propOne]) myTable2 = TruthTable([propTwo]) if myTable1.table == myTable2.table: print("The propositions are equivalent") else: print("The propostitions are not equivalent")
from logic import TruthTable pro1 = raw_input("Enter Proposition 1:\n") pro2 = raw_input("Enter Proposition 2:\n") notTable = TruthTable(['p'] , ['-p']) notTable.display() print notTable.table not1Table = TruthTable(['q'] , ['-q']) not1Table.display() print not1Table.table print "" yesTable = TruthTable(['p' , 'q'] , ['p and q']) yesTable.display() print "" ONETable = TruthTable(['p' , 'q'] , ['p or q']) ONETable.display() print "" TWOTable = TruthTable(['p' , 'q'] , ['p -> q']) TWOTable.display() print ""
while(thing != thang): prop.append(raw_input("Enter a Proposition: ")) print "Would you like to enter more (Y/N): " thing = raw_input() #myTable.display() myVars = getVars(prop) description = [] print "Your table uses the variables: ", myVars for x in myVars: print "Enter meaning of ", x ,":" desc = raw_input() description.append(desc) myTable = TruthTable(prop) consist = 0 #print myTable.table isCase = 2 notCase = 2 for x in myTable.table: #print x stringTime = str(x) #print stringTime l = [] for t in stringTime: try: l.append(int(t)) except ValueError: pass
from logic import TruthTable tables = [TruthTable(['-a']), TruthTable(['a and b']), TruthTable(['a or b']), TruthTable(['a -> b']), TruthTable(['a <-> b'])] for i in tables: i.display() print('\n')
def basic(): print("|1 = not a || 2 = not b || 3 = a and b || 4 = b and a |") print("|5 = a or b || 6 = b or a || 7 = a -> b || 8 = b -> a |") print("|9 = a <-> b || 10 = b <-> a |\n") prop = int(raw_input("Choose a proposition: ")) if prop == 1: myTable = TruthTable(['a', 'b'], ['-a']) myTable.display() print("\n") basic() if prop == 2: myTable = TruthTable(['a', 'b'], ['-b']) myTable.display() print("\n") basic() if prop == 3: myTable = TruthTable(['a', 'b'], ['a and b']) myTable.display() print("\n") basic() if prop == 4: myTable = TruthTable(['a', 'b'], ['b and a']) myTable.display() print("\n") basic() if prop == 5: myTable = TruthTable(['a', 'b'], ['a or b']) myTable.display() print("\n") basic() if prop == 6: myTable = TruthTable(['a', 'b'], ['b or a']) myTable.display() print("\n") basic() if prop == 7: myTable = TruthTable(['a', 'b'], ['a -> b']) myTable.display() print("\n") basic() if prop == 8: myTable = TruthTable(['a', 'b'], ['b -> a']) myTable.display() print("\n") basic() if prop == 9: myTable = TruthTable(['a', 'b'], ['a <-> b']) myTable.display() print("\n") basic() if prop == 10: myTable = TruthTable(['a', 'b'], ['b <-> a']) myTable.display() print("\n") basic() else: print("Not a correct prop!\n") basic()
from logic import TruthTable proposition = input("Enter proposition:") proposition2 = input("Enter proposition:") myTable = TruthTable([proposition, proposition2]) myTable.display() print(myTable.table) result = 0 for row in myTable.table: if row[1][0] != row[1][1]: result += 1 if result > 0: print("The propositions are not equivalent") else: print("The propositions are equivalent")
from logic import TruthTable List = [] end = False while not end: propVar = raw_input("Enter a proposition:") List.append(propVar) more = raw_input("Would you like to enter more?(Y/N):") if more == 'N': end = True propTable = TruthTable(List) consistent = False for i in range(len(propTable.table)): if propTable.table[i][1] == [1] * len(List): # double check it consistent = True break if consistent: print('They are consistent') else: print('They are not consistent') propTable.display() #propTable.display() #print(propTable.table) #row print(propTable.table[0]) #column propTable.table[0][1] )
from logic import TruthTable tempList = [] tempList2 = [] boolean = 1 while boolean: prop1 = input('Enter a proposition: ') prop2 = input('Would you like to enter more (Y/N): ') tempList.append(prop1) if prop2 == 'N': boolean = 0 myTable = TruthTable(tempList) print("Your program uses propositional variables " + str(myTable.vars) + ":") for i in myTable.vars: propTemp = input("Enter meaning of " + str(i) + ": ") tempList2.append(propTemp) for i in myTable.table: temp = 0 for j in range(len(tempList)): if i[1][j] == 1: temp = temp + 1 if(temp == len(tempList)): print("Your description is consistent when:") for j in range(len(tempList)): if(i[0][j]==0): print("It is not the case that "+str(tempList2[j])) if(i[0][j]==1):
from logic import TruthTable p = [] y = 'Y' while (y == 'Y'): p1 = raw_input("Enter a propositon:") p.append(p1) y = raw_input("Would you like to enter more [Y/N]: ") myTable = TruthTable(p) print myTable.table p2 = [] for i in myTable.table: p2.append(i[1]) for j in p2: if (j[0] == j[1]): if (j[0] == 0): print("Your description is consistent.") break else: print("Your description is not consistent.") break
from logic import TruthTable prop = input("Enter proposition 1:") prop2 = input("Enter proposition 2:") equal = 1 myTable = TruthTable(['p', 'q'], [prop]) myTable.display() myTable2 = TruthTable(['p', 'q'], [prop2]) myTable2.display() if (myTable.table == myTable2.table): equal = 1 else: equal = 0 if (equal == 1): print("They are equivalent") else: print("They are not equivalent")
props = [] while not stop: p = input('Enter a proposition: ') props.append(p) enter_more = input('Would you like to enter more Y/N: ') if enter_more == 'N': stop = True elif enter_more == 'Y': stop = False else: print('Not a valid input') exit() tt = TruthTable(props) print('Your propositions contain the following variables: ' + str(tt.vars)) meanings =[] for var in tt.vars: m = input('Enter meaning of ' + var + ': ') meanings.append(m) tt.display() is_consistent = False for row in tt.table: var_values = row[0]
from logic import TruthTable myTable = TruthTable(['p or q']) myTable.display() not_a = TruthTable(['-a']) a_and_b = TruthTable(['a and b']) a_or_b = TruthTable(['a or b']) if_a_then_b = TruthTable(['a <-> b']) a_if_and_only_if_b = TruthTable(['a <-> b'])
from logic import TruthTable l = [] enterMore = "Y" while enterMore == "Y": propOne = input("Enter a propositon:") l.append(propOne) enterMore = input("Would you like to enter more (Y/N):") myTable = TruthTable(l) print(myTable.table) l2 = [] for j in myTable.table: l2.append(j[1]) for i in l2: if (i[0] == i[1]): if (i[0] == 0): print("Your description is consistent.") break else: print("Your description is not consistent.") break
from logic import TruthTable myTable = TruthTable(['-a']) myTable2 = TruthTable(['a and b']) myTable3 = TruthTable(['a or b']) myTable4 = TruthTable(['a -> b']) myTable5 = TruthTable(['a <-> b']) myTable.display() myTable2.display() myTable3.display() myTable4.display() myTable5.display()