예제 #1
0
    def setUp(self):

        dom = set(['b1',  'c1'])
        self.vals = []
        for z in chain.from_iterable(combinations(dom, r) for r in range(len(dom)+1)):
            self.vals.append(extrasem.Valuation([('sleep', set(z))]))

        self.g1 = extrasem.Assignment(values=['b1', 'c1'])

        self.r1 = extrasem.ReferentSystem(variables=['x', 'y'])

        self.possibilities = [[self.r1, self.g1, x] for x in self.vals]
        self.info = extrasem.InformationState(dom, self.possibilities)

        self.inq = extrasem.DynamicInquisitiveState([self.info])
        
        self.possibilities2 = [[self.r1, self.g1, x] for x in self.vals]
        self.info2 = extrasem.InformationState(dom, self.possibilities)

        self.inq2 = extrasem.DynamicInquisitiveState([self.info2])

        self.g2 = extrasem.Assignment(values=['b1', 'c1', 'b1'])

        self.r2 = extrasem.ReferentSystem(variables=['x', 'y', 'z'])
        
        self.w = extrasem.Valuation([('sleep', set(['b1']))])
        self.small_possibilities = [[self.r2, self.g2, x] for x in self.vals]
        self.info4 = extrasem.InformationState(dom, self.small_possibilities)
        self.info5 = extrasem.InformationState(dom, [[self.r2, self.g2, self.w]])
        self.inq4 = extrasem.DynamicInquisitiveState([self.info4])
        self.inq5 = extrasem.DynamicInquisitiveState([self.info5])
예제 #2
0
    def setUp(self):

        dom = set(['b1', 'c1'])
        vals = []
        for z in chain.from_iterable(combinations(dom, r) for r in range(len(dom)+1)):
            vals.append(extrasem.Valuation([('sleep', set(z))]))

        vals2 = vals[0:2]

        g1 = extrasem.Assignment(values=['b1', 'c1'])

        g2 = extrasem.Assignment(values=['b1'])

        r1 = extrasem.ReferentSystem(variables=['x', 'y'])


        r2 = extrasem.ReferentSystem(variables=['x', 'z'])
        self.info = extrasem.InformationState(dom, [[r1, g1, x] for x in vals])

        self.info2 = extrasem.InformationState(dom, [[r1, g1, x] for x in vals])
        self.info3 = extrasem.InformationState(dom, [[r1, g1, x] for x in vals2])

        possibilities = [[r1, g1, x] for x in vals[:-1]] + [[r1, g2, vals[-1]]]

        self.info4 = extrasem.InformationState(dom, possibilities)
예제 #3
0
 def test_values(self):
     new_assignment = self.g1.add("d1")
     self.assertEqual(self.g1, extrasem.Assignment(values=['b1', 'c1']))
     self.assertNotEqual(self.g1, new_assignment)
     self.assertEqual(type(self.g1), type(new_assignment))
     self.assertEqual(new_assignment, extrasem.Assignment(values=['b1', 'c1', 'd1']))
     new_r = self.r1.add("z")
     self.assertEqual(self.r1, extrasem.ReferentSystem(variables=['x', 'y']))
     self.assertNotEqual(self.r1, new_r)
     self.assertEqual(type(self.r1), type(new_r))
     self.assertEqual(new_r, extrasem.ReferentSystem(variables=['x', 'y', 'z']))
     last_assignment = self.g1.purge("p1")
     self.assertEqual(self.g1, extrasem.Assignment(values=['b1', 'c1']))
     self.assertEqual(last_assignment, extrasem.Assignment(values=['b1']))
     smallest = self.g1.purge()
     self.assertEqual(smallest, extrasem.Assignment(values=None))
