1.0 - Propositions and Inference

1.1 - What is Logic?

1.1.1 - Proposition Definitions

1.1.2 - Why Propositions?

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.

1.1.3 - Formal Language

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?

1.1.5 - Example of Semantics - Electrical Environment

Figure 1 - Electrical Environment; Example of semantics

In Computer

In User's Mind

Conclusionlight_1_broken\text{light\_1\_broken}

1.1.6 - Simple Language: Propositional Logic Definitions

1.1.7 - RiPPLE Activity

Are these propositions?
  1. What is the distance between Mars and Earth? Can't be evaluated to either True or False.
  2. x+2=2xx+2=2x Not always true or always false - therefore, not a proposition
  3. x+2=2x When x=1x+2=2x \text { When }x=1 Yes, is either true or false.
  4. 2x<3x2x<3x No, as the truth value changes depending on whether xx is positive or negative.

Atoms are often represented with a symbol called propositional variable, (e.g. p, q)

1.1.8 - Complex Propositions

1.1.9 - Rules for Evaluating Truth

¬p\neg p

pqp\wedge q

pqp\vee q

pqp \Rightarrow q

pqp\Leftrightarrow 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 pq and qpp\Rightarrow q \text { and }q \Rightarrow p

Semantics

RiPPLE Activity - Knowledge Base

A model of a set of clauses is an interpretation which all of the clauses are True;

