def test_tictactoe_cax(self): fsm = self.tictactoe() spec = parseATL("'run = circle' -> ['circlep']X 'run = cross'")[0] agents = {atom.value for atom in spec.right.group} phi = evalATL(fsm, spec.right.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cax(fsm, first, agents, phi) #self.show_cex(explanation, spec.right) self.check_cax(fsm, explanation, agents, phi) spec = parseATL("'run = circle' -> ['crossp']X 'board[1] = circle'")[0] agents = {atom.value for atom in spec.right.group} phi = evalATL(fsm, spec.right.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cax(fsm, first, agents, phi) #self.show_cex(explanation, spec.right) self.check_cax(fsm, explanation, agents, phi)
def test_tictactoe_ceu(self): fsm = self.tictactoe() spec = parseATL( "<'circlep'> ['TRUE' U 'winner != circle' & 'run = stop']")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_ceu(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi) spec = parseATL( "<'circlep', 'crossp'> ['TRUE' U 'winner = empty' & 'run = stop']" )[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_ceu(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi)
def test_cardgame_caw(self): fsm = self.cardgame() spec = parseATL("['dealer'][~'lose' W 'win']")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_caw(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi) spec = parseATL("['dealer'][~'lose' W 'step = 3']")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_caw(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi)
def test_cardgame(self): fsm = self.cardgame() self.assertTrue(check(fsm, parseATL("<'dealer'> X 'pcard=Ac'")[0])) self.assertFalse(check(fsm, parseATL("<'dealer'> G ~'win'")[0])) self.assertTrue(check(fsm, parseATL("['player'] X 'pcard=Ac'")[0])) self.assertTrue(check(fsm, parseATL("['dealer'] F 'win'")[0])) self.assertTrue(check(fsm, parseATL("<'player'> F 'win'")[0]))
def test_tictactoe(self): fsm = self.tictactoe() self.assertTrue(check(fsm, parseATL( "'run = circle' -> <'circlep'> X 'board[1] = circle'")[0])) self.assertTrue(check(fsm, parseATL( "'run = circle' -> ['circlep'] X 'run = cross'")[0])) self.assertTrue(check(fsm, parseATL( "<'circlep'> F 'run = stop'")[0])) self.assertTrue(check(fsm, parseATL( "<'circlep', 'crossp'> G 'winner = empty'")[0])) self.assertTrue(check(fsm, parseATL( "<'circlep'> G 'winner != circle'")[0]))
def test_small(self): fsm = self.small() self.assertFalse( check(fsm, parseATL("'run = p1' -> <'player1'> X 'FALSE'")[0])) self.assertTrue( check(fsm, parseATL("'run = p1' -> <'player1'> G ~'winner = p1'")[0])) self.assertTrue( check( fsm, parseATL("'run = p1' -> <'player1'> X 'board[1] = circle'") [0])) self.assertTrue( check( fsm, parseATL("'run = p1' -> <'player1'> X 'board[1] = cross'")[0])) self.assertTrue( check(fsm, parseATL("'run = p1' -> ['player2'] F 'winner = p1'")[0])) self.assertTrue( check(fsm, parseATL("'run = p1' -> <'player1'> F 'winner = p1'")[0])) self.assertTrue( check(fsm, parseATL("'run = p1' -> <'player1'> F 'winner = p2'")[0])) self.assertFalse( check(fsm, parseATL("'run = p2' -> <'player1'> F 'winner = p2'")[0]))
def test_cardgame_cax(self): fsm = self.cardgame() spec = parseATL("['player']X 'pcard = Ac'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cax(fsm, first, agents, evalATL(fsm, spec.child)) #self.show_cex(explanation, spec) self.check_cax(fsm, explanation, agents, phi) spec = parseATL("['dealer']X 'win'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) # False since we do not want initial states #self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = (sat & eval_simple_expression(fsm, 'step = 1') & fsm.reachable_states) first = fsm.pick_one_state(initsat) explanation = explain_cax(fsm, first, agents, evalATL(fsm, spec.child)) #self.show_cex(explanation, spec) self.check_cax(fsm, explanation, agents, phi)
def test_tictactoe(self): fsm = self.tictactoe() self.assertTrue( check( fsm, parseATL("'run = circle' -> <'circlep'> X 'board[1] = circle'") [0])) self.assertTrue( check( fsm, parseATL("'run = circle' -> ['circlep'] X 'run = cross'")[0])) self.assertTrue(check(fsm, parseATL("<'circlep'> F 'run = stop'")[0])) self.assertTrue( check(fsm, parseATL("<'circlep', 'crossp'> G 'winner = empty'")[0])) self.assertTrue( check(fsm, parseATL("<'circlep'> G 'winner != circle'")[0]))
def test_cardgame_cag(self): fsm = self.cardgame() spec = parseATL("['dealer'] G ~'win'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cag(fsm, first, agents, phi) self.check_ceg(fsm, explanation, agents, phi)
def test_tictactoe_cag(self): fsm = self.tictactoe() spec = parseATL("['circlep'] G 'winner != circle'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cag(fsm, first, agents, phi) self.check_ceg(fsm, explanation, agents, phi)
def test_transmission_cau(self): fsm = self.transmission() spec = parseATL("['transmitter']['TRUE' U ~'received']")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cau(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi)
def test_transmission_cax(self): fsm = self.transmission() spec = parseATL("['sender']X ~'received'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cax(fsm, first, agents, phi) #self.show_cex(explanation, spec) self.check_cax(fsm, explanation, agents, phi)
def test_transmission_cag(self): fsm = self.transmission() spec = parseATL("['sender'] G ~'received'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cag(fsm, first, agents, phi) self.check_ceg(fsm, explanation, agents, phi) spec = parseATL("['transmitter'] G ~'received'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cag(fsm, first, agents, phi) self.check_ceg(fsm, explanation, agents, phi)
def test_cardgame_ceu(self): fsm = self.cardgame() spec = parseATL("<'player'>['TRUE' U 'win']")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_ceu(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi)
def test_cardgame_new(self): fsm = self.cardgamenew() self.assertTrue(check(fsm, parseATL("<'dealer'>F 'player.state=1'")[0])) self.assertTrue(check(fsm, parseATL("<'dealer'>F 'player.state=2'")[0])) self.assertTrue(check(fsm, parseATL("<'dealer'>F 'player.state=3'")[0])) self.assertTrue(check(fsm, parseATL("['player']F 'player.state=1'")[0])) self.assertTrue(check(fsm, parseATL("<'player'>F 'playerwins'")[0])) self.assertFalse(check(fsm, parseATL("<'dealer'>F 'dealerwins'")[0]))
def test_tictactoe_ceu(self): fsm = self.tictactoe() spec = parseATL("<'circlep'> ['TRUE' U 'winner != circle' & 'run = stop']")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_ceu(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi) spec = parseATL("<'circlep', 'crossp'> ['TRUE' U 'winner = empty' & 'run = stop']")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_ceu(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi)
def test_cardgame_cex(self): fsm = self.cardgame() spec = parseATL("<'dealer'>X 'pcard = Ac'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cex(fsm, first, agents, evalATL(fsm, spec.child)) #self.show_cex(explanation, spec) self.check_cex(fsm, explanation, agents, phi) spec = parseATL("<'player'>X 'step = 1'")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.child) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cex(fsm, first, agents, evalATL(fsm, spec.child)) #self.show_cex(explanation, spec) self.check_cex(fsm, explanation, agents, phi)
def test_tictactoe_cau(self): fsm = self.tictactoe() spec = parseATL("['circlep']['TRUE' U ('winner != circle' & 'run = stop')]")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) self.assertEqual(sat, fp(lambda Y : psi | (phi & fsm.pre_nstrat(Y, agents)), BDD.false(fsm.bddEnc.DDmanager))) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cau(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi)
def test_transmission(self): fsm = self.transmission() self.assertFalse(check(fsm, parseATL("<'sender'> F 'received'")[0])) self.assertTrue(check(fsm, parseATL( "<'transmitter'> G ~'received'")[0])) self.assertFalse(check(fsm, parseATL("<'sender'> X 'received'")[0])) self.assertTrue(check(fsm, parseATL( "<'transmitter'> X ~'received'")[0])) self.assertFalse(check(fsm, parseATL( "<'transmitter'> F 'received'")[0])) self.assertTrue(check(fsm, parseATL("<'sender'> G ~'received'")[0]))
def test_small(self): fsm = self.small() self.assertFalse(check(fsm, parseATL( "'run = p1' -> <'player1'> X 'FALSE'")[0])) self.assertTrue(check(fsm, parseATL( "'run = p1' -> <'player1'> G ~'winner = p1'")[0])) self.assertTrue(check(fsm, parseATL( "'run = p1' -> <'player1'> X 'board[1] = circle'")[0])) self.assertTrue(check(fsm, parseATL( "'run = p1' -> <'player1'> X 'board[1] = cross'")[0])) self.assertTrue(check(fsm, parseATL( "'run = p1' -> ['player2'] F 'winner = p1'")[0])) self.assertTrue(check(fsm, parseATL( "'run = p1' -> <'player1'> F 'winner = p1'")[0])) self.assertTrue(check(fsm, parseATL( "'run = p1' -> <'player1'> F 'winner = p2'")[0])) self.assertFalse(check(fsm, parseATL( "'run = p2' -> <'player1'> F 'winner = p2'")[0]))
def test_tictactoe_cau(self): fsm = self.tictactoe() spec = parseATL( "['circlep']['TRUE' U ('winner != circle' & 'run = stop')]")[0] agents = {atom.value for atom in spec.group} phi = evalATL(fsm, spec.left) psi = evalATL(fsm, spec.right) self.assertTrue(check(fsm, spec)) sat = evalATL(fsm, spec) self.assertEqual( sat, fp(lambda Y: psi | (phi & fsm.pre_nstrat(Y, agents)), BDD.false(fsm.bddEnc.DDmanager))) initsat = sat & fsm.init first = fsm.pick_one_state(initsat) explanation = explain_cau(fsm, first, agents, phi, psi) self.check_ceu(fsm, explanation, agents, phi, psi)
def test_transmission(self): fsm = self.transmission() self.assertFalse(check(fsm, parseATL("<'sender'> F 'received'")[0])) self.assertTrue( check(fsm, parseATL("<'transmitter'> G ~'received'")[0])) self.assertFalse(check(fsm, parseATL("<'sender'> X 'received'")[0])) self.assertTrue( check(fsm, parseATL("<'transmitter'> X ~'received'")[0])) self.assertFalse( check(fsm, parseATL("<'transmitter'> F 'received'")[0])) self.assertTrue(check(fsm, parseATL("<'sender'> G ~'received'")[0]))