0

So the question relates to List of lists that store different propositional modal formulaes. I am capable of removing duplicates but I don't know how to find inconsistances. So for example:

Initial List of lists:

[[('not', ('box', 'p')), ('box', 'p'), ('not', 'q'), ('q'), ('diamond', 'r')],
 [('not', 'p'), 'q'], ['or', ('p', 'q')],
 ['not',('or', ('p', 'q'))],['r', 'q']]

The above sample list of lists has some problems I would like to simply find them and print out a message. For example 1st list has box p and negated box p I would like it to be detected. Also it has not q and q.

Similarly, 2nd list has not (p or q) and (p or q). Can anyone suggest a solution to this problem, it could be something easy but I don't seem to be able to think of it.

Ideally, is it possible to mark a sublist as closed? Perhaps assign status closed?

duplode
  • 33,731
  • 7
  • 79
  • 150
marcincuber
  • 3,451
  • 1
  • 17
  • 29
  • Okay time for interrogation: What do you mean by 'I would like it to be detected'? Can you share your code that is not working so that we start somewhere on the same page as you? Why are you not using logic library like `sympy`? – dopstar Nov 01 '15 at 12:22
  • So, I am translating string into tableau format which looks like the list above. By detecting, I simply want to print a message which will tell me that in list[1] there is p and not p formula and therefore this list is inconsistent. I don't use sympy because it is not good enough for modal logic. – marcincuber Nov 01 '15 at 13:40

1 Answers1

0

This is the solution to the problem I presented in the question. Works correctly, in case someone can improve it or make it shorter (or faster) please do post your proposition.

def inconsistent(psi):
for i in range(0,len(psi)):
    for j in range(0,len(psi[i])):
        main = psi[i]
        form = psi[i][j]
        if form[0] == 'not':
            notform = form[1]
            if form and notform in main:
                print "inconsistent: ", psi[i][j]
        else:
            notform = ('not', psi[i][j])
            if form and notform in main:
                print "inconsistent: ", psi[i][j]
            else:
                print "consistent: ", psi[i][j]


test = [[('not', ('box', 'p')), ('box', 'p'), ('not', 'q'), ('q'), ('diamond', 'r')], [('or', ('p', 'q')),('not',('or',('p','q')))],['not',('or', ('p', 'q'))],['r', 'q']]

inconsistent(test);
marcincuber
  • 3,451
  • 1
  • 17
  • 29