Prolog for Linguists Symbolic Systems 139P/239P - PowerPoint PPT Presentation

About This Presentation
Title:

Prolog for Linguists Symbolic Systems 139P/239P

Description:

... Sicstus prolog on your personal Windows or Linux laptop or workstation. ... Variables can stand in for arbitrary Prolog terms (including other variables) ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 23
Provided by: johndo62
Learn more at: https://web.stanford.edu
Category:

less

Transcript and Presenter's Notes

Title: Prolog for Linguists Symbolic Systems 139P/239P


1
Prolog for Linguists Symbolic Systems 139P/239P
  • John Dowding
  • Fall, 2001

2
Goals
  • Gain basic competence in Prolog programming.
  • Understand relationships between Prolog, Logic,
    Logic Programming, and Linguistics.
  • Understand when to (and not to) consider using
    Prolog.

3
Course Requirements
  • Homework assignments most weeks
  • 3 assignments to be handed in (50)
  • Term manipulation
  • Definite Clause Grammars
  • TBD
  • Final project (50)
  • Ill provide some examples
  • 239P should write up a final project proposal,
    and present project in class.

4
Textbook
  • Programming in Prolog, 4th edition, 1994
  • Clocksin and Mellish
  • ISBN 3-540-58350-5

5
Course web page
  • http//www.stanford.edu/class/symbsys139p
  • programs used in class
  • power point slides
  • homework assignments, solutions

6
Office Hours
  • We have reserved 4 workstations in Meyer Cluster,
    in Meyer library
  • 430-530 on Thursday

7
Course Schedule
  • Oct. 8
  • Oct. 15
  • Oct. 22
  • Oct. 29
  • Nov. 5
  • Nov. 12
  • Nov. 26
  • Dec. 3
  • No class on Nov. 19
  • We need to make up 2 classes

8
Running Prolog at Stanford
  • Use Sicstus Prolog 3.8.6
  • On elaine, installed in
  • /afs/ir/class/symbsys139p/bin
  • Add to your path, and run as
  • sicstus
  • Talk to me about installing Sicstus prolog on
    your personal Windows or Linux laptop or
    workstation.

9
History
  • Automatic Theorem Proving
  • Robinson 1965
  • PROgramming in LOGic
  • Kowalski, 1974
  • Deduction as computation
  • Prolog, Colmerauer, Marseille, 1973
  • Edinburgh Prolog, 1977
  • Prolog 10, David Warren
  • Warren Abstract Machine
  • ClocksinMellish, 1981

10
History (cont.)
  • Japanese 5th Generation Project
  • 1981
  • Quintus Corporation
  • 1st Industrial strength Prolog implementation
  • ISO Prolog Standard, 1994
  • P. Deransart, et al.

11
What kind of a thing is Prolog?
  • Very different from C, C, Java, and other
    Procedural languages
  • Symbolic Programming Language
  • Logic Programming Language
  • Declarative Programming Language
  • Database Language

12
Database Program Example
13
Prolog program
  • A Prolog program is defined by a set of
    Predicates
  • Each Predicate has a unique Functor and Arity
  • parent(Parent, Child)
  • a predicate whose functor is parent with arity
    2.
  • Each Predicate is defined by a sequence of
    Clauses
  • A Clause is either a Fact or a Rule
  • fact().
  • head() - goal1(), , goalN().
  • Each argument to a predicate is a Term

14
Terms
  • Each argument to a predicate is a Term
  • A Term is either
  • Atomic
  • Variable
  • Compound

15
Atomic terms
  • Atomic terms can be either atoms or numbers
  • Atoms can be a sequence of alphanumeric
    (including _) characters starting with a lower
    case letter, or a sequence of any characters
    embedded in single quote marks
  • johnDowding symbsys139p quoted atom
    non_quoted_atom
  • Numbers can be integers or floating point
  • Well look at numbers at a later time

16
Variables
  • Variables start with a capital letter or _
    character
  • X Parent _Sibling _
  • Variables can stand in for arbitrary Prolog terms
    (including other variables)
  • Variables that occur with the same name in the
    same clause represent the same variable, except
    for
  • The anonymous variable _, which always
    represents a unique variable.

17
Compound Terms
  • A compound term is a structure with a functor
    and N arguments.
  • functor(Arg1, Arg2, , ArgN)
  • Each argument can be an arbitrary Prolog term

18
Example Successor Arithmetic
  • Simple arithmetic using compound terms to
    represent integers
  • 0 0
  • 1 s(0)
  • 2 s(s(0))
  • 3 s(s(s(0)))
  • 4 s(s(s(s(0))))
  • .
  • .
  • .

19
Structural Induction and Recursion
  • Inductive proofs have a base (or terminating)
    case and an inductive step.
  • Mathematical induction over the space of
    integers
  • Structural induction over subsets of the space
    of Prolog Terms.
  • Many Prolog predicates have this structure
  • is_number(0).
  • is_number(s(Number)) - is_number(Number).

20
Show successor arithmetic example
21
BUILT-IN Predicate compile/1
  • compile(FileName)
  • Load the Prolog program in FileName into memory.

22
Homework
  • Learn how to run SICStus Prolog
  • Type in and query a small database problem
  • Read Chapters 12 of ClocksinMellish
  • Write predicates for successor arithmetic
  • exponential(Number, Exponent, ?Result)
  • factorial(Number, ?Factorial)
Write a Comment
User Comments (0)
About PowerShow.com