Introduction to Comp Logic Plan of preparation Theory + predicate Resolution reasoning CDCL (DPLL) reasoning + algorithm CDCL(T) Z3 logic tasks Basics of Computational Logic Sentence - any proposition for which it is it makes sense to ask whether it is true or false. For example: ‘’Paul is running”, “Laura has red hair”, “It rains and it is a windy day”, “If it’s sunny, then I go to the sea” atomic sentence - if it contains no other sentence as its proper part. composite sentence - if it contains other sentences connectives - The words “and”, “or”, “if ... then”, “not”, “but” are called connectives. A propositional language L is just a set, whose elements are called propositional letters; Special characters in L(connectives) ∧ ("and"), ∨ ("or"), → ("if...then"), ¬ ("not"), Example of how it cannot be used: p ∨ ¬qqq ; ¬¬)p∧ Examples of how it can be used: p, q, (p ∨ q), (¬(p ∨ q)) Order of importance of connectives ¬ binds strongly than ∧, ∨, and ∧, ∨ bind strongly than →. ¬ stronger than ∧, ∨ stronger than →. Important things Uniqueness of reading A ↔ B = (A → B) ∧ (B → A) A → B = ¬A ∨ B Introduce the truth tables for connectives Tautology vs Contradiction Tautology – always true, for example p v ¬p Contradiction – always false, for example p ∧ ¬p SAT problems. In terms of our syllabus, SAT problems can be solved by two ways: ● ● Resolution reasoning DPLL reasoning For both of these reasoning we need to know what are normal forms: ● ● Negation normal form (NNF) Conjunction normal from (CNF) Normal forms NNF - iff it does not contain implications and all negations occurring in it are in front of atomic formulas. Examples: ¬p CNF - iff it is a conjunction of clauses. Example Try on your own Resolution calculus! Tasks to solve: 1) 2) 3) 4) ¬p ∨ ¬q p ∨ ¬q ¬p ∨ q p∨q If we get an empty clause in the end, then it is UNSAT If we got every possible clause and no contradiction → SAT Task 2: 1)p∨q∨s 2)¬s∨r 3)¬r∨p Task 3: 1)a∨r 2)b∨c 3)¬a∨¬p 4)¬a∨¬q 5)¬b∨p 6)¬b∨¬r 7)¬c∨q 8)¬c∨¬r Answer for the HW task UNSAT One more task to revise resolution 1) 2) 3) 4) 5) ¬p∨¬q∨r p∨¬q∨¬r ¬q∨r q∨¬r ¬p∨¬q∨¬r DPLL – the DPLL procedure attempts to construct (by a a mechanism of backtracking) an assignment ∨ that satisfies a given set of clauses F0. DPLL is used in the algorithms CDCL (“Conflict Driven Clause Learning”) is a little bit more advanced version of DPLL, and will be mainly used in the exams, will be introduced a little bit later DPLL: how does it work? Propagation Rule: if we are in the state ∨ , we can pass to the state ∨, lp if F0 contains a clause of the kind D ∨ l, we have that ∨ |= ¬D and the literal l is not defined in ∨ Failure Rule: if we are in the state ∨ , we can terminate with the UNSAT outcome, in case there are not decided literals in ∨ and F0 contains a clause C such that ∨ |= ¬C. (Chronological) Backtracking Rule: if we are in the state ∨ = ∨1, ld, ∨2, we can pass to the state ∨1, ¬lp if there are no decided literals in ∨2 and F0 contains a clause C such that ∨ |= ¬C. Decision Rule: if we are in the state ∨ , we can pass to the state ∨, ld in case the previous rules do not apply, l is not defined in ∨ and either l or ¬l (or both) occur somewhere in F0. In DPLL At the start, you can decide any literal you want, and add it to your solution Then, you look at the clauses and see if anything else could be propagated to our solution, if yes → we propagate this literal (lp) If not → we decide another literal (ld) If we the literal we are trying to propagate is giving us a contradiction (example: we are propagating q, but we already have ¬q in the answer clause, therefore we are forced to do the backtrack to the last decided literal and make it propagated, instead of decided If we have a contradiction and all the literals are propagated => UNSAT If no rules are applying, and the condition ∨ is satisfied, therefore we have SAT CDCL intro CDCL has a few additional steps than DPLL: It is written in this form: ⟨d | F | C⟩ Where ∨ → a place where we add decided or propagated literals, so it is basically our answer clause F is the place where all the clauses are stored, and where we add clauses after the explain rule. α is used to show the status of the algorithm, where α = * is a search state, and otherwise it is a conflict state CDCL initiation ⟨∅ | F0 | ∗⟩ – write this to initiate the algorithm Then everything is the same as in the DPLL rule, except of explain and backjumping rule Explain rule – if there is a clause C that causes the conflict, we can apply resolution to it, making it with the last propagated clause, and then adding it to F, the initial set of clauses Backjump rule – is a more advanced backtracking that allows us to save some time by not going to the first decided literal and making it propagated, but to use the result from the explain rule to propagate some literal CDCL task 1) 2) 3) 4) ¬p∨¬q p∨q ¬p∨q p∨¬q Solve using the CDCL Hint: start with the < ∅, 1-4, *> CDCL task 2: 1) 2) 3) 4) 5) 6) 7) 8) a∨r b∨c ¬a∨¬p ¬a∨¬q ¬b∨p ¬b∨¬r ¬c∨q ¬c∨¬r CDCL task 3: 1) 2) 3) 4) 5) ¬p V q V r p V ¬q V ¬r ¬q V r q V ¬r ¬p V ¬q V ¬r CDCL exam task: 20/02/2023 - ver. B Example of a solution that you will need to provide on exam