def timeCounterfactualsOfHigherComplexity(n = 1): letters = ["p", "q", "r", "s"] connectives = ["~", ">", "&", "|"] # begin the universe S = init(letters) # choose a formula, update with it as a law S = updateLaw(S, randomClassicalFormula(n)) # choose a formula, update it normally S = updateFormula(S, randomClassicalFormula(n)) # "If it had been the case that \psi" is a retraction of ~\psi then update with \psi S = ifItHadBeenTheCase(S, randomClassicalFormula(n))
def checkRandomCounterfactual(cogstate): # generate a random law and update with it: law="("+choice(alphabet)+")>("+choice(alphabet)+")" #print " updating with the law "+law cogstate = updateLaw(cogstate,law) # generate a random fact and update with it: fact=choice(alphabet) #print " updating with the fact "+fact cogstate = updateFormula(cogstate,fact) # generate a random non-trivial counterfactual and check it: cfantecedent=choice(alphabet) restralph=list(alphabet) restralph.remove(cfantecedent) cfconsequent=choice(restralph) #print " checking the counterfactual "+cfantecedent+"~>"+cfconsequent+":" cogstateNew = ifItHadBeenTheCase(cogstate, cfantecedent) result=supports(cogstateNew,cfconsequent)
out += texify(W) # Update with the fact that we see the man W = updateFormula(W, "r") out += texify(W) # Update with the law that if we see a man with a hamburger, he must have # got it at one of the snackbars W = updateLaw(W, "(r)>((p)|(q))") out += texify(W) # Update since we see A is open W = updateFormula(W, "p") out += texify(W) # Compute the counterfactual W = ifItHadBeenTheCase(W, "~(p)") out += texify(W) # Finish the tex file out += texfooter() try: f = open("hansson.tex", "w") try: f.write(out) # Write a string to a file finally: f.close() except IOError: pass call(["pdflatex", "-interaction=batchmode", "hansson.tex"])
language = ['p','q','r'] s0 = worldgen(language) s1=updateFormula(s0, "r") s2=updateLaw(s1, "(r)>((p)|(q))") s3=updateFormula(s1, "p") print "\nThis is s3:" print(texify(s3)) print "\nThe bases of w_7 in s3 are: " pprint(getAllBases(getWorldByName("w_7",s3),s3)) prop=propositionFromFormula(s3,"p") print "\nThe retraction of w_7 with [[p]] is:" pprint(retractOnWorld(s3,"w_7",prop)) print "\nThe retraction of s3 with [[p]] is:" s4=retractOnState(s3,prop) pprint(s4) print(texify(s4)) s5=ifItHadBeenTheCase(s3,"~(p)") print "\nThis is s5:" print texify(s5)