Lisp and Prolog Background Thank you to Prof. Roosen-Runge for the slides on background and history. BH2-1
Lisp History Lisp--invented (about 1958) by the logician and AI researcher John McCarthy Widely used in for applications in AI for over 30 years Used in industry È To develop expert systems & other AI applications È For Rapid Application Development (RAD) BH2-2
Lisp Use Lisp is used as an embedded language Found inside applications like Emacs (MLisp) and AutoCAD (AutoLisp). È Emacs supports Lisp as a language for developing programs È As well as embedded language for controlling and customizing the editor itself BH2-3
Lisp availability On all major and many minor platforms. Numerous free- and shareware versions. Standard: Common Lisp BH2-4
Prolog history Prolog invented ( 1972) by the AI researcher Alan Colmeraurer È Used at York in the Student Information System to check applications for input errors Widely used to develop expert systems & other AI applications including natural language processing È Early ideas developed at University of Montreal; then University of Marseilles BH2-5
Prolog Use & Availability Prolog rumored to be embedded in MS Office On all major and many minor platforms Several free and shareware versions Standard: Edinburgh-style BH2-6
Survival Value McCarthy's Lisp versus Newell's IPL (Information Processing Language) È Both men pioneers in AI and computer science È Both proposed languages at about the same time for symbolic computing to be used in AI research BH2-7
& the winner is? McCarthy? Newell? Why? BH2-8
& the winner is... Value of high-level over low-level language wasn t so clearly recognized in the early days. Newell made what turned out to be a fatal error for his language Newell modelled IPL, not on logic, but on assembler language. This made his language very operational Couldn't be understood in mathematical terms. Wasn't accepted as a notation for AI programs. BH2-9
Low- and High-level Ð 1 Lisp became the assembler language lower-level for AI programmers È Used to build higher-level systems È Wilensky Chapters 21 & 22 give the basis for Prolog! Common Lisp = union of the techniques and tools people have found useful. BH2-10
Low- and High-level Ð 2 Prolog is a higher-level language for knowledge-based programming È More powerful, not necessarily as efficient È More compact È More understandable programs. BH2-11
Denotational vs Operational Programming BH2-12
What is a Denotation? Denotation = object described by an expression or referred to by a name. In denotational programming languages, the object is mathematical È number È abstract symbol È function È equation or proposition BH2-13
Denotation History Concept of denotation comes from the theories of how logic connects to mathematics worked out by Bertrand Russell & Albert North Whitehead at the turn of the century (famous book: Principia Mathematica) Based on ideas from German logician Gottlob Frege Invented the concepts of the predicate calculus and quantifiers: (for all, there exists) BH2-14
Description and Prescription Programs are both descriptions and prescriptions x = y + 3 interpreted operationally (prescription) program = instructions to underlying machine as to what to do Add 3 to y and store result in x Interpreted denotationally (description) program = description of mathematical relationship between input and output. When executed, value of x equals value of y + 3 BH2-15
Prescription Example palindrome ( String x ) : boolean is int half x.length div 2 for i : 0.. half do if x.charat ( i ) x.charat ( x.length 1 i ) ) return false fi end for return true end palindrome BH2-16
Description Example // Given the following two functions. // Result = (x = y) match ( String x, String y ) : boolean // Result is the string reversal of x. reverse ( String x ) : String // Then... palindrome ( String x ) : boolean is return match ( x, reverse (x) ) end panlindrome BH2-17
Functional vs. Declarative Functional (Lisp-like) È palindrome ( x ) is x = rev (x) where rev ( [] ) is [] -- reversal of empty is empty and rev ( w ^ x ) is append ( rev (x), w ) Declarative (Prolog-like) È palindrome ( x ) if rev ( x, x ) where rev ( [], [] ) -- Empty is the reversal of empty and rev ( w ^ x, y ) if rev (x, z) and append ( z, w, y ) BH2-18
Pure Lisp Denotational, functional rather than operational È No states: just a mapping between arguments and result or, from input to output. Pure Lisp is all we will have time to discuss in this course È It's what makes Lisp distinctive BH2-19
Pure Prolog Pure Prolog: denotational & declarative Just 1 state È A knowledge base = database for facts This turned out to be a very big advance! BH2-20
Lisp vs. Prolog? Which AI language an AI researcher uses often depends on where they studied. At MIT and Stanford, almost all Lisp At Edinburgh, almost all Prolog MIT has used a dialect of Lisp called Scheme in their first year programming course for many years. BH2-21
At York We have been more a Prolog shop than a Lisp shop in this department. Prof. Stachniak teaches a 4th year course on Logic Programming which includes a more advanced look at Prolog. BH2-22
Other Choices There are many denotational, functional languages other than Lisp È ML is popular in British and some European universities American universities tend to use Lisp No strong competitors to Prolog at present, mainly variants, extensions, and dialects. Objected-oriented add-ons available for both languages BH2-23
Lisp in Production Work Programmers tend to use operational features This is not good; it is the fault of poor softwaredevelopment tools There are claims that 90% of function calls in Lisp programs are to assignment functions like setq and rplaca! Assignment changes state and is sure sign of an operational description Compare the palindrome programs BH2-24