1 / 25

Predicate Logic

Predicate Logic. Second Term Fourth Year (10 CS). Predicate Calculus. In this course, we shall only study First order Logic (FOL). Higher-Order Logic. First-Order Logic. Introduction to FOL.

kailey
Télécharger la présentation

Predicate 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. Predicate Logic Second Term Fourth Year (10 CS)

  2. Predicate Calculus In this course, we shall only study First order Logic (FOL) Higher-Order Logic First-Order Logic

  3. Introduction to FOL • In propositional calculus, each atomic sentence (P, Q etc.) denotes a proposition of some complexity. There is no way to access the components of an individual assertion. Predicate calculus provides this ability. • Example: In Propositional logic, we may write the entire sentence: P = “It rained on Tuesday” In Predicate Calculus, we may create a predicate weather that describes a relationship between a date/day and weather: weather (Tuesday, rained) Through inference rules, we can manipulate predicate calculus expressions, accessing their individual components and inferring new sentences.

  4. Introduction to FOL • Predicate calculus allows expressions to contain variables. • Variables let us create general assertions about classes of entities: Example: we could state that for all values of X, where X is a day of the week, the statement weather(X, rain) is true; i.e. It rains everyday.

  5. Basic terminology • Object: Objects are things with individual identities and properties that distinguish from other objects. Examples: people, houses, numbers, colours, football matches, 07 CS batch etc. • Relations: Among objects, various relations hold. Example: brother, greater than, has colour, inside, part of etc. • Functions: Relations in which there is only value for a given input. Example: father of, best friend, one more than etc.

  6. Basics Example 1: One plus two equals three Objects: one, two, three, one plus two. Relation: equals Function: plus Example 2: President Musharaf ruled Pakistan in 2004. Objects: Musharaf, Pakistan, 2004. Relation: ruled Properties: President

  7. Basics • In Propositional Logic, every expression is a sentence which represents a fact. • FOL has sentences and terms (which represent objects) • Constant symbols, variables, and function symbols are used to build terms • Quantifiers and predicate symbols are used to build sentences.

  8. Syntax of FOL • Connectives:, , ,  • Quantifiers: ,  • Constants: A, X1, C, Akber, ... • Variables: a, x, s, ... • Predicate: before, HasColor, ... • Function: father, rightArmof, ...

  9. Basics Examples: • Ahmad likes Chocolates. likes(Ahmad , Chocolates) • Asma loves dolls and jewellery. likes(Asma, dolls)likes(Asma, jewellery) • Asim and Adil are brothers of Abid brother(Abid, Asim)brother(Abid, Adil) • Akhtar is older than 20 or Akhtar is younger than 20. older(Akhtar, 20)younger(Akhtar,20) • If Akhtar is older than 20, then he is not younger than 20. older(Akhtar, 20)  younger(Akhtar, 20) • Father of Jawad is Munir father(Jawad) = Munir

  10. Basics Examples: • Father of Sarah and Uncle of Shahid are friends. friends(father_of(Sarah), uncle_of(Shahid)) • All Shaikhs are not Sindhi. x: Shaikh(x)  Sindhi(x) • All men are mortal x: man(x)  mortal(x) • All basket ball players are tall x: (basketball_player(x)  tall(x)) • Everyone likes ice cream x: likes(x, ice_cream)

  11. Basics Examples: • If wishes were horses, beggars would ride equal(wishes, horses)  ride(beggars) • There exists some bird that does not fly x: bird(x) flies(x) • Sanya eats everything that she likes x: (likes(Sanya, x)  eats(Sanya,x)) • There exists a white allegator x: allegator(x)white(x) • No body likes taxes x: likes(x, taxes)

  12. More Examples • Every gardener likes the sun x: gardener(x)  likes(x, sun) • All purple mushrooms are poisonous x: (mushroom(x)purple(x))  poisonous(x) • No purple mushroom is poisonous x: (mushroom(x)purple(x))  poisonous(x) • Everybody loves somebody x y loves(x,y) • There is someone who is loved by everyone y x loves(x,y)

  13. Using FOL Assertions and queries in FOL • Sentences are added to a knowledge base (KB) using TELL. Such sentences are called assertions. Examples: TELL(KB, prime_minister(Geelani)) TELL(KB, King(Baber)) TELL(KB, x King(x)  Person(x))

  14. Using FOL Queries • We ask questions of the knowledge base using ASK. Questions asked using ASK are called queries: ASK(KB, prime_minister(Geelani)) ASK(KB, King(Baber)) ASK(KB, x King(x)  Person(x))

  15. Using FOL The Kinship Domain • The objects in the Kinship domain are people • The properties they have include gender and they related by relations such as parenthood, brotherhood, marriage and so on. Examples: • one’s mother is one’s female parent m,c Mother(c) = m  female(m)  Parent(m,c) • One’s husband is one’s male spouse w, h Husband(h,w)  Male(h)  Spouse(h,w) • Male and female are disjoint categories x Male(x)  Female(x)

  16. Using FOL The Kinship Domain • Parent and child are inverse relations: p,c Parent(p,c)  Child(c,p) • A grand parent is a parent of one’s parent g,c Grandparent(g,c)  Parent(g,p) parent(p,c)

  17. Building a Knowledge Base • An important objective of Knowledge engineering is to build knowledge base. • Following five steps may be used to develop a knowledge base. • Step1: Decide what to talk about. • Step2: Decide on a vocabulary of predicates, functions and constants. • Step3: Encode general knowledge about the domain • Step4: Encode a description of the specific problem instance. • Step5: Pose queries to the inference procedure and get answers.

  18. Example: Electronic Circuit Domain Step1: Decide what to talk about: Before developing knowledge base, you should know: • that there are four types of gates: AND, OR, XOR and NOT. • How each gate works • How the gates are connected in the given circuit • How current flows through the circuit

  19. Example: Electronic Circuit Domain Step2: Decide on a vocabulary • Introduce the predicate Type to define type of a gate. • Introduce the predicate Connected to define connections. • Introduce the predicate Signal to define current flow. • Use the predicate In and Out to define input and output respectively. • Use the connectives , , , , etc. and quantifiers ,  etc. wherever necessary.

  20. Example: Electronic Circuit Domain Step3: Encode general rules Rule 1: If two terminals are connected, then they have the same signal. t1, t2 Connected(t1, t2)  Signal(t1) = Signal(t2) Rule 2: The signal at every terminal is either ON or OFF (but not both). t Signal(t) = On  Signal(t) = Off On  Off Rule 3: Connected is a commutative predicate t1, t2 Connected(t1, t2)  Connected(t2, t1)

  21. Example: Electronic Circuit Domain Rule 4: An OR gate’s output is on if and only if any of inputs are on. g Type(g) = OR  Signal(Out(1,g)) = On  n Signal(In(n,g)) = On Rule 5: An AND gate’s output is Off if and only if any of its inputs are off. g Type(g) = AND  Signal(Out(1,g)) = Off  n Signal(In(n,g)) = Off

  22. Example: Electronic Circuit Domain Rule 6: An Exclusive OR gate’s output is on if and only if its inputs are different g Type(g) = XOR  Signal(Out(1,g)) = On  Signal(In(1,g))  Signal(In(2,g)) Rule 7: A NOT gate’s output is different from its input g Type(g) = NOT  Signal(Out(1,g))  Signal(In(1,g))

  23. Step 4: Encode the specific instance (a) Categorize the gates Type(X1) = XOR Type(X2) = XOR Type(A1) = AND Type(A2) = AND Type(O1) = OR (b) Define the Connections Connected(Out(1, X1), In(1,X2)) Connected(In(1,C1), In(1,X1)) Connected(Out(1, X1), In(2,A2)) Connected(In(1,C1), In(1,A1)) Connected(Out(1, A2), In(1,O1)) Connected(In(2,C1), In(2,X1)) Connected(Out(1, A1), In(2,O1)) Connected(In(2,C1), In(2,A1)) Connected(Out(1, X2), Out(1,C1)) Connected(In(3,C1), In(2,X2)) Connected(Out(1, O1), In(2,C1)) Connected(In(3,C1), In(1,A2))

  24. Example: Electronic Circuit Domain Step 5: Pose queries to the inference procedure (i) What combinations of inputs would cause the first output of C1 (the sum bit) to be OFF and the second output of C1 to be ON? i1, i2, i3 Signal(In(1,C1)=i1  Signal(In(2,C1) = i2  Signal(In(3,C1) = i3Signal(Out(1,C1) = Off  Signal(Out(2,C1) =On The answer is: (i1 = On  i2 = On  i3 = Off) (i1 = On  i2 = Off  i3 = On) (i1 = Off  i2 = On  i3 = On)

  25. Example: Electronic Circuit Domain Step 5: Pose queries to the inference procedure (ii) What are the possible set of values of all the terminals for the circuit i1, i2, i3, o1, o2 Signal(In(1,C1)=i1  Signal(In(2,C1) = i2  Signal(In(3,C1) = i3Signal(Out(1,C1) = o1  Signal(Out(2,C1) =o2 This query will return a complete input/output table for the circuit, which can be used to check that it does in fact add its inputs correctly.

More Related