Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Introduction to Logic Programming. 2 Human Logic Humans are information processors, We acquire information about the world and use this information.

Similar presentations


Presentation on theme: "1 Introduction to Logic Programming. 2 Human Logic Humans are information processors, We acquire information about the world and use this information."— Presentation transcript:

1 1 Introduction to Logic Programming

2 2 Human Logic Humans are information processors, We acquire information about the world and use this information to further our ends Logic is the study of what follows from what. What conclusions follow from a set of premises. We use Logic just about everything we do. We use it in our personal lives. We use it in our professional activities. We use the language of Logic to state observations, to define concepts, and to formalize theories. We use logical reasoning to derive conclusions from these bits of information. We use logical proofs to convince others of these conclusions.

3 Human Logic…..Cont. One of the strengths is our ability to represent and manipulate logical information, not just simple facts but also more complex forms of information, such as Ex. Ex. A simple children puzzle of blocks. Given some facts about the arrangement of five blocks in a stack, and we are asked to determine their exact arrangement. 3  The red block is on the green block.  The green block is somewhere above the blue block.  The green block is not on the blue block.  The yellow block is on the green block or the blue block.  There is some block on the black block. Negations, Alternatives, Constraints

4 Human Logic…..Cont. Even though the information is not literally present in what we are given, it is possible to derive that information. In particular, the conclusions shown below all follow from the premises above. 4  The red block is on the green block.  The green block is on the yellow block.  The yellow block is on the blue block.  The blue block is on the black block.  The black block is directly on the table.

5 Human Logic…..Cont. 5  All Accords are Hondas.  All Hondas are Japanese.  Therefore, all Accords are Japanese. They share the same reasoning structure  All x are y.  All y are z.  Therefore, all x are z.

6 Human Logic…..Cont. 6  All Toyotas are cars.  Some cars are made in America.  Therefore, some Toyotas are made in America.  All Toyotas are cars.  Some cars are Porsches.  Therefore, some Toyotas are Porsches. If we replace x by Toyotas and y by Japanese and z by made in America Correct Incorrect if we replace x by Toyotas and y by cars and z by Porsches Conclusions that are true whenever the premises are true

7 Logic is the science of arguments ( جدال ) All rational inquiry (استفسار عقلاني) turns on the ideal of a logical consequence (نتيجة), the idea that some claim must necessarily follow from others. Arguments are designed to show that one claim logically follows from others. Logic allows to determine whether the arguments succeed. An argument is a set of statements, one of which (the conclusion) is supposed to follow from the others (the premises).

8 Statement Statement: A sentence that has a truth value, i.e., a sentence that is either true or false (but never both). Statements are true when what they assert (تأكد ) about the world is the case. Types of statements:  Simple: A simple statement asserts exactly one fact about the world  Compound: A compound statement is one or more simple statements plus logical connectives. There are 5 logical connectives: not, and, or, if- then, if and only if NOTE: TRUTH is a property of statements. VALIDITY is a property of arguments

9 Conclusion & Premise Conclusion: A statement one is urged to accept on the basis of reasons given. Premise: A statement given as a reason for believing some other statement. Correctly identifying the premises and conclusion of an argument are essential if we are to evaluate it.

10 Models Each way the world can be is called a model (or interpretation). If a sentence is true in a model we say that the model satisfies the sentence. Otherwise it falsifies the sentence. A countermodel to an argument satisfies all the premises but falsifies the conclusion. 10 ECE Dep. of Tehran Univ. - Programming Language Design

11 Valid Argument Definition: An argument is valid iff it has no countermodel. In other words, if every model that satisfies the premises also satisfies the conclusion. Definition: If an argument is valid, we say that the premises entail the conclusion. 11 ECE Dep. of Tehran Univ. - Programming Language Design

12 Deductive Validity A characteristic of arguments in which the truth of the premises guarantees the truth of the conclusion. It is impossible for both the premises of a valid argument to be true and the conclusion to be false. Any argument that is not valid is invalid or non-valid Validity is not Directly Determined by truth and falsity of sentences involved There are valid arguments with true conclusions and valid arguments with false conclusions. There are valid arguments with true premises and valid arguments with false premises.

