Logic programming - PowerPoint PPT Presentation

About This Presentation
Title:

Logic programming

Description:

This program creates a small set of facts and rules on who is the ancestor of whom. ... parent(tina, sally). parent(sally, diane). parent(sam, bill). Logic ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 9
Provided by: Joh6294
Category:
Tags: logic | mff | programming | small | tina

less

Transcript and Presenter's Notes

Title: Logic programming


1
Logic programming
2
Introduction
  • To express program in symbolic logic
  • Also called declarative language
  • Only the specification of desired results are
    stated
  • State the form of the result rather than how a
    result is to be computed
  • Logic programming is a declarative approach of
    writing computer programs based on Logic

3
Brief history
  • 1970s
  • AI group
  • To specifying predicate calculus
  • Prolog

4
Predicate calculus
  • Proposition a logical statement that is true or
    not true
  • Formal logic describes proposition that allows
    them to be checked or validity

5
Logic Programming Example
  • Suppose we have the following sentences
  • CS student of NTHU must take the core course
    cs2403
  • A CS student can not obtain a degree without
    passing the required course
  • I am a CS student of NTHU and want to obtain a
    degree, should I pass cs2403?

6
  • / Filename ancestor.pro
  • This program creates a small set of facts and
    rules on who is the ancestor of whom. The user
    types the desired goal interactively when the
    program is run./
  • / ancestor(A, B) means A is an ancestor of B /
  • ancestor(bob, susan).
  • ancestor(A, X) - parent(A, X).
  • ancestor(A, X) - parent(A, C), ancestor(C, X).
  • / parent(P, C) means P is a parent of C /
  • parent(fred, sally).
  • parent(tina, sally).
  • parent(sally, diane).
  • parent(sam, bill).

7
Logic Programming Prolog Query
  • Queries
  • ancestor(fred, sally).
  • Yes
  • ancestor(fred, diane).
  • Yes
  • ancestor(fred, bill).
  • No

8
Logic Programming Reference
  • Book
  • Ralph P. Grimaldi, DISCRETE AND COMBINATORIAL
    MATHEMATICS, 5TH ED, Pearson Education, 2004
  • Ulf Nilsson and Jan Ma luszy_nski, LOGIC,
    PROGRAMMING AND PROLOG, 2ND ED, Ulf Nilsson and
    Jan Ma luszy_nski, 2000
  • Web
  • http//cis.stvincent.edu/carlsond/prolog.html
  • http//ktiml.mff.cuni.cz/bartak/prolog/index.html
  • http//www.cs.auckland.ac.nz/j-hamer/07.363/prolo
    g-for-se.html
  • http//www.swi-prolog.org/
Write a Comment
User Comments (0)
About PowerShow.com