1 Logic Programming And Prolog MacLennan - Chapter 13 ECE Department of Tehran University Programming Language Design Course Student Lecture Sadegh Dorri.

Slides:



Advertisements
Similar presentations
CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Advertisements

SLD-resolution Introduction Most general unifiers SLD-resolution
Cs7120 (Prasad)L22-MetaPgm1 Meta-Programming
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
2 /59  History and Motivation  Structural  Data Structure  Control Structure  Evaluation and Epilog 3.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
ISBN Chapter 3 Describing Syntax and Semantics.
Chapter 12 - Logic Programming
CS 330 Programming Languages 12 / 12 / 2006 Instructor: Michael Eckmann.
Artificial Intelligence programming and Prolog Language Tutorial
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Inference and Resolution for Problem Solving
Artificial Intelligence and Lisp Lecture 6 LiU Course TDDC65 Autumn Semester, 2010
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Describing Syntax and Semantics
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
CPS 506 Comparative Programming Languages
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
CS 321 Programming Languages and Compilers Prolog part 2.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
1 Lecture 15: Introduction to Logic Programming with Prolog (Section 11.3) A modification of slides developed by Felix Hernandez-Campos at UNC Chapel Hill.
Chapter 16 Logic Programming Languages. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 16 Topics Introduction A Brief Introduction to.
1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
F28PL1 Programming Languages Lecture 16: Prolog 1.
Logical Inference 2 rule based reasoning
Logic Programming Module 2AIT202 Website Lecturer: Dave Sharp Room: AG15
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
CHAPTER 15 & 16 Functional & Logic Programming Languages.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
Prolog Program Style (ch. 8) Many style issues are applicable to any program in any language. Many style issues are applicable to any program in any language.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
CS 363 Comparative Programming Languages Logic Programming Languages.
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Programming Languages Third Edition Chapter 4 Logic Programming.
CSE 3302 Programming Languages Chengkai Li Spring 2008 Logic Programming: Prolog Lecture 21 – Prolog, Spring CSE3302 Programming Languages, UT-Arlington.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
ISBN Chapter 16 Logic Programming Languages.
Dr. Muhammed Al-Mulhem ICS An Introduction to Prolog.
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Answer Extraction To use resolution to answer questions, for example a query of the form  X C(X), we must keep track of the substitutions made during.
1-1 An Introduction to Prolog Sept Prolog statements Like other programming languages, Prolog consists of collection of statements. Prolog.
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Logic Programming Lecture 2: Unification and proof search.
Artificial Intelligence and Lisp Lecture 6 LiU Course TDDC65 Autumn Semester,
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Chapter 3 of Programming Languages by Ravi Sethi
Prolog a declarative language
Logic Programming And Prolog
Logic Programming Languages
Prolog a declarative language
Prolog a declarative language
Prolog a declarative language
Logic Programming Language
Chapter 2: Prolog (Introduction and Basic Concepts)
Presentation transcript:

1 Logic Programming And Prolog MacLennan - Chapter 13 ECE Department of Tehran University Programming Language Design Course Student Lecture Sadegh Dorri Nogourani Sadegh Dorri Nogourani

2 ECE Dep. of Tehran Univ. - Programming Language Design 5 th -Generation Languages Declarative (nonprocedural)  Functional Programming  Logic ProgrammingImperative  Object Oriented Programming

3 ECE Dep. of Tehran Univ. - Programming Language Design Nonprocedural Programming Sorting procedurally: 1. Find the min in the remained numbers. 2. Swap it with the first number. 3. Repeat steps 1,2 until no number remains. Sorting nonprocedurally: 1. B is a sorting of A ↔ B is a permutation of A and B is ordered. 2. B is ordered ↔ for each i<j: B[i] ≤ B[j] Which is higher level?

4 ECE Dep. of Tehran Univ. - Programming Language Design Automated Theorem Proving A.T.P: Developing programs that can construct formal proofs of propositions stated in a symbolic language. Construct the desired result to prove its existence (most A.T.P.’s). In Logic Programming, programs are expressed in the form of propositions and the theorem prover constructs the result(s). J. A. Robinson: A program is a theory (in some logic) and computation is deduction from the theory.

5 ECE Dep. of Tehran Univ. - Programming Language Design Programming In Logic (Prolog) Developed in Groupe d’Intelligence Artificielle (GIA) of the University of Marseilles (early 70s) to process a natural language (French). Interpreters: Algol-W (72), FORTRAN (73), Pascal (76), Implemented on many platforms (Now) Application in AI since mid-70s Successor to LISP for AI apps Not standardized (but has ISO standard now)

