Artificial
Intelligence I:
introduction
Lecturer: Tom Lenaerts
Institut de Recherches Interdisciplinaires et de
Développements en Intelligence Artificielle (IRIDIA)
Université Libre de Bruxelles
TLo (IRIDIA) 2October 13, 2015
Practical stuff
 Course homepage:
 http://iridia.ulb.ac.be/~tlenaert/teach/ai1.
html
 Mailinglist:
 02452-valvas@elvas.vub.ac.be
 Textbook:
 S. Russell and P. Norvig Artificial
Intelligence:A Modern Approach
Prentice Hall, 2003, Second Edition
 Excercices:
 Joachim de Beule en Bart De
Vylder.
 Lisp (~scheme++)
 Exam: written at end of 1st. sem.
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
TLo (IRIDIA) 3October 13, 2015
Course overview
 What is AI.
 Intelligent agents.
 Problem solving.
 Knowledge and reasoning.
 Planning.
 Uncertain knowledge and reasoning.
 Learning.
 Communicating, perceiving and acting.
TLo (IRIDIA) 4October 13, 2015
Outline
 What is AI
 A brief history
 The State of the art (see book)
 Reading
 Lisp
 And its relation to Scheme
TLo (IRIDIA) 5October 13, 2015
What is Artificial Intelligence
 Creative extension of philosophy:
 Understand and BUILD intelligent entities
 Origin after WWII
 Highly interdisciplinary
 Currently consist of huge variety of subfields
 This course will discuss some of them
TLo (IRIDIA) 6October 13, 2015
What is Artificial Intelligence
 Different definitions due to different criteria
 Two dimensions:
 Thought processes/reasoning vs. behavior/action
 Success according to human standards vs. success
according to an ideal concept of intelligence:
rationality.
Systems that think like humans Systems that think rationally
Systems that act like humans Systems that act rationally
TLo (IRIDIA) 7October 13, 2015
Systems that act like humans
 When does a system behave intelligently?
 Turing (1950) Computing Machinery and Intelligence
 Operational test of intelligence: imitation game
 Test still relevant now, yet might be the wrong question.
 Requires the collaboration of major components of AI:
knowledge, reasoning, language understanding, learning,
…
TLo (IRIDIA) 8October 13, 2015
Systems that act like humans
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
Andrew Hodges.
Alan Turing, the enigma
Available at amazon.co.uk
Problem with Turing test: not reproducible, constructive or
amenable to mathematical analysis.
TLo (IRIDIA) 9October 13, 2015
Systems that think like humans
 How do humans think?
 Requires scientific theories of internal brain activities
(cognitive model):
 Level of abstraction? (knowledge or circuitry?)
 Validation?
 Predicting and testing human behavior
 Identification from neurological data
 Cognitive Science vs. Cognitive neuroscience.
 Both approaches are now distinct from AI
 Share that the available theories do not explain anything
resembling human intelligence.
 Three fields share a principal direction.
TLo (IRIDIA) 10October 13, 2015
Systems that think like humans
 Some references;
 Daniel C. Dennet.
Consciousness explained.
 M. Posner (edt.)
Foundations of cognitive
science
 Francisco J. Varela et al.
The Embodied Mind
 J.-P. Dupuy. The
mechanization of the mind
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
TLo (IRIDIA) 11October 13, 2015
Systems that think rationally
 Capturing the laws of thought
 Aristotle: What are ‘correct’ argument and thought
processes?
 Correctness depends on irrefutability of reasoning processes.
 This study initiated the field of logic.
 The logicist tradition in AI hopes to create intelligent systems using
logic programming.
 Problems:
 Not all intelligence is mediated by logic behavior
 What is the purpose of thinking? What thought should one have?
TLo (IRIDIA) 12October 13, 2015
Systems that think rationally
 A reference;
 Ivan Bratko, Prolog
programming for
artificial intelligence.
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
TLo (IRIDIA) 13October 13, 2015
Systems that act rationally
 Rational behavior: “doing the right thing”
 The “Right thing” is that what is expected to maximize
goal achievement given the available information.
 Can include thinking, yet in service of rational action.
 Action without thinking: e.g. reflexes.
 Two advantages over previous approaches:
 More general than law of thoughts approach
 More amenable to scientific development.
 Yet rationality is only applicable in ideal environments.
 Moreover rationality is not a very good model of reality.
