Preface: these notes are primarily based on Chapter 2 of Ertel's text.
We introduce both the syntax and semantics of propositional logic.
We assume that there is a set, Σ, of symbols that represent our base atomic formulas.
We let symbols t and f be literals for true and false, respectively
We consider the following operators: ¬, ∧, ∨, ⇒, ⇔
Well-formed formula
DEFINITION:
An assignment (aka, interpreation, world,
model) is a function,
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" |
A ∧ B ⇒ ¬ C ∨ D ∧ E ⇔ F ⇒ Gwould 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 ⇒ Cis 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
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 |
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
THEOREM:
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:
Proof:
Note that
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 calculus is a purely syntactic proof system that
uses discrete steps resulting in a derivation. We use the notation
Example: we could consider a calculus in which we only apply modus
ponens, namely that if our knowledge base has formula A and
formula
Example: another calculus is based on the resolution
rule, in which we use the two formulas
DEFINITION:
A calculus is sound if every derived formula is
valid. That is, for any KB and Q, if
DEFINITION:
A calculus is complete if every formula that is valid
can be derived. That is, for any KB and Q, if
Examples:
As isolated rules, both modus ponens and resolution are
sound (this can be shown by truth table). However,
neither is complete. For example,
we know that
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:
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.
Example:
| |
|
| ≡ |
via implication |
| ≡ |
via De Morgan's law |
| ≡ |
via distribution |
| ≡ |
via distribution |
| ≡ |
via associative law |
Example (for students):
---Spoiler Alert---
| |
|
| ≡ |
via removal of ⇔ |
| ≡ |
via removal of nested ⇒ operators |
| ≡ |
via removal of remaining ⇒ operators |
| ≡ |
via De Morgan's law (and double-negative) |
| ≡ |
via distributive law |
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.
We will restate the resolution rule as follows. If we have
a precondition
We could allow A to be the literal f, in which case the
resolution rule represents modus ponens, in that
Since A and C could themselves be compound disjunctions, a more general view of resolution is as follows:
derives the resolvent
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
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
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
Example from book (paraphrased):
A traveler who is unsure of his English is speaking to an
English family. As a result, there is some ambiguity in
interpreting what he hears.
Create a propositional logic formula; convert it to CNF; apply resolution to test consistency or to derive further knowledge.
---Spoiler Alert---
Original formula:
CNF:
For purpose of resolution, we label the clauses as follows:
1) (S ∨ N)
2) (¬S)
3) (N ∨ P)
4) (¬N ∨ P)
As next step in resolution, we could resolve(1,2) or could
resolve(3,4) or resolve(1,4). This gets us respectively
5) (N)
6) (P)
7) (S ∨ P)
There are no further resolutions possible. Therefore the
original knowledge base is consistent, and we note that our
updated knowledge base includes the facts
Example from the book (paraphrased):
Three girls practice high jump for their physical education
final exam. The bar is set to 1.20 meters.
---Spoiler Alert---
Formula:
CNF:
Resolution can be used to eventually derive contradiction.
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
using the following equivalent formula
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.)
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
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 |
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:
The only clause with Q as its head is
There is only one clause with P as its head:
There are two different clauses with L as the head, and we could
choose to consider either one. The first is
In this case, we would make both A and B as subgoals, and quickly find that both of those exist as facts. This allows us to infer L as a fact.
In the recursive process, we now return to the fact that we had
M as a subgoal. To prove that, we must use the clause
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).