1 cs 4700: foundations of artificial intelligence bart selman [email protected] module:...

91
1 CS 4700: Foundations of Artificial Intelligence Bart Selman [email protected] Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N: Chapter 7

Upload: philip-leonard

Post on 24-Dec-2015

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

1

CS 4700Foundations of Artificial Intelligence

Bart Selmanselmancscornelledu

Module Knowledge Reasoning and PlanningPart 1

Logical AgentsRampN Chapter 7

2

A Model-Based Agent

Requires Knowledge and Reasoning

3

Knowledge and Reasoning

Knowledge and Reasoning humans are very good at acquiring new information by combining raw knowledge experience with reasoning AI-slogan ldquoKnowledge is powerrdquo (or ldquoData is powerrdquo)

Examples Medical diagnosis --- physician diagnosing a patient infers what disease based on the knowledge heshe acquired as a student textbooks prior cases Common sense knowledge reasoning --- common everyday assumptions inferences eg ldquolecture starts at fourrdquo infer pm not am when traveling I assume there is some way to get from the airport to the hotel

4

Logical agents Agents with some representation of the complex knowledge about the world its environment and uses inference to derive new information from that knowledge combined with new inputs (eg via perception)

Key issues1- Representation of knowledge

What form Meaning semantics2- Reasoning and inference

processes Efficiency

5

Knowledge-base Agents

Key issuesndash Representation of knowledge knowledge basendash Reasoning processes inferencereasoning

() called Knowledge Representation (KR) language

Knowledge base = set of sentences in a formal language representing facts about the world()

6

Knowledge basesKey aspects

ndash How to add sentences to the knowledge base ndash How to query the knowledge base

Both tasks may involve inference ndash ie how to derive new sentences from old sentences

Logical agents ndash inference must obey the fundamental requirement that when one asks a question to the knowledge base the answer should follow from what has been told to the knowledge base previously (In other words the inference process should not ldquomake thingsrdquo uphellip)

A simple knowledge-based agent

The agent must be able tondash Represent states actions etcndash Incorporate new perceptsndash Update internal representations of the worldndash Deduce hidden properties of the worldndash Deduce appropriate actionsndash

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 2: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

2

A Model-Based Agent

Requires Knowledge and Reasoning

3

Knowledge and Reasoning

Knowledge and Reasoning humans are very good at acquiring new information by combining raw knowledge experience with reasoning AI-slogan ldquoKnowledge is powerrdquo (or ldquoData is powerrdquo)

Examples Medical diagnosis --- physician diagnosing a patient infers what disease based on the knowledge heshe acquired as a student textbooks prior cases Common sense knowledge reasoning --- common everyday assumptions inferences eg ldquolecture starts at fourrdquo infer pm not am when traveling I assume there is some way to get from the airport to the hotel

4

Logical agents Agents with some representation of the complex knowledge about the world its environment and uses inference to derive new information from that knowledge combined with new inputs (eg via perception)

Key issues1- Representation of knowledge

What form Meaning semantics2- Reasoning and inference

processes Efficiency

5

Knowledge-base Agents

Key issuesndash Representation of knowledge knowledge basendash Reasoning processes inferencereasoning

() called Knowledge Representation (KR) language

Knowledge base = set of sentences in a formal language representing facts about the world()

6

Knowledge basesKey aspects

ndash How to add sentences to the knowledge base ndash How to query the knowledge base

Both tasks may involve inference ndash ie how to derive new sentences from old sentences

Logical agents ndash inference must obey the fundamental requirement that when one asks a question to the knowledge base the answer should follow from what has been told to the knowledge base previously (In other words the inference process should not ldquomake thingsrdquo uphellip)

A simple knowledge-based agent

The agent must be able tondash Represent states actions etcndash Incorporate new perceptsndash Update internal representations of the worldndash Deduce hidden properties of the worldndash Deduce appropriate actionsndash

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 3: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

3

Knowledge and Reasoning

Knowledge and Reasoning humans are very good at acquiring new information by combining raw knowledge experience with reasoning AI-slogan ldquoKnowledge is powerrdquo (or ldquoData is powerrdquo)

Examples Medical diagnosis --- physician diagnosing a patient infers what disease based on the knowledge heshe acquired as a student textbooks prior cases Common sense knowledge reasoning --- common everyday assumptions inferences eg ldquolecture starts at fourrdquo infer pm not am when traveling I assume there is some way to get from the airport to the hotel

4

Logical agents Agents with some representation of the complex knowledge about the world its environment and uses inference to derive new information from that knowledge combined with new inputs (eg via perception)

Key issues1- Representation of knowledge

What form Meaning semantics2- Reasoning and inference

processes Efficiency

5

Knowledge-base Agents

Key issuesndash Representation of knowledge knowledge basendash Reasoning processes inferencereasoning

() called Knowledge Representation (KR) language

Knowledge base = set of sentences in a formal language representing facts about the world()

6