6 Structural Organization 13.2

7 parent(X,Y) :- father(X,Y). parent(X,Y) :- mother(X,Y). grandparent(X,Z) :- parent(X,Y), parent(Y,Z). ancestor(X,Z) :- parent(X,Z). ancestor(X,Y) :- parent(X,Y), ancestor(Y,Z). sibling(X,Y) :- mother(M,X), mother(M,Y), father(F,X), father(F,Y), X \= Y. father(F,X), father(F,Y), X \= Y. cousin(X,Y) :- parent(U,X), parent(V,Y), sibling(U,V). father(albert, jeffrey). mother(alice, jeffrey). father(albert, george). mother(alice, george). father(john, mary). mother(sue, mary). father(george, cindy). mother(mary, cindy). father(george, victor). mother(mary, victor).

8 ?- [kinship]. % kinship compiled 0.00 sec, 3,016 bytes Yes ?- ancestor(X, cindy), sibling(X, jeffrey). X = george  Yes ?- grandparent(albert, victor). Yes ?- cousin(alice, john). No ?- sibling(A,B). A = jeffrey, B = george ;  A = george, B = jeffrey ;  A = cindy, B = victor ;  A = victor, B = cindy ;  No SWI Prolog

9 ECE Dep. of Tehran Univ. - Programming Language Design Clauses Programs are constructed from A number of clauses: :- Programs are constructed from A number of clauses: :- Clauses have three forms:  hypotheses (facts)  conditions (rules)  goals Both and are composed of relationships (also called predications or literals) assertions (database) questions

10 ECE Dep. of Tehran Univ. - Programming Language Design Relationships Represent properties of and relations among the individuals A relationship is application of a predicate to one or more terms Terms:  atoms (or constants): john, 25, …  variables (begin with uppercase letters): X, …  compounds Horn clause form: At most one relationship in Horn clause form: At most one relationship in

11 ECE Dep. of Tehran Univ. - Programming Language Design Compound Terms It is more convenient to describe individuals without giving them names (expressions or compounds as terms). using functors (tags): d(X, plus(U,V), plus(DU,DV)) :- d(X,U,DU), d(X,V,DV). or using infix functors: d(X, U+V, DU+DV) :- d(X,U,DU), d(X,V,DV). instead of d(X,W,Z) :- sum(U,V,W), d(X,U,DU), d(X,V,DV), sum(DU,DV,Z). with less readability and some other things…

12 Data Structures 13.3

13 ECE Dep. of Tehran Univ. - Programming Language Design Primitives and Constructors Few primitives and No constructors. Data types and data structures are defined implicitly by their properties.

14 ECE Dep. of Tehran Univ. - Programming Language Design Example (datatype) Natural number arithmetic sum(succ(X), Y, succ(Z)) :- sum(X,Y,Z). sum(0,X,X). dif(X,Y,Z) :- sum(Z,Y,X). :-sum(succ(succ(0)),succ(succ(succ(0))),A). A = succ(succ(succ(succ(succ(0))))) Very inefficient! (Why such a decision?) Use of ‘is’ operator (unidirectional)

15 ECE Dep. of Tehran Univ. - Programming Language Design Principles Simplicity  Small number of built-in data types and operationsRegularity  Uniform treatment of all data types as predicates and terms

16 ECE Dep. of Tehran Univ. - Programming Language Design Data Structures Compound terms can represent data structures Example: Lists in LISP (car (cons X L)) = X (cdr (cons X L)) = L (cons (car L) (cdr L)) = L, for nonnull L

17 ECE Dep. of Tehran Univ. - Programming Language Design Lists in Prolog Using compound terms: car( cons(X,L), X). cdr( cons(X,L), L). list(nil). list(cons(X,L)) :- list(L). null(nil). What about null(L)? How to accomplish (car (cons ‘ (a b) ‘ (c d)))?

18 ECE Dep. of Tehran Univ. - Programming Language Design Some Syntactic Sugar Using ‘.’ infix functor (in some systems) instead of cons:  Clauses? Most Prolog systems allow the abbreviation:  [X 1, X 2, …, X n ] = X 1. X 2. ….X n.nil  [ ] = nil  ‘.’ is right associative!

19 ECE Dep. of Tehran Univ. - Programming Language Design Component Selection Implicitly done by pattern matching (unification). append( [ ], L, L). append( X.P, L, X.Q) :- append(P,L,Q). Compare with LISP append: (defun append (M L) (if (null M) L (cons (car M) (append (cdr M) L)) )) Taking apart in terms of putting together!  What X and P are cons ’ d to create M?  What number do I add to 3 to get 5 (instead of 5-3)Efficient!?

