Beispiel #1
0
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)
Beispiel #2
0
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()
Beispiel #3
0
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()
Beispiel #4
0
    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
Beispiel #5
0
 def is_safe(self):
     # prove there are no unsafe enactments
     return not consistent(self.unsafe)
Beispiel #6
0
 def is_live(self):
     return self.is_enactable() and not consistent(self.dead_end)
Beispiel #7
0
 def is_enactable(self):
     if self.enactable is None:
         self.enactable = consistent(
             logic.And(self.correct, self.enactability))
     return self.enactable
Beispiel #8
0
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))
Beispiel #9
0
def test_consistent():
    # check basic consistency
    assert consistent(var('a'), var('b'), sequential('a', 'b'))
Beispiel #10
0
def test_reception(Bid, B):
    assert precedence.consistent(Bid.reception)
Beispiel #11
0
def test_reception():
    #assert reception(Bid, B) is None
    assert precedence.consistent(reception(Bid, B))