Intro to Prolog (notes only) Deduction Propositions: 1. Socrates is - - PowerPoint PPT Presentation

intro to prolog notes only
SMART_READER_LITE
LIVE PREVIEW

Intro to Prolog (notes only) Deduction Propositions: 1. Socrates is - - PowerPoint PPT Presentation

CS152 Programming Language Paradigms Prof. Tom Austin, Fall 2016 Intro to Prolog (notes only) Deduction Propositions: 1. Socrates is a man. 2. All men are mortal. Conclusion: Socrates is mortal About Prolog Pro gramming in Log ic


slide-1
SLIDE 1

CS152 – Programming Language Paradigms

  • Prof. Tom Austin, Fall 2016

Intro to Prolog

(notes only)

slide-2
SLIDE 2

Deduction

Propositions:

  • 1. Socrates is a man.
  • 2. All men are mortal.

Conclusion: Socrates is mortal

slide-3
SLIDE 3

About Prolog

  • Programming in Logic

– Logic: "The science of reasoning and proof"

  • A declarative programming language

– you specify what you want – the computer determines how to do it

  • A logical programming language

– Relies on deductive reasoning – Reach conclusion from premises

slide-4
SLIDE 4

References for Prolog

  • "Learn Prolog Now",

http://www.learnprolognow.org

  • SWI-Prolog website (contains manual and

tutorials), http://www.swi-prolog.org

  • "NLP with Prolog in the IBM Watson System",

http://www.cs.nmsu.edu/ALP/2011/03/natural- language-processing-with-prolog-in-the-ibm- watson-system/

slide-5
SLIDE 5

Facts

Socrates is a man. Helen is a woman. In Prolog:

man(socrates). woman(helen).

slide-6
SLIDE 6

Rules

Man is mortal. Woman is mortal. In Prolog:

mortal(X) :- man(X). mortal(X) :- woman(X).

X is a variable True if either statement matches.

slide-7
SLIDE 7

More facts and rules. married(socrates). married(helen). husband(Person) :- married(Person), man(Person).

comma is "and"

slide-8
SLIDE 8

Query: Is Socrates mortal?

?- mortal(socrates). true .

Prolog result in bold. The prompt

slide-9
SLIDE 9

Query: Who is mortal?

?- mortal(Person). Person = socrates ; Person = helen.

Hit semicolon for more results, period to quit.

slide-10
SLIDE 10

Lab: Murder Mystery

  • See Canvas for details.