20 ECE Dep. of Tehran Univ. - Programming Language Design Complex Structures A tree using lists (in LISP):  (times (plus x y) (plus y 1)) Using compound terms directly (as records):  times(plus(x, y), plus(y, 1)) Using predicates directly:  sum(x, y, t1).  sum(y, 1, t2).  prod(t1, t2, t3). Which is better?

21 ECE Dep. of Tehran Univ. - Programming Language Design Why Not Predicates? Symbolic differentiation using predicate structured expressions: d(X,W,Z) :- sum(U,V,W), d(X,Y,DU), d(X,V,DV), sum(DU,DV,Z). d(X,W,Z) :- prod(U,V,W), d(X,U,DU), d(X,V,DV), prod(DU,V,A), prod(U,DV,B), sum(A,B,Z). d(X,X,1). d(X,C,0) :- atomic(C), C \= X.

22 ECE Dep. of Tehran Univ. - Programming Language Design Why Not Predicates? (cont.) Waste use of intermediate (temporary) variables Less readability Unexpected answers! sum(x,1,z). :- d(x,z,D). No  Why? What did you expect?  How to correct it?

23 ECE Dep. of Tehran Univ. - Programming Language Design Closed World Model All that is true is what can be proved on the basis of the facts and rules in the database. Very reasonable in object-oriented apps (modeling a real or imagined world)  All existing objects are defined.  No object have a given property which cannot be found in db. Not suitable for mathematical problems (Why?)  An object is generally take to exist if its existance doesn’t contradict the axioms. Predicates are better for OO-relationships, Compounds for mathematical ones (Why?)  We cannot assume existance of 1+0 whenever needed.

24 ECE Dep. of Tehran Univ. - Programming Language Design An Argument! What’s the answer? equal(X,X). :- equal(f(Y),Y). ? What’s the logical meaning? (occurs check) Any other meaning? Can it be represented in a finite amount of memory? Should we detect it?

25 Control Structures 13.4

26 ECE Dep. of Tehran Univ. - Programming Language Design Algorithm = Logic + Control N. Wirth: Program = data structure + algorithm R. Kowalski: Algorithm = logic + control In conventional programming:  Logic of a program is closely related to its control  A change in order of statements alters the meaning of program In (pure) logic programming:  Logic (logic phase) is determined by logical interrelationships of the clauses not their order.  Control (control phase) affects the order in which actions occur in time and only affects the efficiency of programs. Orthogonality Principle

27 ECE Dep. of Tehran Univ. - Programming Language Design Top-Down vs. Bottom-Up Control Top-down ≈ Recursion:  Try to reach the hypotheses from the goal. Bottom-up ≈ Iteration:  Try to reach the goal from the hypotheses.Hybrid:  Work from both the goals and the hypotheses and try to meet in the middle. Which one is better? :- fib(3, F). N=3, M=2, K=1, F=G+H :- fib(2,F). N=2, M=1, k=0, N=2, M=1, k=0,F=G+H :- fib(1,F). F=1 :- fib(1,1). :- fib(0,F). F=1 :- fib(0,1). :- fib(1,F). F=1 :- fib(1,1). fib(0,1). fib(1,1). fib(N,F) :- N=M+1, M=K+1, fib(M,G), fib(K,H), F=G+H, N>1.

28 ECE Dep. of Tehran Univ. - Programming Language Design Procedural Interpretation We have seen logical and record (data structure) interpretations. Clauses can also be viewed as procedure invocations:  : proc. definition  : proc. body (a series of proc. calls)  Multiple definitions: branches of a conditional (case)  fib() example… Procedure calls can be executed in any order or even concurrently! (pure logic) Input/Output params are not distinguished!  fib(3,3) ↔ true. fib(3,F) ↔ F=3. fib(N,3) ↔ N=3. fib(N,F) ↔ ?

29 ECE Dep. of Tehran Univ. - Programming Language Design Unify, Fail, Redo… Heavy use of unification, backtracking and recursion. Unification (Prolog pattern matching – from Wikipedia):  One-time assignment (binding)  uninst. var with atom/term/another uninst. var (aliasing) (occurs check)  atom with the same atom  compound with compound if top predicates and arities of the terms are identical and if the parameters can be unified simultaneously  We can use ‘=‘ operator to explicitly unify two termsBacktracking:  Make another choice if a choice (unif./match) failes or want to find other answers.  In logic prog. It is the rule rather than the exception.  Very expensive! Example: len([ ], 0). len(X.T, L+1) :- len(T,L).