예제 #4
0
    def test_values(self):
        extended_inq = self.inq.evaluate("exists z. (-sleep(z))")

        g_extra1 = extrasem.Assignment(values=['b1', 'c1', 'b1'])

        r2 = extrasem.ReferentSystem(variables=['x', 'y', 'z'])

        info1 = extrasem.InformationState(self.dom, [[r2, g_extra1,  extrasem.Valuation([('sleep', set(['c1'])), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra1,  extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])]])
        
        g_extra2 = extrasem.Assignment(values=['b1', 'c1', 'c1'])
        
        info2 = extrasem.InformationState(self.dom, [[r2, g_extra2,  extrasem.Valuation([('sleep', set(['b1'])), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra2,  extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])]])
        
        info3 = extrasem.InformationState(self.dom, [[r2, g_extra1,  extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra2,  extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])]])
        
        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([info1, info2, info3]) )

        extended_inq = self.inq.evaluate("-(exists z. sleep(z))")

        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])]])]) )

        extended_inq = self.inq.evaluate("sleep(mary) | sleep(john)") 
        
        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('sleep', set(['b1'])), ('john', 'b1'), ('mary', 'c1')])]]), extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('sleep', set(['c1'])), ('john', 'b1'), ('mary', 'c1')])], [self.r1, self.g1, extrasem.Valuation([('sleep', set(['c1', 'b1'])), ('john', 'b1'), ('mary', 'c1')])]])]))

        extended_inq = self.inq.evaluate("(exists z. sleep(z)) | (exists w. (sleep(w)))") 
        
        extended_inq = self.inq.evaluate("sleep(mary) -> sleep(john)") 
        
        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('sleep', set(['b1'])), ('john', 'b1'), ('mary', 'c1')])], [self.r1, self.g1, extrasem.Valuation([('sleep', set(['c1', 'b1'])), ('john', 'b1'), ('mary', 'c1')])], [self.r1, self.g1, extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])]])]))

        extended_inq = self.inq.evaluate("all z. sleep(z)")

        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[r2, g_extra1, extrasem.Valuation([('sleep', set(['c1', 'b1'])), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra2, extrasem.Valuation([('sleep', set(['c1', 'b1'])), ('john', 'b1'), ('mary', 'c1')])]])]))

        extended_inq = self.inq.evaluate("-(all z. sleep(z))")
        
        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('sleep', set(['b1'])), ('john', 'b1'), ('mary', 'c1')])], [self.r1, self.g1, extrasem.Valuation([('sleep', set(['c1'])), ('john', 'b1'), ('mary', 'c1')])], [self.r1, self.g1, extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])]])]))

        extended_inq = self.inq.evaluate("all z. -(sleep(z))")
        
        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[r2, g_extra1, extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra2, extrasem.Valuation([('sleep', set()), ('john', 'b1'), ('mary', 'c1')])]])]))

        extended_inq = self.inq.evaluate("!sleep(x)")

        self.assertEqual(extended_inq, self.inq.evaluate("sleep(x)"))
            
        extended_inq = self.inq.evaluate("!(sleep(x) | sleep(y))")
        
        self.assertEqual(extended_inq, extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('sleep', set(['b1'])), ('john', 'b1'), ('mary', 'c1')])], [self.r1, self.g1, extrasem.Valuation([('sleep', set(['c1'])), ('john', 'b1'), ('mary', 'c1')])], [self.r1, self.g1, extrasem.Valuation([('sleep', set(['b1', 'c1'])), ('john', 'b1'), ('mary', 'c1')])]])]))

        extended_inq = self.inq.evaluate("?sleep(x)")

        self.assertEqual(extended_inq, self.inq.evaluate("sleep(x) | -sleep(x)"))
예제 #5
0
    def setUp(self):

        dom = set(['b1', 'c1'])
        vals = []
        for z in chain.from_iterable(combinations(dom, r) for r in range(len(dom)+1)):
            vals.append(extrasem.Valuation([('sleep', set(z))]))

        vals2 = vals[0:2]

        self.g1 = extrasem.Assignment(values=['b1', 'c1'])


        self.r1 = extrasem.ReferentSystem(variables=['x', 'y'])
예제 #6
0
    def test_values(self):
        new_infostate = self.info.evaluate("sleep (mary)")

        tested1 = extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1'), ('c1')])) ])], [self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('c1')])) ])]])
        self.assertEqual(tested1, new_infostate)

        new_infostate = self.info.evaluate("-sleep (john)")

        tested1 = extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('c1')])) ])], [self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set()) ])]])
        self.assertEqual(tested1, new_infostate)

        new_infostate = self.info.evaluate("sleep (mary) & sleep(john)")

        tested2 = extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1'), ('c1')])) ])] ])
        self.assertEqual(tested2, new_infostate)

        extended_info = self.info.evaluate("exists z. (sleep(z) | -sleep(z)) ") #empty(x) is a dummy prop, always satisfied

        g_extra1 = extrasem.Assignment(values=['b1', 'c1', 'b1'])
        g_extra2 = extrasem.Assignment(values=['b1', 'c1', 'c1'])

        r2 = extrasem.ReferentSystem(variables=['x', 'y', 'z'])

        info1 = extrasem.InformationState(self.dom, [[r2, g_extra1, x] for x in self.vals] +\
                [[r2, g_extra2, x] for x in self.vals])
        
        self.assertEqual(extended_info, info1)

        extended_info = self.info.evaluate("sleep(mary) -> sleep(john)") 

        tested3 = extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1'), ('c1')])) ])], [self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1')])) ])], [self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set()) ])] ])
        
        self.assertEqual(extended_info, tested3)

        extended_info = self.info.evaluate("all z. sleep(z)")

        tested4 = extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1'), ('c1')])) ])] ])

        self.assertEqual(extended_info, tested4)

        extended_info = self.info.evaluate("-(all z. sleep(z))")
        
        tested5 = extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set()) ])], [self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1')])) ])], [self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('c1')])) ])]])
        self.assertEqual(tested5, extended_info)

        extended_info = self.info.evaluate("all z. -(sleep(z))")
        tested6 = extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set()) ])] ])

        self.assertEqual(extended_info, tested6)
