1 / 31

Declarative Programming

Declarative Programming. Motivation Warm Fuzzies What is Logic? ... Logic Programming? Mechanics of Prolog Terms, Substitution, Unification, Horn Clauses, Proof process Example: List Processing Theoretical Foundations Semantics Logic / Theorem Proving … Resolution Other Issues

Download Presentation

Declarative Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Declarative Programming • Motivation • Warm Fuzzies • What is Logic? ... Logic Programming? • Mechanics of Prolog • Terms, Substitution, Unification, Horn Clauses, Proof process • Example: List Processing • Theoretical Foundations • Semantics • Logic / Theorem Proving … Resolution • Other Issues • Search Strategies • Declarative/Procedural, ... • “Impure'' Operators” --- NOT, ! • Utilities • ? Constraint Programming • ? Bayesian Belief Nets

  2. Entailment • Spse we assert 1, 2, … on(a,b), on(a,b) ⇒ above(a,b), … Then. .. you should believe 1, 2, … • What else should we believe? (Should we believe some β – eg, “above(a,b)”?) • Entailment addresses this: You should believe all (and only) entailments. • Later: Present ALGORITHM for computing these entailments

  3. Interpretation • Vocabulary: (literals) onab: if a is immediately on b onbc: if b is immediately on c aboveab: a is (somewhere) above b aboveac: a is (somewhere) above c •  An “interpretation” (aka “world”) assigns True xor False to each literal n literals ⇒ 2 n possible worlds, I a b c

  4. Models • Write Ii if  is True (+) in world Ii • So I1onbc ⊭I6onac • Let I () = { I ∣⊨I  }

  5. I(onab) Models • Write Ii if  is True (+) in world Ii • So I1onbc ⊭I6onbc • Let I () = { I ∣⊨I  }

  6. Models • Before seeing anything, REAL-WORLDI= {I1,…,I16}

  7. Models • Before seeing anything, REAL-WORLDI= {I1,…,I16} • Asserting  means REAL-WORLDI() Eg: Asserting onabmeans REAL-WORLD ∈ I(onab) = {I1,…,I8} Each assertion ELIMINATES some possible worlds

  8. I(onab)

  9. I(¬onab)

  10. I(onab) I(onac)

  11. I(onac & onab)

  12. I(¬onac v aboveab)

  13. Boolean Combinations I(χ) = {I ∣⊨ I χ} • I (onab) = {I1,…,I8} • I (¬onab) = {I9,…,I16} • I (onab ⋀ onac) = {I1,…,I8}∩ {I1,…,I4,I9,…,I12} = {I1,…,I4} • I (¬onab ⋁ aboveab) = {I9,…,I16} ∪ {I1,I2,I5,I6,I9,I10,I13,I14} = {I1,I2,I5,I6,I9,…,I16} Note: I( ¬ ) = I – I() I( ⋁ ξ) = I () ∪ I (ξ) I( ⋀ ξ) = I () ∩ I(ξ)

  14. What else to believe? • Assert ¬onab ⋁ aboveab ⇒ REAL-WORLD I (¬onab ⋁ aboveab)= {I1, I2, I5, I6, I9, …, I16 } • Assert onab • REAL-WORLD I (¬onab ⋁ aboveab) ⋂ I(onab) = {I1, I2, I5,I6}

  15. What else to believe? • REAL-WORLD I (¬onab ⋁ aboveab) ⋂ I(onab) = {I1, I2, I5,I6} • In each such world,aboveabalso holds! I ( [¬onab ⋁ aboveab]&onab)  I(aboveab ) ⇒ We should believeaboveab !

  16. Entailment • Given set of assertions  = {1, … } set of (remaining) possible worlds = I () • Spse  holds in each world I  I ( )I (  )  I ( ) • Then you should believe … as  is true, in every “still possible” world ! • Write this    “ entails ” “ is entailed by ”

  17. Answering Queries1. Semantical Approach • Entailment specifies what we should believe. • To decide {i}  Given n literals, write n  2n table. Let W = all 2n rows For each assertion i let W := W ⋂I (i) (ie, eliminate every row that does not satisfy i) Check  column. If ``+'' in each row (of W) then Answer “YES: {i}   '' else Answer “IDK: {i} ⊭ '' • Problem: HUGE table! (  in predicate calculus)

  18. Answering Queries2. Syntactic Approach • Proof Process (aka ``derivation'', ``deduction'') is mechanic process ... for deciding whether conclusion follows from premises • First consider “forward chaining”: KB ↝ KB' • Implemented by ... Apply sequence of individual (sound) Inference Rulesto initial set of premises, to find new ones • Sound  preserves truth If believe ``antecedent'', must believe conclusion • Inference Rules  HornClause

  19. -- - man(s) --- --- -- man(X)  mortal(X) - - -- - mortal(s) - - -- - KB1 r1  • -- - man(s) --- --- -- man(X)  mortal(X) - - -- - mortal(s) • - -- - cat(p) • -- - man(s) --- --- -- man(X)  mortal(X) - - -- - mortal(s) • - -- - cat(p) KB2 KBk r2  r9  r3  … Derivation Process • -- - man(s) --- --- -- man(X)  mortal(X) - - -- - - - -- - KB0

  20. New Facts from Old:A sound Inference rule Called “Modus Ponens” Written:

  21. Sound Inference Rules

  22. Sound Rules of Inference irj KB0 KB1 Inference rule irjmaps KB0 into KB1 If irj is sound [aka Truth-Preserving], then KB0 ⊨KB1 … I(KB0) I(KB1) So… RW ∊ KB0 RW ∊ KB1 … if believeKB0 , must believe KB1 !

  23. RW I(KB1) Sound Rules of Inference If irj is sound [aka Truth-Preserving], then KB0 ⊨KB1 … I(KB0) I(KB1) So… RW ∊ KB0 RW ∊ KB1 Hence: If believeKB0 , must believe KB1. Possible worlds I(KB0)

  24. Sound Rules of Inference – con’t • In general, KB1 = KB0 + . So KB1⊨KB0 • … KB1, KB0 hold in EXACTLY same worlds: Possible worlds I(KB0) I(KB1) • If each rij is sound, then sequence ri1 … rin is sound.

  25. KB0 KB1 KBN KB0 KB1 KBN ri1 ri1 … riN … riN Answering Queries • Adding Truths (Forward Chaining) • Given KB0 produce KBNs.t. If {rij}j sound, thenKB0⊧KBN • Answering Questions (Backward Chaining) • Given KB0 , ; determine if KB⊧  • Requires sound <ri j >j s.t. and  KBN

  26. How to Reason? Q:How to reason? Given KB, q, determine if KB ⊨ q ? A: Select Inference Rule IR Select Facts(s) {Fi} from KB Apply rule IR to Facts {Fi} to get new Fact  Add  to KB Repeat until find  = q Issues: 1. Lots of Inference Rules… Which one to use, when? 2. Is overall system “complete”? If  answer, guaranteed to find it?

  27. Properties of Derivation Process • ⊢ is SOUND ⊢ ⊨ Produces only “true” results • ⊢ is COMPLETE •  ⊢  ⊨ • Produces all “true” results • ⊢ is DECIDABLE •  ⊢? returns Y or N in finite time ?

  28. Just say “No” f’sure Degenerate ⊦ • For any ,  ⊂ WFFs:  ⊬N  ⊢P • Notice • ⊢Nis SOUND (returns everything logically entailed) • ⊢Pis COMPLETE (returns everything logically entailed) • ⊢N , ⊢Pis DECIDABLE(answer every question)

  29. Fundamental Limitation • For any sufficiently complicated domain • as complex as arithmetic • No ⊢ can be • SOUND, COMPLETE, DECIDABLE!! • Reduction to halting Problem. Not Predicate Calculus’s fault: Reasoning is inherently undecidable, no manner what formalism used

  30. Responses • Deals only with WORST-case! • “Typical” case can be better. • TradeOffs (to increase efficiency): • ? Sacrifice SOUNDness? • No – too severe. • ? Sacrifice COMPLETEness? • Reasonable ... Specific proposals: • - Use only (incomplete set of) Inference Rules • - Use complete set of Inference Rules, • but limit depth (…stop expanding nodes…) • ? Sacrifice EXPRESSIVEness? • [EXPRESSIVEness  what can be distinguished.] • Common approach! • (After all, Logic’s distinctions caused problems!) • Disallow “Ⅴ” “¬” “” …

  31. Implemented Systems • DataBase Systems • ≈Sound, Complete, Limited Expressiveness • Prolog • ≈Sound, complete, Limited Expressiveness • General Theorem Provers • ≈Sound, Complete, Complete Expressiveness • Production System (Emycin, OPS) • ≈Sound, ≈ Complete, Limited Expressiveness • Frame systems • ?Sound?, ?Complete?, Limited Expressiveness • Description Languages • Sound, Complete, Limited Expressiveness • Truth Maintenance

More Related