Martin Kay - PowerPoint PPT Presentation

About This Presentation
Title:

Martin Kay

Description:

Bratko, I. (1986) Prolog Programming for Artificial Intelligence. ... The Herald. Swedish Institute of Computer Science (SICS) Sicstus Prolog. 1 ~ sicstus ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 22
Provided by: marti67
Learn more at: https://web.stanford.edu
Category:
Tags: herald | kay | martin

less

Transcript and Presenter's Notes

Title: Martin Kay


1
Introduction to
Prolog
  • Martin Kay
  • Stanford University

2
Topics
  • Books
  • Starting and stopping Prolog
  • Consulting and reconsulting files
  • Assertions and queries
  • Constants and variables
  • Nondeterminism
  • Lists
  • Facts and rules

3
Books
  • Bratko, I. (1986) Prolog Programming for
    Artificial Intelligence. International Computer
    Science Series, Addison Wesley.
  • Clocksin, W. F. and C. S. Mellish (1981)
    Programming in Prolog. Springer-Verlag, Berlin.
  • König, E. and R. Seiffert (1989) Grudkurs Prolog
    für Linguisten. UTB für Wissenschaft
    Uni-Taschenbücher, A. Franke Verlag, Tübingen.
  • O'Keefe, R. (1990) The Craft of Prolog. MIT
    Press, Cambridge, Massachusetts.
  • Ross, P. (1989) Advanced Prolog. Addison Weseley.
  • Sterling, L. and E. Shapiro (1986) The Art of
    Prolog. MIT Press, Cambridge, Massachusetts.

4
Sicstus Prolog
  • Swedish Institute of Computer Science (SICS)

Setting the path environment variable (on Leland)
elaine27gt more .cshrc _at_() Leland Systems
.cshrc version 3.0.4 elaine27gt more .cshrc
_at_() Leland Systems .cshrc version
3.0.4 .... set path( /afs/ir/class/ling138/b
in path) ....
5
Sicstus Prolog
  • Swedish Institute of Computer Science (SICS)

1 sicstus SICStus 2.1 9 Fri Oct 21 163141
PDT 1994 ?- halt. 2
6
(No Transcript)
7
(No Transcript)
8
(No Transcript)
9
(No Transcript)
10
Queries
11
Queries
Now we can make this a real link!
12
(No Transcript)
13
Consulting files
  • ?- consult(maize).
  • consulting /tmp_mnt/tilde/kay/pl/parsers/maize.pl
    ...
  • /tmp_mnt/tilde/kay/pl/parsers/maize.pl
    consulted, 160 msec 1056 bytes
  • yes
  • ?-

consult(maize.pl). maize. maize.pl.
14
Facts and Rules
  • past(dive, dived).
  • past_tense(dive, dove).
  • pres_part(dive, diving).
  • sing3(dive, dives).
  • past_tense(write, wrote).
  • past_part(write, written).
  • pres_part(write, writing).
  • sing3(write, writes).
  • past_part(Verb, Word) -
  • past(Verb, Word).
  • past_tense(Verb, Word) -
  • past(Verb, Word).

Head
Goal
15
The /2 operator
  • ?- Xfoo.
  • X foo ?
  • yes
  • ?- XY.
  • Y X ?
  • yes
  • ?- foo(A, b)foo(a, B).
  • A a,
  • B b ?
  • yes

16
Unification
  • ?- p(a, Q, b) p(A, A, A).
  • no
  • ?- p(a, Q, R) p(A, A, A).
  • A a,
  • Q a,
  • R a
  • yes
  • ?- p(q(a, a), r(X, X), s(Y, Y))p(X, Y, Z).
  • X q(a,a),
  • Y r(q(a,a),q(a,a)),
  • Z s(r(q(a,a),q(a,a)),r(q(a,a),q(a,a))) ?
  • yes

17
Ordered Pairs
?- Xa b c . Xa, b, c yes
?- Xa b. Xa b yes
18
member/2
  • ?- member(b, a,b,c).
  • yes
  • ?- member(X, a, b, c).
  • X a ?
  • X b ?
  • X c ?
  • no
  • ?- member(a, X, b, Y).
  • X a ?
  • Y a ?
  • no

member(H, H_). member(X, _T) -
member(X, T).
19
append/3
  • ?- append(a, b, c, p, q, r, X).
  • X a,b,c,p,q,r ?
  • yes
  • ?- append(a, b, c, X, a, b, c, d, e, f).
  • X d,e,f ?
  • yes
  • ?- append(X, d, e, f,a, b, c, d, e, f).
  • X a,b,c ?
  • yes

append(, A, A). append(CD, A, CB) -
append(D, A, B).
20
(Naive) reverse/2
  • ?- reverse(a, b, c, X).
  • X c,b,a ?
  • yes
  • ?- reverse(X, a, b, c).
  • X c,b,a ?
  • yes
  • ?- Xa, b, B, A, reverse(X, X).
  • A a,
  • B b,
  • X a,b,b,a ?
  • yes

reverse(, ). reverse(HT, Rev) -
reverse(T, RT), append(RT, H, Rev).
21
Interrupting Prolog
  • foo(a, b).
  • C
  • Prolog interruption (h for help)? a
  • Execution aborted
  • ?-
Write a Comment
User Comments (0)
About PowerShow.com