CS 541 Lecture -*- Outline -*- * Introduction to Logic Programming ** additional motivation for logic programming in particular immensely fruitful area of research (because of fundamental connections to both logic and computation) great tool for operational semantics and type theory, as it resembles their notation ** logic programming idea ------------------------------------------ CREATING THE IDEA OF LOGIC PROGRAMMING Recall motivation for declarative prog: 1. write programs efficiently 2. execute specifications 3. separate directions about control and data structures How would you specify a sort routine? ------------------------------------------ sorted(List) = List' where ordered(List') and permutation(List, List') Q: How can we then use this to sort some particular list L? exist L' . sort(L) = L' Q: How could such a theorem be proved? - give the sorted list L' (constructive) - prove that every list can be sorted (nonconstructive) ------------------------------------------ ABSTRACTING FROM THE EXAMPLE Model: programs are modeled as Specification of a problem: a problem to be solved is Answer to a problem: ------------------------------------------ ... relations between input and output ... a decription of facts and relationships and an existential conjecture about the existence of a relationship. for example, sorted(List, List') if ordered(List') and permutation(List,List'). exists O . L = [3,1,2] and sorted(L, O)? ... a constructive proof of the conjecture, which thus actually produces the output. e.g., the sorted list The problem (for the language designer/implementor) is: how to state such descriptions and conjectures how to instruct a system to do such constructive proofs how to do it fast ** History (omit) 1930s Herbrand and others develop proof procedures for pred. 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) as fast as LISP! 1979 Kowalski's paper: Algorithm = Logic + Control 1981 Japanese adopt Prolog for fifth-generation computing effort (This produces some interesting work, but not what was hoped) ** What to read in Dale Miller's notes "\Prolog: An Introduction to the Language and its Logic" skimed parts would be helpful to read, but don't have to be read very carefully. essential skim topic ch. 1 intro ch. 2 kinds, types, and signatures ch. 3 first-order Horn clauses ch. 4 modules and the top level ch. 5 first-order Hereditary Harhop formulas 6.1-6.4 Simply-typed lambda terms and formulas 6.5 higher-order logics ch. 7 Computing with \-terms ch. 8 Higher-order programming ch. 9 higher-order hereditary Harrop formulas