Docsity

Propositional Logic & Limitations: AI Course, Study notes of Computer Science

Partial preview of the text

Download Propositional Logic & Limitations: AI Course and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence

Programming

First-Order Logic

Chris Brooks Department of Computer Science University of San Francisco

Representation

Propositional Logic has several nice features

Lets us easily express disjunction and negation

“There is a pit in (1,1) or in (2,2)” “There is not a pit in (1,1)” This is hard to do in C/Java/Python - variables canonly take on a single value. There’s no obvious way to

assign

x

the value “3 or

4” or “some value less than 10”.

Separates declarative knowledge from inferenceprocedures Compositional

The meaning of a sentence is a function of themeaning of its parts.

Department of Computer Science — University of San Francisco – p.1/

Resolution

Inference can be done using DeMorgan’s, ModusPonens, And-elimination, etc Sound, but not necessarily complete. Also, search can be inefficient: there might be manyoperators that can be applied in a particular state. Luckily, there is a complete rule for inference (whencoupled with a complete search algorithm) that uses asingle operator. This is called

resolution

A

B

and

A

C

allows us to conclude

B

C

A

is either true or not true. If

A

is true, then

C

must

be true. if

A

is false, then

B

must be true.

This can be generalized to clauses of any length.

Department of Computer Science — University of San Francisco – p.3/

Conjunctive Normal Form

Resolution works with disjunctions. This means that our knowledge base needs to be in thisform. Conjunctive Normal Form is a conjunction of clausesthat are disjunctions. (

A

B

C

D

E

F

G

H

I

Every propositional logic sentence can be converted toCNF.

Department of Computer Science — University of San Francisco – p.4/

Example

B

1 ,^1

P

1 ,^2

P

2 , 1

Eliminating equivalence produces:

B

1 ,^1

P

1 , 2

P

2 ,^1

P

1 , 2

P

2 ,^1

B

1 ,^1

Removing implication gives us:

B

1 ,^1

P

1 ,^2

P

2 , 1

P

1 , 2

P

2 ,^1

B

1 ,^1

Department of Computer Science — University of San Francisco – p.6/

Example

We then use DeMorgan’s rule to move negation inwards:

B

1 ,^1

P

1 , 2

P

2 ,^1

P

1 ,^2

P

2 ,^1

B

1 ,^1

Finally, we distribute OR over AND:

B

1 ,^1

P

1 , 2

P

2 ,^1

P

1 ,^2

B

1 ,^1

P

2 ,^1

B

1 ,^1

Now we have clauses that can be plugged into aresolution theorem prover. (can break ANDs intoseparate sentences) They’re less readable by a human, but morecomputationally useful.

Department of Computer Science — University of San Francisco – p.7/

Example

Prove that there is not a pit in (1,2).

P

1 ,^2

Relevant Facts:

R

2 a

B

1 ,^1

P

1 ,^2

P

2 ,^1

R

2 b

P

1 ,^2

B

1 ,^1

R

2 c

P

2 ,^1

B

1 , 1

R

4

B

1 ,^1

Insert

R

n

P

1 , 2

into the KB

Department of Computer Science — University of San Francisco – p.9/

Example

Resolve

R

n

with

R

2 b

to get:

R

6

B

1 , 1

We already have a contradiction, since

R

4

B

1 ,^1

Therefore, the sentence we inserted into the KB must befalse. Most proofs take more than one step to get to acontradiction ...

Department of Computer Science — University of San Francisco – p.10/

How to use a KB: Forward Chaining

Forward chaining involves starting with a KB andcontinually applying Modus Ponens to derive all possiblefacts. This is sometimes called data-driven reasoning Start with domain knowledge and see what thatknowledge tells you. This is very useful for discovering new facts or rules Less helpful for proving a specific sentence true or false

Search is not directed towards a goal

Department of Computer Science — University of San Francisco – p.12/

How to Use A KB: Backward Chainin

Backward chaining starts with the goal and “worksbackward” to the start. Example: If we want to show that

A

is entailed, find a

sentence whose consequent is

A

Then try to prove that sentence’s antecendents. This is sometimes called query-driven reasoning. More effective at proving a particular query, sincesearch is focused on a goal. Less likely to discover new and unknown information. Means-ends analysis is a similar sort of reasoning. Prolog uses backward chaining.

Department of Computer Science — University of San Francisco – p.13/

Applications

Propositional logic can work nicely in bounded domains

All objects of interest can be enumerated.

Fast algorithms exist for solving SAT problems via modelchecking.

Search all models to find one that satisfies asentence. Can be used for some scheduling and planningproblems

Constraint satisfaction problems can be expressed inpropositional logic.

Often, we’ll use a predicate-ish notation as syntacticsugar.

Department of Computer Science — University of San Francisco – p.15/

Weaknesses of Propositional Logic

There are several problems with propositional logic:

Lack of conciseness. (How to say “There is a pit inevery square”?) Lack of ability to quantify (How to say “There is asquare that has a pit”?) Lack of ability to deal with large domains.

What if there were an infinite number of rooms? What is we wanted to write sentences about theintegers?

The problem stems from the fact that propositional logicdeals with facts that are either true or false. No way to indicate that terms in different sentences referto the same object. No way to talk about relations between objects.

Department of Computer Science — University of San Francisco – p.16/

Expressivity

Functions: father-of(bart) = homer, fall-classes(student)= AI, etc. First-order logic

gives us all of this.

Department of Computer Science — University of San Francisco – p.18/

Models in first-order logic

Recall that a model is the set of “possible worlds” for acollection of sentences. In propositional logic, this meant truth assignments tofacts. In FOL, models have objects in them. The

domain

of a model is the set of objects in that world.

For example, the Simpsons model might have thedomain

{Marge, Homer, Lisa, Bart, Maggie}

We can then specify relations and functions betweenthese objects

married-to(marge, homer), baby(maggie),father(bart) = homer

Department of Computer Science — University of San Francisco – p.19/