Exemple #1
0
def test_nodes_not_follow_formula():
    worlds = [
        World('RWW', {
            '1:R': True,
            '2:W': True,
            '3:W': True
        }),
        World('RRW', {
            '1:R': True,
            '2:R': True,
            '3:W': True
        })
    ]
    relations = {}
    ks = KripkeStructure(worlds, relations)
    formula = And(Atom('2:W'), Atom('3:W'))
    expected_result = ['RRW']
    result = ks.nodes_not_follow_formula(formula)
    assert expected_result == result
Exemple #2
0
from mlsolver.formula import Atom, Box, Or, Box_a, And, Box_star
from mlsolver.AcesAndEights import AcesAndEights

# Create new Aces and Eights Kripke
agentA = AcesAndEights()

# The Game is (88, AA, AA)
# And(Not(Box_a('1', Atom('1:R'))), Not(Box_a('1', Not(Atom('1:R')))
new_model = agentA.ks.solve(And(And(Atom('2AA'), Atom('3AA')), Atom('188')))
print("Test")
Exemple #3
0
def test_eq_depth_three_with_and():
    node_one = Node('s', And(Atom('p'), Atom('q')),
                    [Node('s', Atom('p'), [Node('s', Atom('q'), [])])])
    node_two = node_one
    assert node_one == node_two
Exemple #4
0
def test_next_and_is_derived():
    node = Node('s', And(Atom('p'), Atom('q')),
                [Leaf('s', 'p', [Leaf('s', 'q', [], True)], True)])
    node.is_derived = True
    next_node = node.__next__()
    assert next_node is None
Exemple #5
0
def test_next_and_not_derived():
    node = Node('s', And(Atom('p'), Atom('q')), [])
    next_node = node.__next__()
    assert next_node is node
Exemple #6
0
def test_semantic_p_and_q():
    worlds = [World('1', {'p': True, 'q': True})]
    relations = {}
    ks = KripkeStructure(worlds, relations)
    mpl = And(Atom('p'), Atom('q'))
    assert True == mpl.semantic(ks, '1')
Exemple #7
0
    def __init__(self):
        worlds = [
            World('RWW', {
                '1:R': True,
                '2:W': True,
                '3:W': True
            }),
            World('RRW', {
                '1:R': True,
                '2:R': True,
                '3:W': True
            }),
            World('RRR', {
                '1:R': True,
                '2:R': True,
                '3:R': True
            }),
            World('WRR', {
                '1:W': True,
                '2:R': True,
                '3:R': True
            }),
            World('WWR', {
                '1:W': True,
                '2:W': True,
                '3:R': True
            }),
            World('RWR', {
                '1:R': True,
                '2:W': True,
                '3:R': True
            }),
            World('WRW', {
                '1:W': True,
                '2:R': True,
                '3:W': True
            }),
            World('WWW', {
                '1:W': True,
                '2:W': True,
                '3:W': True
            }),
        ]

        relations = {
            '1': {('RWW', 'WWW'), ('RRW', 'WRW'), ('RWR', 'WWR'),
                  ('WRR', 'RRR')},
            '2': {('RWR', 'RRR'), ('RWW', 'RRW'), ('WRR', 'WWR'),
                  ('WWW', 'WRW')},
            '3': {('WWR', 'WWW'), ('RRR', 'RRW'), ('RWW', 'RWR'),
                  ('WRW', 'WRR')}
        }

        relations.update(add_reflexive_edges(worlds, relations))
        relations.update(add_symmetric_edges(relations))

        self.ks = KripkeStructure(worlds, relations)

        # Wise man ONE does not know whether he wears a red hat or not
        self.knowledge_base.append(
            And(Not(Box_a('1', Atom('1:R'))), Not(Box_a('1',
                                                        Not(Atom('1:R'))))))

        # This announcement implies that either second or third wise man wears a red hat.
        self.knowledge_base.append(Box_star(Or(Atom('2:R'), Atom('3:R'))))

        # Wise man TWO does not know whether he wears a red hat or not
        self.knowledge_base.append(
            And(Not(Box_a('2', Atom('2:R'))), Not(Box_a('2',
                                                        Not(Atom('2:R'))))))

        # This announcement implies that third men has be the one, who wears a red hat
        self.knowledge_base.append(Box_a('3', Atom('3:R')))