def create_si_contra(): #define the initial atomic name in the WCS: one for each observed card #these atoms have value None D = basicLogic.atom('D') K = basicLogic.atom('K') three = basicLogic.atom('3') seven = basicLogic.atom('7') #this is the atom which means NOT (D) Dprime = basicLogic.atom("D'") #create an epistemic state containing the known facts and conditionals basePointContra = epistemicState.epistemicState('WST') #the set of conditionals with the contraposition rule delta_contra = ["( 3 | D )", " ( D' | 7 ) "] #the set of conditionals as a set of <basicLogic> clauses deltaAsLogic = scpNotationParser.stringListToBasicLogic(delta_contra) #the set of facts known, this prevents negative heads in rules S_contra = ["( ( D ) <- ( ! D' ) )"] #the set of known facts as <basicLogic> SAsLogic = scpNotationParser.stringListToBasicLogic(S_contra) #the set of abducibles, any subset of which might be an explanation abducibs = [ '( D <- T )', '( D <- F )', '( K <- T )', '( K <- F )', '( 3 <- T )', '( 3 <- F )', '( 7 <- T )', '( 7 <- F )' ] abducibs = ['( D <- T )', '( K <- T )', '( 3 <- T )', '( 7 <- T )'] #transform the set of abducibles to a set of <basicLogic> clauses logAbducibs = scpNotationParser.stringListToBasicLogic(abducibs) #set the structural variables of the only epistemic state in the intial state point basePointContra['S'] = SAsLogic basePointContra['Delta'] = deltaAsLogic basePointContra['V'] = [D, K, three, seven, Dprime] basePointContra['R'] = {'abducibles': logAbducibs} return [basePointContra]
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())
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())
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())
def abducibleSuppression(): print("===========================================================") print("=================ABDUCIBLE SUPPRESSION=====================") print("===========================================================") basePoint1 = epistemicState.epistemicState('el') delta1 = ["( l | e )"] S1 = ["( e <- T )"] delta1AsLogic = scpNotationParser.stringListToBasicLogic(delta1) S1AsLogic = scpNotationParser.stringListToBasicLogic(S1) basePoint1['S'] = S1AsLogic basePoint1['Delta'] = delta1AsLogic basePoint1['V'] = [e, l] #The elo case expressed as the addition of information to the el case basePoint2 = copy.deepcopy(basePoint1) basePoint2.setName('elo') #The possible starting states for the SCP extraConditional = ["( l | o )"] extraConditionalAsLogic = scpNotationParser.stringListToBasicLogic( extraConditional) basePoint2['Delta'] = basePoint2['Delta'] + extraConditionalAsLogic basePoint2['V'] = basePoint2['V'] + [o] #abducibs = [ '( l <- T )', '( l <- F )','( o <- T )', '( o <- F )'] abducibs = ['( o <- T )', '( o <- F )'] logAbducibs = scpNotationParser.stringListToBasicLogic(abducibs) basePoint1['R'] = {'abducibles': logAbducibs} basePoint2['R'] = {'abducibles': logAbducibs} #Create the first state point statePoints = [basePoint1, basePoint2] s_i = statePoints f = f_suppression_studyLate #The desired output of the external evaluation function gamma = { 'el': 'She will study late in the library', 'elo': 'We are uncertain if she will study late in the library' } #test ctm c = CTM.CTM() c.setSi(s_i) c.appendm(ADDAB) c.appendm(ABDUCIBLES) c.appendm(WC) c.appendm(SEMANTIC) predictions = f(c) print('predictions: ', predictions) print("Lenient Interp") print( StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)) print("Strict Interp") print( StatePointOperations.predictionsModelsGamma_strict(predictions, gamma)) print("f(pi) models gamma_noSup? : ", (StatePointOperations.predictionsModelsGamma_lenient( predictions, gamma)))
def createBasePoint_el(): basePoint_el = epistemicState.epistemicState('el') delta1 = ["( l | e )"] S1 = ["( e <- T )"] delta1AsLogic = scpNotationParser.stringListToBasicLogic(delta1) S1AsLogic = scpNotationParser.stringListToBasicLogic(S1) basePoint_el['S'] = S1AsLogic basePoint_el['Delta'] = delta1AsLogic basePoint_el['V'] = [e, l] return basePoint_el
) print("Epistemic state:") print(epi) print("response(p_bar):", responses[-1]) print("------------------------------") return responses # THE SET OF COGNITIVE OPERATIONS APPROPRIATE TO THE SUPPRESSION TASK ADDAB = CognitiveOperation.m_addAB() WC = CognitiveOperation.m_wc() SEMANTIC = CognitiveOperation.m_semantic() ABDUCIBLES = CognitiveOperation.m_addAbducibles(maxLength=4) DELETE = CognitiveOperation.m_deleteo() basePoint1 = epistemicState.epistemicState('el') delta1 = ["( l | e )"] S1 = ["( e <- T )"] delta1AsLogic = scpNotationParser.stringListToBasicLogic(delta1) S1AsLogic = scpNotationParser.stringListToBasicLogic(S1) basePoint1['S'] = S1AsLogic basePoint1['Delta'] = delta1AsLogic basePoint1['V'] = [e, l] #The elo case expressed as the addition of information to the el case basePoint2 = copy.deepcopy(basePoint1) basePoint2.setName('elo') #The possible starting states for the SCP extraConditional = ["( l | o )"] extraConditionalAsLogic = scpNotationParser.stringListToBasicLogic( extraConditional)