The input is a Boolean formula in 2-CNF, given as a string of symbols.
Example: p /\ (p -> q) /\ (p -> ~r) /\ (~r / ~s) /\ (s / ~q)
I am using Resolution method to solve this 2 cnf sat problem but I am stuck with how to compare literals of two clauses in python as we need to check the variable and its negation in another clause
This is your homework, so no one is going to just do it for you. We can help if you're stuck at a specific point, but we won't do the work you are expected to do.
That said, I can give you some hints on how your code should be organized:
EDIT
Sorry for misunderstanding your question.
simpyhas alogicmodule with a lot of features, including a resolution function. But if you need to restrict yourself to the standard library then you will have to work a bit with strings.I'm assuming each clause is: a) a single literal; b) an implication with exactly two literals; c) a disjunction of two or more literals, and that each variable is exactly 1 character. If we wanted to manage more complex cases we would need to define a simple tokenizer.
This is a possible code for the first function: