Question: [EC1-3] ( theorems.py ) Because there are only 4 different values True , False for each of two bool variables A , B , you
[EC1-3] (theorems.py) Because there are only 4 different values True, False for each of two bool variables A, B, you can verify the following Boolean identities by substituting each of the four possible values (A,B) into the identity, then printing out the entire expression:
A and (A or B) == A (Covering Theorem 1: cover_1(A,B))
A or (A and B) == A (Covering Theorem 2: cover_2(A,B))
(A and B) or (A and not B) == A (Combining Theorem 1: combine_1(A,B))
(A or B) and (A or not B) == A (Combining Theorem 2: combine_2(A,B))
not (A or B) == (not A) and (not B) (De Morgan's Theorem 1: morgan_1(A,B))
not (A and B) == (not A) or (not B) (De Morgan's Theorem 2: morgan_2(A,B))
If the identities are correct, you should get an output of True in each of the four cases.
Do so by writing a Python program that does this. First, create Boolean functions for each of the above 6 theorems, with names and parameters as shown. Within the function body of each, return the value obtained by evaluating the given expression. Then write a for loop that generates each of the four possible bool value combinations for (A,B). (We'll talk about several ways of doing this within class.) Within your loop body, print out the value returned from calling each of the above 6 functions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
