def test_composition_pointers(): goal_list = [ CGTGoal(name="goal_1", contracts=[BooleanContract(["a"], ["b"])]), CGTGoal(name="goal_2", contracts=[BooleanContract(["c"], ["d"])]) ] cgt = composition(goal_list, name="goal_composed", description="description of goal_composed") new_goal = CGTGoal(name="goal_2", contracts=[BooleanContract(["e"], ["f"])]) print(cgt) print(goal_list[0]) goal_list[0] = composition([goal_list[0], new_goal]) print(goal_list[0]) print(cgt)
def consolidate_bottom_up(self): """It recursivly re-perfom composition and conjunction and refinement operations up to the rood node""" from src.goals.operations import conjunction, composition if self.connected_to is not None: node = self.connected_to refined_by, refined_with = node.get_refinement_by() if refined_with == "CONJUNCTION": conjunction(refined_by, connect_to=node) elif refined_with == "COMPOSITION": composition(refined_by, connect_to=node) elif refined_with == "REFINEMENT": node.refine_by(refined_by, consolidate=False) else: raise Exception(refined_with + " consolidation not supported") node.consolidate_bottom_up() else: return
def test_two_contracts_composition(): goal_list = [ CGTGoal(name="goal_1", contracts=[BooleanContract(["a"], ["b"])]), CGTGoal(name="goal_2", contracts=[BooleanContract(["c"], ["d"])]) ] goal_composed = composition(goal_list, name="goal_composed", description="description of goal_composed") print(goal_composed)
def test_three_contracts_composition(): goal_list = [ CGTGoal(name="goal_1", contracts=[BooleanContract(["a"], ["b"])]), CGTGoal(name="goal_2", contracts=[BooleanContract(["c"], ["d"])]), CGTGoal(name="goal_3", contracts=[BooleanContract(["e"], ["f"])]) ] goal_composed = composition(goal_list, name="goal_composed", description="description of goal_composed") print(goal_composed) assert str(goal_composed.get_ltl_assumptions()) == "((a & c) & e)"