lectures 11 / 12 knowledge representation propositional logic

51
Lectures 11 / 12 Knowledge Representation Propositional Logic CSE 573 Artificial Intelligence I Henry Kautz Fall 2001

Upload: tocho

Post on 08-Jan-2016

25 views

Category:

Documents


1 download

DESCRIPTION

Lectures 11 / 12 Knowledge Representation Propositional Logic. CSE 573 Artificial Intelligence I Henry Kautz Fall 2001. How Did You Represent Your Knowledge of Chess?. Advantages of Procedural Representation of Knowledge. Consider Queries…. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Lectures 11 / 12 Knowledge Representation Propositional Logic

Lectures 11 / 12Knowledge Representation

Propositional Logic

Lectures 11 / 12Knowledge Representation

Propositional Logic

CSE 573

Artificial Intelligence IHenry Kautz

Fall 2001

Page 2: Lectures 11 / 12 Knowledge Representation Propositional Logic

How Did You Represent Your Knowledge of Chess?

How Did You Represent Your Knowledge of Chess?

Page 3: Lectures 11 / 12 Knowledge Representation Propositional Logic

Advantages of Procedural Representation of Knowledge

Advantages of Procedural Representation of Knowledge

Page 4: Lectures 11 / 12 Knowledge Representation Propositional Logic

Consider Queries…Consider Queries…

1. From the initial position, can a pawn move forward 2 squares?

2. From any other position, can a pawn move forward 2 squares?

3. When can a King move move than 1 square at a time?

Page 5: Lectures 11 / 12 Knowledge Representation Propositional Logic

What Other Problems with Procedural Approach?

What Other Problems with Procedural Approach?

Consider representing large amounts of knowledge…

Page 6: Lectures 11 / 12 Knowledge Representation Propositional Logic

Declarative Knowledge Representation

Declarative Knowledge Representation

• Non-procedural representations are called declarative.

• What is the standard CS approach to declarative knowledge representation?

• What difficulty would that approach have in representing our knowledge of chess?

Page 7: Lectures 11 / 12 Knowledge Representation Propositional Logic

What About English?What About English?

Page 8: Lectures 11 / 12 Knowledge Representation Propositional Logic

DesiderataDesiderata

1. Declarative

• separate kx from use of kx

2. Expressive

• general rules as well as facts

• incomplete information

3. Concise – Generate many new conclusions

• exponential / infinite number

4. Effectively computable

• unambiguous, even without context

Page 9: Lectures 11 / 12 Knowledge Representation Propositional Logic

Basic Idea of LogicBasic Idea of Logic

By starting with true assumptions, you can deduce true conclusions.

Page 10: Lectures 11 / 12 Knowledge Representation Propositional Logic

TruthTruth

Francis Bacon (1561-1626) No pleasure is comparable to the standing upon the vantage-ground of truth.

Thomas Henry Huxley (1825-1895) Irrationally held truths may be more harmful than reasoned errors.

John Keats (1795-1821) Beauty is truth, truth beauty; that is allYe know on earth, and all ye need to know.

Blaise Pascal (1623-1662) We know the truth, not only by the reason, but also by the heart.

François Rabelais (c. 1490-1553) Speak the truth and shame the Devil.

Daniel Webster (1782-1852) There is nothing so powerful as truth, and often nothing so strange.

Page 11: Lectures 11 / 12 Knowledge Representation Propositional Logic

The Big ThreeThe Big Three

Page 12: Lectures 11 / 12 Knowledge Representation Propositional Logic

EntailmentEntailment

m – something that determines whether a sentence S is true or false – a “state of affairs”

m S• S is true in m• m is a model of S

S T• S entails T• Every model of S is a model of T• When S is true, then T must be true

Page 13: Lectures 11 / 12 Knowledge Representation Propositional Logic

Truth in the World vs Truth in a Model

Truth in the World vs Truth in a Model

• It is hard to formally talk about truth in the “real world”

• So m is generally a mathematical object that “mirrors” the world in some important way

• E.g.: m is a truth assignment – a function from sentences to {1, 0}

Sentence m

Page 14: Lectures 11 / 12 Knowledge Representation Propositional Logic

Intended vs. Unintended ModelsIntended vs. Unintended Models

Sentence m1

m2

?

Page 15: Lectures 11 / 12 Knowledge Representation Propositional Logic

Satisfiability and ValiditySatisfiability and Validity

Fix a language L and a set of possible models M.

• S is satisfiable if it is true is some model:

m S• S is unsatisfiable if it is false in all models.

• S is valid if it is true in all models:

S

Page 16: Lectures 11 / 12 Knowledge Representation Propositional Logic

Propositional LogicPropositional Logic

Ingredients of a sentence:1. Propositions (variables)

literal = a variable or a negated variable2. Special symbols: true, false3. Logical Connectives , , ,

Ingredients of a model:1. Truth assignment: function that assigns

true/false (1/0) to each variable2. Always assigns symbol true 1, symbol false 03. Truth assignment of sentences computed by

applying truth-tables for connectives

Page 17: Lectures 11 / 12 Knowledge Representation Propositional Logic

Truth Tables for ConnectivesTruth Tables for Connectives

0 0

0 1

1 0

1 1

0 0

0 1

1 0

1 1

0 0

0 1

1 0

1 1

0

1

Page 18: Lectures 11 / 12 Knowledge Representation Propositional Logic

Key Idea: Compositional Semantics

Key Idea: Compositional Semantics

Unlike English, Propositional Logic has compositional semantics:

• The truth of a sentence is a function of the truth of its subparts– Context is not relevant, once truth of propositions is

determined!

• Compare:

John believes Mary loves him.

Page 19: Lectures 11 / 12 Knowledge Representation Propositional Logic

Relation of Entailment and Implication

Relation of Entailment and Implication

S T

iff

S T

Page 20: Lectures 11 / 12 Knowledge Representation Propositional Logic

Relation of Validity and Unsatisfiability

Relation of Validity and Unsatisfiability

Siff

S is unsatisfiable:There is no m such that m S

If a sentence is true in all worlds, its negation is true in no worlds

Page 21: Lectures 11 / 12 Knowledge Representation Propositional Logic

InferenceInference

• Mechanical process for computing new sentences

• Does not depend on understanding intended meaning of sentences!

• Many different possible systems of inference

• Modus ponens:

{ P, P Q } Q

Page 22: Lectures 11 / 12 Knowledge Representation Propositional Logic

Soundness and CompletenessSoundness and Completeness

Sound:

if S T then S T

Complete:

if S T then S T

Refutation Complete:

if S is unsatisfiable then S false

Page 23: Lectures 11 / 12 Knowledge Representation Propositional Logic

Why Refutation Completeness is All We Need

Why Refutation Completeness is All We Need

S T

iff S T

iff (S T) is unsatisfiable

iff ( S T) is unsatisfiable

iff (S T) is unsatisfiable

iff (S T) false

Page 24: Lectures 11 / 12 Knowledge Representation Propositional Logic

Special Syntactic FormsSpecial Syntactic Forms

• General PL:

((q r) s)) (s t)• Clausal form (CNF – conjunctive normal form):

( q r s ) ( s t)

{ ( q r s ), ( s t) }

empty clause () = false

• Binary clauses: 1 or 2 literals per clause

{ ( q r), ( s t) }

• Horn clauses: 0 or 1 positive literal per clause

{ ( q r s ), ( s t) }

{ ((qr) s ), ((st) false) }

Page 25: Lectures 11 / 12 Knowledge Representation Propositional Logic

ResolutionResolution

{ (p ), ( p ) }

R

( )

– Defined for clauses (CNF) , any disjunctions of literals

– Remove any repeated literals from conclusion

{ (p q), ( p q) } R (q)

Page 26: Lectures 11 / 12 Knowledge Representation Propositional Logic

Resolution ProofResolution Proof

• DAG, where leaves are input clauses

• Internal nodes are resolvants

• Root is false (empty clause)

(p q) (p q)

(q) (q)

()

Page 27: Lectures 11 / 12 Knowledge Representation Propositional Logic

ExampleExample

If the unicorn is mythical, then it is immortal, but if it is not mythical, it is a mortal mammal. If the unicorn is either immortal or a mammal, then it is horned.

Prove: the unicorn is horned.

M = mythical I = immortal

A = mammal H = horned

Page 28: Lectures 11 / 12 Knowledge Representation Propositional Logic

ExampleExample

( A H)

(M A)

( H) (I H)

( M)

( M I)(I)(A)

(M)

()

Page 29: Lectures 11 / 12 Knowledge Representation Propositional Logic

Completeness of ResolutionCompleteness of Resolution

Resolution is refutation complete

• Why is this remarkable?

Page 30: Lectures 11 / 12 Knowledge Representation Propositional Logic

Conversion to Clausal FormConversion to Clausal Form

(q r ) (s t)

