Propositional Logic

Preface: these notes are primarily based on Chapter 2 of Ertel's text.


We introduce both the syntax and semantics of propositional logic.

Syntax

Well-formed formula

Semantics

DEFINITION:
An assignment (aka, interpreation, world, model) is a function, Σ → {t, f}, that maps each base literal to either true of false.

For a given assignment, any well-formed formula will evaluate to either true or false, using standard Boolean algebra. Specifically, our operators are as follows:

syntax operator pronunciation
¬A negation "not A"
A ∧ B conjunction "A and B"
A ∨ B disjunction "A or B"
A ⇒ B implication "if A then B"
A ⇔ B equivalence "A if and only if B"

When forming compound formula, we assume precedence of operators ordered as given in the above table, with equivalent operators evaluated left-to-right. Therefore the formula:

A ∧ B ⇒ ¬ C ∨ D ∧ E ⇔ F ⇒ G
would be interpreted as if parenthesized in the following way
((A ∧ B) ⇒ ((¬ C) ∨ (D ∧ E))) ⇔ (F ⇒ G)
We will try to avoid relying on left-to-right ordering of implications and equivalence, although technically
A ⇒ B ⇒ C
is interpretted as
(A ⇒ B) ⇒ C

It is easiest to describe the semantics by providing a truth table, giving the value of a formula for each assignment of the base literals.

A B ¬A A ∧ B A ∨ B A ⇒ B A ⇔ B
t t t f t t t t
t f t f f t f f
f t t t f t t f
f f t t f f t t



DEFINITION:
We say that a given formula is:


DEFINITION:
Two formulas F and G are said to be semantically equivalent if they take on the same truth value for any interpretation.
We denote this as F ≡ G. In propositional logic, this is the same as saying that the formula F ⇔ G is a tautology.