Knowledge basesKey aspects

ndash How to add sentences to the knowledge base ndash How to query the knowledge base

Both tasks may involve inference ndash ie how to derive new sentences from old sentences

Logical agents ndash inference must obey the fundamental requirement that when one asks a question to the knowledge base the answer should follow from what has been told to the knowledge base previously (In other words the inference process should not ldquomake thingsrdquo uphellip)

A simple knowledge-based agent

The agent must be able tondash Represent states actions etcndash Incorporate new perceptsndash Update internal representations of the worldndash Deduce hidden properties of the worldndash Deduce appropriate actionsndash

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 4: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

4

Logical agents Agents with some representation of the complex knowledge about the world its environment and uses inference to derive new information from that knowledge combined with new inputs (eg via perception)

Key issues1- Representation of knowledge

What form Meaning semantics2- Reasoning and inference

processes Efficiency

5

Knowledge-base Agents

Key issuesndash Representation of knowledge knowledge basendash Reasoning processes inferencereasoning

() called Knowledge Representation (KR) language

Knowledge base = set of sentences in a formal language representing facts about the world()

6

Knowledge basesKey aspects

ndash How to add sentences to the knowledge base ndash How to query the knowledge base

Both tasks may involve inference ndash ie how to derive new sentences from old sentences

Logical agents ndash inference must obey the fundamental requirement that when one asks a question to the knowledge base the answer should follow from what has been told to the knowledge base previously (In other words the inference process should not ldquomake thingsrdquo uphellip)

A simple knowledge-based agent

The agent must be able tondash Represent states actions etcndash Incorporate new perceptsndash Update internal representations of the worldndash Deduce hidden properties of the worldndash Deduce appropriate actionsndash

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 5: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

5

Knowledge-base Agents

Key issuesndash Representation of knowledge knowledge basendash Reasoning processes inferencereasoning

() called Knowledge Representation (KR) language

Knowledge base = set of sentences in a formal language representing facts about the world()

6

Knowledge basesKey aspects

ndash How to add sentences to the knowledge base ndash How to query the knowledge base

Both tasks may involve inference ndash ie how to derive new sentences from old sentences

Logical agents ndash inference must obey the fundamental requirement that when one asks a question to the knowledge base the answer should follow from what has been told to the knowledge base previously (In other words the inference process should not ldquomake thingsrdquo uphellip)

A simple knowledge-based agent

The agent must be able tondash Represent states actions etcndash Incorporate new perceptsndash Update internal representations of the worldndash Deduce hidden properties of the worldndash Deduce appropriate actionsndash

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 6: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

6

Knowledge basesKey aspects

ndash How to add sentences to the knowledge base ndash How to query the knowledge base

Both tasks may involve inference ndash ie how to derive new sentences from old sentences

Logical agents ndash inference must obey the fundamental requirement that when one asks a question to the knowledge base the answer should follow from what has been told to the knowledge base previously (In other words the inference process should not ldquomake thingsrdquo uphellip)

A simple knowledge-based agent

The agent must be able tondash Represent states actions etcndash Incorporate new perceptsndash Update internal representations of the worldndash Deduce hidden properties of the worldndash Deduce appropriate actionsndash

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 7: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

A simple knowledge-based agent

The agent must be able tondash Represent states actions etcndash Incorporate new perceptsndash Update internal representations of the worldndash Deduce hidden properties of the worldndash Deduce appropriate actionsndash

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 8: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

8

KR language candidate logical language (propositional first-order) combined with a logical inference mechanism

How close to human thought (mental-models Johnson-Laird)

What is ldquothe language of thoughtrdquo

Why not use natural language (eg English)

We want clear syntax amp semantics (well-definedmeaning) and mechanism to infer new informationSoln Use a formal language

Greeks Boole Frege --- Rational thought Logic

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 9: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

9

Consider to-the-right-of(xy)

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 10: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

10

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 11: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

11

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 12: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

12

Procedural style

Knowledge-based alternative

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 13: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

13

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 14: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

14

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 15: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

15The ldquosymbol grounding problemrdquo

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 16: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

16

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 17: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

17

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 18: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

18

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 19: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

19Ie Models(KB) Models( )

Note KB defines exactly the set of worlds we are interested in

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 20: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

20

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 21: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

21

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 22: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

22

Note (1) This was Aristotlersquos original goal ---Construct infallible arguments based purelyon the form of statements --- not on the ldquomeaningrdquoof individual propositions(2) Sets of models can be exponential size or worsecompared to symbolic inference (deduction)

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 23: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

23

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 24: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

24

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 25: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

25

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 26: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

26

Intermezzo Reflections on Inference Knowledge and Data ca 2012

In the logical agent perspective we take the ldquoknowledge-basedrdquo approach

Wersquoll have a knowledge base capturing our world knowledge in a formal language Wersquoll use an inference procedure to derive new information

Representation has well-defined syntax and semantics meaning

