0% found this document useful (0 votes)
7 views

3 6-LogicProgramming

Uploaded by

Sujithra Jones
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

3 6-LogicProgramming

Uploaded by

Sujithra Jones
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

NPTEL

Video Course on Machine Learning

Professor Carl Gustaf Jansson, KTH

Week 3 Forms of Representation

Video 3.6 Logic Programming


General characteristics of this Representation

Logic programming is an abstract model of computation.

In this lecture logic programming is illustrated by the Prolog language. Other


dialects of logic programming exists with slightly different properties.

A logic program is an encoding of a problem in logic from which a problem


solution is logically derivable. The execution of the program can be
considered as the side effect of a theorem proving process.

An important concept in logic programming is the separation of programs into


their logic components and their control components as captured by the
slogan
´Algorithm = Logic + Control´.

A logic program can also be regarded as a generalized relational database


including both rules and facts.
Interdisciplinary sources of inspiration for this
Representation

Logic programming is a computational model emanating from


theorem proving in predicate logic as investigated in Theoretical Philosophy.

A logic program is set of axioms and Logic programming can be viewed as


controlled deduction.

The logic programming engine tries to find a resolution refutation of the


negated query. The desired computation is the side effect of the refutation
proof. The resolution method used in logic programming is called SLD
resolution.
Core components of this Representation
Logic programming is based on Terms and Statements.
Statements can be Facts, Rules and Queries which are
syntactically Horn clauses.

A Fact as well as a Query is a single Goal. A fact is ended with a Fact father(john,tom).
period `.´ A Goal is ended by a questionmark ´?´. Query father(X,tom)?

A rule has the form A:-B1,B2,....,BN where A is the Head and the
Rule grandfather(X,Y):-
Bi´s are the Body. The A and the Bi´s are Goals.
father(X,Z), parent(Z,Y).

A Goal is a Compound Term = a functor (atom) followed by a set


of arguments that in turn can be a Term. A term can be a
compound term, a variable or an atom (constant).

Variables are universally quantified with the scope of the


statement.

Statements (queries, facts, rules) with only atoms are called


Ground statements.
Example of logic program
male(john). male(tom). male(george). male(tim)
female(ann), female (diana), female(mary) female(sue)

father(john,tom). father(tom, george). father(george, tim).


mother(diana,tom). mother(ann, george). mother(sue, tim).

parent(X,Y):-mother(X,Y).
parent(X,Y):-mother(X,Y).

sister(X,Y):- female(X), parent(M,Y), parent(F,Y),


parent (M,X), parent (F,X).

grandfather(X,Y):- father(X,Z), parent(Z,Y).


grandmother(X,Y):- mother(X,Z), parent (Z,Y).

ancestor(X,Y):-parent(X,Y).
ancestor(X,Y):-parent(X,Z),ancestor(Z,Y).

father(X,tom)? grandfather(X, tim)? ancestor(diana, tim)?


Execution of a Logic program
Execution of a Logic program is initiated by the user's posting of a
single goal, called the query. The logic programming systems tries to
find a resolution refutation of the negated query.

If the negated query can be refuted, it follows that the query, with the
appropriate variable bindings in place, is a logical consequence of
the program. In that case, all generated variable bindings are reported
to the user, and the query is said to have succeeded.

Operationally, the logic programming execution strategy can be


thought of as a generalization of function calls in other languages,
one difference being that multiple clause heads can match a given
call.

In that case, the system creates a choice-point, unifies the goal with
the clause head of the first alternative, and continues with the goals of
that first alternative.

If any goal fails in the course of executing the program, all variable
bindings that were made since the most recent choice-point was
created are undone, and execution continues with the next alternative
of that choice point. This execution strategy is called chronological
Learning for this Representation
Inductive Logic Programming is a subfield of machine learning where prolog
statements are induced from examples.

The standard logic programming representation is used to uniformly represent


both examples, hypotheses and background knowledge.

Input to inductive logic programming systems:


logic programming encoding of background knowledge and the data-set.

Output from inductive logic programming systems :


hypothesis logic programming statements that entails all positive and no
negative examples.
NPTEL

Video Course on Machine Learning

Professor Carl Gustaf Jansson, KTH

Thanks for your attention!

The next lecture 3.7 will be on the topic:

Tutorial for Week 3

You might also like