-
Notifications
You must be signed in to change notification settings - Fork 30
/
main.py
56 lines (41 loc) · 1.7 KB
/
main.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
"""You can test your functions in this module as in the following code: """
from formula import *
from functions import *
formula1 = Atom('p') # p
formula2 = Atom('q') # q
formula3 = And(formula1, formula2) # (p /\ q)
formula4 = And(Atom('p'), Atom('s')) # (p /\ s)
formula5 = Not(And(Atom('p'), Atom('s'))) # (¬(p /\ s))
formula6 = Or(Not(And(Atom('p'), Atom('s'))), Atom('q')) # ((¬(p /\ s)) v q)
formula7 = Implies(Not(And(Atom('p'), Atom('s'))), And(Atom('q'), Atom('r'))) # ((¬(p /\ s)) -> (q /\ r))
formula8 = Implies(Not(And(Atom('p'), Atom('s'))), And(Atom('q'), Not(And(Atom('p'), Atom('s')))))
# ((¬(p /\ s)) -> (q /\ (¬(p /\ s))))
# formula9 = Not('q')
print(formula1 == formula3)
print(formula1 == formula2)
print(formula3 == And(Atom('p'), Atom('q')))
print('formula1:', formula1)
print('formula2:', formula2)
print('formula3:', formula3)
print('formula4:', formula4)
print('formula5:', formula5)
print('formula6:', formula6)
print('formula7:', formula7)
print('formula8:', formula8)
print('length of formula1:', length(formula1))
print('length of formula3:', length(formula3))
print('length of formula7:', length(formula7))
print('subformulas of formula7:')
print(subformulas(formula7))
for subformula in subformulas(formula7):
print(subformula)
# end for
print('length of formula8:', length(formula8))
print('subformulas of formula8:')
for subformula in subformulas(formula8):
print(subformula)
# end for
# we have shown in class that for all formula A, len(subformulas(A)) <= length(A):
# for example, for formula8:
print('number of subformulas of formula8:', len(subformulas(formula8)))
print('len(subformulas(formula8)) <= length(formula8):', len(subformulas(formula8)) <= length(formula8))