How far are actual AI systems in the knowledge reasoning paradigm

Specifically where do Deep Blue Watson and Siri fit

What about IR Google Translate and Googlersquos Knowledge Graph

And ldquoshallow semanticsrdquo Semantic Web

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 27: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

27

WatsonIBMrsquos Jeopardy playing system

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 28: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

28

Chris Welty from IBM on Watson and ldquounderstandingrdquo

httpspectrumieeeorgpodcastat-workinnovationwhat-is-toronto

See 4 min mark for discussion on ldquounderstandingrdquoTill around min 11

>

IBMWatsonQampAnorm

null

11772368

eng - iTunPGAP0

eng - iTunNORM 0000032A 00000000 00006DC5 00000000 00071E58 00000000 000081CA 00000000 00065FA1 00000000

eng - iTunSMPB 00000000 00000210 00000710 00000000031811E0 00000000 008FAAC7 00000000 00000000 00000000 00000000 00000000 00000000

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 29: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

29

WatsonKey aspects

1) Limited number of categories of types of questions

2) Well-defined knowledge sources (Wikipedia Encyclopedias

Dictionaries etc) Not WWW (Contrast Google Knowl Graph)

3) Around 70 ldquoexpertrdquo modules that handle different aspects of the possible question and answers 1000+ hypotheses

4) Final result based on a confidence vote

5) Limited language parsing Lot based on individual words (like IR)

6) Form of IR ldquo+rdquo (parsing limited knowledge graph ldquobooks have authorsrdquo ldquomovie has actors and directorrdquo ldquoverb represents an actionrdquo etc )

7) Some game theory to reason about whether to answer

To some extent Watson ldquounderstandsrdquo(Itrsquos actually a bit of a problem for IBMhellip Clients expect too much)

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 30: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

31

Semantic Web

Datagov in process of converting CSV data into Resource Description Framework

ndash RPI Tetherless World Constellation - Jim Hendler Berners-Lee

ndash RDF - triples (facts) class subclass

ndash OWL - defined classes constraints

Directly grows out of KR work in AAAI community 1985 - 2005

ndash Ron Brachman Hector Levesque Deborah McGuinness Alex Borgida Peter Patel-Schneider Franz Baader Francesco Donini

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 31: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

32

AI Knowledge-Data-

Inference Triangle

2012

KnowledgeIntensive

DataIntensive

InferenceSearch

Intensive

Common Sense

Watson

Google Search (IR)

Googlersquos Knowl Graph

SiriVerification

NLU

Computer Vision

Deep Blue

Robbinrsquos ConjM

achine LearningSemantic Web

20+yr GAP

Google Transl

4-color thm

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 32: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

33

Back to Knowledge-Based Agentshellip

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 33: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

34

Illustrative example Wumpus World

Performance measurendash gold +1000 ndash death -1000 (falling into a pit or being eaten by the wumpus)ndash -1 per step -10 for using the arrow

Environmentndash Rooms squares connected by doors ndash Squares adjacent to wumpus are smellyndash Squares adjacent to pit are breezyndash Glitter iff gold is in the same squarendash Shooting kills wumpus if you are facing itndash Shooting uses up the only arrowndash Grabbing picks up gold if in same squarendash Releasing drops the gold in same squarendash Randomly generated at start of game Wumpus only senses current room

Sensors Stench Breeze Glitter Bump Scream [perceptual inputs]Actuators Left turn Right turn Forward Grab Release Shoot

(Somewhat whimsical)

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 34: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

35

Wumpus world characterization

Fully Observable No ndash only local perception

Deterministic Yes ndash outcomes exactly specified

Static Yes ndash Wumpus and Pits do not move

Discrete Yes

Single-agent Yes ndash Wumpus is essentially a ldquonatural featurerdquo

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 35: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

36

Exploring a wumpus world

Stench Breeze Glitter Bump Scream

None none none none none

The knowledge base of the agent consists of the rules of the Wumpus world plus the percept ldquonothingrdquo in [11]

Boolean perceptfeature valueslt0 0 0 0 0gt

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 36: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

37

Stench Breeze Glitter Bump Scream

None none none none none

T=0 The KB of the agent consists of the rules of the Wumpus world plusthe percept ldquonothingrdquo in [11]By inference the agentrsquos knowledge base also has the information that[21] and [12] are okayAdded as propositions

World ldquoknownrdquo to agentat time = 0

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 37: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

38

Further exploration

Stench Breeze Glitter Bump Scream

T = 1 What followsPit(22) or Pit(31)

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

Where next

T = 0T = 1

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 38: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

39

S

Where is Wumpus

Wumpus cannot be in (11) or in (22) (Why) Wumpus in (13)Not breeze in (12) no pit in (22) but we know there is pit in (22) or (31) pit in (31)

P

P

1 2 3 4

1

2

3

4

Stench none none none none

P

W

PS

T=3

Stench Breeze Glitter Bump Scream

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 39: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

40

