-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_10_02.py
39 lines (37 loc) · 929 Bytes
/
main_10_02.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
class HashTable():
def __init__(self):
self.H = []
def insert(self,i,l,h):
self.H.append((i,l,h))
def contains(self,i,l,h):
if (i,l,h) in self.H:
return True
else:
return False
def lookup(self,i,l,h):
return (i,l,h)
class ROBDD():
def __init__(self,expr):
self.H = HashTable()
self.expr = expr
def make(self,i,l,h):
if l == h:
return l
elif self.H.contains(i,l,h):
return self.H.lookup(i,l,h)
else:
self.H.insert(i,l,h)
return self.H.lookup(i,l,h)
def build(self):
self.build_(self.expr[0],1)
'''
TODO: Fix this
'''
def build_(self,term,i):
if i>len(self.expr):
if self.expr[-1] == 0:
return 0
else:
return 1
else:
return make(i,build_())