KB={pqqrsKB=\begin{cases}p \Leftarrow q\\ q\\ r \Leftarrow s\end{cases}

Figure 2 - Knowledge Base Truth Table

I1I_1 is a model of KB as:

pq   >>  TrueTrue   >>   Truep \Leftarrow q \ \ \ >> \ \ True \Leftarrow True \ \ \ >> \ \ \ True

q           >>  True                  >>   Trueq\ \ \ \ \ \ \ \ \ \ \ >> \ \ True \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ >> \ \ \ True

rs   >>  TrueTrue   >>   Truer \Leftarrow s \ \ \ >> \ \ True \Leftarrow True \ \ \ >> \ \ \ True

I2I_2 is not a model of KB as:

pq   >>  FalseFalse >>   Truep \Leftarrow q \ \ \ >> \ \ False \Leftarrow False \ >> \ \ \ True

q           >>  False                  >>   Falseq\ \ \ \ \ \ \ \ \ \ \ >> \ \ False \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ >> \ \ \ \color{#FF6666}False

rs   >>  FalseFalse >>   Truer \Leftarrow s \ \ \ >> \ \ False \Leftarrow False \ >> \ \ \ True

I3I_3 is a model of KB as:

pq   >>  TrueTrue   >>   Truep \Leftarrow q \ \ \ >> \ \ True \Leftarrow True \ \ \ >> \ \ \ True

q           >>  True                  >>   Trueq\ \ \ \ \ \ \ \ \ \ \ >> \ \ True \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ >> \ \ \ True

rs   >>  FalseFalse >>  Truer \Leftarrow s \ \ \ >> \ \ False \Leftarrow False \ >> \ \ True

I4I_4 is a model of KB as:

pq   >>  TrueTrue   >>   Truep \Leftarrow q \ \ \ >> \ \ True \Leftarrow True \ \ \ >> \ \ \ True

q           >>  True                  >>   Trueq\ \ \ \ \ \ \ \ \ \ \ >> \ \ True \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ >> \ \ \ True

rs   >>  TrueFalse >>   Truer \Leftarrow s \ \ \ >> \ \ True \Leftarrow False \ >> \ \ \ True

I5I_5 is not a model of KB as:

pq   >>  TrueTrue   >>   Truep \Leftarrow q \ \ \ >> \ \ True \Leftarrow True \ \ \ >> \ \ \ True

q           >>  True                  >>   Trueq\ \ \ \ \ \ \ \ \ \ \ >> \ \ True \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ >> \ \ \ True

rs   >>  FalseTrue >>   Falser \Leftarrow s \ \ \ >> \ \ False \Leftarrow True \ >> \ \ \ \color{#FF7777}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 qq is true. In the knowledge base, if pp is true, then qq must be true.

There is no constraint in the knowledge base that causes rr or ss 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.

  1. Choose a task domain (intended interpretation)
  2. Associate an atom with each proposition you want to represent
  3. Tell the system clauses that are true in the intended interpretation: axiomatizing the domain
  4. Ask questions about the intended interpretation
  5. If KBgKB \models g then gg must be true in the intended interpretation
  6. Users can interpret the answer using their intended interpretation of the symbols.

Computer's View of Semantics

Deduction: Sentences entailed by the current KB can be added to the KB.

Representing the Electrical Environment

Symbols

light_l1\text{light\_}l_1

light_l2\text{light\_}l_2

down_s1\text{down\_}s_1

on_s2\text{on\_}s_2

on_s3\text{on\_}s_3

ok_l1\text{ok\_}l_1

ok_l2\text{ok\_}l_2

ok_cb1\text{ok\_}cb_1

ok_cb2\text{ok\_}cb_2

live_outside\text{live\_outside}

Logic Sentences

lit_l1live_w0ok_l1\text{lit\_}l_1 \Leftarrow \text{live\_}w_0 \wedge \text{ok\_}l_1

live_w0live_w1on_s2\text{live\_}w_0\Leftarrow \text{live\_}w_1 \wedge \text{on\_}s_2

live_w1live_w2off_s2\text{live\_}w_1 \Leftarrow \text{live\_}w_2 \wedge \text{off\_}s_2

live_w2live_w3off_s1\text{live\_}w_2 \Leftarrow \text{live\_}w_3 \wedge \text{off\_}s_1

lit_l2live_w3ok_l2\text{lit\_}l_2 \Leftarrow \text{live\_}w_3 \wedge \text{ok\_}l_2

live_w4live_w3on_s3\text{live\_}w_4 \Leftarrow \text{live\_}w_3 \wedge \text{on\_}s_3

...

Conclusion - Terminology

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 ABA \models B) iff every model of AA is also a model of BB (i.e. ABA \Rightarrow 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. AB)A \Rightarrow B)

2.2 - Simple Validity / Model Checking

Check if ¬P1,2\neg P_{1,2} is entailed by the knowledge base.

Knowledge Base

R1:¬P1,1R_1: \neg P_{1,1}

R2:B1,1(P1,2P2,1)R_2: B_{1,1} \Leftrightarrow (P_{1,2} \vee P_{2,1})

R3:B2,1(P1,1P2,2P3,1)R_3: B_{2,1} \Leftrightarrow (P_{1,1} \vee P_{2,2} \vee P_{3,1})

R4:¬B1,1R_4: \neg B_{1,1}

R5:B2,1R_5: B_{2,1}

2.2.1 - Simple Model Checking

Enumerate the models
Figure 3 - Truth Table for simple model checking example.

Sound The result is correct

Complete It always gives an answer

Complexity nn is the number of propositional variables.

2.2.2 - Theorem Proving - Check Validity without Checking All Models

(αβ)(βα)(\alpha \wedge \beta) \equiv (\beta \wedge \alpha)

(αβ)(βα)(\alpha \vee \beta) \equiv (\beta \vee \alpha)

((αβ)γ)(α(βγ))((\alpha \wedge \beta)\wedge \gamma) \equiv (\alpha \wedge (\beta \wedge \gamma))

((αβ)γ)(α(βγ))((\alpha \vee \beta)\vee \gamma) \equiv (\alpha \vee (\beta \vee \gamma))

¬(¬α)α\neg (\neg \alpha) \equiv \alpha

(αβ)(¬β¬α)(\alpha \Rightarrow \beta) \equiv (\neg \beta \Rightarrow \neg \alpha)

(αβ)(¬αβ)(\alpha \Rightarrow \beta) \equiv (\neg \alpha \vee \beta)

(αβ)((αβ)(βα))(\alpha \Leftrightarrow \beta) \equiv ((\alpha \Rightarrow \beta) \wedge (\beta \Rightarrow \alpha))

¬(αβ)(¬α¬β)\neg (\alpha \wedge \beta) \equiv(\neg \alpha \vee \neg \beta)

¬(αβ)(¬α¬β)\neg (\alpha \vee \beta)\equiv (\neg \alpha \wedge \neg \beta )

(α(βγ))((αβ)(αγ))(\alpha \wedge (\beta \vee \gamma)) \equiv ((\alpha \wedge \beta) \vee (\alpha \wedge \gamma))

(α(βγ))((αβ)(αγ))(\alpha \vee (\beta \wedge \gamma)) \equiv ((\alpha \vee \beta) \wedge (\alpha \vee \gamma))

Commutativity of \wedge

Commutativity of \vee

Associativity of \wedge

Associativity of \vee

Double-negation elimination

Contraposition

Implication Elimination

Biconditional Elimination

De Morgan


Distributivity of \wedge over \vee

Distributivity of \vee over \wedge

2.2.3 - Transformations of Logical Expressions

Modus Ponens (Model that affirms)

αβαβ\begin{equation*} \begin{split} \alpha\Rightarrow\beta\\ \alpha \\ \hline \beta \end{split} \end{equation*}

Moduss Tollens (Model that Denies)

αβ¬β¬α\begin{equation*} \begin{split} \alpha\Rightarrow\beta\\ \neg\beta \\ \hline \neg\alpha \end{split} \end{equation*}

And-elimination (for a conjunction, any of the conjuncts can be inferred)

αβα\begin{equation*} \begin{split} \alpha\wedge\beta \\ \hline \alpha \end{split} \end{equation*}

2.2.4 - Example - Theorem Proving using Natural Deduction / Logic

Knowledge Base

S1:¬P1,1S_1: \neg P_{1,1}

S2:B1,1(P1,2P2,1)S_2: B_{1,1} \Leftrightarrow (P_{1,2} \vee P_{2,1})

S3:B2,1(P1,1P2,2P3,1)S_3: B_{2,1} \Leftrightarrow (P_{1,1}\vee P_{2,2}\vee P_{3,1})

S4:¬B1,1S_4:\neg B_{1,1}

S5:B2,1S_5:B_{2,1}

S2:B1,1(P1,2P2,1)\color{#AAA}S_2: B_{1,1} \Leftrightarrow (P_{1,2} \vee P_{2,1})

S6:(B1,1(P1,2P2,1))((P1,2P2,1)B1,1)S_6: (B_{1,1} \Rightarrow (P_{1,2} \vee P_{2,1}))\wedge ((P_{1,2} \vee P_{2,1})\Rightarrow B_{1,1})

Using biconditional elimination on S2S_2

S7:(P1,2P2,1)B1,1S_7:(P_{1,2} \vee P_{2,1}) \Rightarrow B_{1,1} Using And elimination on S6S_6

S8:S_8: ¬(P1,2P2,1)\neg(P_{1,2}\vee P_{2,1}) Using Modus tollens on S4S_4 and S7S_7

S9:¬P1,2¬P2,1S_9: \neg P_{1,2} \wedge \neg P_{2,1} Using De Morgan to S8S_8

S10:¬P1,2S_{10}: \neg P_{1,2} Using And elimination to S9S_9

3.0 - Conjunctive Normal Form (CNF)

Given α,β\alpha, \beta and γ\gamma 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

Untitled

3.1 - Conjunctive Normal Form

3.1.1 - Converting to CNF

Convert (AB)(CD)(A \vee B)\Rightarrow (C\Rightarrow D)
  1. Eliminate Arrows

    (AB)(¬CD)(A \vee B) \Rightarrow (\neg C\vee D) Using (αβ)(¬αβ)(\alpha \Rightarrow \beta)\equiv(\neg\alpha \vee\beta)

    ¬(AB)(¬CD)\neg(A\vee B) \vee (\neg C \vee D) Using (αβ)(¬αβ)(\alpha \Rightarrow \beta)\equiv(\neg\alpha \vee\beta)

  2. Drive in negations

    (¬A¬B)(¬CD)(\neg A\wedge\neg B)\vee(\neg C \vee D) Using De Morgan's

  3. Distribute OR over AND

    (¬A¬CD)(¬B¬CD)(\neg A\vee\neg C\vee D)\wedge(\neg B\vee\neg C\vee D) Using Distributive

3.1.2 - Resolution Refutation

3.1.3 - Resolution Refutation Example

Knowledge Base:

(PQ)(PR)(QR)(P \vee Q)\wedge (P\Rightarrow R)\wedge(Q\Rightarrow R)

  1. Elimination of arrows

    (PQ)(PR)(QR)(P \vee Q)\wedge (P\Rightarrow R)\wedge(Q\Rightarrow R)

    (PQ)(¬PR)(¬QR)(P \vee Q)\wedge (\neg P\vee R)\wedge(\neg Q\vee R)

  2. Drive in negations using De Morgan's

    As there are no external negations, we don't have to do anything

  3. Distribute OR over AND

    As there are only ORs inside the parentheses and ANDs outside the parenthesis, there is nothing to do.

  4. Negate the Desired Conclusion

4.0 - Satisfiability

4.1 - Davis-Putnam-Logemann-Loveland (DPLL) Tree Search Algorithm

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.

https://www.cs.ubc.ca/labs/beta/Projects/SATzilla/