P

W

P

We reasoned about the possible states the Wumpus world can be in given our percepts and our knowledge of the rules of the Wumpus world Ie the content of KB at T=3

Essence of logical reasoning Given all we know Pit_in_(31) holds

(ldquoThe world cannot be differentrdquo)

What follows is what holds true in all those worlds that satisfy what is known at that time T=3 about the particular Wumpus world we are in

Models(KB) Models(P_in_(31))

Example property P_in_(31)

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 40: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

41

Formally Entailment

Situation after detecting nothing in [11] moving right breeze in [21] Ie T=1

Consider possible models for KB with respect to the cells (12) (22) and (31) with respect to the existence or non existence of pits

3 Boolean choices 8 possible interpretations

(enumerate all the models or

ldquopossible worldsrdquo wrt Pitt location)

Knowledge Base (KB) in the Wumpus World Rules of the wumpus world + new percepts

T = 1

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 41: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

42

KB = Wumpus-world rules + observations (T=1)

Is KB consistent with all8 possible worlds Worlds

that violate KB(are inconsistentwith what weknow)

Q Why does world violate KB

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 42: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

43

Entailment in Wumpus World

KB = Wumpus-world rules + observations

α1 = [12] has no pit KB α1

ndash In every model in which KB is true α1 is True (proved by ldquomodel checkingrdquo)

Models of the KB and α1

So KB definesall worlds thatwe hold possibleQueries we want to know the properties of those worldsThatrsquos how the semantics of logical entailment is defined

Note alpha_1holds in more models than KBThatrsquos OK but we donrsquot care aboutthose worlds

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 43: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

44

Wumpus modelsKB = wumpus-world rules + observations

α2 = [22] has no pit this is only True in some

of the models for which KB is True therefore KB α2

Model Checking

Models of α2

A model of KB where does NOT hold α2

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 44: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

45

Entailment vialdquoModel Checkingrdquo

Inference by Model checking ndash We enumerate all the KB models and check if α1 and α2 are

True in all the models (which implies that we can only use it

when we have a finite number of models)

Ie using semantics directly

Models(KB) Models( )

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 45: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

46

Example redux More formal

Stench Breeze Glitter Bump Scream

None none none none none

V

A ndash agentV ndash visitedB - breeze

AB P

P

None breeze none none none

How do we actually encode backgroundknowledge and percepts in formal language

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 46: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

47

Wumpus World KBDefine propositions

Let Pij be true if there is a pit in [i j]

Let Bij be true if there is a breeze in [i j]

Sentence 1 (R1) P11

Sentence 2 (R2) B11

Sentence 3 (R3) B21

Pits cause breezes in adjacent squaresrdquo

Sentence 4 (R4) B11 (P12 P21)

Sentence 5 (R5) B21 (P11 P22 P31)etc

Notes (1) one such statement about Breeze for each square (2) similar statements about Wumpus and stench

and Gold and glitter (Need more propositional letters)

[Given][Observation T = 0][Observation T = 1]

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 47: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

48

What about Time What about ActionsIs Time represented NoCan include time in propositions

Explicit time Pijt Bijt Lijt etc

Many more props O(TN2) (Lijt for agent at (ij) at time t)

Now we can also model actions use props Move(i j k l t) Eg Move(1 1 2 1 0)What knowledge axiom(s) capture(s) the effect of an Agent

move

Move(i j k l t) ( L(i j t+1) AElig L(k l t+1))

Is this it What about i j k and lWhat about Agent location at time t

)

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 48: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

49

Improved

Move(i j k l t) (L(i j t) AElig L(i j t+1) AElig L(k l t+1)) For all tuples (i j k l) that represent legitimate possible moves Eg (1 1 2 1) or (1 1 1 2)

Still some remaining subtleties when representing time andactions What happens to propositions at time t+1 compared to attime t that are not involved in any actionEg P(1 3 3) is derived at some point What about P(1 3 4) True or False RampN suggests having P as an ldquoatemporal varrdquo since it cannot change over

time Nevertheless we have many other vars that can change over time called ldquofluentsrdquo

Values of propositions not involved in any action should not change ldquoThe Frame Problemrdquo Frame Axioms RampN 771

Move implies a change in the world statea change in the world state implies a move occurred

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 49: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

50

Successor-State Axioms

Ft+1 (ActionCausesFt Ccedil (F(t) ActionCausesNotFt))

Axiom schemaF is a fluent (prop that can change over time)

For example

