def test_implication(self): var_node_1 = Variable('req', '', 'output') var_node_2 = Variable('gnt', '', 'output') add_node = Implies(var_node_1, var_node_2) pastifier = STLPastifier() add_node.accept(pastifier) new_node = pastifier.pastify(add_node) self.assertEqual('(req)->(gnt)', new_node.name, 'Implication pastification assertion')
def test_complex_mixed_2(self): var_node_1 = Variable('req', '', 'output') var_node_2 = Variable('gnt', '', 'output') ev_node = TimedEventually(var_node_1, 5, 6) once_node = TimedOnce(var_node_2, 1, 2) alw_node = TimedAlways(once_node, 3, 3) add_node = Implies(ev_node, alw_node) add_node.horizon = 6 pastifier = STLPastifier() add_node.accept(pastifier) new_node = pastifier.pastify(add_node) self.assertEqual('(once[0,1](req))->(once[1,2](once[3,3](gnt)))', new_node.name, 'Complex pastification assertion')
def test_complex_bounded_future_2(self): var_node_1 = Variable('req', '', 'output') var_node_2 = Variable('gnt', '', 'output') var_node_3 = Variable('ack', '', 'output') until_node = TimedUntil(var_node_1, var_node_2, 1, 2) ev_node = TimedEventually(var_node_3, 0, 6) add_node = Implies(until_node, ev_node) add_node.horizon = 6 pastifier = STLPastifier() add_node.accept(pastifier) new_node = pastifier.pastify(add_node) self.assertEqual('((once[4,4](req))precedes[1,2](once[4,4](gnt)))->(once[0,6](ack))', new_node.name, 'Complex pastification assertion')
def test_complex_bounded_future_1(self): var_node_1 = Variable('req', '', 'output') var_node_2 = Variable('gnt', '', 'output') cnt_node_1 = Constant(3) cnt_node_2 = Constant(3) pd_node_1 = Predicate(var_node_1, cnt_node_1, StlComparisonOperator.GEQ) pd_node_2 = Predicate(var_node_2, cnt_node_2, StlComparisonOperator.GEQ) rise_node = Rise(pd_node_1) hist_node = TimedAlways(pd_node_2, 3, 4) once_node = TimedEventually(hist_node, 1, 2) add_node = Implies(rise_node, once_node) add_node.horizon = 6 pastifier = STLPastifier() add_node.accept(pastifier) new_node = pastifier.pastify(add_node) self.assertEqual('(rise((once[6,6](req))>=(3)))->(once[0,1](historically[0,1]((gnt)>=(3))))', new_node.name, 'Complex pastification assertion')
def visitExprImplies(self, ctx): child1 = self.visit(ctx.expression(0)) child2 = self.visit(ctx.expression(1)) node = Implies(child1, child2) node.horizon = max(child1.horizon, child2.horizon) return node
def visitImplies(self, element, args): child1_node = self.visit(element.children[0], args) child2_node = self.visit(element.children[1], args) node = Implies(child1_node, child2_node) return node