logic programming languages. objective to introduce the concepts of logic programming and logic...

32
Logic Programming Languages

Post on 19-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Logic Programming Languages

Page 2: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Objective

• To introduce the concepts of logic programming and logic programming languages

• To introduce a brief description of a subset of prolog

Page 3: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Introduction

• Logic programs are declarative programs – Specify the desired

results - true– State the fact

Logical InferencingProcess

Symboliclogic

Result

Programming Language

Page 4: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Introduction

• The major difference between logic programming and other programming languages (imperative and functional)– Every data item that exist in logic

programming has written in specific representation (symbolic logic)

• Prolog is a logic programming that widely used logic language

Page 5: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Introduction

• Prolog specified the way of computer carries out the computation and it is divided to 3 parts:– logical declarative semantic of prolog– new fact prolog can infer from the

given fact– explicit control information supplied

by the programmer

Page 6: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Symbolic representation: Predicate Calculus

Predicate Calculus

SymbolicLogic

Logic Formalism

Proposition

Higher-orderPL

FOPL

• mathematical representation of formal logic

• is a particular form of symbolic logic that is used for logic programming

Page 7: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

• symbolic logic used for the three basic need of formal logic

• to express propositions

• to express the relationships between propositions

• to describe how new propositions can be inferred from other propositions that are assumed to be true

Symbolic representation: Predicate Calculus

Predicate Calculus

SymbolicLogic

Logic Formalism

Proposition

Higher-orderPL

FOPL

Page 8: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

• Formal logic was developed to provide a method for describing proposition.

Symbolic representation: Predicate Calculus

Predicate Calculus

SymbolicLogic

Logic Formalism

Proposition

Higher-orderPL

FOPL

Page 9: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

• Proposition is a logical statement also known as fact

• consist of object and relationships of object to each other

Symbolic representation: Predicate Calculus

Predicate Calculus

SymbolicLogic

Logic Formalism

Proposition

Higher-orderPL

FOPL

Page 10: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Proposition

• Object: – Constant represents an object, or – Variable represent different objects at different times

• Simple proposition called as atomic propositions, consist of compound terms – one element of mathematic relation which written in a form that has the appearance of mathematical function notation.

Example (constants):single parameter (1-tuple): man(jake) double parameter (2-tuples): like(bob,steak)

Page 11: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Proposition

• Object: – Constant represents an object, or – Variable represent different objects at different times

• Simple proposition called as atomic propositions, consist of compound terms – one element of mathematic relation

Example:single parameter (1-tuple): man(jake) double parameter (2-tuples): like(bob,steak)

functor shows the names the relation

Page 12: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Proposition

• Object: – Constant represents an object, or – Variable represent different objects at different times

• Simple proposition called as atomic propositions, consist of compound terms – one element of mathematic relation

Example:single parameter (1-tuple): man(jake) double parameter (2-tuples): like(bob,steak)

list of parameter

Page 13: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Proposition

• Two modes for proposition: – proposition defined to be true (fact), and – the truth of the proposition is something

that is to be determined (queries)

• Compound propositions have two or more atomic proposition, which are connected by logical operator (is the same way logic expression in imperative languages)

Page 14: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Logic operators

Name Symbol Example Meaning

negation ¬ ¬ a not a

conjunction a b a and b

disjunction a b a or b

equivalence a b a is equivalent to b

implication a b a implies b

a b b implies a

Page 15: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Compound propositions

Example:a b ca b d(a (b)) d

Precedence:

higher

lower

Page 16: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Variables in Proposition

• Variable known as quantifiers• Predicate calculus includes two

quanifiers, X – variable, and P – proposition

Name Example Meaning

universal X,P For all X, P is true

existential X,P There exists a value of X such that P is true

Page 17: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Variables in Proposition

ExampleX.(woman(X) human(X))X.(mother(mary,X) male(X))

Page 18: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Variables in Proposition

ExampleX.(woman(X) human(X)) for any value of X, if X is a woman, then X is a human (NL: woman is a human)

X.(mother(mary,X) male(X))

Page 19: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Variables in Proposition

ExampleX.(woman(X) human(X)) for any value of X, if X is a woman, then X is a human (NL: woman is a human)

X.(mother(mary,X) male(X)) there exist a value of X such that mary is the mother of X and X is a male (NL: mary has a son)

Page 20: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Clausal Form

• Simple form of proposition, it is a standard form for proposition without loss of generality

• Why we need to transform PC into CF?– too many different ways of stating

propositions that have the same meaning

Example: X.(woman(X) human(X)) X.(man(X) human(X))

Page 21: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Clausal Form

• General syntax for CFB1 B2 … Bn A1 A2 … Am

if all the As are true, then at least one B is true

Example: human(X) woman(X) man(X)

likes(bob, trout) likes(bob, fish) fish(trout)

Page 22: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Clausal Form

Example:likes(bob, trout) likes(bob, fish) fish(trout)

• Characteristics of CF:– Existential quantifiers are not required– Universal quantifiers are implicit in the use

of variables in the atomic propositions– No operator other than conjunction and

disjunction are required

consequent antecedent

Page 23: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Clausal Form

Example:likes(bob, trout) likes(bob, fish) fish(trout)

if bob likes fish and trout is a fish, then bob likes trout

Page 24: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Clausal Form

Example:father(louis, al) father(louis, violet) father(al,bob) mother(violet, bob) grandfather(louis, bob)

if al is bob’s father and violet is bob’s mother and louis is bob’s grandfather, louis is either al’s father or violet’s father

Page 25: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Proving Theorems

• Method to inferred the collection of proposition– use a collections of proposition to

determine whether any interesting or useful fact can be inferred from them

• Introduced by Alan Robinson (1965)

Page 26: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

• Alan Robinson introduced resolution in automatic theorem proving– resolution is an inference rule that

allows inferred proposition to be computed from given propositions

– resolution was devised to be applied to propositions in clausal form

Proving Theorems

Page 27: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

• Idea of resolution:

P1 P2 and Q1 Q2which given

P1 is identical to Q2 Q1 P2

Proving Theorems

Page 28: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Example:

older(joanne, jake) mother(joanne, jake)wiser(joanne, jake) older(joanne, jake)

wiser(joanne, jake) mother(joanne, jake)

Proving Theorems

Page 29: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Example:

father(bob, jake) mother(bob, jake) parent(bob, jake)

gfather(bob, fred) father(bob, jake) father(jake, fred)

gfather(bob, fred) mother(bob, jake) parent(bob, jake) father(jake, fred)

Proving Theorems

Page 30: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

• Process of determining useful values for variables during resolution – unification

• Unification– Hypotheses : original propositions– Goal: presented in negation of the

theorem– Proposition in unification must be

presented in Horn Clauses

Proving Theorems

Page 31: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

• Horn Clauses:– Headed Horn ClausesExample: likes(bob, trout) likes(bob, fish)

fish(trout)

– Headless Horn ClausesExample: father(bob, jake)

Proving Theorems

Page 32: Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description

Applications of Symbolic Computation

• Relational databases• Mathematical logic• Abstract problem solving• Understanding natural language• Design automation• Symbolic equation solving• Biochemical structure analysis• Many areas of artificial intelligent