-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram2.py
141 lines (112 loc) · 4.17 KB
/
Program2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
def q1(p,q,r):
return (not p or q) or (not q or r)
def q2(p,q,r):
return (not p or q) and (not q or r)
def q3(p,q,r):
return (not((not p or q) and (not q or r)) or (not p or q))
def q4(p,q,r):
return(not((p or q)and(not p or r)) or (q or r))
def q5(p,q,r):
return(not((p or q) and (not p or q) and (not q or r)) or r)
def tauto(q1):
return
print(" q1 ")
print("------------------------------------------------------------------")
print("| p | q | r | a |")
print("------------------------------------------------------------------")
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q1(p,q,r)
print('|','\t',p,'\t','|','\t',q,'\t','|','\t',r,'\t','|','\t',a,'\t','|')
print("------------------------------------------------------------------")
s=True
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q1(p,q,r)
s= s and a
if s == True:
print('q1 is a Tautology')
else:
print("q2 is not a Tautology")
print(" q2 ")
print("------------------------------------------------------------------")
print("| p | q | r | a |")
print("------------------------------------------------------------------")
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q2(p,q,r)
print('|','\t',p,'\t','|','\t',q,'\t','|','\t',r,'\t','|','\t',a,'\t','|')
print("------------------------------------------------------------------")
s2=True
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q2(p,q,r)
s2= s2 and a
if s2 == True:
print('q2 is a Tautology')
else:
print("q2 is not a Tautology")
print(" q3 ")
print("------------------------------------------------------------------")
print("| p | q | r | a |")
print("------------------------------------------------------------------")
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q3(p,q,r)
print('|','\t',p,'\t','|','\t',q,'\t','|','\t',r,'\t','|','\t',a,'\t','|')
print("------------------------------------------------------------------")
s3=True
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q3(p,q,r)
s3= s3 and a
if s3 == True:
print('q3 is a Tautology')
else:
print("q3 is not a Tautology")
print(" q4 ")
print("------------------------------------------------------------------")
print("| p | q | r | a |")
print("------------------------------------------------------------------")
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q4(p,q,r)
print('|','\t',p,'\t','|','\t',q,'\t','|','\t',r,'\t','|','\t',a,'\t','|')
print("------------------------------------------------------------------")
s4=True
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q4(p,q,r)
s4= s4 and a
if s4 == True:
print('q4 is a Tautology')
else:
print("q2 is not a Tautology")
print(" q5 ")
print("------------------------------------------------------------------")
print("| p | q | r | a |")
print("------------------------------------------------------------------")
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q5(p,q,r)
print('|','\t',p,'\t','|','\t',q,'\t','|','\t',r,'\t','|','\t',a,'\t','|')
print("------------------------------------------------------------------")
s5=True
for p in [True , False]:
for q in [True , False]:
for r in [True,False]:
a=q5(p,q,r)
s5= s5 and a
if s5 == True:
print('q5 is a Tautology')
else:
print("q5 is not a Tautology")