ie L_11 was ldquoas beforerdquo with [no movement action or bump into wall] or resulted from some action (movement into L_11

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 50: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

51

Some example inferencesSection 771 RampN

Actions and inputs up to time 6Note includes turns

Define ldquoOKrdquo

In milliseconds with modern SAT solver

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 51: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

52

Alternative formulation Situation CalculusRampN 1042

No explicit time Actions are what changes the worldfrom ldquosituationrdquo to ldquosituationrdquo More elegant but still need frame axioms to capture what stays the sameInherent with many representation formalisms ldquophysicalrdquopersistance does not come for free (and probably shouldnrsquot)

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 52: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

53

Inference by enumeration ldquomodel checkingrdquoStyle I

The goal of logical inference is to decide whether KB α for some For example given the rules of the Wumpus World is P22 entailed Relevant propositional symbols

R1 P11

R2 B11

R3 B21

Pits cause breezes in adjacent squaresR4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

Inference by enumeration We have 7 relevant symbols Therefore 27 = 128 interpretations Need to check if P22 is true in all of the KB models(interpretations that satisfy KB sentences)

Q KB has many more symbols Why can we restrict ourselves to these symbols here But be careful typically we canrsquot

Models(KB) Models( P22 )

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 53: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

54

All equivalentProp FO Logic1) KB sup2 reg

2) M(KB) micro M(reg)

3) sup2 (KB ) reg) deduction thm RampN 75

4) KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo enumeration (style I RampN 744)

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

entailment

