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: # Logical functionsdef impliesp q:return not p or qdef contrapositivep q:return impliesnot q not pdef conversep q:return impliesq pdef inversep q:return impliesnot p not qdef biconditionalp q:return p qdef xorpq:return p or q and not p and q# Logical equivalencesdef distributivep q r:return impliesp or q rimpliesp r and impliesq rdef exportationp q r:return impliesp and q r impliesp impliesq rdef reductionp q:return not impliesp qp and not qdef equivalencepq:return biconditionalpqnot xorpqdef truthTable:# Columns # TASK: Modify each column as required for your compound statementcol 'p'col 'q'col 'r'colp q'colp q r'colp r'colq r'colp rq rprintfcoltcoltcoltcoltcoltcoltcolttcolprint# 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 compoundstatementcol pcol qcol rcol p or qcol impliesp or q rcol impliesprcol impliesqrcol impliespr and impliesqrprintfcoltcoltcoltcoltcolttcoltcolttcoltruthTablep q r p q p q r p r q r p rq rTrue 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: # Task: Modify values for p and q# and try each logical function and logical equivalence# Example:p Trueq True# Example:printnot xorpqprint biconditionalpqTrueTrue Compound statements using conditionals in English: def propositiontostringp q:prop fIf p then q"return prop# TASK: Replace p and q for another compound statementdef main:p it rains"q "the ground is wet"printOriginal Proposition: propositiontostringp qpinv it does not rain"qinv "the ground is not wet"printInverse: propositiontostringpinv, qinvprintConverse: propositiontostringq pprintContrapositive: propositiontostringqinv, pinvmainOriginal 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 Solve some of the true tables on step by hand
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