30 ECE Dep. of Tehran Univ. - Programming Language Design Prolog’s Control Regime Prolog lang. is defined to use depth-first search:  Top to bottom (try the clauses in order of entrance)  Left to right  In pure logic prog., some complete deductive algorithm such as Robinson’s resolution algorithm must be implemented. DFS other than BFS  Needs much fewer memory  Doesn’t work for an infinitely deep tree (responsibility of programmer) Some programs may fail if clauses and subgoals are not ordered correctly (pp ) Predictable execution of impure predicates (write, nl, read, retract, asserta, assertz, …)

31 [trace] ?- ancestor(X, cindy), sibling(X,jeffrey). EventDepthSubgoal ================================== Call:(1) ancestor(X, cindy) Call:(2) parent(X, cindy) Call:(3) father(X, cindy) Exit:(3) father(george, cindy) Exit:(2) parent(george, cindy) Exit:(1) ancestor(george, cindy) Call:(1) sibling(george, jeffrey) Call:(2) mother(M, george) Exit:(2) mother(alice, george) Call:(2) mother(alice, jeffrey) Exit:(2) mother(alice, jeffrey) Call:(2) father(F, george) Exit:(2) father(albert, george) Call:(2) father(albert, jeffrey) Exit:(2) father(albert, jeffrey) Call:(2) george\=jeffrey Exit:(2) george\=jeffrey Exit:(1) sibling(george, jeffrey) X = george Yes SWI Prolog

32 If we move parent(X,Y) :- father(X,Y) before parent(X,Y) :- mother(X,Y), we have: EventDepthSubgoal ================================== Call:(1)ancestor(X, cindy) Call:(2)parent(X, cindy) Call:(3)mother(X, cindy) Exit:(3)mother(mary, cindy) Exit:(2)parent(mary, cindy) Exit:(1)ancestor(mary, cindy) Call:(1)sibling(mary, jeffrey) Call:(2)mother(M, mary) Exit:(2)mother(sue, mary) Call:(2)mother(sue, jeffrey) Fail:(2)mother(sue, jeffrey) Redo:(2)mother(M, mary) Fail:(2)mother(M, mary) Fail:(1)sibling(mary, jeffrey) Redo:(3)mother(X, cindy) Fail:(3)mother(X, cindy) Redo:(2)parent(X, cindy) … SWI Prolog

33 ECE Dep. of Tehran Univ. - Programming Language Design Cut!  ‘!’: Discard choice points of parent frame and frames created after the parent frame. Always is satisfied. Used to guarantee termination or control execution order. i.e. in the goal :- p(X,a), !  Only produce the 1 st answer to X  Probably only one X satisfies p and trying to find another one leads to an infinite search! i.e. in the rule color(X,red) :- red(X), !.  Don’t try other choices of red (mentioned above) and color if X satisfies red  Similar to then part of a if-then-elseif Fisher, J.R., Prolog Tutorial,

34 ECE Dep. of Tehran Univ. - Programming Language Design Red-Green Cuts (!) A ‘green’ cut  Only improves efficiency  e.g. to avoid additional unnecessary computation A ‘red’ cut  e.g. block what would be other consequences of the program  e.g. control execution order (procedural prog.) Fisher, J.R., Prolog Tutorial,

35 ECE Dep. of Tehran Univ. - Programming Language Design Three Examples p(a). p(X) :- s(X), r(X). p(X) :- u(X). r(a). r(b). s(a). s(b). s(c). u(d). :- p(X), ! :- r(X), !, s(Y). :- r(X), s(Y), ! :- r(X), !, s(X). part(a). part(b). part(c). red(a). black(b). color(P,red) :- red(P),!. color(P,black) :- black(P),!. color(P,unknown). :- color(a, C). :- color(c, C). :- color(a, unknown). Fisher, J.R., Prolog Tutorial, max(X,Y,Y) :- Y>X, !. max(X,Y,X). :- max(1,2,D). :- max(1,2,1). See also MacLennan’s example p.476

36 ECE Dep. of Tehran Univ. - Programming Language Design Higher-Order Rules Logic programming is limited to first-order logic: can’t bind variables to predicates themselves. e.g. red (f-reduction) is illegal: (p(x,y,z) ↔ z=f(x,y)) red(P,I,[ ],I). red(P,I,X.L,S) :- red(P,I,L,T), P(X,T,S). But is legal if the latter be defined as: red(P,I,X.L,S):- red(P,I,L,T), Q=..[P,X,T,S], call(Q).  What ’ s the difference?

37 ECE Dep. of Tehran Univ. - Programming Language Design Higher-Order Rules (cont.) In LISP, both code and data are first-order objects, but in Prolog aren ’ t. Robinson resolution algorithm is refutation complete for first-order predicate logic. Gödel ’ s incompleteness theorem: No algorithm is refutation complete for higher-order predicate logic. So, Prolog indirectly supports higher-order rules.