TLo (IRIDIA) 14October 13, 2015
Systems that act rationally
 Some references;
 Michael Wooldridge.
Reasoning about
rational agents.
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
TLo (IRIDIA) 15October 13, 2015
Rational agents
 An agent is an entity that perceives and acts
 This course is about designing rational agents
 An agent is a function from percept histories to actions:
 For any given class of environments and task we seek the
agent (or class of agents) with the best performance.
 Problem: computational limitations make perfect
rationality unachievable.
f:P*→A
TLo (IRIDIA) 16October 13, 2015
Foundations of AI
 Different fields have contributed to AI in the form of
ideas,viewpoints and techniques.
 Philosophy: Logic, reasoning, mind as a physical system,
foundations of learning, language and rationality.
 Mathematics: Formal representation and proof algorithms,
computation, (un)decidability, (in)tractability, probability.
 Psychology: adaptation, phenomena of perception and motor
control.
 Economics: formal theory of rational decisions, game theory.
 Linguistics: knowledge represetatio, grammar.
 Neuroscience: physical substrate for mental activities.
 Control theory: homeostatic systems, stability, optimal agent
design.
TLo (IRIDIA) 17October 13, 2015
A brief history
 What happened after WWII?
 1943: Warren Mc Culloch and Walter Pitts: a model of
artificial boolean neurons to perform computations.
 First steps toward connectionist computation and learning
(Hebbian learning).
 Marvin Minsky and Dann Edmonds (1951) constructed the first
neural network computer
 1950: Alan Turing’s “Computing Machinery and
Intelligence”
 First complete vision of AI.
TLo (IRIDIA) 18October 13, 2015
A brief history (2)
 The birth of AI (1956)
 Darmouth Workshop bringing together top minds on automata
theory, neural nets and the study of intelligence.
 Allen Newell and Herbert Simon: The logic theorist (first nonnumerical
thinking program used for theorem proving)
 For the next 20 years the field was dominated by these participants.
 Great expectations (1952-1969)
 Newell and Simon introduced the General Problem Solver.
 Imitation of human problem-solving
 Arthur Samuel (1952-)investigated game playing (checkers ) with great
success.
 John McCarthy(1958-) :
 Inventor of Lisp (second-oldest high-level language)
 Logic oriented, Advice Taker (separation between knowledge and
reasoning)
TLo (IRIDIA) 19October 13, 2015
A brief history (3)
 The birth of AI (1956)
 Great expectations continued ..
 Marvin Minsky (1958 -)
 Introduction of microworlds that appear to require intelligence to
solve: e.g. blocks-world.
 Anti-logic orientation, society of the mind.
 Collapse in AI research (1966 - 1973)
 Progress was slower than expected.
 Unrealistic predictions.
 Some systems lacked scalability.
 Combinatorial explosion in search.
 Fundamental limitations on techniques and representations.
 Minsky and Papert (1969) Perceptrons.
TLo (IRIDIA) 20October 13, 2015
A brief history (4)
 AI revival through knowledge-based systems (1969-
1970)
 General-purpose vs. domain specific
 E.g. the DENDRAL project (Buchanan et al. 1969)
 First successful knowledge intensive system.
 Expert systems
 MYCIN to diagnose blood infections (Feigenbaum et al.)
 Introduction of uncertainty in reasoning.
 Increase in knowledge representation research.
 Logic, frames, semantic nets, …
TLo (IRIDIA) 21October 13, 2015
A brief history (5)
 AI becomes an industry (1980 - present)
 R1 at DEC (McDermott, 1982)
 Fifth generation project in Japan (1981)
 American response …
 Puts an end to the AI winter.
 Connectionist revival (1986 - present)
 Parallel distributed processing (RumelHart and
McClelland, 1986); backprop.
TLo (IRIDIA) 22October 13, 2015
A brief history (6)
 AI becomes a science (1987 - present)
 Neats vs. scruffies.
 In speech recognition: hidden markov models
 In neural networks
 In uncertain reasoning and expert systems: Bayesian network
formalism
 …
 The emergence of intelligent agents (1995 - present)
 The whole agent problem:
