Beispiel #1
0
    def test_coins(self):
        fsm = self.coins()

        from tools.atlkPO.evalGen import split
        agents = {'a1', 'a2'}
        strats = split(fsm,
                       fsm.protocol(agents) & fsm.reachable_states,
                       agents,
                       semantics='individual')
        self.assertEqual(len(list(strats)), 64)

        self.assertFalse(
            check(fsm,
                  parseATLK("<'a1', 'a2'> F 'result = win'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'a1', 'a2'> F 'result = win'")[0],
                  implem="partialSI",
                  semantics="individual",
                  variant="FS"))

        config.partial.filtering = True
        self.assertFalse(
            check(fsm,
                  parseATLK("<'a1', 'a2'> F 'result = win'")[0],
                  implem="partialSI",
                  semantics="individual",
                  variant="SF"))
        config.partial.filtering = False
    def test_counters_FSF(self):
        fsm = self.counters()

        from tools.atlkPO.evalGen import split

        agents = {"a1", "a2"}
        strats = split(fsm, fsm.protocol(agents) & fsm.reachable_states, agents, semantics="individual")
        self.assertEqual(len(list(strats)), 16)

        self.assertTrue(
            check(
                fsm, parseATLK("<'a1', 'a2'> F 'v1 & v2'")[0], semantics="individual", implem="symbolic", variant="FSF"
            )
        )
        self.assertFalse(
            check(
                fsm,
                parseATLK("<'a1', 'a2'> G '!v1 & !v2'")[0],
                semantics="individual",
                implem="symbolic",
                variant="FSF",
            )
        )
        self.assertTrue(
            check(
                fsm,
                parseATLK("AG('!v1 & !v2' -> <'a1', 'a2'> G '!v1 | !v2')")[0],
                semantics="individual",
                implem="symbolic",
                variant="FSF",
            )
        )
Beispiel #3
0
    def test_counters_FSF(self):
        fsm = self.counters()

        from tools.atlkPO.evalGen import split
        agents = {'a1', 'a2'}
        strats = split(fsm,
                       fsm.protocol(agents) & fsm.reachable_states,
                       agents,
                       semantics='individual')
        self.assertEqual(len(list(strats)), 16)

        config.partial.filtering = True
        self.assertTrue(
            check(fsm,
                  parseATLK("<'a1', 'a2'> F 'v1 & v2'")[0],
                  semantics="individual",
                  implem="partialSI"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'a1', 'a2'> G '!v1 & !v2'")[0],
                  semantics="individual",
                  implem="partialSI"))
        self.assertTrue(
            check(
                fsm,
                parseATLK("AG('!v1 & !v2' -> <'a1', 'a2'> G '!v1 | !v2')")[0],
                semantics="individual",
                implem="partialSI"))
        config.partial.filtering = False
Beispiel #4
0
 def test_fail(self):
     kos = ["", "'test", "A<'test'>H 'q'", "O", "A<'a'>E<'e'>G 'true'",
            "E<'ac'>[A<'ac'>['a' E<'ac'>['b' W 'c'] W 'd'] "
            "U A<'ac'>['e' U 'f']]", "A<'t't'>G 'q'"]
     
     for s in kos:
         with self.assertRaises(ParseException):
             parseATLK(s)
Beispiel #5
0
    def test_cardgame(self):
        fsm = self.cardgame()

        self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0]))
        self.assertFalse(check(fsm, parseATLK("<'dealer'> G ~'win'")[0]))
        self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0]))
        self.assertTrue(check(fsm, parseATLK("['dealer'] F 'win'")[0]))
        self.assertTrue(check(fsm, parseATLK("<'player'> F 'win'")[0]))
Beispiel #6
0
    def test_fail(self):
        kos = [
            "", "'test", "A<'test'>H 'q'", "O", "A<'a'>E<'e'>G 'true'",
            "E<'ac'>[A<'ac'>['a' E<'ac'>['b' W 'c'] W 'd'] "
            "U A<'ac'>['e' U 'f']]", "A<'t't'>G 'q'"
        ]

        for s in kos:
            with self.assertRaises(ParseException):
                parseATLK(s)
