Declarative Programming Some Prolog Examples - PowerPoint PPT Presentation

About This Presentation
Title:

Declarative Programming Some Prolog Examples

Description:

Faculty of Computer and Information Science. University of Ljubljana. Non-deterministic automaton ... automaton definition. final(s3). trans(s1, a, s1). trans ... – PowerPoint PPT presentation

Number of Views:100
Avg rating:3.0/5.0
Slides: 10
Provided by: aleksande8
Category:

less

Transcript and Presenter's Notes

Title: Declarative Programming Some Prolog Examples


1
Declarative ProgrammingSome Prolog Examples
  • Aleksander Sadikov, Ivan Bratko
  • Faculty of Computer and Information Science
  • University of Ljubljana

2
Non-deterministic automaton
b
a
a
null
null
b
b
3
  • automaton definition
  • final(s3).
  • trans(s1, a, s1).
  • trans(s1, a, s2).
  • trans(s1, b, s1).
  • trans(s2, b, s3).
  • trans(s3, b, s4).
  • silent(s2, s4).
  • silent(s3, s1).

4
Simulator
(a)
null
string
(c)
5
  • simulator definition
  • accepts(State, )-
  • final(State).
  • accepts(State, XRest)-
  • trans(State, X, State1),
  • accepts(State1, Rest).
  • accepts(State, String)-
  • silent(State, State1),
  • accepts(State1, String).

6
(No Transcript)
7
First Solution
  • generalize the number of queens start with no
    queens and add one by one
  • representation 1/Y1, 2/Y2, ..., 8/Y8
  • idea X/Y Others
  • no attacks within Others
  • Y is bounded to interval 1..8
  • queen X/Y must not attack any queen in Others

8
(No Transcript)
9
Second Solution
  • each queen is located at some square
  • to be safe it has to be on a separate
  • column, row, upward and downward diagonal
  • use a richer representation with four
    coordinates!
  • solution is thus select 8 4-tuples from their
    respective domains
  • the elements can be taken only once from the
    domains
Write a Comment
User Comments (0)
About PowerShow.com