“How does an agent act/behave embedded in real environments with
continuous sensory inputs”
TLo (IRIDIA) 23October 13, 2015
Reading
 One course on AI provides a
limited view on a vast research
area
 Reading assignment:
 P.1-138
 Provides background
information on the current
perspective in AI: embodied
cognitive science.
TLo (IRIDIA) 24October 13, 2015
Lisp vs. scheme
 Lisp (= LISt Processor) is the second
oldest programming language still in use
(after FORTRAN).
 Invented by John McCarthy at MIT in
1958.
 Until the mid '80s Lisp was more a family
of dialects than a single language.
 In 1986 an ANSI subcommittee was
formed to standardize these dialects into a
single Common Lisp.
 The result being the first Object Oriented language to
become standardized, in 1994.
 Once you understand Common Lisp it is
easy to adapt yourself to weaker dialects as
for instance Scheme.
TLo (IRIDIA) 25October 13, 2015
Lisp vs Scheme
 Lisp has much more built-in functions and special forms, the Scheme
language definition takes 45 pages while Common Lisp takes 1029
pages)
 Apart from lexical variables(lexically scoped) Lisp also has special
variables (dynamically scoped)
 In a lexically scoped language, the scope of an identifier is fixed
at compile time to some region in the source code containing
the identifier's declaration. This means that an identifier is only
accessible within that region (including procedures declared
within it).
 In a dynamically scoped language an identifier can be referred
to, not only in the block where it is declared, but also in any
function or procedure called from within that block, even if the
called procedure is declared outside the block
TLo (IRIDIA) 26October 13, 2015
Lisp vs Scheme
 Statically vs dynamically scoped variables
