def test_exhaustive_consistent(): # check basic consistency assert consistent(var('a'), var('b'), sequential('a', 'b')) # see how long a causal loop can be before transitivity stops working for i in range(1, 5): clauses = [sequential(to_char(i), 'a')] + chain(i) assert not consistent(and_(*clauses), exhaustive=True)
def handle_safety(protocol, args): reset_stats() expr = protocol.unsafe violation = consistent(expr) print(" Safe: ", not violation) if args.verbose or args.stats: print(" stats: ", stats) if violation and not args.quiet or args.verbose: print_formula(expr) if violation and not args.quiet: print("\nViolation:") pp.pprint(violation) print()
def handle_liveness(protocol, args): reset_stats() e = protocol.is_enactable() violation = consistent(protocol.dead_end) print(" Live: ", e and not violation) if args.verbose or args.stats: print(" stats: ", stats) if violation and not args.quiet or args.verbose: print_formula(protocol.dead_end) if violation and not args.quiet: print("\n Violation:") pp.pprint(violation) print()
def recursive_property(self, prop, filter=None, verbose=None): for r in self.references: if filter and not filter(r): continue # skip references that do not pass the filter formula = prop(self, r) if verbose: print_formula(formula) s = consistent(formula) if s: # found solution; short circuit return s, formula else: # recurse s, formula = r.recursive_property(prop, filter) if s: return s, formula return None, None
def is_safe(self): # prove there are no unsafe enactments return not consistent(self.unsafe)
def is_live(self): return self.is_enactable() and not consistent(self.dead_end)
def is_enactable(self): if self.enactable is None: self.enactable = consistent( logic.And(self.correct, self.enactability)) return self.enactable
def test_consistent2(): # see how long a causal loop can be before transitivity stops working for i in range(1, 5): clauses = [sequential(to_char(i), 'a')] + chain(i) assert not consistent(and_(*clauses))
def test_consistent(): # check basic consistency assert consistent(var('a'), var('b'), sequential('a', 'b'))
def test_reception(Bid, B): assert precedence.consistent(Bid.reception)
def test_reception(): #assert reception(Bid, B) is None assert precedence.consistent(reception(Bid, B))