SlideShare a Scribd company logo
1 of 17
CSE240 – Introduction to
Programming Languages
Lecture 22:
Programming with Prolog I
Javier Gonzalez-Sanchez
javiergs@asu.edu
javiergs.engineering.asu.edu
Office Hours: By appointment
Test Yourselves
LISP
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3
Example 1
; A function that return the leftmost even member."
(defun find-even (L)
(if (null L)
nil
(if (evenp (first L))
(first L)
(find-even (rest L))
)
)
)
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4
Example 2
; develop recursive functions that traverse a list
; and count its elements
(defun recursive-list-length (L)
(if (null L)
0
(1+ (recursive-list-length (rest L)))
)
)
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5
Example 3
; defines a function (get N L) that returns the N member
; of list L –assuming that the elements are numbered from ; zero
onwards
(defun get (N L)
(if (null L)
nil
(if (zerop N)
(first L)
(get (1- N) (rest L))
)
)
)
Logic Programming Paradigm
PROLOG
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 7
Paradigms
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8
Logic Paradigm
• It focus on what is needed (requirements), instead of how to
implement them. It just describe what the problem is and let the
computer find a way to solve the problem, instead describing how to
solve the problem.
• It rely on the environment to find solutions that meet requirements.
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 9
Predicate Logic
• It uses a simplified variation of predicate logic syntax, which is similar
to natural language.
• Predicate logic eliminate all unnecessary words from sentences, then
transform the sentence by placing the relationship (predicate) first
and grouping the objects (arguments) after the relationship
predicate (object, object, object ....)
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 10
Natural Language Predicate Logic Type of Predicate
A car is fast. fast(car). fact
A rose is red. red(rose). fact
Bill likes the car if the car is fast. likes(bill, car) :- fast(car). rule
Humidity is high if it rains high(humidity):- rains(). rule
Jane is mother of Elaine mother_of(jane, elaine). fact
Jane is mother of Mike mother_of(jane, mike). fact
David is father of Jesse father_of(david, jesse). fact
Jesse is father of Obed father_of(jesse, obed). fact
Grandmother X of Z if (X is mother of Y
and (Y is mother of Z or Y is father of Z)
grandmother_of(X, Z) :- mother_of(X, Y),
( mother_of(Y, Z); father_of(Y, Z) ).
rule
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 11
Predicate Logic
• Facts: What is known, e.g.,
Bill likes car and bike, and he travels with one of them
likes(bill, car), likes(bill, bike)
travels(bill, car); travels(bill, bike)
• Rules: What you can infer from the given facts. Rules enable you to
infer facts from other facts, e.g.,
Bill is the father of Joe, if Joe is the son of bill.
father(bill, joe) :- son(joe, bill).
, means AND
; means OR
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 12
Prolog
• PROLOG (PROgramming LOGic)
• Interpreter.
• Deductive database: set of statements and a deduction system.
• Facts and Rules
• Queries
• Upper-Case variables
• Lower-Case constants and names
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 13
Install a Prolog Interpreter
SWI - Prolog
http://www.swi-prolog.org/download/stable
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 14
Install a Prolog Interpreter
To enter rules from the command line, type this :
[user].
This puts you in a mode where you can enter facts and rules. Otherwise you get this kind of
message:
ERROR: Undefined procedure: (DWIM could not correct goal)
You can then enter facts (or rules) e.g. :
father(me,sarah).
After having entered the knowledge, type CONTROL-D to come back to the mode where you
can enter questions. Then you can ask:
?- father(me,X).
X = sarah
To quit:
halt.
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 15
Online Prolog Interpreter
Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 16
Summary
Logic/Declarative Paradigm
Key idea:
A program is a set of facts about
objects,
rules about objects, and questions
(queries) about the relations between
objects.
Features:
• get rid of programming altogether.
CSE240 – Introduction to Programming Languages
Javier Gonzalez-Sanchez
javiergs@asu.edu
Fall 2017
Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.

More Related Content

Similar to 201801 CSE240 Lecture 22

Similar to 201801 CSE240 Lecture 22 (20)

201707 CSE110 Lecture 05
201707 CSE110 Lecture 05   201707 CSE110 Lecture 05
201707 CSE110 Lecture 05
 
201801 CSE240 Lecture 21
201801 CSE240 Lecture 21201801 CSE240 Lecture 21
201801 CSE240 Lecture 21
 
201707 CSE110 Lecture 08
201707 CSE110 Lecture 08  201707 CSE110 Lecture 08
201707 CSE110 Lecture 08
 
201707 CSE110 Lecture 04
201707 CSE110 Lecture 04   201707 CSE110 Lecture 04
201707 CSE110 Lecture 04
 
Claire98
Claire98Claire98
Claire98
 
Fp
FpFp
Fp
 
Stochastic Processes Homework Help
Stochastic Processes Homework HelpStochastic Processes Homework Help
Stochastic Processes Homework Help
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
 
201801 CSE240 Lecture 19
201801 CSE240 Lecture 19201801 CSE240 Lecture 19
201801 CSE240 Lecture 19
 
Pl vol1
Pl vol1Pl vol1
Pl vol1
 
201707 CSE110 Lecture 15
201707 CSE110 Lecture 15   201707 CSE110 Lecture 15
201707 CSE110 Lecture 15
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2
 
10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prolog
 
201801 CSE240 Lecture 01
201801 CSE240 Lecture 01201801 CSE240 Lecture 01
201801 CSE240 Lecture 01
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
Word2vec slide(lab seminar)
Word2vec slide(lab seminar)Word2vec slide(lab seminar)
Word2vec slide(lab seminar)
 
Introduction to lambda calculus
Introduction to lambda calculusIntroduction to lambda calculus
Introduction to lambda calculus
 
Types Working for You, Not Against You
Types Working for You, Not Against YouTypes Working for You, Not Against You
Types Working for You, Not Against You
 
Prolog 7-Languages
Prolog 7-LanguagesProlog 7-Languages
Prolog 7-Languages
 
Pl vol1
Pl vol1Pl vol1
Pl vol1
 

More from Javier Gonzalez-Sanchez (20)

201804 SER332 Lecture 01
201804 SER332 Lecture 01201804 SER332 Lecture 01
201804 SER332 Lecture 01
 
201801 SER332 Lecture 03
201801 SER332 Lecture 03201801 SER332 Lecture 03
201801 SER332 Lecture 03
 
201801 SER332 Lecture 04
201801 SER332 Lecture 04201801 SER332 Lecture 04
201801 SER332 Lecture 04
 
201801 SER332 Lecture 02
201801 SER332 Lecture 02201801 SER332 Lecture 02
201801 SER332 Lecture 02
 
201801 CSE240 Lecture 26
201801 CSE240 Lecture 26201801 CSE240 Lecture 26
201801 CSE240 Lecture 26
 
201801 CSE240 Lecture 25
201801 CSE240 Lecture 25201801 CSE240 Lecture 25
201801 CSE240 Lecture 25
 
201801 CSE240 Lecture 20
201801 CSE240 Lecture 20201801 CSE240 Lecture 20
201801 CSE240 Lecture 20
 
201801 CSE240 Lecture 18
201801 CSE240 Lecture 18201801 CSE240 Lecture 18
201801 CSE240 Lecture 18
 
201801 CSE240 Lecture 17
201801 CSE240 Lecture 17201801 CSE240 Lecture 17
201801 CSE240 Lecture 17
 
201801 CSE240 Lecture 16
201801 CSE240 Lecture 16201801 CSE240 Lecture 16
201801 CSE240 Lecture 16
 
201801 CSE240 Lecture 15
201801 CSE240 Lecture 15201801 CSE240 Lecture 15
201801 CSE240 Lecture 15
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 
201801 CSE240 Lecture 13
201801 CSE240 Lecture 13201801 CSE240 Lecture 13
201801 CSE240 Lecture 13
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
 
201801 CSE240 Lecture 11
201801 CSE240 Lecture 11201801 CSE240 Lecture 11
201801 CSE240 Lecture 11
 
201801 CSE240 Lecture 10
201801 CSE240 Lecture 10201801 CSE240 Lecture 10
201801 CSE240 Lecture 10
 
201801 CSE240 Lecture 09
201801 CSE240 Lecture 09201801 CSE240 Lecture 09
201801 CSE240 Lecture 09
 
201801 CSE240 Lecture 08
201801 CSE240 Lecture 08201801 CSE240 Lecture 08
201801 CSE240 Lecture 08
 
201801 CSE240 Lecture 07
201801 CSE240 Lecture 07201801 CSE240 Lecture 07
201801 CSE240 Lecture 07
 
201801 CSE240 Lecture 06
201801 CSE240 Lecture 06201801 CSE240 Lecture 06
201801 CSE240 Lecture 06
 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 

Recently uploaded (20)

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 

201801 CSE240 Lecture 22

  • 1. CSE240 – Introduction to Programming Languages Lecture 22: Programming with Prolog I Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu Office Hours: By appointment
  • 3. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 3 Example 1 ; A function that return the leftmost even member." (defun find-even (L) (if (null L) nil (if (evenp (first L)) (first L) (find-even (rest L)) ) ) )
  • 4. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 4 Example 2 ; develop recursive functions that traverse a list ; and count its elements (defun recursive-list-length (L) (if (null L) 0 (1+ (recursive-list-length (rest L))) ) )
  • 5. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 5 Example 3 ; defines a function (get N L) that returns the N member ; of list L –assuming that the elements are numbered from ; zero onwards (defun get (N L) (if (null L) nil (if (zerop N) (first L) (get (1- N) (rest L)) ) ) )
  • 7. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 7 Paradigms
  • 8. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 8 Logic Paradigm • It focus on what is needed (requirements), instead of how to implement them. It just describe what the problem is and let the computer find a way to solve the problem, instead describing how to solve the problem. • It rely on the environment to find solutions that meet requirements.
  • 9. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 9 Predicate Logic • It uses a simplified variation of predicate logic syntax, which is similar to natural language. • Predicate logic eliminate all unnecessary words from sentences, then transform the sentence by placing the relationship (predicate) first and grouping the objects (arguments) after the relationship predicate (object, object, object ....)
  • 10. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 10 Natural Language Predicate Logic Type of Predicate A car is fast. fast(car). fact A rose is red. red(rose). fact Bill likes the car if the car is fast. likes(bill, car) :- fast(car). rule Humidity is high if it rains high(humidity):- rains(). rule Jane is mother of Elaine mother_of(jane, elaine). fact Jane is mother of Mike mother_of(jane, mike). fact David is father of Jesse father_of(david, jesse). fact Jesse is father of Obed father_of(jesse, obed). fact Grandmother X of Z if (X is mother of Y and (Y is mother of Z or Y is father of Z) grandmother_of(X, Z) :- mother_of(X, Y), ( mother_of(Y, Z); father_of(Y, Z) ). rule
  • 11. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 11 Predicate Logic • Facts: What is known, e.g., Bill likes car and bike, and he travels with one of them likes(bill, car), likes(bill, bike) travels(bill, car); travels(bill, bike) • Rules: What you can infer from the given facts. Rules enable you to infer facts from other facts, e.g., Bill is the father of Joe, if Joe is the son of bill. father(bill, joe) :- son(joe, bill). , means AND ; means OR
  • 12. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 12 Prolog • PROLOG (PROgramming LOGic) • Interpreter. • Deductive database: set of statements and a deduction system. • Facts and Rules • Queries • Upper-Case variables • Lower-Case constants and names
  • 13. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 13 Install a Prolog Interpreter SWI - Prolog http://www.swi-prolog.org/download/stable
  • 14. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 14 Install a Prolog Interpreter To enter rules from the command line, type this : [user]. This puts you in a mode where you can enter facts and rules. Otherwise you get this kind of message: ERROR: Undefined procedure: (DWIM could not correct goal) You can then enter facts (or rules) e.g. : father(me,sarah). After having entered the knowledge, type CONTROL-D to come back to the mode where you can enter questions. Then you can ask: ?- father(me,X). X = sarah To quit: halt.
  • 15. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 15 Online Prolog Interpreter
  • 16. Javier Gonzalez-Sanchez | CSE 240 | Fall 2017 | 16 Summary Logic/Declarative Paradigm Key idea: A program is a set of facts about objects, rules about objects, and questions (queries) about the relations between objects. Features: • get rid of programming altogether.
  • 17. CSE240 – Introduction to Programming Languages Javier Gonzalez-Sanchez javiergs@asu.edu Fall 2017 Disclaimer. These slides can only be used as study material for the class CSE240 at ASU. They cannot be distributed or used for another purpose.