CS 342 Lecture -*- Outline -*- * Introduction to Logic Programming and Prolog ** Paradigms of programming *draw Venn diagram *** Procedural **** Imperative or von Neumann (mutation, assignment) Algol 60, Pascal, Ada ***** Objects with indefinite lifetimes (heap-based) CLU, LISP ****** Object-oriented (dynamic binding + inheritance) ST-80, Simula, CLOS **** Applicative (no mutation, no assignment) Pure LISP, data-flow languages ***** Functional (first-class functions) FP, Pure LISP ****** Lazy (lazy evaluation) Miranda *** Declarative (nonprocedural) **** Database systems (relations + queries) SQL **** Logic-oriented (horn-clauses) Prolog **** Constraint-based Bertrand, Thing-Lab **** Equational-logic based OBJ *** Other dimensions: parallelism, type systems, ... ** History 1930s Herbrand and others develop proof procedures for predicate calculus 1960 Prawitz introduces unification as aid to theorem proving 1965 Robinson's resolution algorithm 1973 first FORTRAN version of Prolog (U. Marseille-Aix, Colmerauer) 1977 first Prolog compiler (Edinburgh, due to Warren, fast as LISP!) 1981 Japanese adopt Prolog for fifth-generation computing effort ** Goals extremely high level, declarative WRITE programs efficiently (vs. running efficiently) ** Claims of Logic programming: (questions we'll look at) Algorithm = logic + control vs Algorithms + data structures = programs Specification = implementation Good for rapid prototyping (partly because it may be inefficient) Human-oriented (friendly) ** Logic programming techniques *** nonprocedural, what is to be done, instead of how *** proofs can be constructive to prove that there is an sorted version of list X, exhibit the sorted version of the list *** programs are propositions that assert existence of desired result *** Think of programs as *relations* plus(X,Y,Z) {<1,3,4>, <2,9,11>, ...} reverse(L1,L2) {<[1,2,3], [3,2,1]>, ...}