Beispiel #7
0
    def test_cardgame_post_fair_improved_symbolic(self):
        fsm = self.cardgame_post_fair()

        self.assertFalse(check(fsm, parseATLK("<'player'> X 'win'")[0], implem="symbolic", variant="FSF"))

        self.assertTrue(
            check(
                fsm, parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0], implem="symbolic", variant="FSF"
            )
        )
    def test_cardgame_post_fair_not_improved(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(
                fsm,
                parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0],
                implem="symbolic",
                semantics="individual",
            )
        )
        self.assertTrue(
            check(
                fsm,
                parseATLK(
                    "AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))"
                )[0],
                implem="symbolic",
                semantics="individual",
            )
        )

        self.assertTrue(
            check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], implem="symbolic", semantics="individual")
        )
        self.assertFalse(check(fsm, parseATLK("['dealer'] F 'win'")[0], implem="symbolic", semantics="individual"))
        self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], implem="symbolic", semantics="individual"))
        self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], implem="symbolic", semantics="individual"))
        self.assertTrue(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], implem="symbolic", semantics="individual"))

        # Player can win
        self.assertTrue(check(fsm, parseATLK("<'player'> F 'win'")[0], implem="symbolic", semantics="individual"))
        # Dealer can avoid fairness
        self.assertTrue(check(fsm, parseATLK("<'dealer'> F 'FALSE'")[0], implem="symbolic", semantics="individual"))
 def test_coins(self):
     fsm = self.coins()
     
     from tools.atlkPO.evalGen import split
     agents = {'a1', 'a2'}
     strats = split(fsm, fsm.protocol(agents) & fsm.reachable_states,
                    agents, semantics='individual')
     self.assertEqual(len(list(strats)), 64)
     
     self.assertFalse(check(fsm, parseATLK("<'a1', 'a2'> F 'result = win'")[0], implem="generatorSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'a1', 'a2'> F 'result = win'")[0], implem="generatorSI", semantics="individual", variant="FSF"))
 def test_counters(self):
     fsm = self.counters()
     
     from tools.atlkPO.evalGen import split
     agents = {'a1', 'a2'}
     strats = split(fsm, fsm.protocol(agents) & fsm.reachable_states,
                    agents, semantics='individual')
     self.assertEqual(len(list(strats)), 16)
     
     self.assertTrue(check(fsm, parseATLK("<'a1', 'a2'> F 'v1 & v2'")[0], implem="generatorSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'a1', 'a2'> G '!v1 & !v2'")[0], implem="generatorSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("AG('!v1 & !v2' -> <'a1', 'a2'> G '!v1 | !v2')")[0], implem="generatorSI", semantics="individual"))
Beispiel #11
0
    def test_cardgame_post_fair_not_improved(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(fsm,
                  parseATLK(
                      "K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(
                fsm,
                parseATLK(
                    "AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))"
                )[0],
                implem="partialSI",
                semantics="individual"))

        self.assertTrue(
            check(fsm,
                  parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("['dealer'] F 'win'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("['player'] X 'pcard=Ac'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'dealer'> X 'pcard=Ac'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'dealer'> G ~'win'")[0],
                  implem="partialSI",
                  semantics="individual"))

        # Player can win
        self.assertTrue(
            check(fsm,
                  parseATLK("<'player'> F 'win'")[0],
                  implem="partialSI",
                  semantics="individual"))
        # Dealer can avoid fairness
        self.assertTrue(
            check(fsm,
                  parseATLK("<'dealer'> F 'FALSE'")[0],
                  implem="partialSI",
                  semantics="individual"))
Beispiel #12
0
    def test_cardgame_post_fair_improved_symbolic(self):
        fsm = self.cardgame_post_fair()

        self.assertFalse(
            check(fsm,
                  parseATLK("<'player'> X 'win'")[0],
                  implem="symbolic",
                  variant="FSF"))

        self.assertTrue(
            check(fsm,
                  parseATLK(
                      "K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #13
0
    def test_cardgame_post_fair_improved_symbolic6(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(fsm,
                  parseATLK("<'dealer'> G ~'win'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #14
0
    def test_cardgame_post_fair_improved_symbolic4(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(fsm,
                  parseATLK("['player'] X 'pcard=Ac'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #15
0
    def test_cardgame_post_fair_improved_symbolic3(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(fsm,
                  parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #16
0
    def test_cardgame_post_fair_improved_symbolic12(self):
        fsm = self.cardgame_post_fair()

        self.assertFalse(
            check(fsm,
                  parseATLK("['dealer'] F 'win'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #17
0
    def test_cardgame_post_fair_improved_symbolic11(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(fsm,
                  parseATLK("<'player'> F <'player'>[~'lose' U 'win']")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #18
0
    def test_cardgame_post_fair_improved_symbolic9(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(fsm,
                  parseATLK("EG ~'win'")[0],
                  implem="symbolic",
                  variant="FSF"))
        self.assertTrue(
            check(fsm,
                  parseATLK("EF 'win'")[0],
                  implem="symbolic",
                  variant="FSF"))
        self.assertFalse(
            check(fsm,
                  parseATLK("AF 'win'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #19
0
    def test_cardgame_post_fair_improved_symbolic8(self):
        fsm = self.cardgame_post_fair()

        # Dealer can avoid fairness
        self.assertTrue(
            check(fsm,
                  parseATLK("<'dealer'> F 'FALSE'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #20
0
    def test_cardgame_post_fair_improved_symbolic7(self):
        fsm = self.cardgame_post_fair()

        # Player can win
        self.assertTrue(
            check(fsm,
                  parseATLK("<'player'> F 'win'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #21
0
    def test_atom(self):
        s = "'c <= 3'"
        asts = parseATLK(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertTrue(isinstance(ast, Spec))
        self.assertTrue(isinstance(ast, Atom))
        self.assertEqual(ast.value, "c <= 3")
Beispiel #22
0
 def test_atom(self):
     s = "'c <= 3'"
     asts = parseATLK(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertTrue(isinstance(ast, Spec))
     self.assertTrue(isinstance(ast, Atom))
     self.assertEqual(ast.value, "c <= 3")
Beispiel #23
0
    def test_tictactoe(self):
        fsm = self.tictactoe()

        self.assertTrue(
            check(
                fsm,
                parseATLK(
                    "'run = circle' -> <'circlep'> X 'board[1] = circle'")[0]))
        self.assertTrue(
            check(
                fsm,
                parseATLK("'run = circle' -> ['circlep'] X 'run = cross'")[0]))
        self.assertTrue(check(fsm, parseATLK("<'circlep'> F 'run = stop'")[0]))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'circlep', 'crossp'> G 'winner = empty'")[0]))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'circlep'> G 'winner != circle'")[0]))
Beispiel #24
0
    def test_cardgame_post_fair_improved_symbolic2(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(
                fsm,
                parseATLK(
                    "AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))"
                )[0],
                implem="symbolic",
                variant="FSF"))
    def test_cardgame_improved(self):
        fsm = self.cardgame()

        self.assertTrue(
            check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], variant="FS", implem="symbolic", semantics="individual")
        )
        self.assertFalse(
            check(fsm, parseATLK("<'dealer'> G ~'win'")[0], variant="FS", implem="symbolic", semantics="individual")
        )
        self.assertTrue(
            check(
                fsm,
                parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0],
                variant="FS",
                implem="symbolic",
                semantics="individual",
            )
        )
        self.assertFalse(
            check(fsm, parseATLK("<'player'> F 'win'")[0], variant="FS", implem="symbolic", semantics="individual")
        )

        self.assertTrue(
            check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], variant="FS", implem="symbolic", semantics="individual")
        )
        self.assertTrue(
            check(fsm, parseATLK("['dealer'] F 'win'")[0], variant="FS", implem="symbolic", semantics="individual")
        )
Beispiel #26
0
    def test_transmission_with_know_not_improved(self):
        fsm = self.transmission_with_knowledge()

        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> F 'received'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> G ~'received'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> X 'received'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> X ~'received'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'transmitter'> F 'received'")[0],
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'sender'> G ~'received'")[0],
                  implem="partialSI",
                  semantics="individual"))
Beispiel #27
0
    def test_transmission_with_know_improved_symbolic(self):
        fsm = self.transmission_with_knowledge()

        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> G ~'received'")[0],
                  implem="symbolic",
                  variant="FSF"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> F 'received'")[0],
                  implem="symbolic",
                  variant="FSF"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> X 'received'")[0],
                  implem="symbolic",
                  variant="FSF"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> X ~'received'")[0],
                  implem="symbolic",
                  variant="FSF"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'transmitter'> F 'received'")[0],
                  implem="symbolic",
                  variant="FSF"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'sender'> G ~'received'")[0],
                  implem="symbolic",
                  variant="FSF"))
Beispiel #28
0
    def test_CEF(self):
        s = "<'agent'>F 'test'"
        asts = parseATLK(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertTrue(isinstance(ast, CEF))
        for ag in ast.group:
            self.assertTrue(isinstance(ag, Atom))
        self.assertEqual(len(ast.group), 1)
        self.assertEqual(ast.group[0].value, 'agent')
        self.assertTrue(isinstance(ast.child, Atom))
        self.assertEqual(ast.child.value, "test")
Beispiel #29
0
 def test_CEF(self):
     s = "<'agent'>F 'test'"
     asts = parseATLK(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertTrue(isinstance(ast, CEF))
     for ag in ast.group:
         self.assertTrue(isinstance(ag, Atom))
     self.assertEqual(len(ast.group), 1)
     self.assertEqual(ast.group[0].value, 'agent')
     self.assertTrue(isinstance(ast.child, Atom))
     self.assertEqual(ast.child.value, "test")
Beispiel #30
0
    def test_cardgame_post_fair_improved_symbolic2(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(
                fsm,
                parseATLK(
                    "AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))"
                )[0],
                implem="symbolic",
                variant="FSF",
            )
        )
Beispiel #31
0
 def test_deep_spec(self):
     s = ("<'a','b'>[['c'][['e'] F ('p' & 'q') W K<'a'> 'p'] U <'d'>G "
          "nC<'g','e'> ('c' -> EF 'k')]")
     asts = parseATLK(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertTrue(isinstance(ast, CEU))
     
     self.assertEqual(len(ast.group), 2)
     self.assertTrue(isinstance(ast.group[0], Atom))
     self.assertEqual(ast.group[0].value, "a")
     self.assertTrue(isinstance(ast.group[1], Atom))
     self.assertEqual(ast.group[1].value, "b")
     
     self.assertTrue(isinstance(ast.left, CAW))
     self.assertEqual(len(ast.left.group), 1)
     self.assertTrue(isinstance(ast.left.group[0], Atom))
     self.assertEqual(ast.left.group[0].value, "c")
     self.assertTrue(isinstance(ast.left.left, CAF))
     self.assertEqual(len(ast.left.left.group), 1)
     self.assertTrue(isinstance(ast.left.left.group[0], Atom))
     self.assertEqual(ast.left.left.group[0].value, "e")
     self.assertTrue(isinstance(ast.left.left.child, And))
     self.assertTrue(isinstance(ast.left.left.child.left, Atom))
     self.assertEqual(ast.left.left.child.left.value, "p")
     self.assertTrue(isinstance(ast.left.left.child.right, Atom))
     self.assertEqual(ast.left.left.child.right.value, "q")
     self.assertTrue(isinstance(ast.left.right, K))
     self.assertTrue(isinstance(ast.left.right.agent, Atom))
     self.assertEqual(ast.left.right.agent.value, "a")
     self.assertTrue(isinstance(ast.left.right.child, Atom))
     self.assertEqual(ast.left.right.child.value, "p")
     
     self.assertTrue(isinstance(ast.right, CEG))
     self.assertEqual(len(ast.right.group), 1)
     self.assertTrue(isinstance(ast.right.group[0], Atom))
     self.assertEqual(ast.right.group[0].value, "d")
     self.assertTrue(isinstance(ast.right.child, nC))
     self.assertEqual(len(ast.right.child.group), 2)
     self.assertTrue(isinstance(ast.right.child.group[0], Atom))
     self.assertEqual(ast.right.child.group[0].value, "g")
     self.assertTrue(isinstance(ast.right.child.group[1], Atom))
     self.assertEqual(ast.right.child.group[1].value, "e")
     self.assertTrue(isinstance(ast.right.child.child, Implies))
     self.assertTrue(isinstance(ast.right.child.child.left, Atom))
     self.assertEqual(ast.right.child.child.left.value, "c")
     self.assertTrue(isinstance(ast.right.child.child.right, EF))
     self.assertTrue(isinstance(ast.right.child.child.right.child, Atom))
     self.assertEqual(ast.right.child.child.right.child.value, "k")
Beispiel #32
0
    def test_deep_spec(self):
        s = ("<'a','b'>[['c'][['e'] F ('p' & 'q') W K<'a'> 'p'] U <'d'>G "
             "nC<'g','e'> ('c' -> EF 'k')]")
        asts = parseATLK(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertTrue(isinstance(ast, CEU))

        self.assertEqual(len(ast.group), 2)
        self.assertTrue(isinstance(ast.group[0], Atom))
        self.assertEqual(ast.group[0].value, "a")
        self.assertTrue(isinstance(ast.group[1], Atom))
        self.assertEqual(ast.group[1].value, "b")

        self.assertTrue(isinstance(ast.left, CAW))
        self.assertEqual(len(ast.left.group), 1)
        self.assertTrue(isinstance(ast.left.group[0], Atom))
        self.assertEqual(ast.left.group[0].value, "c")
        self.assertTrue(isinstance(ast.left.left, CAF))
        self.assertEqual(len(ast.left.left.group), 1)
        self.assertTrue(isinstance(ast.left.left.group[0], Atom))
        self.assertEqual(ast.left.left.group[0].value, "e")
        self.assertTrue(isinstance(ast.left.left.child, And))
        self.assertTrue(isinstance(ast.left.left.child.left, Atom))
        self.assertEqual(ast.left.left.child.left.value, "p")
        self.assertTrue(isinstance(ast.left.left.child.right, Atom))
        self.assertEqual(ast.left.left.child.right.value, "q")
        self.assertTrue(isinstance(ast.left.right, K))
        self.assertTrue(isinstance(ast.left.right.agent, Atom))
        self.assertEqual(ast.left.right.agent.value, "a")
        self.assertTrue(isinstance(ast.left.right.child, Atom))
        self.assertEqual(ast.left.right.child.value, "p")

        self.assertTrue(isinstance(ast.right, CEG))
        self.assertEqual(len(ast.right.group), 1)
        self.assertTrue(isinstance(ast.right.group[0], Atom))
        self.assertEqual(ast.right.group[0].value, "d")
        self.assertTrue(isinstance(ast.right.child, nC))
        self.assertEqual(len(ast.right.child.group), 2)
        self.assertTrue(isinstance(ast.right.child.group[0], Atom))
        self.assertEqual(ast.right.child.group[0].value, "g")
        self.assertTrue(isinstance(ast.right.child.group[1], Atom))
        self.assertEqual(ast.right.child.group[1].value, "e")
        self.assertTrue(isinstance(ast.right.child.child, Implies))
        self.assertTrue(isinstance(ast.right.child.child.left, Atom))
        self.assertEqual(ast.right.child.child.left.value, "c")
        self.assertTrue(isinstance(ast.right.child.child.right, EF))
        self.assertTrue(isinstance(ast.right.child.child.right.child, Atom))
        self.assertEqual(ast.right.child.child.right.child.value, "k")
Beispiel #33
0
 def test_transmission_with_know_not_improved_partial(self):
     fsm = self.transmission_with_knowledge()
     
     self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], implem="partial"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], implem="partial"))
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'sender'> G ~'received'")[0], implem="partial"))
Beispiel #34
0
    def test_transmission_with_know_improved_symbolic(self):
        fsm = self.transmission_with_knowledge()

        self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], implem="symbolic", variant="FSF"))
        self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0], implem="symbolic", variant="FSF"))
        self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], implem="symbolic", variant="FSF"))
        self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], implem="symbolic", variant="FSF"))
        self.assertFalse(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], implem="symbolic", variant="FSF"))
        self.assertTrue(check(fsm, parseATLK("<'sender'> G ~'received'")[0], implem="symbolic", variant="FSF"))
 def test_transmission_with_know_improved(self):
     fsm = self.transmission_with_knowledge()
     
     self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'sender'> G ~'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
 def test_transmission_with_know_FSF(self):
     fsm = self.transmission_with_knowledge()
     
     self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0], variant="FSF", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], variant="FSF", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], variant="FSF", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], variant="FSF", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], variant="FSF", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'sender'> G ~'received'")[0], variant="FSF", semantics="individual"))
 def test_cardgame_improved(self):
     fsm = self.cardgame()
     
     self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'player'> F 'win'")[0], variant="FS", implem="partial", semantics="individual"))
     
     self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("['dealer'] F 'win'")[0], variant="FS", implem="partial", semantics="individual"))
 def test_cardgame_post_fair_early_filtering(self):
     fsm = self.cardgame_post_fair()
     
     config.partial.filtering = True
     
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], variant="FS", implem="partialSI", semantics="individual"))
     
     self.assertTrue(check(fsm, parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))")[0], variant="FS", implem="partialSI", semantics="individual"))
     
     self.assertFalse(check(fsm, parseATLK("['dealer'] F 'win'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], variant="FS", implem="partialSI", semantics="individual"))
     
     # Player can win
     self.assertTrue(check(fsm, parseATLK("<'player'> F 'win'")[0], variant="FS", implem="partialSI", semantics="individual"))
     # Dealer can avoid fairness
     self.assertTrue(check(fsm, parseATLK("<'dealer'> F 'FALSE'")[0], variant="FS", implem="partialSI", semantics="individual"))
     
     config.partial.filtering = False
Beispiel #39
0
 def test_transmission_with_know_improved_partial_strat_only(self):
     fsm = self.transmission_with_knowledge()
     config.partial.alternate.type = {"strat"}
     
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("<'sender'> G ~'received'")[0], implem="partial", variant="FS"))
 def test_transmission_post_fair_improved(self):
     fsm = self.transmission_post_fair()
     
     self.assertTrue(check(fsm, parseATLK("<'sender'> F 'received'")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], variant="FS", implem="partial", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], variant="FS", implem="partial", semantics="individual"))
     
     # False because the sender does not know if the bit is already
     # transmitted (and in this case, no strategy can avoid 'received')
     self.assertFalse(check(fsm, parseATLK("<'sender'> G ~'received'")[0], variant="FS", implem="partial", semantics="individual"))
 def test_transmission_post_fair_improved(self):
     fsm = self.transmission_post_fair()
     
     self.assertTrue(check(fsm, parseATLK("<'sender'> F 'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
     
     # False because the sender does not know if the bit is already
     # transmitted (and in this case, no strategy can avoid 'received')
     self.assertFalse(check(fsm, parseATLK("<'sender'> G ~'received'")[0], variant="FS", implem="partialSI", semantics="individual"))
 def test_cardgame_early_filtering(self):
     fsm = self.cardgame()
     
     config.partial.filtering = True
     self.assertFalse(check(fsm, parseATLK("<'player'> F 'win'")[0], variant="FS", implem="partialSI", semantics="individual"))        
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], variant="FS", implem="partialSI", semantics="individual"))
     
     self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], variant="FS", implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("['dealer'] F 'win'")[0], variant="FS", implem="partialSI", semantics="individual"))
     
     config.partial.filtering = False
    def test_transmission_early_filtering(self):
        fsm = self.transmission()

        config.partial.filtering = True

        # False because transmitter cannot win if received is already true
        # and he has no clue about it
        self.assertFalse(
            check(fsm,
                  parseATLK("<'transmitter'> G ~'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> X 'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        # False because transmitter cannot win if received is already true
        # and he has no clue about it
        self.assertFalse(
            check(fsm,
                  parseATLK("<'transmitter'> X ~'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))

        # False because the sender does not know if the bit is already
        # transmitted (and in this case, no strategy can avoid 'received')
        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> G ~'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))

        self.assertFalse(
            check(fsm,
                  parseATLK("<'transmitter'> F 'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> F 'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))

        config.partial.filtering = False
    def test_transmission_improved(self):
        fsm = self.transmission()

        # False because transmitter cannot win if received is already true
        # and he has no clue about it
        self.assertFalse(
            check(
                fsm,
                parseATLK("<'transmitter'> G ~'received'")[0],
                variant="FS",
                implem="symbolic",
                semantics="individual",
            )
        )
        self.assertFalse(
            check(fsm, parseATLK("<'sender'> X 'received'")[0], variant="FS", implem="symbolic", semantics="individual")
        )
        # False because transmitter cannot win if received is already true
        # and he has no clue about it
        self.assertFalse(
            check(
                fsm,
                parseATLK("<'transmitter'> X ~'received'")[0],
                variant="FS",
                implem="symbolic",
                semantics="individual",
            )
        )

        # False because the sender does not know if the bit is already
        # transmitted (and in this case, no strategy can avoid 'received')
        self.assertFalse(
            check(
                fsm, parseATLK("<'sender'> G ~'received'")[0], variant="FS", implem="symbolic", semantics="individual"
            )
        )

        self.assertFalse(
            check(
                fsm,
                parseATLK("<'transmitter'> F 'received'")[0],
                variant="FS",
                implem="symbolic",
                semantics="individual",
            )
        )
        self.assertFalse(
            check(fsm, parseATLK("<'sender'> F 'received'")[0], variant="FS", implem="symbolic", semantics="individual")
        )
Beispiel #45
0
    def test_transmission(self):
        fsm = self.transmission()

        self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0]))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> G ~'received'")[0]))
        self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0]))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> X ~'received'")[0]))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'transmitter'> F 'received'")[0]))
        self.assertTrue(check(fsm, parseATLK("<'sender'> G ~'received'")[0]))
 def test_transmission_not_improved(self):
     fsm = self.transmission()
     
     self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0], semantics="individual"))
     # False because transmitter cannot win if received is already true
     # and he has no clue about it
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], semantics="individual"))
     # False because transmitter cannot win if received is already true
     # and he has no clue about it
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], semantics="individual"))
     
     # False because the sender does not know if the bit is already
     # transmitted (and in this case, no strategy can avoid 'received')
     self.assertFalse(check(fsm, parseATLK("<'sender'> G ~'received'")[0], semantics="individual"))
    def test_transmission_with_know_early_filtering(self):
        fsm = self.transmission_with_knowledge()

        config.partial.filtering = True

        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> F 'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> G ~'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'sender'> X 'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'transmitter'> X ~'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'transmitter'> F 'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'sender'> G ~'received'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))

        config.partial.filtering = False
    def test_cardgame_early_filtering(self):
        fsm = self.cardgame()

        config.partial.filtering = True
        self.assertFalse(
            check(fsm,
                  parseATLK("<'player'> F 'win'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("<'dealer'> X 'pcard=Ac'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertFalse(
            check(fsm,
                  parseATLK("<'dealer'> G ~'win'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))

        self.assertTrue(
            check(fsm,
                  parseATLK("['player'] X 'pcard=Ac'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))
        self.assertTrue(
            check(fsm,
                  parseATLK("['dealer'] F 'win'")[0],
                  variant="FS",
                  implem="partialSI",
                  semantics="individual"))

        config.partial.filtering = False
Beispiel #49
0
 def test_transmission_post_fair_not_improved_partial(self):
     fsm = self.transmission_post_fair()
     
     self.assertTrue(check(fsm, parseATLK("<'sender'> F 'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], implem="partial"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], implem="partial"))
     
     # False because the sender does not know if the bit is already
     # transmitted (and in this case, no strategy can avoid 'received')
     self.assertFalse(check(fsm, parseATLK("<'sender'> G ~'received'")[0], implem="partial"))
     
     self.assertTrue(check(fsm, parseATLK("EF 'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("EG ~'received'")[0], implem="partial"))
     self.assertFalse(check(fsm, parseATLK("AG ~'received'")[0], implem="partial"))
     self.assertFalse(check(fsm, parseATLK("AF 'received'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("AF ~'received'")[0], implem="partial"))
Beispiel #50
0
    def test_cardgame_post_fair_improved_symbolic11(self):
        fsm = self.cardgame_post_fair()

        self.assertTrue(
            check(fsm, parseATLK("<'player'> F <'player'>[~'lose' U 'win']")[0], implem="symbolic", variant="FSF")
        )
Beispiel #51
0
 def test_cardgame_improved_partial_univ_only(self):
     fsm = self.cardgame()
     config.partial.alternate.type = {"univ"}
     
     self.assertFalse(check(fsm, parseATLK("<'player'> X 'win'")[0],
                      implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'player'> F 'win'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("['dealer'] F 'win'")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("EG ~'win'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("EF 'win'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("AF 'win'")[0], implem="partial", variant="FS"))
     
     self.assertFalse(check(fsm, parseATLK("<'player'> G <'player'> F 'win'")[0], implem="partial", variant="FS"))
     
     self.assertFalse(check(fsm, parseATLK("<'player'> F <'player'>[~'lose' U 'win']")[0], implem="partial", variant="FS"))
     
     self.assertFalse(check(fsm, parseATLK("AG <'player'> X 'pcard = Ac'")[0], implem="partial", variant="FS"))
Beispiel #52
0
 def test_transmission_post_fair_improved_partial_strat_only(self):
     fsm = self.transmission_post_fair()
     config.partial.alternate.type = {"strat"}
     
     self.assertTrue(check(fsm, parseATLK("<'sender'> F 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], implem="partial", variant="FS"))
     
     # False because the sender does not know if the bit is already
     # transmitted (and in this case, no strategy can avoid 'received')
     self.assertFalse(check(fsm, parseATLK("<'sender'> G ~'received'")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("EF 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("EG ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("AG ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("AF 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("AF ~'received'")[0], implem="partial", variant="FS"))
 def test_cardgame_not_improved(self):
     fsm = self.cardgame()
     
     self.assertTrue(check(fsm, parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0], implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))")[0], implem="partialSI", semantics="individual"))
     
     self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], implem="partialSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("['dealer'] F 'win'")[0], implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], implem="partialSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("<'player'> F 'win'")[0], implem="partialSI", semantics="individual"))
     
     self.assertTrue(check(fsm, parseATLK("EG ~'win'")[0], implem="partialSI", semantics="individual"))
     self.assertTrue(check(fsm, parseATLK("EF 'win'")[0], implem="partialSI", semantics="individual"))
     self.assertFalse(check(fsm, parseATLK("AF 'win'")[0], implem="partialSI", semantics="individual"))
Beispiel #54
0
    def test_cardgame_post_fair_improved_symbolic12(self):
        fsm = self.cardgame_post_fair()

        self.assertFalse(check(fsm, parseATLK("['dealer'] F 'win'")[0], implem="symbolic", variant="FSF"))
Beispiel #55
0
 def test_cardgame_post_fair_not_improved_partial(self):
     fsm = self.cardgame_post_fair()
     
     self.assertTrue(check(fsm, parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))")[0], implem="partial"))
     
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], implem="partial"))
     self.assertFalse(check(fsm, parseATLK("['dealer'] F 'win'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], implem="partial"))
     
     # Player can win
     self.assertTrue(check(fsm, parseATLK("<'player'> F 'win'")[0], implem="partial"))
     # Dealer can avoid fairness
     self.assertTrue(check(fsm, parseATLK("<'dealer'> F 'FALSE'")[0], implem="partial"))
     
     self.assertTrue(check(fsm, parseATLK("EG ~'win'")[0], implem="partial"))
     self.assertTrue(check(fsm, parseATLK("EF 'win'")[0], implem="partial"))
     self.assertFalse(check(fsm, parseATLK("AF 'win'")[0], implem="partial"))
     
     self.assertTrue(check(fsm, parseATLK("<'player'> G <'player'> F 'win'")[0], implem="partial"))
     
     self.assertTrue(check(fsm, parseATLK("<'player'> F <'player'>[~'lose' U 'win']")[0], implem="partial"))
Beispiel #56
0
 def test_cardgame_post_fair_improved_partial_strat_only(self):
     fsm = self.cardgame_post_fair()
     config.partial.alternate.type = {"strat"}
     
     self.assertFalse(check(fsm, parseATLK("<'player'> X 'win'")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("['dealer'] F 'win'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], implem="partial", variant="FS"))
     
     # Player can win
     self.assertTrue(check(fsm, parseATLK("<'player'> F 'win'")[0], implem="partial", variant="FS"))
     # Dealer can avoid fairness
     self.assertTrue(check(fsm, parseATLK("<'dealer'> F 'FALSE'")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("EG ~'win'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("EF 'win'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("AF 'win'")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("<'player'> G <'player'> F 'win'")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("<'player'> F <'player'>[~'lose' U 'win']")[0], implem="partial", variant="FS"))
Beispiel #57
0
 def test_tpfni_partial_vs_normal(self):
     fsm = self.transmission_post_fair()
     
     self.assertTrue(check(fsm, parseATLK("<'sender'> F 'received'")[0]))
     self.assertTrue(check(fsm, parseATLK("<'sender'> F 'received'")[0], implem="partial"))
Beispiel #58
0
    def test_cardgame_not_improved_symbolic(self):
        fsm = self.cardgame()

        self.assertTrue(
            check(fsm, parseATLK("K<'player'>'pcard=none' & K<'player'>'dcard=none'")[0], implem="symbolic")
        )
        self.assertTrue(
            check(
                fsm,
                parseATLK(
                    "AG('step = 1' -> ~(K<'player'> 'dcard=Ac' | K<'player'> 'dcard=K' | K<'player'> 'dcard=Q'))"
                )[0],
                implem="symbolic",
            )
        )

        self.assertTrue(check(fsm, parseATLK("<'dealer'> X 'pcard=Ac'")[0], implem="symbolic"))
        self.assertFalse(check(fsm, parseATLK("<'dealer'> G ~'win'")[0], implem="symbolic"))
        self.assertTrue(check(fsm, parseATLK("['player'] X 'pcard=Ac'")[0], implem="symbolic"))
        self.assertTrue(check(fsm, parseATLK("['dealer'] F 'win'")[0], implem="symbolic"))
        self.assertTrue(check(fsm, parseATLK("AG('step = 1' -> ~<'player'> X 'win')")[0], implem="symbolic"))
        self.assertFalse(check(fsm, parseATLK("<'player'> F 'win'")[0], implem="symbolic"))

        self.assertTrue(check(fsm, parseATLK("EG ~'win'")[0], implem="symbolic"))
        self.assertTrue(check(fsm, parseATLK("EF 'win'")[0], implem="symbolic"))
        self.assertFalse(check(fsm, parseATLK("AF 'win'")[0], implem="symbolic"))

        self.assertFalse(check(fsm, parseATLK("<'player'> G <'player'> F 'win'")[0], implem="symbolic"))

        self.assertFalse(check(fsm, parseATLK("<'player'> F <'player'>[~'lose' U 'win']")[0], implem="symbolic"))

        self.assertFalse(check(fsm, parseATLK("AG <'player'> X 'pcard = Ac'")[0], implem="symbolic"))
Beispiel #59
0
 def test_transmission_improved_partial_univ_only(self):
     fsm = self.transmission()
     config.partial.alternate.type = {"univ"}
     
     self.assertFalse(check(fsm, parseATLK("<'sender'> F 'received'")[0], implem="partial", variant="FS"))
     # False because transmitter cannot win if received is already true
     # and he has no clue about it
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> G ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'sender'> X 'received'")[0], implem="partial", variant="FS"))
     # False because transmitter cannot win if received is already true
     # and he has no clue about it
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> X ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("<'transmitter'> F 'received'")[0], implem="partial", variant="FS"))
     
     # False because the sender does not know if the bit is already
     # transmitted (and in this case, no strategy can avoid 'received')
     self.assertFalse(check(fsm, parseATLK("<'sender'> G ~'received'")[0], implem="partial", variant="FS"))
     
     self.assertTrue(check(fsm, parseATLK("EF 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("EG ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("AG ~'received'")[0], implem="partial", variant="FS"))
     self.assertFalse(check(fsm, parseATLK("AF 'received'")[0], implem="partial", variant="FS"))
     self.assertTrue(check(fsm, parseATLK("AF ~'received'")[0], implem="partial", variant="FS"))