5) (KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 54: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

55

Proof techniques

M(KB) micro M(reg)

KB ` reg

by defn semantic proofs truth tablesldquomodel checkingrdquo (style I RampN 744) Done

soundness and completenesslogical deduction symbol pushingproof by inference rules (style II)eg modus ponens (RampN 751)

(KB AElig reg) is inconsistent Proof by contradictionuse CNF clausal formResolution (style III RampN 75)SAT solvers (style IV RampN 76) most effective

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 55: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

56

Aside

Standard syntax and semantics for propositionallogic (CS-2800 see 741 and 742)

Syntax

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 56: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

57

Semantics

Note Truth value of a sentence is built from its parts ldquocompositional semanticsrdquo

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 57: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

58

Logical equivalences

()

() key to go to clausal (Conjunctive Normal Form)Implication for ldquohumansrdquo clauses for machinesde Morgan laws also very useful in going to clausal form

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 58: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

59

Style II Proof by inference rulesModus Ponens (MP)

P

P

Wumpus worldat T = 1

V AB

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

How can we show that KR sup2 P12 R4 B11 (P12 P21)It follows (bicond elim)

B11 ) (P12 P21) AElig (P12 P21) ) B11

And-elimination (751 RampN)

(P12 P21) ) B11

By contrapositive

B11 ) ( (P12 Ccedil P21))Thus (de Morgan)

B11 ) (P12 AElig P21)By Modus Ponens using R2 we get

(P12 AElig P21)Finally by And-elimination we get

P12

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 59: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

60

Length of Proofs

Why bother with inference rules We could always use a truth table

to check the validity of a conclusion from a set of premises

But resulting proof can be much shorter than truth table method

Consider KBp_1 p_1 p_2 p_2 p_3 hellip p_(n-1) p_n

To prove conclusion p_n

Inference rules Truth table n-1 MP steps 2n

Key open question Is there always a short proof for any validconclusion Probably not The NP vs co-NP question(The closely related P vs NP question carries a $1M prize)

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 60: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

61

Style III Resolution

P

P

Wumpus worldat T = 1

V AB

First we need a conversion to ConjunctiveNormal Form (CNF) or Clausal Form

Letrsquos consider converting R4 in clausal form

R4 B11 (P12 P21)We have

B11 ) (P12 Ccedil P21)which gives (implication elimination)

( B11 Ccedil P12

Ccedil P21)

Also

(P12 P21) ) B11

which gives

( (P12 Ccedil P21) Ccedil B11) Thus

( P12 AElig P21) Ccedil B11 leaving

( P12 Ccedil B11 )

( P21 Ccedil B11 )

(note clauses in red)

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 61: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

62

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

KB at T = 1R1 P11

R2 B11

R3 B21

R4 B11 (P12 P21)

R5 B21 (P11 P22 P31)

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 62: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

63

How can we show that KR sup2 P12

Proof by contradiction Need to show that (KB AElig P12) is inconsistent (unsatisfiable)

Resolution rule

(reg Ccedil p) and (macr Ccedil p)

gives resolvent (logically valid conclusion)

(reg Ccedil macr)

If we can reach the empty clause then KBis inconsistent (And vice versa)

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 63: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

64

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21

Show that (KB AElig P12) is inconsistent (unsatisfiable)

R4b with P12 resolves to B11which with R2 resolves to the empty clause So we can conclude KB sup2 P12 (make sure you use ldquowhat you want to proverdquo)

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 64: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

65

P

P

Wumpus worldat T = 1

V AB

KB at T=1 in clausal form

R1 P11

R2 B11

R3 B21

R4a B11 Ccedil P12

Ccedil P21

R4b P12 Ccedil B11

R4c P21 Ccedil B11

R5a B21 Ccedil P11 Ccedil P22 Ccedil P31

R5b P11 Ccedil B21

R5c P22 Ccedil B21

R5d P31 Ccedil B21 Note that R5a resolved with R1 andthen resolved with R3 gives (P22 Ccedil P31)

Almost therehellip to show KB sup2 (P22 Ccedil P31) we need to show KB AElig ( (P22 Ccedil P31)) is inconsistent So show KB AElig P22 AElig P31 is inconsistentThis follows from (P22 Ccedil P31) because in two more resolution steps we get the empty clause (a contradiction)

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 65: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

66

Length of ProofsWhat is hard for resolution

Consider Given a fixed pos int N

(P(i1) Ccedil P(i2) Ccedil hellip P(iN)) for i = 1 hellip N+1

( P(ij) Ccedil P(irsquoj)) for j= 1 hellip N i = 1 hellip N+1 irsquo = 1 hellipN+1 j == jrsquo

Think of P(ij) for ldquoobject i in location jrdquo

What does this encode

Pigeon hole problemhellip

Provable requires exponential number of resolutionsteps to reach empty clause (Haken 1985) Method ldquocanrsquot countrdquo

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 66: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

67

Style IV SAT SolversInstead of using resolution to show that

KB AElig reg

modern Satisfiability (SAT) solvers operating on the clausal formare much more efficient

The SAT solvers treat the set of clauses as a set of constraints (disjunctions) on Boolean variables ie a CSP problem Current solvers are very powerful Can handle 1 Million+ variables and several millions of clauses

Systematic Davis Putnam (DPLL) + series of improvementsStochastic local search WalkSAT (issue)

See RampN 76 ldquoIronicallyrdquo we are back to semantic model checking but way more clever than basic truth assignment enumeration (exponentially faster)

is inconsistent

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 67: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

68

DPLL improvements

1) Component analysis (disjoint sets of constraints Problem decomposition)

2) Clever variable and value ordering (eg degree heuristics)

3) Intelligent backtracking and clause learning (conflict learning)

4) Random restarts (heavy tails in search spaceshellip)

5) Clever data structures

Backtracking + hellip

1+ Million Boolean vars amp 10+ Million clauseconstraintsare feasible nowadays (eg Minisat solver)

Has changed the world of verification (hardwaresoftware)over the last decade (incl Turing award for Clarke)Widely used in industry Intel Microsoft IBM etc

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 68: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

69

Satisfiability (SATCSP) or Inference

Really solving the same problem but SATCSP view appears more effective

iff M(KB) micro M(reg) iff (KB AElig reg) is unsat KB sup2 reg

Assume KB and reg is in CNF (clausal form) Note that KB sup2 (macr AElig deg) iff (KB sup2 macr) and (KB sup2 deg) (consider defn in terms of models)So can break conjunction in several queries one foreach disjunction (clause) Each a call to a SAT solver to checkKB AElig (l1 Ccedil l2 hellip ) for consist or equivalently check KB AElig l1 AElig l2 hellip (ie CNF form) for consistency

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 69: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

70

KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip The SAT solvers essentially views the KB as a set of constraints that

defines a subset of the set of all 2N possible worlds (N prop vars)

The query reg also defines a subset of the 2N possible worlds (Above

we used a single clause (l1 Ccedil l2 hellip) where li is a var or its negation)

The SATCSP solvers figures out whether there are any worlds

consistent with the KB constraints that do not satisfy the constraints

of the query If so than the query does not follow from the KB

Aside In verification such a world exposes a bug

If such worlds do not exist then the query must be entailed by the KB

(M(KB) micro M(reg) Search starts from query)

Viewing logical reasoning as reasoning about constraints on the

way the ldquoworld can berdquo is quite actually quite natural Itrsquos definitely

a computationally effective strategy

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 70: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

71

Some examples of SAT solving

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 71: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Application I --- Diagnosis

bull Problem diagnosis a malfunctioning devicendash Carndash Computer systemndash Spacecraft

bull wherendash Design of the device is knownndash We can observe the state of only certain parts of

the device ndash much is hidden

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 72: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Model-Based Consistency-Based Diagnosis

bull Idea create a logical formula that describes how the device should workndash Associated with each ldquobreakablerdquo component C is a

proposition that states ldquoC is okayrdquondash Sub-formulas about component C are all conditioned on

C being okaybull A diagnosis is a smallest of ldquonot okayrdquo assumptions

that are consistent with what is actually observed

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 73: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Consistency-Based Diagnosis

1 Make some Observations O2 Initialize the Assumption Set A to assert that

all components are working properly3 Check if the KB A O together are inconsistent

(can deduce false)4 If so delete propositions from A until

consistency is restored (cannot deduce false) The deleted propositions are a diagnosis

There may be many possible diagnoses

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 74: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Example Automobile Diagnosisbull Observable Propositions

EngineRuns GasInTank ClockRunsbull Assumable Propositions

FuelLineOK BatteryOK CablesOK ClockOKbull Hidden (non-Assumable) Propositions

GasInEngine PowerToPlugsbull Device Description F

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns(BatteryOK CablesOK) PowerToPlugs(BatteryOK ClockOK) ClockRuns

bull Observations EngineRuns GasInTank ClockRuns

Note of course a highly simplified set of axioms

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 75: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Example

bull Is F Observations Assumptions consistent

bull F EngineRuns GasInTank ClockRuns FuelLineOK BatteryOK CablesOK ClockOK falsendash Must restore consistency

bull F EngineRuns GasInTank ClockRuns BatteryOK CablesOK ClockOK satisfiablendash FuelLineOK is a diagnosis

bull F EngineRuns GasInTank ClockRuns FuelLineOK CablesOK ClockOK falsendash BatteryOK is not a diagnosis

(GasInTank FuelLineOK) GasInEngine(GasInEngine PowerToPlugs) EngineRuns

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 76: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Complexity of Diagnosisbull If F is Horn then each consistency test takes linear O(n)

time ndash unit propagation is complete for Horn clausesbull Complexity = ways to delete propositions from

Assumption Set that are consideredndash Single fault diagnosis ndash O(n2)ndash Double fault diagnosis ndash O(n3)ndash Triple fault diagnosis ndash O(n4)

In practice for non-Horn use SAT solver for consistency check

Horn clause at most one positive literal Also consider )

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 77: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

NASA Deep Space Onebull Autonomous diagnosis amp repair ldquoRemote

Agentrdquobull Compiled systems schematic to 7000 var

SAT problem

Started January 1996Launch October 15th 1998Experiment May 17-21

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 78: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Deep Space One

bull a failed electronics unitndash Remote Agent fixed by reactivating the unit

bull a failed sensor providing false informationndash Remote Agent recognized as unreliable and therefore correctly ignored

bull an altitude control thruster (a small engine for controlling the spacecrafts orientation) stuck in the off position ndash Remote Agent detected and compensated for by switching to a mode that

did not rely on that thruster

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 79: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

II --- Testing Circuit Equivalence

bull Do two circuits compute the same function

bull Circuit optimizationbull Is there input for which

the two circuits compute different values

(Satisfying assignment will tell us Reveals bug)

A B

nand

A B

C Crsquo

Formal spec OR Possible implementationusing hardware gates (invertor amp nand)

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 80: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

A B

nand

A B

C Crsquo

D E

( )

( )

C A B

C D E

D A

E B

C C

Informally Given the same inputs values for A and Blogic specifies outputs (C and Crsquo) Are there inputs for whichC and Crsquo differ

Descr of OR

Descr ofHardware

Our queryDoes this holdYes iff negation withKB is inconsistent

Note if consitentmodel reveals ldquobugrdquoin hardware design

What happens if you addinstead of Still OK

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 81: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

III --- SAT Translation of N-Queens

bull At least one queen each row(Q11 v Q12 v Q13 v v Q18)(Q21 v Q22 v Q23 v v Q28)

bull No attacks (columns)(~Q11 v ~Q21)(~Q11 v ~Q31)(~Q11 v ~Q41)

bull No attacks (diag need left and right)(~Q11 v ~Q22)(~Q11 v ~Q33)(~Q11 v ~Q44)

How about No attacks (rows)(~Q11 v ~Q12)(~Q11 v ~Q13)(~Q11 v ~Q14)

hellipRedundant Why Sometimes slows solver

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 82: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

More compactlybull At least one queen each row(Qi1 v Qi2 v QiN) for 1 lt= i lt= N

bull No attacks (columns ldquolook in ith columnrdquo)(~Qji v ~Qjrsquoi) for 1 lt= ijjrsquo lt= N and j == jrsquo

bull No attacks (diag need left and right)(~Qij v ~Qirsquojrsquo) for 1 lt= i irsquo j jrsquo st |i ndash irsquo| = |j ndash jrsquo| amp i == irsquo amp j == jrsquo

Or in first order logic syntax eg second constraint set8 i 8 j 8 jrsquo (j == jrsquo ) ( Qji Ccedil Qjrsquoi)) with bounded type quantifier 1 lt= i j jrsquo lt= NReally a compact ldquopropositional schemardquoFirst-order logic for finite domains is equiv to prop logicFor SAT solver always ldquoground to propositionalrdquo

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 83: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

IV --- SAT Translation of Graph ColoringAt least one color per node i

(C_i1 v Q_i2 v Q_i3 v v Q_iK)

At most one color per node i (~C_ik v ~Q_ikrsquo) for all k == krsquo

If node i and node j (== i) share an edge need to have different colors

(~C_il v ~Q_jl) for all 1 lt= I lt= K

C_ik for node i has color kTotal colors K Total nodes N

Note Translation fromldquoproblemrdquo into SATReverse of usualtranslation to show NP-completeness

Works also for (easy)polytime problems

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 84: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

V --- Symbolic Model Checkingbull Any finite state machine is characterized by a transition function

ndash CPUndash Networking protocol

bull Wish to prove some invariant holds for any possible inputsbull Bounded model checking formula is sat iff invariant fails k steps

in the future

1

10

vector of Booleans representing

state of machine at time

01

(

t

k

i i i o ki

S

t

State Input State

State

S S I S S

1) Can go to CNF2) Equivalent to planning as propositional inferenceSATPLAN(Kautz amp Selman 1996)

774 RampNThe k-step planis satisfying assignment Note frac12 is just like our ldquomoverdquo earlier

Axioms says what happens ldquonextrdquo

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 85: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

A real-world example

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 86: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

ie ((not x1) or x7) and ((not x1) or x6)

and hellip etc

Bounded Model Checking instance

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 87: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

(x177 or x169 or x161 or x153 hellip or x17 or x9 or x1 or (not x185))

clauses constraints are getting more interestinghellip

10 pages later

hellip

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 88: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

4000 pages later

hellip

a 59-cnf clausehellip

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 89: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Finally 15000 pages later

The Chaff SAT solver (Princeton) solves this instance in less than one minute

Note that hellip

What makes this possible

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 90: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Progress in Last 20 yearsbull Significant progress since the 1990rsquos How muchbull Problem size We went from 100 variables 200 constraints (early 90rsquos)

to 1000000+ variables and 5000000+ constraints in 20 years

bull Search space from 10^30 to 10^300000[Aside ldquoone can encode quite a bit in 1M variablesrdquo]

bull Is this just Moorersquos Law It helped but not muchhellip ndash 2x faster computers does not mean can solve 2x larger instances ndash search difficulty does not scale linearly with problem size In fact for O(2^n) 2x faster handle 1 more variable Mainly algorithmic progress Memory growth also key

bull Tools 50+ competitive SAT solvers available (eg Minisat solver)bull See httpwwwsatcompetitionorg

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines
Page 91: 1 CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Module: Knowledge, Reasoning, and Planning Part 1 Logical Agents R&N:

Forces Driving Faster Better SAT SolversInference engines

bull From academically interesting to practically relevant ldquoRealrdquo benchmarks with real interest in solving them

bull Regular SAT Solver Competitions (Germany-89 Dimacs-93 China-96 SAT-02 SAT-03 hellip SAT-07 SAT-09 SAT-2011)ndash ldquoIndustrial-instances-onlyrdquo SAT Races (2008 2010)ndash A tremendous resource Eg SAT Competition 2006 (Seattle)

bull 35+ solvers submitted downloadable mostly open sourcebull 500+ industrial benchmarks 1000+ other benchmarksbull 50000+ benchmark instances available on the Internet

bull Constant improvement in SAT solvers is the key to the success of eg SAT-based planning verification and KB inference

  • CS 4700 Foundations of Artificial Intelligence
  • Slide 2
  • Knowledge and Reasoning
  • Slide 4
  • Knowledge-base Agents
  • Knowledge bases
  • A simple knowledge-based agent
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Intermezzo Reflections on Inference Knowledge and Data ca
  • Watson
  • Slide 28
  • Watson (2)
  • Semantic Web
  • AI Knowledge- Data- Inference Triangle 2012
  • Back to Knowledge-Based Agentshellip
  • Illustrative example Wumpus World
  • Wumpus world characterization
  • Exploring a wumpus world
  • Slide 37
  • Further exploration
  • Slide 39
  • Slide 40
  • Formally Entailment
  • Slide 42
  • Entailment in Wumpus World
  • Wumpus models
  • Entailment via ldquoModel Checkingrdquo
  • Example redux More formal
  • Wumpus World KB
  • What about Time What about Actions
  • Slide 49
  • Successor-State Axioms
  • Some example inferences Section 771 RampN
  • Alternative formulation Situation Calculus RampN 1042
  • Inference by enumeration ldquomodel checkingrdquo Style I
  • All equivalent Prop FO Logic
  • Proof techniques
  • Aside
  • Slide 57
  • Slide 58
  • Style II Proof by inference rules Modus Ponens (MP)
  • Length of Proofs
  • Style III Resolution
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Length of Proofs (2)
  • Style IV SAT Solvers
  • DPLL improvements
  • Satisfiability (SATCSP) or Inference
  • KB sup2 (l1 Ccedil l2 hellip) iff KB AElig l1 AElig l2 hellip
  • Some examples of SAT solving
  • Application I --- Diagnosis
  • Model-Based Consistency-Based Diagnosis
  • Consistency-Based Diagnosis
  • Example Automobile Diagnosis
  • Example
  • Complexity of Diagnosis
  • NASA Deep Space One
  • Deep Space One
  • II --- Testing Circuit Equivalence
  • Slide 81
  • III --- SAT Translation of N-Queens
  • More compactly
  • IV --- SAT Translation of Graph Coloring
  • V --- Symbolic Model Checking
  • A real-world example
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Progress in Last 20 years
  • Forces Driving Faster Better SAT Solvers Inference engines