Page 31: Lectures 11 / 12 Knowledge Representation Propositional Logic

New Variable TrickNew Variable Trick

Putting a formula in clausal form may increase its size exponentially

But can avoid this by introducing dummy variables(abc)(def) {(ad),(ae),(af),

(bd),(be),(bf), (cd),(ce),(cf) }

(abc)(def) {(gh),(abcg),(ga),(gb),(gc), (defh),(hd),(he),(hf)}

Dummy variables don’t change satisfiability!

Page 32: Lectures 11 / 12 Knowledge Representation Propositional Logic

Complexity of InferenceComplexity of Inference

Formal complexity of the problem of sound and complete inference is separate from the particular system of inference.

In general:

For clausal form:

For binary clauses:

For Horn clauses:

Page 33: Lectures 11 / 12 Knowledge Representation Propositional Logic

Is Resolution “Optimal”?Is Resolution “Optimal”?

For binary and Horn clauses: polynomial time

• Requires some further implementation tricks to be linear rather than quadratic

In general: can require exponential time, even on certain easy problems…

Page 34: Lectures 11 / 12 Knowledge Representation Propositional Logic

Pigeon Hole FormulasPigeon Hole Formulas

• PH Problem: Formula encodes that you cannot place n+1 pigeons in n holes (one per hole)

• Proposed Cook/Karp around 1971; “Resolved” by Armin Haken 1985.

• PH takes exponentially many resolution steps (no matter in what order)

• Does this prove NP P?No, because there are other proof systems

that do have short proofs for pigeon hole. Need to prove that every proof system has large proofs for some problem.

Page 35: Lectures 11 / 12 Knowledge Representation Propositional Logic

Using a Satisfiability Procedure for Inference

Using a Satisfiability Procedure for Inference

Recall Davis-Putnam procedure:

• Backtracking CSP search to find a truth assignment that satisfies a formula

How can we use it for inference, e.g. to prove

S T ?

Page 36: Lectures 11 / 12 Knowledge Representation Propositional Logic

Using a Satisfiability Procedure for Inference

Using a Satisfiability Procedure for Inference

Recall Davis-Putnam procedure:

• Backtrack CSP search to find a truth assignment that satisfies a formula

How can we use it for inference, e.g. to prove

S T ?

S T iff (S T) is unsatisfiable

• Negate T, put it in clausal form, add to S

• Run DP: if no model found, theorem proved!

Page 37: Lectures 11 / 12 Knowledge Representation Propositional Logic

Search Tree vs Proof TreeSearch Tree vs Proof Tree

• For an unsat formula, the Davis-Putnam search tree can be converted to a resolution proof tree

• Replace each failed leaf with the clause that failed there

• Internal nodes are resolvants

• Thus, DP is a particular resolution strategy

• Asymptotically not the best resolution strategy, but usually best in practice – efficient use of memory!

Page 38: Lectures 11 / 12 Knowledge Representation Propositional Logic

Axiom SchemasAxiom Schemas

Useful to allow schemas that stand for sets of sentences.

• Blowup: (index range)nesting

for i, j in {1, 2, 3, 4} such that adjacent(i,j):

for c in {R, B, G}:

( Xc,i Xc,j)

12 4

3

Page 39: Lectures 11 / 12 Knowledge Representation Propositional Logic

Horn TheoriesHorn Theories

Recall the special case of Horn clauses:{ ( q r s ), ( s t) }{ ((qr) s ), ((st) false) }

Many problems naturally take the form of such if/then rules

A very simple (linear time) form of inference is refutation complete for Horn theories:

Unit resolution (one clause must be unit)= unit propagation= Arc consistency

Page 40: Lectures 11 / 12 Knowledge Representation Propositional Logic

Expert System for Automobile Diagnosis

Expert System for Automobile Diagnosis

Knowledge Base:

GasInTank FuelLineOK GasInEngine

GasInEngine GoodSpark EngineRuns

PowerToPlugs PlugsClean GoodSpark

BatteryCharged CablesOK PowerToPlugs

Observed:

EngineRuns,GasInTank, PlugsClean, BatteryCharged

Prove:

FuelLineOK CablesOK

Page 41: Lectures 11 / 12 Knowledge Representation Propositional Logic

Solution by Unit Propagation (Arc Consistency)

Solution by Unit Propagation (Arc Consistency)