예제 #7
0
    def setUp(self):

        dom = set(['b1',  'c1'])
        self.vals = []
        for z in chain.from_iterable(combinations(dom, r) for r in range(len(dom)+1)):
            self.vals.append(extrasem.Valuation([('sleep', set(z))]))

        self.w = extrasem.Valuation([('dance', set(['b1']))])

        self.g1 = extrasem.Assignment(values=['b1', 'c1'])

        self.g2 = extrasem.Assignment(values=['b1'])

        self.r1 = extrasem.ReferentSystem(variables=['x', 'y'])
        
        self.possibilities = [[self.r1, self.g1, x] for x in self.vals]
        self.info = extrasem.InformationState(dom, self.possibilities)
예제 #8
0
    def setUp(self):

        self.dom = set(['b1',  'c1'])
        self.vals = []
        for z in chain.from_iterable(combinations(self.dom, r) for r in range(len(self.dom)+1)):
            self.vals.append(extrasem.Valuation([('sleep', set(z))]))
        for x in self.vals:
            x['john'] = 'b1'
            x['mary'] = 'c1'

        self.g1 = extrasem.Assignment(values=['b1', 'c1'])

        self.r1 = extrasem.ReferentSystem(variables=['x', 'y'])
        
        self.possibilities = [[self.r1, self.g1, x] for x in self.vals]

        self.info = extrasem.InformationState(self.dom, self.possibilities)

        self.inq = extrasem.DynamicInquisitiveState([self.info])
예제 #9
0
    def test_values(self):
        new_inqstate = self.inq.evaluate("sleep (mary)")

        tested1 = extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1'), ('c1')])) ])], [self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('c1')])) ])]])])
        self.assertEqual(tested1, new_inqstate)

        new_inqstate = self.inq.evaluate("sleep (mary) & sleep(john)")

        tested2 = extrasem.DynamicInquisitiveState([extrasem.InformationState(self.dom, [[self.r1, self.g1, extrasem.Valuation([('john', 'b1'), ('mary', 'c1'), ('sleep', set([('b1'), ('c1')])) ])] ])])
        self.assertEqual(tested2, new_inqstate)
        
        extended_inq = self.inq.evaluate("exists z. (!(sleep(z) | -sleep(z)))")

        self.assertEqual(extrasem.DynamicInquisitiveState([self.info]), self.inq)
        
        g_extra1 = extrasem.Assignment(values=['b1', 'c1', 'b1'])

        r2 = extrasem.ReferentSystem(variables=['x', 'y', 'z'])

        part1  = [[r2, g_extra1, x] for x in self.vals]
        
        g_extra2 = extrasem.Assignment(values=['b1', 'c1', 'c1'])
        
        part2  = [[r2, g_extra2, x] for x in self.vals]

        info1 = extrasem.InformationState(self.dom, part1 + part2)

        self.assertEqual(extended_inq.find_maximal().pop(), info1)
        
        extended_inq2 = extended_inq.evaluate("sleep(z)")

        info1 = extrasem.InformationState(self.dom, [[r2, g_extra1,  extrasem.Valuation([('sleep', set(['b1'])), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra1,  extrasem.Valuation([('sleep', set(['b1', 'c1'])), ('john', 'b1'), ('mary', 'c1')])]])
        info2 = extrasem.InformationState(self.dom, [[r2, g_extra2,  extrasem.Valuation([('sleep', set(['c1'])), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra2,  extrasem.Valuation([('sleep', set(['b1', 'c1'])), ('john', 'b1'), ('mary', 'c1')])]])
        info3 = extrasem.InformationState(self.dom, [[r2, g_extra1,  extrasem.Valuation([('sleep', set(['b1', 'c1'])), ('john', 'b1'), ('mary', 'c1')])], [r2, g_extra2,  extrasem.Valuation([('sleep', set(['b1', 'c1'])), ('john', 'b1'), ('mary', 'c1')])]])

        self.assertEqual(extended_inq2, extrasem.DynamicInquisitiveState([info1, info2, info3]))
예제 #10
0
vals.append(sem.Valuation([('see', set([('b1', 'c1')])), ('like', set([('b1', 'c1'), ('c1', 'c1')]))]))
#vals.append(sem.Valuation([('see', set([('b1', 'c1')])), ('like', set())]))
vals.append(sem.Valuation([('see', set([('b1', 'c1'), ('c1', 'c1')])), ('like', set([('b1', 'c1'), ('c1', 'c1')])) ]))
#vals.append(sem.Valuation([('see', set([('b1', 'c1'), ('c1', 'c1')])), ('like', set())]))

#furthermore, we add naming functions, so we can refer to b1 and c1

#for x in vals:
#    x['john'] = 'b1'
#    x['mary'] = 'c1'

#now we create an assignment function
g1 = sem.Assignment(values=['b1', 'c1'])

#and we create referent system
r1 = sem.ReferentSystem(variables=['x', 'y'])

#all possibilities are put together as triples with identical g1 and r1, but varying worlds
possibilities = [[r1, g1, x] for x in vals]
info = sem.InformationState(dom, possibilities)

inq = sem.DynamicInquisitiveState([info])

#some examples
exp_list = []
exp_list.append("exists z(exists v (see(z, v)))")
exp_list.append("exists z(exists v (see(z, v))) & ?like(z, v)")
exp_list.append("X(exists z(exists v (see(z, v))))")
exp_list.append("all z(exists v(see(z, v)))")

print("Original state:")