1 / 47

Logic

Logic. Propositional Logic. Logic as a Knowledge Representation Language. A Logic is a formal language, with precisely defined syntax and semantics, which supports sound inference. Independent of domain of application.

addo
Download Presentation

Logic

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

  2. Propositional Logic

  3. Logic as a Knowledge Representation Language • A Logic is a formal language, with precisely defined syntax and semantics, which supports sound inference. Independent of domain of application. • Different logics exist, which allow you to represent different kinds of things, and which allow more or less efficient inference. • ..

  4. propositional logic, predicate logic, temporal logic, modal logic, description logic.. • But representing some things in logic may not be very natural, and inferences may not be efficient. More specialised languages may be better

  5. Formal Languages Intelligent systems require that we have Knowledge formally represented New inferences/conclusions possible. Formal languages have been developed to support knowledge representation. One important one is the use of logic - very general purpose way to formally represent truths about the world, and draw sound conclusions from these.

  6. Propositional logic • In general a logic is defined by • syntax: what expressions are allowed in the language. • Semantics: what they mean, in terms of a mapping to real world • proof theory: how we can draw new conclusions from existing statements in the logic. • Propositional logic is the simplest..

  7. What is a proposition Proposition = Statement that may be either true or false. John is in the classroom. Mary is enrolled in 270A. If A is true, and A implies B, then B is true. If some A are B, and some B are C, then some A are C. If some women are students, and some students are men, then ….

  8. Propositional Logic: Syntax • Symbols (e.g., letters, words) are used to represent facts about the world, e.g., • “P” represents the fact “Andrew likes chocolate” • “Q” represents the fact “Andrew has chocolate” • These are called atomic propositions • True and false are also atomic propositions

  9. Logical connectives are used to represent and: , or:  , if-then: , not: . • Statements or sentences in the language are constructed from atomic propositions and logical connectives. • P  Q “Andrew likes chocolate and he doesn’t have any.” • P Q “If Andrew likes chocolate then Andrew has chocolate”

  10. Propositional Logic: Semantics • What does it all mean? • Sentences in propositional logic tell you about what is true or false. • P  Q means that both P and Q are true. • P  Q means that either P or Q is true (or both)

  11. Concerns What does it mean to say a statement is true? What are sound rules for reasoning What can we represent in propositional logic? What is the efficiency? Can we guarantee to infer all true statements?

  12. Propositional Logic: Semantics • P  Q means that if P is true, so is Q. • This is all formally defined using truth tables. X Y X v Y T T TT F T F T TF F F We now know exactly what is meant in terms of the truth of the elementary propositions when we get a sentence in the language (e.g., P => Q v R).

  13. Truth Tables • The truth tables for Propositional Calculus are as follows

  14. Negation

  15. Conjunction

  16. Disjunction

  17. Implication

  18. Exclusive Or

  19. IFF Equivalence

  20. Proof Theory • How do we draw new conclusions from existing supplied facts? • We can define inference rules, which are guaranteed to give true conclusions given true premises. • For propositional logic useful one is modus ponens: • If A is true and A=> B is true, then conclude B is true. A, A B ————————— B

  21. Proof Theory and Inference • So, let P mean “It is raining”, Q mean “I carry my umbrella”. • If we know that P is true, and P => Q is true.. • We can conclude that Q is true. • Note that certain expressions are equivalent • think about P => Q and  P v Q.

  22. More complex rules of inference • Other rules of inference can be used, e.g.,: • This is essentially the resolution rule of inference, used in Prolog. A v B,  B v C ——————————————— A v C

  23. Consider • What can we conclude? sunny v raining  raining v umbrella

  24. Semantics • Model = possible world • x+y = 4 is true in the world x=3, y=1. • x+y = 4 is false in the world x=3, y = 1. • Entailment S1,S2,..Sn |= S means in every world where S1…Sn are true, S is true. • Careful: No mention of proof – just checTaoiseach all the worlds. • Some cognitive scientists argue that this is the way people reason.

  25. Reasoning or Inference Systems • Proof is a syntactic property. • Rules for deriving new sentences from old ones. • Sound: any derived sentence is true. • Complete: any true sentence is derivable. • NOTE: Logical Inference is monotonic. Can’t change your mind.

  26. Translation into Propositional Logic • If it rains, then the game will be cancelled. • If the game is cancelled, then we clean house. • Can we conclude? • If it rains, then we clean house. • p = it rains, q = game cancelled r = we clean house. • If p then q. not p or q • If q then r. not q or r • if p then r. not p or r (resolution)

  27. What can’t we say? • Quantification: every student has a father. • Relations: If X is married to Y, then Y is married to X. • Probability: There is an 80% chance of rain. • Combine Evidence: This car is better than that one because… • Uncertainty: Maybe John is playing golf.

  28. Advantages of propositional logic Propositional logic is declarative Propositional logic allows partial/disjunctive/negated information • (unlike most data structures and databases) • Propositional logic is compositional: • meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,2 Meaning in propositional logic is context-independent • (unlike natural language, where meaning depends on context)

  29. Disadvantages Propositional logic has very limited expressive power • (unlike natural language) • E.g., cannot say "pits cause breezes in adjacent squares“ • except by writing one sentence for each square

  30. First-order logic • Whereas propositional logic assumes the world contains facts, • first-order logic (like natural language) assumes the world contains Objects: people, houses, numbers, colors, baseball games, wars, … Relations: red, round, prime, brother of, bigger than, part of, comes between, …

  31. And • Functions: father of, best friend, one more than, plus, …

  32. Syntax of FOL: Basic elements • Constants TaoiseachJohn, 2, DIT,... • Predicates Brother, >,... • Functions Sqrt, LeftLegOf,... • Variables x, y, a, b,... • Connectives , , , ,  • Equality = • Quantifiers , 

  33. Atomic sentences Atomic sentence = predicate (term1,...,termn) or term1 = term2 Term = function (term1,...,termn) or constant or variable • E.g., Brother(TaoiseachJohn,RichardTheLionheart) > (Length(LeftLegOf(Richard)), Length(LeftLegOf(TaoiseachJohn)))

  34. Complex sentences • Complex sentences are made from atomic sentences using connectives S, S1 S2, S1  S2, S1 S2, S1S2, E.g. Sibling(TaoiseachJohn,Richard)  Sibling(Richard,TaoiseachJohn) >(1,2)  ≤ (1,2) >(1,2)  >(1,2)

  35. Truth in first-order logic • Sentences are true with respect to a model and an interpretation • Model contains objects (domainelements) and relations among them • Interpretation specifies referents for constantsymbols→objects predicatesymbols→relations functionsymbols→ functional relations • An atomic sentence predicate(term1,...,termn) is true iff the objects referred to by term1,...,termn are in the relation referred to by predicate

  36. Universal quantification • <variables> <sentence> Everyone at DIT is smart: x At(x,DIT)  Smart(x) • x P is true in a model m iff P is true with x being each possible object in the model

  37. Roughly speaTaoiseach, equivalent to the conjunction of instantiations of P At(TaoiseachJohn,DIT)  Smart(TaoiseachJohn)  At(Richard,DIT)  Smart(Richard)  At(DIT,DIT)  Smart(DIT)  ...

  38. A common mistake to avoid • Typically,  is the main connective with  • Common mistake: using  as the main connective with : x At(x,DIT)  Smart(x) means “Everyone is at DIT and everyone is smart”

  39. Existential quantification • <variables> <sentence> • Someone at DIT is smart: • x At(x,DIT)  Smart(x)$ • xP is true in a model m iff P is true with x being some possible object in the model

  40. Roughly speaTaoiseach, equivalent to the disjunction of instantiations of P At(TaoiseachJohn,DIT)  Smart(TaoiseachJohn)  At(Richard,DIT)  Smart(Richard)  At(DIT,DIT)  Smart(DIT)  ...

  41. Another common mistake to avoid • Typically,  is the main connective with  • Common mistake: using  as the main connective with : x At(x,DIT)  Smart(x) is true if there is anyone who is not at DIT!

  42. Properties of quantifiers • x y is the same as yx • x y is the same as yx • x y is not the same as yx • x y Loves(x,y) • “There is a person who loves everyone in the world” • yx Loves(x,y) • “Everyone in the world is loved by at least one person” • Quantifier duality: each can be expressed using the other • x Likes(x,IceCream) x Likes(x,IceCream) • x Likes(x,Broccoli) xLikes(x,Broccoli)

  43. Equality • term1 = term2is true under a given interpretation if and only if term1and term2refer to the same object • E.g., definition of Sibling in terms of Parent: x,ySibling(x,y)  [(x = y)  m,f  (m = f)  Parent(m,x)  Parent(f,x)  Parent(m,y)  Parent(f,y)]

  44. Using FOL The kinship domain: • Brothers are siblings x,y Brother(x,y) Sibling(x,y)

  45. One's mother is one's female parent m,c Mother(c) = m (Female(m) Parent(m,c)) • “Sibling” is symmetric x,y Sibling(x,y) Sibling(y,x)

  46. Knowledge engineering in FOL • Identify the task • Assemble the relevant knowledge • Decide on a vocabulary of predicates, functions, and constants • Encode general knowledge about the domain • Encode a description of the specific problem instance • Pose queries to the inference procedure and get answers • Debug the knowledge base

  47. Summary • First-order logic: • objects and relations are semantic primitives • syntax: constants, functions, predicates, equality, quantifiers

More Related