1 / 14

An Introduction to Logical Programming

An Introduction to Logical Programming. Predicate Calculus. Logic programming is based on formal logic. Formal logic was developed to provide a method for describing propositions. Propositions are logical statements that may or may not be true.

Download Presentation

An Introduction to Logical 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. An Introduction toLogical Programming ICS535-101

  2. Predicate Calculus • Logic programming is based on formal logic. • Formal logic was developed to provide a method for describing propositions. • Propositions are logical statements that may or may not be true. • Symbolic logic can be used for the three basic needs of formal logic: • To express propositions • To express the relationship between propositions • To describe how new propositions can be inferred from other propositions that are assumed to be true. ICS535-101

  3. Predicate Calculus • One form of symbolic logic that is used for logic programming is called first-order predicate calculus (predicate calculus for short). • A brief look at predicate calculus follows: • Propositions Are logical statements that may or may not be true. There are two types of propositions; • Atomic Propositions: consists of two parts: a functor or relation and an ordered list of parameters. Examples: man (ahmed) 1-tuple predicate likes (ahmed, steak) 2-tuple predicate ICS535-101

  4. Predicate Calculus 2. CompoundProposition: have two or more atomic propositions, which are connected by Logical Connectors. Logical Connectors are operators that connects simple predicates to produce complex ones. A list of these connectors is: ICS535-101

  5. Examples • The following are examples of CompoundPropositions: • The precedence of the operators is: • The second example is equivalent to: ICS535-101

  6. Predicate Calculus • Quantifiers • We can introduce variables into propositions using Quantifiers. • There are two quantifiers: • Universal quantifier (reads for all), and • Existential quantifier  (reads there exists). • For example: • X.(man(X)human (X)) • X.(mother (mary, X) ∩male(X)) ICS535-101

  7. Clausal Form • Clausal Form • In predicate calculus we can represent the same proposition with more than one way. • This will represent a problem if we want to use this technique with computers. • Therefore, we must use a standard form to representpropositioncalled the clausal form. • All propositions can be expressed in clausal form. ICS535-101

  8. Clausal Form • A proposition in “Clausal Form” has the following general syntax: • B1 B2 ….  Bn A1 A2 ….  Am • The meaning of this proposition is as follows: • If all the As are true, then at least one B is true. • The characteristics of the clausal formproposition are: • Existential quantifiers are not required. • Universal quantifiers are implicit • No operators other than conjunction and disjunction are required • Disjunctions appear on the left side and conjunctions on the right side. • All predicate calculus propositions can be converted to clausal form. ICS535-101

  9. Clausal Form • The right side of clausal form is called the “antecedent” or the “head” and the left side is the “consequence” or the “tail”. • Examples of Clausal forms are: likes(ahmed, hamour)  likes(ahmed, fish)  fish(hamour) father( louis, al )  father( louis, violet )  father( al, bob )  mother( violet, bob )  grandfather( louis, bob ) ICS535-101

  10. PC and Theorem Proving • Resolution is an inference rule that is used to infer propositions from given propositions.The concept of resolution is the following: • From (P  Q) and (R  P) infer (R  Q) • Example • Fromolder(ahmed, ali)  father(ahmed, ali) and wiser(ahmed, ali)  older(ahmed, ali) • Then infer wiser(ahmed, ali)  father(ahmed, ali) ICS535-101

  11. Resolution • The mechanics of this resolution construction are as follows: • The left sides of the two propositions are ANDed together to make the left side of the new proposition. • Same thing is done to get the right side. • Any term that appears on both sides of the new propositions is removed from both sides. ICS535-101

  12. Unification • The presence of variables in propositions requires resolution to find values for those variables that allow the matching process to succeed. • This process of determining useful values for variables is called unification. • The temporary assigning of values to variables to allow unification is called instantiation • Example • What if we havewiser(X,Y)  older(X,Y) • Then we need to do unification (instantiation){X/ahmed and Y/ali } • This will be discussed in the context of Prolog. ICS535-101

  13. Horn Clauses • When prepositions are used for resolution, only a restricted kind of clausal form called Horn clauses can be used. • A Horn clause is a clause that has one of two forms: • A single atomic proposition on the left side, or • An empty left side. • This mean that a Horn clause will contain one predicate head, in this case we call it headed Horn clause, or it has an empty head and we call it headlessHorn clause. ICS535-101

  14. Horn Clauses • Headed Horn clauses are used to state relationships, such as: likes(ahmed, hamour)  likes(ahmed, fish)  fish(hamour) • Headedless Horn clauses are used to state facts, such as father(muhammed, khaled) • Most but not all, propositions can be stated in Horn clauses. ICS535-101

More Related