Question: Logical functions and laws using conditionalsTASK: Read and modify code acordingly [ 4 7 ] : # Logical functionsdef implies ( p , q )

Logical functions and laws using conditionalsTASK: Read and modify code acordingly[47]: # Logical functionsdef implies(p, q):return not p or qdef contrapositive(p, q):return implies(not q, not p)def converse(p, q):return implies(q, p)def inverse(p, q):return implies(not p, not q)def biconditional(p, q):return p == qdef xor(p,q):return (p or q) and (not (p and q))# Logical equivalencesdef distributive(p, q, r):return implies(p or q, r)==(implies(p, r) and implies(q, r))def exportation(p, q, r):return implies(p and q, r)== implies(p, implies(q, r))def reduction(p, q):return not implies(p, q)==(p and not q)def equivalence(p,q):return biconditional(p,q)==(not xor(p,q))def truthTable():# Columns1 # TASK: Modify each column as required for your compound statementcol1= 'p'col2= 'q'col3= 'r'col4='p q'col5='(p q) r'col6='p r'col7='q r'col8='(p r)(q r)'print(f'{col1}\t{col2}\t{col3}\t{col4}\t{col5}\t{col6}\t{col7}\t\t{col8}')print('-'*90)# Iteration of proposition valuesfor p in [True, False]:for q in [True, False]:for r in [True, False]:# Columns# TASK: Modify each column as required for your compoundstatementcol1= pcol2= qcol3= rcol4= p or qcol5= implies((p or q), r)col6= implies(p,r)col7= implies(q,r)col8= implies(p,r) and implies(q,r)print(f'{col1}\t{col2}\t{col3}\t{col4}\t{col5}\t\t{col6}\t{col7}\t\t{col8}')truthTable()p q r p q (p q) r p r q r (p r)(q r)------------------------------------------------------------------------------------------True True True True True True True TrueTrue True False True False False False FalseTrue False True True True True True TrueTrue False False True False False True FalseFalse True True True True True True TrueFalse True False True False True False FalseFalse False True False True True True TrueFalse False False False True True True TrueTesting each logic function[62]: # Task: Modify values for p and q# and try each logical function and logical equivalence# Example:p = Trueq = True# Example:print((not xor(p,q)))print( biconditional(p,q))TrueTrue1.23. Compound statements using conditionals in English[39]: def proposition_to_string(p, q):prop = f"If {p}, then {q}."return prop# TASK: Replace p and q for another compound statementdef main():p ="it rains"q = "the ground is wet"print("Original Proposition: ", proposition_to_string(p, q))p_inv ="it does not rain"q_inv = "the ground is not wet"print("Inverse: ", proposition_to_string(p_inv, q_inv))print("Converse: ", proposition_to_string(q, p))print("Contrapositive: ", proposition_to_string(q_inv, p_inv))main()Original Proposition: If it rains, then the ground is wet.Inverse: If it does not rain, then the ground is not wet.Converse: If the ground is wet, then it rains.Contrapositive: If the ground is not wet, then it does not rain.1.34. Solve some of the true tables on step 1 by hand

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!