13 The following argument is VALID: All trout are mammals All mammals can breath So, all trout can breath This argument is valid because IF the premises are true THEN the conclusion MUST be true. This holds even though the premises are in fact false.

14 Patterns of reasoning 14 Induction Reasoning Induction Reasoning reasoning from the particular to the general.  I have seen 1000 black ravens ( الغربان).  I have never seen a raven that is not black.  Therefore, every raven is black. Now try red Hondas. If we see enough cases in which something is true and we never see a case in which it is false, we tend to conclude that it is always true.

15 Patterns of reasoning 15 Abduction Reasoning Abduction Reasoning reasoning from effects to possible causes  If there is no fuel, the car will not start.  If there is no spark, the car will not start.  There is spark.  The car will not start.  Therefore, there is no fuel.

16 Patterns of reasoning 16 Reasoning by analogy reasoning in which we infer a conclusion based on similarity of two situations  The flow in a pipe is proportional to its diameter.  Wires are like pipes.  Therefore, the current in a wire is proportional to diameter.

17 Formal Logic 17 Formal Logic is a formal version of human deductive logic. It provides a formal language with an clear syntax and a precise meaning, and it provides rules for manipulating expressions in a way that respects this meaning. EX. Ibrahim is three times as old as Mohamed. Ibrahim's age and Mohamed's age add up to twelve. How old are Ibrahim and Mohamed? x − 3y = 0 x + y = 12 −4y = −12 y = 3 x = 9

18 Applications 18  Mathematics: Automated reasoning programs can be used to check proofs and, in some cases, to produce proofs or portions of proofs.

19 19 Database Systems Database in Tabular Form Database in Sentential Form Constraints Definitions

20 20 Hardware Engineering Circuit: Behavior: Applications: Simulation Configuration Diagnosis Test Generation x y z s c o a b

21 21 Information Integration Schema Master Schema Schema Rules Consumers Access and Update Own Schema Suppliers Distributed Mgmt Own Schema Exchanges Master Schema Mapping Rules Integration Data

22 22 Regulations and Business Rules

23 Declarative programming 23 Logic programming is a declarative style of programming. The programmer says what they want to compute, but does not explicitly specify how to compute it. It is up to the interpreter (compiler/implementation) to figure out how to perform the computation requested. Examples: Logic programming (Prolog), database query languages (SQL), functional programming (Haskell) In contrast, in a Imperative (procedural) programming, the program explicitly describes the individual steps of computation. Examples: C, object-oriented programming (Java)

24 logic program 24  A logic program is given as a collection of assumed properties (stated as logical formulas) about the world (or rather about the world of the program(  The user supplies a logical formula stating a property that might or might not hold in the world as a query  The system determines whether the queried property is a consequence of the assumed properties in the program  One declarative aspect is that the user does not specify the method by which the system determines whether or not the query is a consequence of the program.  Another is that whether or not the query is indeed a consequence is independent of the method chosen by the system.

25 25 Multiple Logics  Propositional Logic : Symbols in the language represent “conditions” in the world, and complex sentences in the language express interrelationships among these conditions. The primary operators are Boolean connectives, such as and, or, and not. If it is raining, the ground is wet.  Relational Logic (Predicate, Frist order) : expands upon Propositional Logic by providing a means for explicitly talking about individual objects and their interrelationships (not just monolithic conditions). In order to do so, we expand our language to include object constants, relation constants, variables of various sorts, and quantifiers. If x is a parent of y, then y is a child of x.

26 Exercises 26 All x are z. All y are z. Therefore, some x are y. Some x are y. All y are z. Therefore, some x are z. All x are y. Some y are z. Therefore, some x are z. 1. 2. 3. Correct Incorrect

27 27 Thank You!


Download ppt "1 Introduction to Logic Programming. 2 Human Logic Humans are information processors, We acquire information about the world and use this information."

Similar presentations


Ads by Google