def lit2bdd(self, lit): """ Convert AIGER lit into BDD """ # query cache if lit in self.lit_to_bdd: return self.lit_to_bdd[lit] # get stripped lit stripped_lit = strip_lit(lit) (intput, latch, and_gate) = self.get_lit_type(stripped_lit) # is it an input, latch, gate or constant if intput or latch: result = BDD(stripped_lit) elif and_gate: result = (self.lit2bdd(and_gate.rhs0) & self.lit2bdd(and_gate.rhs1)) else: # 0 literal, 1 literal and errors result = BDD.false() # cache result self.lit_to_bdd[stripped_lit] = result self.bdd_to_lit[result] = stripped_lit # check for negation if lit_is_negated(lit): result = ~result self.lit_to_bdd[lit] = result self.bdd_to_lit[result] = lit return result
def lit2bdd(self, lit): """ Convert AIGER lit into BDD """ # query cache if lit in self.lit_to_bdd: return self.lit_to_bdd[lit] # get stripped lit stripped_lit = strip_lit(lit) (intput, latch, and_gate) = self.get_lit_type(stripped_lit) # is it an input, latch, gate or constant if intput or latch: result = BDD(stripped_lit) elif and_gate: result = (self.lit2bdd(and_gate.rhs0) & self.lit2bdd(and_gate.rhs1)) else: # 0 literal, 1 literal and errors result = BDD.false() # cache result self.lit_to_bdd[stripped_lit] = result self.bdd_to_lit[result] = stripped_lit # check for negation if lit_is_negated(lit): result = ~result self.lit_to_bdd[lit] = result self.bdd_to_lit[result] = lit return result
def upost(self, q): assert isinstance(q, BDD) if q in self.succ_cache: return iter(self.succ_cache[q]) A = BDD.true() M = set() while A != BDD.false(): a = A.get_one_minterm(self.uinputs) trans = BDD.make_cube( imap( lambda x: BDD.make_eq( BDD(self.aig.get_primed_var(x.lit)), self.aig.lit2bdd(x.next).and_abstract( q, self.latch_cube)), self.aig.iterate_latches())) lhs = trans & a rhs = self.aig.prime_all_inputs_in_bdd(trans) simd = BDD.make_impl(lhs, rhs).univ_abstract(self.platch_cube)\ .exist_abstract(self.pcinputs_cube)\ .univ_abstract(self.cinputs_cube) simd = self.aig.unprime_all_inputs_in_bdd(simd) A &= ~simd Mp = set() for m in M: if not (BDD.make_impl(m, simd) == BDD.true()): Mp.add(m) M = Mp M.add(a) log.DBG_MSG("Upost |M| = " + str(len(M))) self.succ_cache[q] = map(lambda x: (q, x), M) return iter(self.succ_cache[q])
def upost(self, q): assert isinstance(q, BDD) if q in self.succ_cache: return iter(self.succ_cache[q]) A = BDD.true() M = set() while A != BDD.false(): a = A.get_one_minterm(self.uinputs) trans = BDD.make_cube( imap(lambda x: BDD.make_eq(BDD(self.aig.get_primed_var(x.lit)), self.aig.lit2bdd(x.next) .and_abstract(q, self.latch_cube)), self.aig.iterate_latches())) lhs = trans & a rhs = self.aig.prime_all_inputs_in_bdd(trans) simd = BDD.make_impl(lhs, rhs).univ_abstract(self.platch_cube)\ .exist_abstract(self.pcinputs_cube)\ .univ_abstract(self.cinputs_cube) simd = self.aig.unprime_all_inputs_in_bdd(simd) A &= ~simd Mp = set() for m in M: if not (BDD.make_impl(m, simd) == BDD.true()): Mp.add(m) M = Mp M.add(a) log.DBG_MSG("Upost |M| = " + str(len(M))) self.succ_cache[q] = map(lambda x: (q, x), M) return iter(self.succ_cache[q])
def cpost(self, s): assert isinstance(s, tuple) q = s[0] au = s[1] if s in self.succ_cache: L = self.succ_cache[s] else: L = BDD.make_cube( imap(lambda x: BDD.make_eq(BDD(x.lit), self.aig.lit2bdd(x.next) .and_abstract(q & au, self.latch_cube & self.uinputs_cube)), self.aig.iterate_latches()))\ .exist_abstract(self.cinputs_cube) self.succ_cache[s] = L M = set() while L != BDD.false(): l = L.get_one_minterm(self.latches) L &= ~l self.Venv[l] = True M.add(l) log.DBG_MSG("Cpost |M| = " + str(len(M))) return iter(M)
def cpost(self, s): assert isinstance(s, tuple) q = s[0] au = s[1] if s in self.succ_cache: L = self.succ_cache[s] else: L = BDD.make_cube( imap(lambda x: BDD.make_eq(BDD(x.lit), self.aig.lit2bdd(x.next) .and_abstract(q & au, self.latch_cube & self.uinputs_cube)), self.aig.iterate_latches()))\ .exist_abstract(self.cinputs_cube) self.succ_cache[s] = L M = set() while L != BDD.false(): l = L.get_one_minterm(self.latches) L &= ~l self.Venv[l] = True M.add(l) log.DBG_MSG("Cpost |M| = " + str(len(M))) return iter(M)