1 Introduction to Logic Programming. 2 Human Logic Humans are information processors, We acquire...

Post on 29-Dec-2015

218 views 1 download

Tags:

transcript

1

Introduction to Logic Programming

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

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.

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.

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.

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

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

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 ifNOTE: TRUTH is a property of statements. VALIDITY is a property of arguments

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.

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.

ECE Dep. of Tehran Univ. - Programming Language Design

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.

The following argument is VALID:

All trout are mammalsAll 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

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

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

Reasoning by analogyreasoning 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

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 = 0x + y = 12−4y = −12

y = 3x = 9

18

Applications

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

19

Database Systems

Database in Tabular Form Database in Sentential Form

parentart bob

art bea

bea coe

Constraints

Definitions

parent (art,bob)

parent (art,bea)

parent (bob,coe)

parent (x,y) parent(y,z) grandparent (x, z)

parent (x, x)

parent (x, y) parent (y, x)

20

Hardware Engineering

Circuit: Behavior:

Applications:SimulationConfigurationDiagnosisTest Generation

o (x y) (x y)

a z o

b x y

s (o z) (o z)

c a b

x

y

z

s

c

o

a

b

21

Information Integration

Schema

Schema Schema Schema Schema

Master Schema

Schema Schema

RulesRules Rules

RulesRules Rules Rules

ConsumersAccess and UpdateOwn Schema

SuppliersDistributed MgmtOwn Schema

ExchangesMaster SchemaMapping RulesIntegration Data

22

Regulations and Business Rules

23

Declarative programming

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

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

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

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

Incorrect

27

Thank You!