38 ECE Dep. of Tehran Univ. - Programming Language Design Negative Facts How to define nonsibling ? Logically … nonsibling(X,Y) :- X = Y. nonsibling(X,Y) :- mother(M1,X), mother(M2,Y), M1 \= M2. nonsibling(X,Y) :- father(F1,X), father(F2,Y), F1 \= F2. But if parents of X or Y are not in database?  What is the answer of nonsibling? Can be solved by… nonsibling(X,Y) :- no_parent(X). nonsibling(X,Y) :- no_parent(Y).  How to define no_parent ?

39 ECE Dep. of Tehran Univ. - Programming Language Design Negative Facts (cont.) Problem: There is no positive fact expressing the absence of parent. Cause:  Horn clauses are limited to  C :- P1,P2,…,Pn ≡ C holds if P1^P2^ … ^Pn hold.  No conclusion if P1^P2^ … ^Pn don ’ t hold!  If, not iff

40 ECE Dep. of Tehran Univ. - Programming Language Design Cut-fail Solutions: Stating all negative facts such as no_parent  Tedious  Error-prone  Negative facts about sth are usually much more than positive facts about it “Cut-fail” combination  nonsibling(X,Y) is satisfiable if sibling(X,Y) is not (i.e. sibling(X,Y) is unsatisfiable)  nonsibling(X,Y) :- sibling(X,Y), !, fail.  nonsibling(X,Y).  how to define ‘fail’ ?!

41 ECE Dep. of Tehran Univ. - Programming Language Design negation :- unsatisfiablility ‘not’ predicate  not(P) is satisfiable if P is not (i.e. is unsatisfiable).  not(P) :- call(P), !, fail.  not(P).  nonsibling(X,Y) :- not( sibling(X,Y) ). Is ‘not’ predicate the same as ‘logical negation’? (see p.484)

42 Evaluation and Epilog 13.5

43 ECE Dep. of Tehran Univ. - Programming Language Design Topics Logic programs are self-documenting Pure logic programs separate logic and control Prolog falls short of logic programming Implementation techniques are improving Prolog is a step toward nonprocedural programming

44 ECE Dep. of Tehran Univ. - Programming Language Design Self-documentation Programming in a higher-level, … Application orientation and… Transparency  programs are described in terms of predicates and individuals of the problem domain. Promotes clear, rapid, accurate programming

45 ECE Dep. of Tehran Univ. - Programming Language Design Separation of Logic and Control Simplifies programming Correctness only deals with logic Optimization in control cannot affect correctness Obeys Orthogonality Principle

46 ECE Dep. of Tehran Univ. - Programming Language Design Prolog vs. Logic Programming Definite control strategy  Programmers make explicit use of it and the result have little to do with logic  Reasoning about the order of events in Prolog is comparable in difficaulty with most imperative of conventional programming languages Cut doesn’t make any sense in logic! not doesn’t correspond to logical negation

47 ECE Dep. of Tehran Univ. - Programming Language Design Improving Efficiency Prolog is far from an efficient language. So, it’s applications are limited to apps in which:  Performance is not important  Difficult to implement in a conventional lang. New methods are invented Some compilers produce code comparable to LISP

48 ECE Dep. of Tehran Univ. - Programming Language Design Toward Nonprocedural Programming Pure logic programs prove the possibility of nonprocedural programming. In Prolog, DFS requires programmers to think in terms of operations and their proper ordering in time (procedurally). And Prolog’s control regime is more unnatural than conventional languages. So, there is still much more important work to be done before nonprocedural programming becomes practical.

49 ECE Dep. of Tehran Univ. - Programming Language Design Covered Sections of MacLennan  except topics starting on pp. 471, 475, 477, 484, 485, 486,

50 ECE Dep. of Tehran Univ. - Programming Language Design Presentation References Colmerauer, Alain, Philippe Roussel, The Birth of Prolog, Nov. 1992, URL: mrs.fr/~colmer/ArchivesPublications/HistoireProlog/19november92.pdf Fisher, J.R., Prolog Tutorial, 2004, URL: MacLennan, Bruce J., Principles of Programming Languages: Design, Evaluation and Implementation, 3rd ed, Oxford University Press, 1999 Merritt, Dennis, “Prolog Under the Hood: An Honest Look”, PC AI magazine, Sep/Oct 1992 “Unification”, Wikipedia, the free encyclopedia, 25 Sep. 2005, URL:

51 Thank You!