A proposition is a statement that is true or false in each interpretation.
1.1.2 - Why Propositions?
Specifying logical formulae is often more natural than filling in tables (i.e. large truth tables)
It is easier to check correctness and debug formulae than tables (think of checking linear algebraic expressions versus matrices containing a set of linear equations)
We can exploit the Boolean nature for (algorithmic) efficient reasoning (pruning, consistency and the resolution rule)
We need a language for asking queries (of what follows in all models) that may be more complicated than asking for the value of a variable.
You may only have partial knowledge of some constraints
It is easy to incrementally add formulae
It can be extended to infinitely many variables with infinite domains (using logical quantification)
1.1.3 - Formal Language
The formal language representation and reasoning system is made up of:
Syntax Specifies the legal sentences
Semantics Specifies the meanings of symbols
Atoms are logical formulae with no deeper propositional structure (i.e. the primitive components of a formal language)
These are usually associated with a reasoning theory or proof procedure: a (non-deterministic specification of how an answer can be produced).
There are many types of logic:
Propositional logic (used in this course)
Predicate / first order logic
High order logic
1.1.4 - Semantics - Human's View of Semantics
Step 1 - Begin with a task domain (e.g. scheduling trains on the network)
Step 2 - Choose atoms in the computer to denote propositions. These atoms have meaning to the knowledge base designer
Step 3 - Tell the system knowledge about the domain
Step 4 - Ask the system questions - Is this statement true at all times?
The system can tell you whether the question is a logical consequence (of the knowledge base)
You can interpret the answer with the meaning associated with the atoms.
1.1.5 - Example of Semantics - Electrical Environment
In Computer
light1_broken⇐sw_on∧power∧unlit_light_1
sw_on
power⇐lit_light_2
unlit_light_1
lit_light_2
In User's Mind
∗light_1_broken∗ Light #1 is broken
sw_on Switch is up
power There is power in the building
unlit_light_1 Light 1 isn't lit
lit_light_2 Light 2 is lit
Conclusion → light_1_broken
The computer doesn't know the meaning of the symbols
The user can interpret the symbols using their own meanings.
An atom is a symbol (Starting with a lowercase letter)
A sentence (or body) is an atom or is of the form s1∧s2 where s1 and s2 are sentences.
A definite clause is an atom or is a rule of the form h⇐s where h is an atom and s is a sentence
h⇐s:h is implied by s
A knowledge base is a set of definite clauses.
1.1.7 - RiPPLE Activity
An atomic proposition / atom is a symbol.
We use the convention that propositions consist of letters, digits, and underscores (_) (and start with a lowercase character)
Atoms are known to be either true or false
Are these propositions?
What is the distance between Mars and Earth? Can't be evaluated to either True or False.
x+2=2x Not always true or always false - therefore, not a proposition
x+2=2x When x=1 Yes, is either true or false.
2x<3x No, as the truth value changes depending on whether x is positive or negative.
Atoms are often represented with a symbol called propositional variable, (e.g. p, q)
1.1.8 - Complex Propositions
Complex propositions (or sentences) can be built from simpler propositions using logical connectives.
Brackets, ()
Negation, ¬
And/Conjunction, ∧
Or/Disjunction, ∨
Implication, ⇒
Biconditional/Equivalence, ⇔
1.1.9 - Rules for Evaluating Truth
¬p
p∧q
p∨q
p⇒q
p⇔q
is TRUE iff p is FALSE
is TRUE iff p is TRUEand q is TRUE
is TRUEiff p is TRUE or q is TRUE
is TRUEiff p is FALSE or q is TRUE
is FALSE iff p is TRUEand q is FALSE
is TRUEiff p⇒q and q⇒p
Semantics
An interpretation I assigns a truth value to each atom
A sentence s1∧s2 is true in I if s1 is true in I and s2 is true in I
A rule h⇐b is false in I if b is true in I and h is false in I
The rule is otherwise true
A knowledge base KB is true in I if and only if every clause in KB is true in I
A model of a set of clauses is an interpretation in which all the clauses are TRUE
If KB is a set of clauses and g is a conjunction of atoms, g is a logical consequence of KB, written KB⊨g if g is TRUE in every model of KB
That is, KB⊨g if there is no interpretation in which KB is TRUE and g is false.
RiPPLE Activity - Knowledge Base
A model of a set of clauses is an interpretation which all of the clauses are True;
KB=⎩⎨⎧p⇐qqr⇐s
I1 is a model of KB as:
p⇐q>>True⇐True>>True
q>>True>>True
r⇐s>>True⇐True>>True
I2 is not a model of KB as:
p⇐q>>False⇐False>>True
q>>False>>False
r⇐s>>False⇐False>>True
I3 is a model of KB as:
p⇐q>>True⇐True>>True
q>>True>>True
r⇐s>>False⇐False>>True
I4 is a model of KB as:
p⇐q>>True⇐True>>True
q>>True>>True
r⇐s>>True⇐False>>True
I5 is not a model of KB as:
p⇐q>>True⇐True>>True
q>>True>>True
r⇐s>>False⇐True>>False
Which of p, q, r, s logically follow from KB? Suppose p, q, r and s are clauses. Does the knowledge base entail these variables?
From the knowledge base, we know that q is true. In the knowledge base, if p is true, then q must be true.
There is no constraint in the knowledge base that causes r or s to be true.
User's View of Semantics
How logic is used to represent a problem.
Formulate information as propositional logic sentences, to create a knowledge base.
Choose a task domain (intended interpretation)
Associate an atom with each proposition you want to represent
Tell the system clauses that are true in the intended interpretation: axiomatizing the domain
An axiom is something that is self-evidently true.
Axioms are the starting point for determining what is true in our models.
Ask questions about the intended interpretation
If KB⊨g then g must be true in the intended interpretation
i.e. if the questions that you are asking are logical consequences of the knowledge base, they must be true.
Users can interpret the answer using their intended interpretation of the symbols.
Computer's View of Semantics
The computer doesn't have access to the intended interpretation
All it knows is the knowledge base
The computer can determine if a formula is a logical consequence of KB
If KB⊨g then g must be true in the intended interpretation
If KB⊨g then there is a model of KB in which g is false. This could be the intended interpretation.
Deduction: Sentences entailed by the current KB can be added to the KB.
Added to the knowledge base for later reference / so that we don't have to compute it later
Querying the knowledge base is a process that can take a significant amount of time
Representing the Electrical Environment
Symbols
light_l1
light_l2
down_s1
on_s2
on_s3
ok_l1
ok_l2
ok_cb1
ok_cb2
live_outside
Logic Sentences
lit_l1⇐live_w0∧ok_l1
live_w0⇐live_w1∧on_s2
live_w1⇐live_w2∧off_s2
live_w2⇐live_w3∧off_s1
lit_l2⇐live_w3∧ok_l2
live_w4⇐live_w3∧on_s3
...
Conclusion - Terminology
A sentence is valid → Its truth value is TRUE for all possible interpretations (e.g. p∨¬p)
The sentence p∨¬p is valid as it is True for all possible truth values that p can take.
A sentence is satisfiable → Its truth value is TRUE for at least one of the possible interpretations (e.g. ¬p)
Everything that is valid is also satisfiable.
The sentence ¬p is satisfiable as it is True when p=False
A sentence is unsatisfiable → Its truth value is FALSE for all possible interpretations (e.g. p∧¬p)
The sentence p∧¬p is unsatisfiable as it is true for all possible values of p
For propositional logic, we can always decide if a sentence is valid / satisfiable / unsatisfiable in finite time (decidable problems).
Given a very large amount of computational power, we can always determine whether the problem is either valid, satisfiable or unsatisfiable.
2.0 - Validity
2.1 - Terminology
A model of a sentence: An interpretation that makes the sentence to be true
A sentence A entails another sentence B (denoted as A⊨B) iff every model of A is also a model of B (i.e. A⇒B is valid)
Two sentences A and B have semantics which result in interpretations of A and B.
If A entails B, all models of B are models of A
(i.e. A⇒B)
2.2 - Simple Validity / Model Checking
Check if ¬P1,2
is entailed by the knowledge base.
Knowledge Base
R1:¬P1,1
R2:B1,1⇔(P1,2∨P2,1)
R3:B2,1⇔(P1,1∨P2,2∨P3,1)
R4:¬B1,1
R5:B2,1
2.2.1 - Simple Model Checking
Enumerate the models
All true/false values for P1,1,B1,1,P1,2,P2,1,P2,2,P3,1
Check if
¬P1,2
is true in all models where the knowledge base
(R1∧R2∧R3∧R4∧R5)
is true
Sound The result is correct
Complete It always gives an answer
Complexityn is the number of propositional variables.
Time: O(2n)⇐ This is bad!
Space: O(n)
2.2.2 - Theorem Proving - Check Validity without Checking All Models
Use logical equivalence:
For any two sentences$\alpha, \beta$ sentences (which may be atomic or complex), we can convert them to logically equivalent statements using predicate logic rules.
Two sentences are logically equivalent iff true in the same models: α≡β iff α⊨β and β⊨α
(α∧β)≡(β∧α)
(α∨β)≡(β∨α)
((α∧β)∧γ)≡(α∧(β∧γ))
((α∨β)∨γ)≡(α∨(β∨γ))
¬(¬α)≡α
(α⇒β)≡(¬β⇒¬α)
(α⇒β)≡(¬α∨β)
(α⇔β)≡((α⇒β)∧(β⇒α))
¬(α∧β)≡(¬α∨¬β)
¬(α∨β)≡(¬α∧¬β)
(α∧(β∨γ))≡((α∧β)∨(α∧γ))
(α∨(β∧γ))≡((α∨β)∧(α∨γ))
Commutativity of ∧
Commutativity of ∨
Associativity of ∧
Associativity of ∨
Double-negation elimination
Contraposition
Implication Elimination
Biconditional Elimination
De Morgan
Distributivity of ∧ over ∨
Distributivity of ∨ over ∧
2.2.3 - Transformations of Logical Expressions
Modus Ponens (Model that affirms)
α⇒βαβ
Moduss Tollens (Model that Denies)
α⇒β¬β¬α
And-elimination (for a conjunction, any of the conjuncts can be inferred)
α∧βα
2.2.4 - Example - Theorem Proving using Natural Deduction / Logic
Enumerate the models
All true/false values for
P1,1,B1,1,P1,2,P2,1,P2,2,P3,1
Check if ¬P1,2 is true in all models where the knowledge base (R1∧R2∧R3∧R4∧R5) IS TRUE
Knowledge Base
S1:¬P1,1
S2:B1,1⇔(P1,2∨P2,1)
S3:B2,1⇔(P1,1∨P2,2∨P3,1)
S4:¬B1,1
S5:B2,1
S2:B1,1⇔(P1,2∨P2,1)
S6:(B1,1⇒(P1,2∨P2,1))∧((P1,2∨P2,1)⇒B1,1)
Using biconditional elimination on S2
S7:(P1,2∨P2,1)⇒B1,1 Using And elimination on S6
S8:¬(P1,2∨P2,1) Using Modus tollens on S4 and S7
S9:¬P1,2∧¬P2,1 Using De Morgan to S8
S10:¬P1,2 Using And elimination to S9
3.0 - Conjunctive Normal Form (CNF)
Given α,β and γ sentences (atomic or complex):
This single inference rule is sound and complete only when applied to propositional logic sentences written in Conjunctive Normal Form.
To make use of this rule, we need to re-express the sentences in our knowledge base in Conjunctive Normal Form
3.1 - Conjunctive Normal Form
Conjunctive Normal Form (CNF) - Conjunctions of disjunctions, e.g. (¬A∨B)∧(C∨D)∧(E∨F)
Some terminology:
Clause A disjunction of atoms, e.g. (¬A∨B)
Literals Variables or the negation of variables, A,¬A,B (atoms or negation of atoms)
CNF is quite useful for model checking and for solving satisfiability problems too - in fact, we've seen it before!
Constraint networks from the previous lecture!
3.1.1 - Converting to CNF
Three steps to convert to CNF
Eliminate arrows
Drive in negations using De Morgan
Distribute OR over AND
Note that disjunctions (OR) are inside the parentheses, and the conjunctions (AND) are outside.
Convert (A∨B)⇒(C⇒D)
Eliminate Arrows
(A∨B)⇒(¬C∨D) Using (α⇒β)≡(¬α∨β)
¬(A∨B)∨(¬C∨D) Using (α⇒β)≡(¬α∨β)
Drive in negations
(¬A∧¬B)∨(¬C∨D) Using De Morgan's
Distribute OR over AND
(¬A∨¬C∨D)∧(¬B∨¬C∨D) Using Distributive
3.1.2 - Resolution Refutation
There are three steps to perform resolution refutation
Convert all sentences to CNF
Negate the desired conclusion
Apply the resolution rule until we either:
derive false (a contradiction)
can't apply the rule anymore
Resolution Refutation is sound and complete (for propositional logic)
If we derive a contradiction, the conclusion follows from the axioms (proof by contradiction)
If we can't apply any more, the conclusion cannot be proved from the axioms. (no entailment; not a valid statement)
3.1.3 - Resolution Refutation Example
Knowledge Base:
(P∨Q)∧(P⇒R)∧(Q⇒R)
Elimination of arrows
(P∨Q)∧(P⇒R)∧(Q⇒R)
(P∨Q)∧(¬P∨R)∧(¬Q∨R)
Drive in negations using De Morgan's
As there are no external negations, we don't have to do anything
Distribute OR over AND
As there are only ORs inside the parentheses and ANDs outside the parenthesis, there is nothing to do.
Negate the Desired Conclusion
4.0 - Satisfiability
4.1 - Davis-Putnam-Logemann-Loveland (DPLL) Tree Search Algorithm
An assign-and-simplify strategy
Consider a search tree where at each level, we consider the possible arguments to one variable, say V
On one branch, we assume V is FALSE and on the other that it is TRUE
Given an assignment for a variable, we can simplify the sentence and then repeat the process for another variable
DPLL is a backtracking algorithm for systematically doing this.
The algorithm is building a solution while trying assignments - you have a partial solution which might prove successful or not as you go
Provides an ordering of variables to check first - this is the key to its efficiency.
The algorithm is building a solution while trying assignments - you have a partial solution which might prove successful or not as you go
Provides an ordering of variables to check first - this is the key to its efficiency
Definitions:
Clause: A disjunction of literals
Literals: Variables or the negation of variables
Unit clause: Clause which has exactly one literal which is still unassigned and the other (assigned) literals are all assigned to FALSE
Pure variable: Appears as positive only or negative only in S (a sentence)
If the current assignment is valid, you can determine the value of the unassigned pure variable in a unit clause, because the literal must be true
E.g. if we have (X1∨X2∨X3)∧(X1∨X4∨X5)∧(X1∨X4) and we have already assigned X1=FALSE then choose X4 and set it to TRUE
If all variables in the clause are false, then the variable that you are looking at must be true.
DPLL provides an ordering of which variables to check first:
DPLL(Sentence S)
If S is empty, return TRUE
If S has an empty clause, return False
If S has a unit clause, return DPLL(S(U)) // Assign the one unassigned variable
Unit clause: Consists of only 1 unassigned literal
S(U) means a simplified S after a value is assigned to U
If S has a pure variable U, return DPLL(S(U))
Pure variable: Appears as positive only or negative only in S
Pick a variable v // Pick a new variable v, using a heuristic
If DPLL(S(v)) then return TRUE
Else return DPLL(S(v))
Heuristics to pick the variable: Max # of occurrences, min size clauses (only one has to be true, harder to satisfy with less variables).
Basically, pick the most constrained variable first (if it's going to fail, it's better to fail early)
DPLL Algorithm
Sound: The result is correct
Complete: It always gives an answer
Speed and memory consumption depends greatly on:
Which symbol is being assigned first
Which assignment is being followed first
A lot of other methods, heuristics and meta-heuristics have been proposed for SAT problems.