1 / 67

Course: Engineering Artificial Intelligence

Course: Engineering Artificial Intelligence. Dr. Radu Marinescu. Lecture 7. Today’s class. Logic Propositional logic First order logic. What is logic?. A formal language Syntax – what expressions are legal Semantics – what legal expressions mean

raine
Download Presentation

Course: Engineering Artificial Intelligence

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. Course:Engineering Artificial Intelligence Dr. Radu Marinescu Lecture 7

  2. Today’s class • Logic • Propositional logic • First order logic

  3. What is logic? • A formal language • Syntax – what expressions are legal • Semantics – what legal expressions mean • Proof system – a way of manipulating syntactic expressions to get other syntactic expressions (which will tell us something new)

  4. What is logic? • A formal language • Syntax – what expressions are legal • Semantics – what legal expressions mean • Proof system – a way of manipulating syntactic expressions to get other syntactic expressions (which will tell us something new) • Why proofs? Two kinds of inferences an agent might want to make • Multiple percepts => conclusions about the world • Current state & operators => properties of next state

  5. Propositional logic syntax • Syntax: what you’re allowed to write • for (int t = 0; t == 100; t++) {…} • “Colorless green ideas sleep furiously” (Noam Chomsky)

  6. Propositional logic syntax • Syntax: what you’re allowed to write • for (int t = 0; t == 100; t++) {…} • “Colorless green ideas sleep furiously” (Noam Chomsky) • Sentences (WFF: well formed formulas) • true and false are sentences

  7. Propositional logic syntax • Syntax: what you’re allowed to write • for (int t = 0; t == 100; t++) {…} • “Colorless green ideas sleep furiously” (Noam Chomsky) • Sentences (WFF: well formed formulas) • true and false are sentences • Propositional variables are sentences: P, Q, R, Z

  8. Propositional logic syntax • Syntax: what you’re allowed to write • for (int t = 0; t == 100; t++) {…} • “Colorless green ideas sleep furiously” (Noam Chomsky) • Sentences (WFF: well formed formulas) • true and false are sentences • Propositional variables are sentences: P, Q, R, Z • If Φ and Ψ are sentences, then so are (Φ), ¬ Φ, Φ /\ Ψ, Φ \/ Ψ, Φ → Ψ, Φ ↔ Ψ

  9. Propositional logic syntax • Syntax: what you’re allowed to write • for (int t = 0; t == 100; t++) {…} • “Colorless green ideas sleep furiously” (Noam Chomsky) • Sentences (WFF: well formed formulas) • true and false are sentences • Propositional variables are sentences: P, Q, R, Z • If Φ and Ψ are sentences, then so are (Φ), ¬ Φ, Φ ˄ Ψ, Φ ˅ Ψ, Φ → Ψ, Φ ↔ Ψ • Nothing else is a sentence

  10. Precedence • Precedence rules enable “shorthand” form of sentences, but formally only the fully parenthesized form is legal • Syntactically ambiguous forms allowed in shorthand only when semantically equivalent: A ˄ B ˄ C is equivalent to (A ˄ B) ˄ C and A ˄ (B ˄ C) highest lowest

  11. Semantics • Meaning of a sentence is truth value {t, f} • Interpretation is an assignment of truth values to propositional variables • holds(Φ, i) [Sentence Φ is tin interpretation i] • fails(Φ, i) [Sentence Φ is f in interpretation i]

  12. Semantic rules • holds(true, i) for all i • fails(false, i) for all I • holds(¬Φ, i) if and only if fails(Φ, i) • holds(Φ˄Ψ, i) iff holds(Φ, i) and holds(Ψ, i) • holds(Φ˅Ψ, i) iff holds(Φ, i) or holds(Ψ, i) (negation) (conjunction) (disjunction)

  13. Semantic rules • holds(true, i) for all i • fails(false, i) for all I • holds(¬Φ, i) if and only if fails(Φ, i) • holds(Φ˄Ψ, i) iff holds(Φ, i) and holds(Ψ, i) • holds(Φ˅Ψ, i) iff holds(Φ, i) or holds(Ψ, i) • holds(P, i) iff i(P) = t • fails(P, i) iff i(P) = f (negation) (conjunction) (disjunction)

  14. Some important shorthand • Φ→Ψ ≡ ¬Φ˅Ψ(conditional, implication) • Φ↔Ψ≡ (Φ→Ψ) ˄ (Ψ→Φ) (biconditional, equivalence) antecedent → consequent

  15. Some important shorthand • Φ→Ψ ≡ ¬Φ˅Ψ(conditional, implication) • Φ↔Ψ≡ (Φ→Ψ) ˄ (Ψ→Φ) (biconditional, equivalence) antecedent → consequent Truth tables

  16. Some important shorthand • Φ→Ψ ≡ ¬Φ˅Ψ(conditional, implication) • Φ↔Ψ≡ (Φ→Ψ) ˄ (Ψ→Φ) (biconditional, equivalence) antecedent → consequent Truth tables Note that implication is not “causality”, if P is f then P→Q is t

  17. Terminology • A sentence is valid iff its truth table value is t in all interpretations • Valid sentences: true, ¬false, P ˅ ¬P • A sentence is satisfiable iff its truth value is t in at least one interpretation • Valid sentences: P, true, ¬P • A sentence is unsatisfiable iff its truth value is f in all interpretations • Unsatisfiable sentences: P ˄¬P, false, ¬true

  18. Terminology • A sentence is valid iff its truth table value is t in all interpretations • Valid sentences: true, ¬false, P ˅ ¬P • A sentence is satisfiable iff its truth value is t in at least one interpretation • Valid sentences: P, true, ¬P • A sentence is unsatisfiable iff its truth value is f in all interpretations • Unsatisfiable sentences: P ˄¬P, false, ¬true All are finitely decidable!

  19. Examples Interpretation that make sentence’s truth value = f Sentence Valid? smoke → fire smoke ˅ ¬fire valid

  20. Examples Interpretation that make sentence’s truth value = f Sentence Valid? smoke → smoke ¬ smoke ˅ smoke valid smoke → fire ¬ smoke ˅ fire satisfiable, not valid smoke = t, fire = f

  21. Examples Interpretation that make sentence’s truth value = f Sentence Valid? smoke → smoke ¬smoke ˅ smoke valid smoke → fire ¬smoke ˅ fire satisfiable, not valid smoke = t, fire = f (s → f) → (¬s → ¬f) s = f, f = t s → f = t, ¬s → ¬f = f satisfiable, not valid

  22. Examples Interpretation that make sentence’s truth value = f Sentence Valid? smoke → smoke ¬smoke ˅ smoke valid smoke → fire ¬smoke ˅ fire satisfiable, not valid smoke = t, fire = f (s → f) → (¬s → ¬f) s = f, f = t s → f = t, ¬s → ¬f = f satisfiable, not valid (s → f) → (¬f → ¬s) valid

  23. Satisfiability • Related to constraint satisfaction • Given a sentence S, try to find an interpretation i such that holds(S, i) • Analogous to finding an assignment of values to variables such that the constraints hold

  24. Satisfiability • Related to constraint satisfaction • Given a sentence S, try to find an interpretation i such that holds(S, i) • Analogous to finding an assignment of values to variables such that the constraints hold • Brute force method: enumerate all interpretations and check • Better methods • Heuristic search • Constraint propagation • Stochastic search

  25. Satisfiability problems • Scheduling nurses to work in a hospital • Propositional variables represent, for example, that Pat is working on Tuesday at 2 • Constraints on the schedule are represented using logical expressions over the variables • Finding bugs in software • Propositional variables represent states of the program • Use logic to describe how the program works and to assert there is a bug • If the sentence is satisfiable, you’ve found a bug

  26. A good lecture? • Imagine we knew that: • If today is sunny, then Thomas will be happy (S → H) • If Thomas is happy, the lecture will be good (H → G) • Today is sunny (S) Should we conclude that the lecture will be good?

  27. Checking interpretations

  28. Checking interpretations

  29. Checking interpretations Good lecture!

  30. Entailment • A knowledge base (KB) entails a sentence S iff every interpretation that makes KB true also makes S true holds KB S holds holds subset interpretations interpretations

  31. Computing entailment • Enumerate all interpretations • Select those in which all elements of KB are true • Check to see if S is true in all those interpretations holds KB S holds holds subset interpretations interpretations

  32. Computing entailment • Enumerate all interpretations • Select those in which all elements of KB are true • Check to see if S is true in all those interpretations Way too many interpretations in general !! holds KB S holds holds subset interpretations interpretations

  33. Entailment and Proof • A proof is a way to test whether a KB entails a sentence, without enumerating all possible interpretations proof holds KB S holds holds subset interpretations interpretations

  34. Proof • Proof is a sequence of sentences • First ones are premises (in KB) • Then, you can write down on the next line the result of applying an inference rule to previous lines • When S is on a line, you have proved S from KB • If inference rules are sound, then any S you can prove from KB is entailed by KB • If inference rules are complete, then any S that is entailed by KB can be proved from KB

  35. Natural deduction • Some inference rules AND- introduction Modus tolens AND- elimination Modus ponens

  36. Natural deduction example Prove S

  37. Natural deduction example Prove S

  38. Natural deduction example Prove S

  39. Natural deduction example Prove S

  40. Natural deduction example Prove S

  41. Natural deduction example Prove S

  42. Proof systems • There are many natural deduction systems; they are typically “proof checkers”, sound but not complete • Natural deduction uses lots of inference rules which introduces a large branching factor in the search for a proof • In general, you need to do “proof by cases” which introduces even more branching Prove R

  43. Propositional resolution • Resolution rule: • Single inference rule is a sound and complete proof system • Requires all sentences to be converted to conjunctive normal form (CNF)

  44. Conjunctive normal form (CNF) • Conjunctive normal form (CNF) formulas:

  45. Conjunctive normal form (CNF) • Conjunctive normal form (CNF) formulas: • (A ˅ B ˅ ¬C) is a clause, which is a disjunction of literals • A, B, and ¬C are literals, each of which is a variable or the negation of a variable • Each clause is a requirement that must be satisfied and can be satisfied in multiple ways • Every sentence in propositional logic can be written in CNF

  46. Converting to CNF • Eliminate arrows using definitions • Drive in negations using De Morgan’s Laws • Distribute OR over AND • Every sentence can be converted to CNF, but it may grow exponentially in size

  47. CNF conversion example

  48. CNF conversion example • Eliminate arrows

  49. CNF conversion example • Eliminate arrows • Drive in negations

  50. CNF conversion example • Eliminate arrows • Drive in negations • Distribute

More Related