THEOREM:
The following are tautologies
¬A ∨ B A ⇒ B (implication)
A ⇒ B ¬B ⇒ ¬A (contraposition)
(A ⇒ B) ∧ (B ⇒ A) (A ⇔ B) (equivalence)
¬(A ∧ B) ¬A ∨ ¬B (De Morgan's law)
¬(A ∨ B) ¬A ∧ ¬B
A ∨ (B ∧ C) (A ∨ B) ∧ (A ∨ C) (distributive law)
A ∧ (B ∨ C) (A ∧ B) ∨ (A ∧ C)
A ∨ ¬A t (tautology)
A ∧ ¬A f (contradition)
A ∨ f A
A ∨ t t
A ∧ f f
A ∧ t A


Proof Systems

We next consider the notion of a formula logically following from a set of existing knowledge, as well as ways in which we might formally prove such entailment.

DEFINITION:
We say that a knowledge base KB entails a formula Q (or equivalently that Q follows from KB) if every model of KB is also a model of Q.
We write KB ⊨ Q.

THEOREM:
KB ⊨ Q if and only if KB ⇒ Q is a tautology.

A Proof System is a constructive way to prove that a knowledge base entails a formula. In propositional logic, there are finitely many (2n) possible assignments, and so examination of a truth table can be used as a proof system. Unfortunately, this is not a very efficient system.

As a step in another direction, we note that entailment can be proven by contradiction based on the following variant of the earlier theorem.

THEOREM:
KB ⊨ Q if and only if KB ∧ ¬Q is unsatisfiable.
Proof: Note that (KB ∧ ¬Q) ≡ ¬(KB ⇒ Q), so it being unsatisfiable is the same as saying that (KB ⇒ Q) is a tautology.

This approach is used by PROLOG (and other systems), by temporarily adding the negated query ¬Q to the knowledge base and then deriving a contradition (typically of the form A ∧ ¬A for some A).

A calculus is a purely syntactic proof system that uses discrete steps resulting in a derivation. We use the notation KB ⊢ Q if Q can be derived from KB in accordance with a given calculus.

DEFINITION:
A calculus is sound if every derived formula is valid. That is, for any KB and Q, if KB ⊢ Q, then KB ⊨ Q.

DEFINITION:
A calculus is complete if every formula that is valid can be derived. That is, for any KB and Q, if KB ⊨ Q, then KB ⊢ Q.


Normal Forms

To keep automatic proof systems simple, they typically require that boolean formulas adhere to a particular conventional syntax known as a normal form.

A commonly used form is conjunctive normal form (CNF), in which the formula is expressed as a conjunction of clauses, with each clause being a disjunction of positive or negative literals.

THEOREM:
Any well-formed formula can be transformed into an equivalent conjunctive normal form.

Proof: not given in text book, but constructive algorithm can be defined:

  1. Remove use of ⇒ and ⇔ operators by using equivalent formulation with ¬, ∧ and ∨
  2. Use De Morgan's law to "push" all negations down to the literals (and cancelling any double-negatives)
    1. If outermost operator is an ∧, then independently compute CNF for each of its operands and trivially combine them.
    2. Otherwise, outermost operator is ∨; compute CNF of each of its operands and then repeatedly use distributive law to combine those results.

Simplifications can be made to remove redundant literals in clauses, and if a contradiction exists within a clause, then the entire formula is unsatisfiable and thus equivalent to f.

Unfortunately, there are formulas that require exponential increase in size when converting to equivalent CNF.

Conjunctive normal form is particularly appealing when representing a knowledge base KB, as the knowledge is simply a collection of clauses, and new knowledge can be reincorporated by adding further clauses.


Resolution

We will restate the resolution rule as follows. If we have a precondition (A ∨ B) ∧ (¬B ∨ C) then we can derive the resolvent (A ∨ C). Notice that complementary literals B and ¬B appear in the respective two clauses

We could allow A to be the literal f, in which case the resolution rule represents modus ponens, in that B ∧ (B ⇒ C) ⊢ C.

Since A and C could themselves be compound disjunctions, a more general view of resolution is as follows:

(A1 ∨ A2 ∨ ... ∨ Am ∨ B) ∧ (¬B ∨ C1 ∨ C2 ∨ ... ∨ Cn)
derives the resolvent
(A1 ∨ A2 ∨ ... ∨ Am ∨ C1 ∨ C2 ∨ ... ∨ Cn)

It is also worth noting that if a pair of clauses have two or more complementary literals, there is no benefit to resolving them, as the result is trivially true (for example, if we resolve on complementary B1 and there exists a complementary B2 elsewhere, the resolvant clause will thus contain B2 ∨ ¬B2 and be trivially a tautology.

Finally, if the two initial clauses have a shared literal with the same sign, we will only list that literal once in the resolvent, so as to avoid duplicates. For example, we allow (A ∨ B ∨ C) ∧ (A ∨ ¬B ∨ ¬D) to resolve to (A ∨ C ∨ ¬D), rather than the redundant syntax (A ∨ C ∨ A ∨ ¬D).

Resolution Calculus
Given an initial knowledge base, the resolution calculus states that we can repeatedly resolve any pair of clauses that have exactly one complementary pair of literals, adding the resolvent to the knowledge base.

If we ever find two complementary clauses, such as (A) and (¬A), we conventionally say that these resolve to an empty clause, reflecting the inherent inconsistency of the original knowledge base. Although resolution is not complete for derivation of general propositional logic formulas, we have the following fundamental theorem:

Example: (adapted from Neopolitan/Jiang)
Assume we have the following premises:
Premise 1) ¬B
Premise 2) A ⇒ B
Premise 3) ¬A ⇒ (C ∨ D)
Premise 4) C ⇒ D
Premise 5) F
Premise 6) F ⇒ ¬E

Goal is to prove D.

---Spoiler Alert---
We convert to CNF, add the negated goal, and then begin resolution (choice of resolutions steps is indeterminate):
Fact 1) ¬B (premise 1)
Fact 2) ¬A ∨ B (premise 2)
Fact 3) A ∨ C ∨ D (premise 3)
Fact 4) ¬C ∨ D (premise 4)
Fact 5) F (premise 5)
Fact 6) ¬F ∨ E (premise 6)
Fact 7) ¬D (the negated goal)
Fact 8) A ∨ C (Resolvent of 3 and 7)
Fact 9) B ∨ C (Resolvent of 2 and 8)
Fact 10) C (Resolvent of 1 and 9)
Fact 11) D (Resolvent of 4 and 10)
Fact 12) False (Resolvent of 7 and 11)

THEOREM:
The resolution calculus for the proof of unsatisfiability of formulas in conjunctive normal form is sound and complete.

