def createRarelyRule(rule):
    rarelyIsRule = False
    rarelyIsHead = False
    isImplication = isinstance(rule, basicLogic.operator_bitonic_implication)
    rarelyIsRule = isinstance(rule, basicLogic.operator_monotonic_rarely)

    if isImplication:
        rarelyIsHead = isinstance(rule.clause2,
                                  basicLogic.operator_monotonic_rarely)

    rarelyInRightPlace = rarelyIsRule or rarelyIsHead
    if rarelyIsHead:
        c1 = rule.clause1
        c2 = basicLogic.operator_monotonic_negation(rule.clause1)
        #known to be mostly
        c3 = basicLogic.operator_monotonic_negation(rule.clause2.clause)
        r = basicLogic.operator_tritonic_defaultRule(c1, c2, c3)

        return r
    elif rarelyIsRule:
        c1 = basicLogic.TRUE
        c2 = rule.clause
        c3 = basicLogic.operator_monotonic_negation(rule.clause)
        r = basicLogic.operator_tritonic_defaultRule(c1, c2, c3)
        return r
    else:
        print("Requirement that 'mostly' is the second clause in a->m(b)")
        raise Exception()
Exemplo n.º 2
0
def example_nixon():
    DEFAULT = cop.m_default()
    W = no.stringListToBasicLogic(['( quaker <- T )', ' ( republican <- T ) '])
    #W = no.stringListToBasicLogic([' bird ', ' penguin '])

    V = no.stringListToBasicLogic(['quaker', 'republican', 'pacifist'])
    #dParts = no.stringListToBasicLogic(['( bird <- T )', '( penguin <- F ) ', '( flies <- T )'])
    dParts = no.stringListToBasicLogic(
        ['( quaker <- T )', '( pacifist <- T ) ', '( pacifist <- T )'])
    default1 = basicLogic.operator_tritonic_defaultRule(
        dParts[0], [dParts[1]], dParts[2])

    dParts2 = no.stringListToBasicLogic(
        ['( republican <- T )', '( pacifist <- F ) ', '( pacifist <- F )'])
    default2 = basicLogic.operator_tritonic_defaultRule(
        dParts2[0], [dParts2[1]], dParts2[2])
    D = [default1, default2]

    basePoint = epistemicState.epistemicState('Bird Example')
    basePoint['D'] = D
    basePoint['W'] = W
    basePoint['V'] = V

    ctm_flight = CTM.CTM()
    ctm_flight.si = [basePoint]
    ctm_flight.appendm(DEFAULT)

    print(ctm_flight)
    print(ctm_flight.evaluate())
Exemplo n.º 3
0
def example_birds():
    W = no.stringListToBasicLogic(['( bird <- T )'])

    V = no.stringListToBasicLogic(['bird', 'flies', 'penguin'])
    dParts = no.stringListToBasicLogic(
        ['( bird <- T )', '( flies <- T ) ', '( flies <- T )'])
    default1 = basicLogic.operator_tritonic_defaultRule(
        dParts[0], [dParts[1]], dParts[2])

    dParts2 = no.stringListToBasicLogic(
        ['( cold <- T )', '( flies <- F ) ', '( flies <- F )'])
    default2 = basicLogic.operator_tritonic_defaultRule(
        dParts2[0], [dParts2[1]], dParts2[2])
    D = [default1, default2]

    basePoint = epistemicState.epistemicState('Bird Example')
    basePoint['D'] = D
    basePoint['W'] = W
    basePoint['V'] = V

    ctm_flight = CTM.CTM()
    ctm_flight.si = [basePoint]
    #ctm_flight.appendm(TH)
    ctm_flight.appendm(DEFAULT)

    print(ctm_flight)
    print(ctm_flight.evaluate())
Exemplo n.º 4
0
def example_suppression():
    W = no.stringListToBasicLogic(['( e <- T )'])
    #W = no.stringListToBasicLogic([' bird ', ' penguin '])
    
    V =  no.stringListToBasicLogic(['e', 'l', 'o'])
    #dParts = no.stringListToBasicLogic(['( bird <- T )', '( penguin <- F ) ', '( flies <- T )'])
    dParts1 = no.stringListToBasicLogic(['( e <- T )', '( ab1 <- F ) ', '( l <- T )'])
    default1 = basicLogic.operator_tritonic_defaultRule(dParts1[0],[dParts1[1]],dParts1[2])
    
    dParts2 = no.stringListToBasicLogic(['( o <- T )', '( ab2 <- F ) ', '( l <- T )'])
    default2 = basicLogic.operator_tritonic_defaultRule(dParts2[0],[dParts2[1]],dParts2[2])
    
    dParts3 = no.stringListToBasicLogic(['( o <- F )', '( ab1 <- T ) ', '( ab1 <- T )'])
    default3 = basicLogic.operator_tritonic_defaultRule(dParts3[0],[dParts3[1]],dParts3[2])
    
    dParts4 = no.stringListToBasicLogic(['( e <- F )', '( ab2 <- T ) ', '( ab2 <- T )'])
    default4 = basicLogic.operator_tritonic_defaultRule(dParts4[0],[dParts4[1]],dParts4[2])
    
    D=[default1,default2,default3,default4]
    
    basePoint = epistemicState.epistemicState('Bird Example')
    basePoint['D']=D
    basePoint['W']=W
    basePoint['V']=V
    
    
    ctm_flight = CTM.CTM()
    ctm_flight.si=[basePoint]
    #ctm_flight.appendm(TH)
    ctm_flight.appendm(DEFAULT)
    
    
    print (ctm_flight)
    print (ctm_flight.evaluate())