def marking_predicate(self) -> mona.Formula: m = mona.Variable("m") unique_in_component = mona.UniversalFirstOrder( [m], mona.Conjunction([ mona.Disjunction([ mona.Conjunction( [cast(mona.Formula, mona.ElementIn(m, pos))] + [cast(mona.Formula, mona.ElementNotIn(m, neg)) for neg in c.state_variables if neg != pos]) for pos in c.state_variables]) for c in self.system.components])) flow_invariant = mona.PredicateCall("flow_invariant", self.system.state_variables) trap_invariant = mona.PredicateCall("trap_invariant", self.system.state_variables) return mona.PredicateDefinition( "marking", self.system.state_variables, [], mona.Conjunction([ unique_in_component, flow_invariant, trap_invariant, ])).simplify()
def initially_marked_trap_predicate(self) -> mona.Formula: inner = mona.Conjunction([ mona.PredicateCall("trap", self.system.state_variables), mona.PredicateCall("intersects_initial", self.system.state_variables)]) return mona.PredicateDefinition( "initially_marked_trap", self.system.state_variables, [], inner).simplify()
def trap_invariant_predicate(self) -> mona.Formula: trap_states = [mona.Variable(f"T{s}") for s in self.system.states] precondition = mona.PredicateCall("initially_marked_trap", trap_states) postcondition = mona.PredicateCall( "intersection", trap_states + self.system.state_variables) return mona.PredicateDefinition( "trap_invariant", self.system.state_variables, [], mona.UniversalSecondOrder(trap_states, mona.Implication(precondition, postcondition)) ).simplify()
def flow_invariant_predicate(self) -> mona.Formula: flow_states = [mona.Variable(f"F{s}") for s in self.system.states] precondition = mona.PredicateCall( "initially_uniquely_marked_flow", flow_states) postcondition = mona.PredicateCall( "unique_intersection", flow_states + self.system.state_variables) return mona.PredicateDefinition( "flow_invariant", self.system.state_variables, [], mona.UniversalSecondOrder( flow_states, mona.Implication(precondition, postcondition)) ).simplify()
def deadlock_predicate(self) -> mona.Formula: inner = mona.Conjunction( [mona.PredicateCall(f"dead_transition_{number}", self.system.state_variables) for number in range(1, len(self.clauses) + 1)]) return mona.PredicateDefinition( "deadlock", self.system.state_variables, [], inner).simplify()
def as_mona(self): left = self.left.as_mona() right = self.right.as_mona() return mona.PredicateCall("is_next", [left, right])
def as_mona(self): argument = self.argument.as_mona() return mona.PredicateCall("is_last", [argument])
def marking_predicate_call(self) -> mona.Formula: return mona.PredicateCall("marking", self.system.state_variables)
def property_check(self, property_name: str) -> mona.Formula: return mona.PredicateCall(property_name, self.system.state_variables)