Knowledge Base and Observations:( GasInTank FuelLineOK GasInEngine)( GasInEngine GoodSpark EngineRuns)( PowerToPlugs PlugsClean GoodSpark)( BatteryCharged CablesOK PowerToPlugs)(EngineRuns)(GasInTank)(PlugsClean)(BatteryCharged)

Negation of Conclusion:(FuelLineOK)(CablesOK)

Page 42: Lectures 11 / 12 Knowledge Representation Propositional Logic

How Do You Know What to Prove?

How Do You Know What to Prove?

In this example were given the diagnosis we wanted to prove:

FuelLineOK CablesOK

But, in general, how do you know what to prove?

A powerful and widely-used technique for finding an hypothesis that explains an observed system fault ( EngineRuns) is Consistency Based Diagnosis.

Page 43: Lectures 11 / 12 Knowledge Representation Propositional Logic

Consistency-Based DiagnosisConsistency-Based Diagnosis

1. Make some Observations O.

2. Initialize the Assumption Set A to assert that all components are working properly.

3. 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

Page 44: Lectures 11 / 12 Knowledge Representation Propositional Logic

ExampleExample

Is KB Observations Assumptions consistent?

KB { EngineRuns, GasInTank, PlugsClean, BatteryCharged} { FuelLineOK, CablesOK } false

• Must restore consistency!

KB { EngineRuns,GasInTank, PlugsClean, BatteryCharged} {CablesOK } false

• So FuelLineOK is a possible diagnosis!

KB { EngineRuns,GasInTank, PlugsClean, BatteryCharged} {FuelLineOK} false

• So CablesOK is a possible diagnosis!

Page 45: Lectures 11 / 12 Knowledge Representation Propositional Logic

Complexity of DiagnosisComplexity of Diagnosis

If KB is Horn, then each consistency test takes linear time.

Complexity = ways to delete propositions from Assumption Set that are considered.

• Single fault diagnosis – O(n2)

• Double fault diagnosis – O(n3)

• Triple fault diagnosis – O(n4)

Page 46: Lectures 11 / 12 Knowledge Representation Propositional Logic

Multiple Fault DiagnosisMultiple Fault Diagnosis

Knowledge Base:GasInTank FuelLineOK GasInEngineEmergencyTankFull GasInEngineGasInEngine GoodSpark EngineRunsPowerToPlugs PlugsClean GoodSparkBatteryCharged CablesOK PowerToPlugs

Observed: EngineRuns,

GasInTank, PlugsClean, BatteryChargedAssumptions:

FuelLineOK, CablesOK, EmergencyTankFull

Page 47: Lectures 11 / 12 Knowledge Representation Propositional Logic

Example: Double FaultExample: Double Fault

Is KB Observations Assumptions consistent?

KB { EngineRuns, GasInTank, PlugsClean, BatteryCharged} { FuelLineOK, CablesOK, EmergencyTankFull } false

• Must restore consistency!

KB { EngineRuns,GasInTank, PlugsClean, BatteryCharged} {CablesOK, EmergencyTankFull } false

• So FuelLineOK is not a diagnosis!

KB { EngineRuns,GasInTank, PlugsClean, BatteryCharged} {CablesOK} false

• So FuelLineOK EmergencyTankFull is double-fault diagnosis!

Page 48: Lectures 11 / 12 Knowledge Representation Propositional Logic

Improving Efficiency of Consistency-Based Diagnosis

Improving Efficiency of Consistency-Based Diagnosis

Suppose there are many assumptions that are irrelevant to the problem

E.g.: AshTraysClean irrelevant to EngineRuns

Only want to try retracting relevant assumptions

Approach:

1. Generate proof tree of inconsistency

2. Assumptions that appear as leafs in the tree (FuelLineOK, CablesOK) are relevant

3. Retract one relevant assumptionRemoving a leaf breaks this particular proof of unsatisfiability

4. Is formula now consistent? If so, done; if not, return to step (1).

For a multiple-fault, will have to repeat!

Page 49: Lectures 11 / 12 Knowledge Representation Propositional Logic

Applications of Diagnostic Inference

Applications of Diagnostic Inference

Many medical expert systems

Circuit testing/debugging

Xerox copy machines

NASA Deep Space One Remote Agent

yes, you know the slide…

Page 50: Lectures 11 / 12 Knowledge Representation Propositional Logic

Compiled into 2,000 variableSAT problem

Real-time planning and diagnosis

Page 51: Lectures 11 / 12 Knowledge Representation Propositional Logic

Coming UpComing Up

• First Order Logic

• Ontologies

• Description Logics

• Reasoning About Change

• Planning (Handout)