Proof: (omitted from book) Clearly, the calculus is sound. And so if we resolve the empty clause, the original formula was unsatisfiable. What remains is to show that if we do all resolutions and cannot generate the empty clause, then the formula is satisfiable. Fortunately, we can constructively build a model by assigning truth values to literals to satisfy all clauses.

Construction considers symbols in arbitrary order and assigns each a truth value, giving the symbol the necessary value if there is any clause that requires that value given all previously assigned values (if no such clause, then we assign arbitrary truth value to symbol). We claim this is feasible, that is, there will never be a variable that is required to have opposite truth values by two different clauses. Proof by contradiction: Assume that variable sk is the first symbol considered for which there was no legal assignment. Consider two clauses demanding opposite values for sk. The resolvent of those clauses uses only symbols already considered, and thus it should have been satisfied.

As an extension to this theorem, we can use resolution to determine whether KB ⊨ Q for arbitrary query Q by adding the complement of Q to the knowledge base; if (KB ∧ ¬Q) is unsatisfiable then it must be that KB ⊨ Q.


Horn Clauses

In general, disjunctive clauses have any number of positive and negative literals.

DEFINITION:
A disjunctive clause with at most one positive literal is known as a Horn clause.

Examples of valid horn clauses:

DEFINITION:
A clause with a single positive literal is a fact. (e.g., B)
If a clause has a positive literal and one or more negative literals, the positive literal is called the head of the clause.
If a clause has only negative literals, this is often known as a goal clause (for reasons we will explain below).

It is easier to interpret a Horn clause, such as
(B ∨ ¬A1 ∨ ¬A2 ∨ ... ∨ ¬An)
using the following equivalent formula
(A1 ∧ A2 ∧ ... ∧ An) ⇒ B
and thus we see that a series of facts, A1, A2, ..., An can be used to derive a new fact B.

Notice that the resolution of two Horn clauses is guaranteed to itself be a Horn clause. (try it!)

Horn clauses are significant because if we restrict a proof system to be a CNF formula using only Horn clauses, then we can consider a more efficient calculus for theorem proving. (We will later see that PROLOG is based on use of Horn clauses for expressing knowledge and queries.)

Forward and Backward Chaining

The first resolution calculus we considered was based on what is known as forward chaining; we started with clauses that we knew to be true (perhaps even including a negated query), and then proceeded to derive additional clauses until reaching our goal or exhausting all possibilities. Unfortunately, that can be time consuming since we in some way have to consider all possibly resolutions of pairwise clauses (including newly derived clauses) to determine if they have a complementary literal, and this may result in an exponential time computation.

In fact, for general CNF formula, there does not exist any algorithm for testing satisfiability in polynomial time unless P=NP, as the satisfiability problem for CNF formula is among the first decision problems shown to be NP-complete.

However, when working only with Horn clauses, entailment of a goal can be tested in worst-case linear time. We consider a form of backward chaining in which we start with the goal we wish to prove and then determine what facts we would need in order to prove it. Specifically, we consider a calculus known as Selection rule-driven Linear resolution for Definitive clauses (SLD).

Consider the following example (using implication syntax to express the clauses equivalently).
Horn clause Equivalent impliciation
Q ∨ ¬P P ⇒ Q
P ∨ ¬L ∨ ¬M L ∧ M ⇒ P
M ∨ ¬B ∨ ¬L B ∧ L ⇒ M
L ∨ ¬A ∨ ¬P A ∧ P ⇒ L
L ∨ ¬A ∨ ¬B A ∧ B ⇒ L
A A
B B

If viewing standard resolution algorithm, to attempt to prove the query Q, we add the goal clause ¬Q to the system.

For backward chaining, in order to prove the goal Q, there must be some other clause that has Q as its head; otherwise Q is not entailed. If there are one or more such clauses, we consider them one at a time (in a fixed order); for each, we declare all literals in the conjunctive condition as new subgoals for our proving system.

The relation between the various Horn clauses can be expressed as a directed graph known as an AND-OR graph. It is easier to describe the algorithm when considering such a graph.

Consider the above example:

Intuitively, the algorithm is performing dynamic programming on the directed AND-OR graph, and therefore its overall running time is proportional to the number of nodes and edges in that graph (which is linear in the size of the original knowledge base).


Michael Goldwasser
Last modified: Tuesday, 03 September 2013