CSE 130 : Spring 2010 Programming Languages Lecture 16: Prolog Lecture 16: Prolog Ranjit Jhala UC San Diego Declarative Programming Declarative Programming Declare problem runtime finds solution Declare problem, runtime finds solution Given a graph of n cities, Fi d ih i i l h Find tour with minimum length Philosophy Writing constraints is easy (human) Writing constraints is easy (human) Writing search heuristic is hard (PL) History: Classical AI History: Classical AI Program = “Expert Databases” Program = Expert Databases Humans describe world as facts and rules System answers questions about world Example: Facts/rules about symptoms and diseases Questions about condition of some patient
9
Embed
Prolog CSE 130 : Spring 2010 16: Ranjit Jhala UC San Diego
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CSE 130 : Spring 2010
Programming Languages
Lecture 16: Prolog Lecture 16: Prolog
Ranjit JhalaUC San Diego
Declarative ProgrammingDeclarative Programming
Declare problem runtime finds solutionDeclare problem, runtime finds solutionGiven a graph of n cities, Fi d i h i i l hFind tour with minimum length
Philosophy Writing constraints is easy (human)Writing constraints is easy (human)Writing search heuristic is hard (PL)
History: Classical AIHistory: Classical AI
Program = “Expert Databases”Program = Expert DatabasesHumans describe world as facts and rulesSystem answers questions about world
Example:Facts/rules about symptoms and diseasesQuestions about condition of some patientQ p
Modern ApplicationsModern Applications
Scheduling Flights NBA Scheduling Flights, NBA, …
Database Queries SQL < Prolog
Config. Management Makefile
Distributed Systems ???Distributed Systems ???
H ll P lHello Prolog
Program Facts+Rules+QueriesProgram = Facts+Rules+Queries
No functions, statements, assignments…
Facts Rules QueriesFacts, Rules, Queries
are all built from
Terms
Constants Variables CompoundAtoms
TermsTerms
Constants Variables CompoundAtoms
TermsTerms
Constants Variables CompoundAtoms
TermsTerms
Constants Variables CompoundAtoms
TermsTerms
Constants Variables CompoundAtoms
TermsTerms
Terms Structured DataTerms = Structured Data
parent factorial
alice 5
alice bob 5
alice 5 parent(alice, bob) factorial(5)
Don’t “mean” anythingDon t mean anything
Facts Rules QueriesFacts, Rules, Queries
are all built from
Terms
Facts = Terms without VariablesFacts Terms without Variables