>(set 'regular 5)
5
>(defun check-regular ()
regular)
CHECK-REGULAR
>(check-regular)
5
> (let ((regular 6))
(check-regular))
5
>(defvar *special* 5)
*SPECIAL*
>(defun check-special ()
*special*)
CHECK-SPECIAL
>(check-special)
5
>(let ((*special* 6))
(check-special))
6
TLo (IRIDIA) 27October 13, 2015
Lisp vs Scheme
 Scheme evaluates the function part of a function call in exactly the same
way as arguments, Lisp doesn’t.
 In Lisp, the role of the symbol depends on the position in the list
(fun arg)
 Example:
(let ((list '(1 2 3)))
(list list))
==>((1 2 3))
 Function calls: Scheme vs. Lisp
(let ((fun (compute-a-function)))
(fun x y)
(map car L)
let ((fun (compute-a-function)))
(funcall fun x y))
(map ‘list #’car L)
TLo (IRIDIA) 28October 13, 2015
Lisp vs Scheme
 Scheme uses one name space for functions, variables, etc.,
Lisp doesn’t.
 Special (global) symbols
(defun square (x) …)
(setf (symbol-function square) (x) …)
 Lexical (local) symbols
(labels ((square (x) …)) …)
(setf square (function (lambda (x) …))
TLo (IRIDIA) 29October 13, 2015
Lisp vs Scheme
 In Lisp defun defines functions in the global
environment even if the function is defined internally to
another function.
(define (stack)
(let ((data ‘()))
(define (push elm) …)
(define (pop) …)
…)
(defun stack ()
(let ((data ‘()))
(defun push (elm) …)
(defun pop () …)
…)
(defun stack ()
(let ((data ‘()))
(labels ((push (elm) …)
(pop () …))
…)
TLo (IRIDIA) 30October 13, 2015
Lisp vs Scheme
 Lisp functions can have rest and optional parameters.
Scheme functions only can have the equivalent of a rest
parameter.
((lambda (a b) (+ a (* b 3))) 4 5) => 19
((lambda (a &optional (b 2)) (+ a (* b 3))) 4 5) => 19
((lambda (a &optional (b 2)) (+ a (* b 3))) 4) => 10
((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x)))
=> (2 nil 3 nil nil)
((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x)) 6)
=> (6 t 3 nil nil)
TLo (IRIDIA) 31October 13, 2015
Lisp vs Scheme
 Lisp functions can have also keyword parameters.
 Or some mixture.
((lambda (a b &key c d) (list a b c d)) 1 2) => (1 2 nil nil)
((lambda (a b &key c d) (list a b c d)) 1 2 :c 6) => (1 2 6 nil)
((lambda (a b &key c d) (list a b c d)) 1 2 :d 8) => (1 2 nil 8)
((lambda (a b &key c d) (list a b c d)) 1 2 :c 6 :d 8) => (1 2 6 8)
((lambda (a b &key c d) (list a b c d)) 1 2 :d 8 :c 6) => (1 2 6 8)
((lambda (a &optional (b 3) &rest x &key c (d a))
(list a b c d x)) 1) => (1 3 nil 1 ())
((lambda (a &optional (b 3) &rest x &key c (d a))
(list a b c d x)) 1 2) => (1 2 nil 1 ())
((lambda (a &optional (b 3) &rest x &key c (d a))
(list a b c d x)) :c 7) => (:c 7 nil :c ())
TLo (IRIDIA) 32October 13, 2015
Lisp vs Scheme
 Lisp has standard macros, Scheme since R5RS.
 “Lisp macros are a way to execute arbitrary code at "compile
time", using entities that are called like functions, but evaluate
their arguments (or not, if they choose not to) in ways that are
controlled by the macro itself. The language used to write the
macro is just Lisp itself, so the full power of the language is
available”
 Allows you to define your own special forms as if or
and.
TLo (IRIDIA) 33October 13, 2015
Lisp vs Scheme
 Lisp has special forms (loop, do, dotimes, …) for
looping, in Scheme the user is asked to use tail-
recursion that is implemented efficiently.
(loop for i fixnum from 3
when (oddp i) collect i
while (< i 5))
⇒ (3 5)
http://iridia.ulb.ac.be/~tlenaert/prog/Lisp/cltl/cltl2.html
TLo (IRIDIA) 34October 13, 2015
Other courses at the VUB
 AI does not end here …
 Artificiele Intelligentie II
 Technieken van de AI I en II
 Autonomous Agents
 Adaptive Systems I en II
 Machine Learning
 Multi-agent systems
 …
TLo (IRIDIA) 35October 13, 2015
Some references
 Understanding Intelligence by Rolf
Pfeifer and Christian Scheier.
 Artificial Intelligence: Structures
and Strategies for Complex
Problem-solving by George Luger.
 Computation and Intelligence:
Collective readings edited by
George Luger.
 Paradigms of Artificial Intelligence
Programming: Case Studies in
Common Lisp by Peter Norvig.

Artificial Intelligence

  • 1.
    Artificial Intelligence I: introduction Lecturer: TomLenaerts Institut de Recherches Interdisciplinaires et de Développements en Intelligence Artificielle (IRIDIA) Université Libre de Bruxelles
  • 2.
    TLo (IRIDIA) 2October13, 2015 Practical stuff  Course homepage:  http://iridia.ulb.ac.be/~tlenaert/teach/ai1. html  Mailinglist:  02452-valvas@elvas.vub.ac.be  Textbook:  S. Russell and P. Norvig Artificial Intelligence:A Modern Approach Prentice Hall, 2003, Second Edition  Excercices:  Joachim de Beule en Bart De Vylder.  Lisp (~scheme++)  Exam: written at end of 1st. sem. QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture.
  • 3.
    TLo (IRIDIA) 3October13, 2015 Course overview  What is AI.  Intelligent agents.  Problem solving.  Knowledge and reasoning.  Planning.  Uncertain knowledge and reasoning.  Learning.  Communicating, perceiving and acting.
  • 4.
    TLo (IRIDIA) 4October13, 2015 Outline  What is AI  A brief history  The State of the art (see book)  Reading  Lisp  And its relation to Scheme
  • 5.
    TLo (IRIDIA) 5October13, 2015 What is Artificial Intelligence  Creative extension of philosophy:  Understand and BUILD intelligent entities  Origin after WWII  Highly interdisciplinary  Currently consist of huge variety of subfields  This course will discuss some of them
  • 6.
    TLo (IRIDIA) 6October13, 2015 What is Artificial Intelligence  Different definitions due to different criteria  Two dimensions:  Thought processes/reasoning vs. behavior/action  Success according to human standards vs. success according to an ideal concept of intelligence: rationality. Systems that think like humans Systems that think rationally Systems that act like humans Systems that act rationally
  • 7.
    TLo (IRIDIA) 7October13, 2015 Systems that act like humans  When does a system behave intelligently?  Turing (1950) Computing Machinery and Intelligence  Operational test of intelligence: imitation game  Test still relevant now, yet might be the wrong question.  Requires the collaboration of major components of AI: knowledge, reasoning, language understanding, learning, …
  • 8.
    TLo (IRIDIA) 8October13, 2015 Systems that act like humans QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture. QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture. Andrew Hodges. Alan Turing, the enigma Available at amazon.co.uk Problem with Turing test: not reproducible, constructive or amenable to mathematical analysis.
  • 9.
    TLo (IRIDIA) 9October13, 2015 Systems that think like humans  How do humans think?  Requires scientific theories of internal brain activities (cognitive model):  Level of abstraction? (knowledge or circuitry?)  Validation?  Predicting and testing human behavior  Identification from neurological data  Cognitive Science vs. Cognitive neuroscience.  Both approaches are now distinct from AI  Share that the available theories do not explain anything resembling human intelligence.  Three fields share a principal direction.
  • 10.
    TLo (IRIDIA) 10October13, 2015 Systems that think like humans  Some references;  Daniel C. Dennet. Consciousness explained.  M. Posner (edt.) Foundations of cognitive science  Francisco J. Varela et al. The Embodied Mind  J.-P. Dupuy. The mechanization of the mind QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture. QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture.
  • 11.
    TLo (IRIDIA) 11October13, 2015 Systems that think rationally  Capturing the laws of thought  Aristotle: What are ‘correct’ argument and thought processes?  Correctness depends on irrefutability of reasoning processes.  This study initiated the field of logic.  The logicist tradition in AI hopes to create intelligent systems using logic programming.  Problems:  Not all intelligence is mediated by logic behavior  What is the purpose of thinking? What thought should one have?
  • 12.
    TLo (IRIDIA) 12October13, 2015 Systems that think rationally  A reference;  Ivan Bratko, Prolog programming for artificial intelligence. QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture.
  • 13.
    TLo (IRIDIA) 13October13, 2015 Systems that act rationally  Rational behavior: “doing the right thing”  The “Right thing” is that what is expected to maximize goal achievement given the available information.  Can include thinking, yet in service of rational action.  Action without thinking: e.g. reflexes.  Two advantages over previous approaches:  More general than law of thoughts approach  More amenable to scientific development.  Yet rationality is only applicable in ideal environments.  Moreover rationality is not a very good model of reality.
  • 14.
    TLo (IRIDIA) 14October13, 2015 Systems that act rationally  Some references;  Michael Wooldridge. Reasoning about rational agents. QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture.
  • 15.
    TLo (IRIDIA) 15October13, 2015 Rational agents  An agent is an entity that perceives and acts  This course is about designing rational agents  An agent is a function from percept histories to actions:  For any given class of environments and task we seek the agent (or class of agents) with the best performance.  Problem: computational limitations make perfect rationality unachievable. f:P*→A
  • 16.
    TLo (IRIDIA) 16October13, 2015 Foundations of AI  Different fields have contributed to AI in the form of ideas,viewpoints and techniques.  Philosophy: Logic, reasoning, mind as a physical system, foundations of learning, language and rationality.  Mathematics: Formal representation and proof algorithms, computation, (un)decidability, (in)tractability, probability.  Psychology: adaptation, phenomena of perception and motor control.  Economics: formal theory of rational decisions, game theory.  Linguistics: knowledge represetatio, grammar.  Neuroscience: physical substrate for mental activities.  Control theory: homeostatic systems, stability, optimal agent design.
  • 17.
    TLo (IRIDIA) 17October13, 2015 A brief history  What happened after WWII?  1943: Warren Mc Culloch and Walter Pitts: a model of artificial boolean neurons to perform computations.  First steps toward connectionist computation and learning (Hebbian learning).  Marvin Minsky and Dann Edmonds (1951) constructed the first neural network computer  1950: Alan Turing’s “Computing Machinery and Intelligence”  First complete vision of AI.
  • 18.
    TLo (IRIDIA) 18October13, 2015 A brief history (2)  The birth of AI (1956)  Darmouth Workshop bringing together top minds on automata theory, neural nets and the study of intelligence.  Allen Newell and Herbert Simon: The logic theorist (first nonnumerical thinking program used for theorem proving)  For the next 20 years the field was dominated by these participants.  Great expectations (1952-1969)  Newell and Simon introduced the General Problem Solver.  Imitation of human problem-solving  Arthur Samuel (1952-)investigated game playing (checkers ) with great success.  John McCarthy(1958-) :  Inventor of Lisp (second-oldest high-level language)  Logic oriented, Advice Taker (separation between knowledge and reasoning)
  • 19.
    TLo (IRIDIA) 19October13, 2015 A brief history (3)  The birth of AI (1956)  Great expectations continued ..  Marvin Minsky (1958 -)  Introduction of microworlds that appear to require intelligence to solve: e.g. blocks-world.  Anti-logic orientation, society of the mind.  Collapse in AI research (1966 - 1973)  Progress was slower than expected.  Unrealistic predictions.  Some systems lacked scalability.  Combinatorial explosion in search.  Fundamental limitations on techniques and representations.  Minsky and Papert (1969) Perceptrons.
  • 20.
    TLo (IRIDIA) 20October13, 2015 A brief history (4)  AI revival through knowledge-based systems (1969- 1970)  General-purpose vs. domain specific  E.g. the DENDRAL project (Buchanan et al. 1969)  First successful knowledge intensive system.  Expert systems  MYCIN to diagnose blood infections (Feigenbaum et al.)  Introduction of uncertainty in reasoning.  Increase in knowledge representation research.  Logic, frames, semantic nets, …
  • 21.
    TLo (IRIDIA) 21October13, 2015 A brief history (5)  AI becomes an industry (1980 - present)  R1 at DEC (McDermott, 1982)  Fifth generation project in Japan (1981)  American response …  Puts an end to the AI winter.  Connectionist revival (1986 - present)  Parallel distributed processing (RumelHart and McClelland, 1986); backprop.
  • 22.
    TLo (IRIDIA) 22October13, 2015 A brief history (6)  AI becomes a science (1987 - present)  Neats vs. scruffies.  In speech recognition: hidden markov models  In neural networks  In uncertain reasoning and expert systems: Bayesian network formalism  …  The emergence of intelligent agents (1995 - present)  The whole agent problem: “How does an agent act/behave embedded in real environments with continuous sensory inputs”
  • 23.
    TLo (IRIDIA) 23October13, 2015 Reading  One course on AI provides a limited view on a vast research area  Reading assignment:  P.1-138  Provides background information on the current perspective in AI: embodied cognitive science.
  • 24.
    TLo (IRIDIA) 24October13, 2015 Lisp vs. scheme  Lisp (= LISt Processor) is the second oldest programming language still in use (after FORTRAN).  Invented by John McCarthy at MIT in 1958.  Until the mid '80s Lisp was more a family of dialects than a single language.  In 1986 an ANSI subcommittee was formed to standardize these dialects into a single Common Lisp.  The result being the first Object Oriented language to become standardized, in 1994.  Once you understand Common Lisp it is easy to adapt yourself to weaker dialects as for instance Scheme.
  • 25.
    TLo (IRIDIA) 25October13, 2015 Lisp vs Scheme  Lisp has much more built-in functions and special forms, the Scheme language definition takes 45 pages while Common Lisp takes 1029 pages)  Apart from lexical variables(lexically scoped) Lisp also has special variables (dynamically scoped)  In a lexically scoped language, the scope of an identifier is fixed at compile time to some region in the source code containing the identifier's declaration. This means that an identifier is only accessible within that region (including procedures declared within it).  In a dynamically scoped language an identifier can be referred to, not only in the block where it is declared, but also in any function or procedure called from within that block, even if the called procedure is declared outside the block
  • 26.
    TLo (IRIDIA) 26October13, 2015 Lisp vs Scheme  Statically vs dynamically scoped variables >(set 'regular 5) 5 >(defun check-regular () regular) CHECK-REGULAR >(check-regular) 5 > (let ((regular 6)) (check-regular)) 5 >(defvar *special* 5) *SPECIAL* >(defun check-special () *special*) CHECK-SPECIAL >(check-special) 5 >(let ((*special* 6)) (check-special)) 6
  • 27.
    TLo (IRIDIA) 27October13, 2015 Lisp vs Scheme  Scheme evaluates the function part of a function call in exactly the same way as arguments, Lisp doesn’t.  In Lisp, the role of the symbol depends on the position in the list (fun arg)  Example: (let ((list '(1 2 3))) (list list)) ==>((1 2 3))  Function calls: Scheme vs. Lisp (let ((fun (compute-a-function))) (fun x y) (map car L) let ((fun (compute-a-function))) (funcall fun x y)) (map ‘list #’car L)
  • 28.
    TLo (IRIDIA) 28October13, 2015 Lisp vs Scheme  Scheme uses one name space for functions, variables, etc., Lisp doesn’t.  Special (global) symbols (defun square (x) …) (setf (symbol-function square) (x) …)  Lexical (local) symbols (labels ((square (x) …)) …) (setf square (function (lambda (x) …))
  • 29.
    TLo (IRIDIA) 29October13, 2015 Lisp vs Scheme  In Lisp defun defines functions in the global environment even if the function is defined internally to another function. (define (stack) (let ((data ‘())) (define (push elm) …) (define (pop) …) …) (defun stack () (let ((data ‘())) (defun push (elm) …) (defun pop () …) …) (defun stack () (let ((data ‘())) (labels ((push (elm) …) (pop () …)) …)
  • 30.
    TLo (IRIDIA) 30October13, 2015 Lisp vs Scheme  Lisp functions can have rest and optional parameters. Scheme functions only can have the equivalent of a rest parameter. ((lambda (a b) (+ a (* b 3))) 4 5) => 19 ((lambda (a &optional (b 2)) (+ a (* b 3))) 4 5) => 19 ((lambda (a &optional (b 2)) (+ a (* b 3))) 4) => 10 ((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x))) => (2 nil 3 nil nil) ((lambda (&optional (a 2 b) (c 3 d) &rest x) (list a b c d x)) 6) => (6 t 3 nil nil)
  • 31.
    TLo (IRIDIA) 31October13, 2015 Lisp vs Scheme  Lisp functions can have also keyword parameters.  Or some mixture. ((lambda (a b &key c d) (list a b c d)) 1 2) => (1 2 nil nil) ((lambda (a b &key c d) (list a b c d)) 1 2 :c 6) => (1 2 6 nil) ((lambda (a b &key c d) (list a b c d)) 1 2 :d 8) => (1 2 nil 8) ((lambda (a b &key c d) (list a b c d)) 1 2 :c 6 :d 8) => (1 2 6 8) ((lambda (a b &key c d) (list a b c d)) 1 2 :d 8 :c 6) => (1 2 6 8) ((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x)) 1) => (1 3 nil 1 ()) ((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x)) 1 2) => (1 2 nil 1 ()) ((lambda (a &optional (b 3) &rest x &key c (d a)) (list a b c d x)) :c 7) => (:c 7 nil :c ())
  • 32.
    TLo (IRIDIA) 32October13, 2015 Lisp vs Scheme  Lisp has standard macros, Scheme since R5RS.  “Lisp macros are a way to execute arbitrary code at "compile time", using entities that are called like functions, but evaluate their arguments (or not, if they choose not to) in ways that are controlled by the macro itself. The language used to write the macro is just Lisp itself, so the full power of the language is available”  Allows you to define your own special forms as if or and.
  • 33.
    TLo (IRIDIA) 33October13, 2015 Lisp vs Scheme  Lisp has special forms (loop, do, dotimes, …) for looping, in Scheme the user is asked to use tail- recursion that is implemented efficiently. (loop for i fixnum from 3 when (oddp i) collect i while (< i 5)) ⇒ (3 5) http://iridia.ulb.ac.be/~tlenaert/prog/Lisp/cltl/cltl2.html
  • 34.
    TLo (IRIDIA) 34October13, 2015 Other courses at the VUB  AI does not end here …  Artificiele Intelligentie II  Technieken van de AI I en II  Autonomous Agents  Adaptive Systems I en II  Machine Learning  Multi-agent systems  …
  • 35.
    TLo (IRIDIA) 35October13, 2015 Some references  Understanding Intelligence by Rolf Pfeifer and Christian Scheier.  Artificial Intelligence: Structures and Strategies for Complex Problem-solving by George Luger.  Computation and Intelligence: Collective readings edited by George Luger.  Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp by Peter Norvig.