CS 360: Programming Language Concepts Lecture 15 Logic Programming
|
|
- Bernice Boone
- 5 years ago
- Views:
Transcription
1 Reference: Ch CS 360: Programming Language Concepts Lecture 15 Logic Programming I. Logic Programming (Generally) What is logic programming? A logic program is a collection of declarations, i.e. things that are true A logic program is executed by running queries against the program Most logic programing languages incorporate unification and backtracking What are some examples of logic programming languages? Prolog SQL Mercury ( Why would anyone program in a logic programming language? II. Prolog Many complex problems can be expressed as a queries against a set of declarations Unification and backtracking are applicable to a wide range of problems Example: the pegs game ( Overview of Prolog Untyped Uses top-down resolution, or backward-chaining Uses depth-first search 1
2 Syntax clause-seq clause clause-seq clause term opt-clause-tail. opt-clause-tail :- term-list term-list term, term-list term term CONST opt-args opt-args ( expr-list ) expr-list expr, expr-list expr expr [ opt-expr-list opt-list-tail ] ILIT CONST VAR _ opt-expr-list expr-list opt-list-tail expr ILIT = (SIGN ) DIGIT DIGIT VAR = UCHAR (UCHAR LCHAR _) CONST = LCHAR (UCHAR LCHAR _) SIGN = + - DIGIT = UCHAR = A... Z LCHAR = a... z The above is actually the syntax of programs. followed by a period (.). A query is just a term 2
3 Loading the file example.pl. [ example.pl ]. The Simpsons person(bart).?- person(bart).?- person(lisa).?- person(x). % X = bart Fathers and mothers father(grampa,homer). father(homer,bart). father(homer,lisa). father(homer,maggie). mother(marge,bart). mother(marge,lisa). mother(marge,maggie).?- father(homer,x). % X = bart?- mother(x,bart). % X = marge Parents parent(x,y) :- father(x,y). parent(x,y) :- mother(x,y).?- parent(x,bart). % X = homer? ; % X = marge 3
4 Mates (slightly broken) mated(x,y) :- father(x,z), mother(y,z).?- mated(homer,x). % X = marge? ; % X = marge? ; % X = marge?- mated(bart,x).?- mated(marge,x). Mates (slightly broken, but in a different way) mated(x,y) :- parent(x,z), parent(y,z).?- mated(homer,x). % X = homer? Mates (very broken) mated(x,y) :- father(x,z), mother(y,z). mated(x,y) :- mated(y,x).?- mated(homer,x). % X = marge??- mated(marge,x). % X = homer??- mated(bart,x). % hangs 4
5 Mates (fixed) mated(x,y) :- father(x,z), mother(y,z). mated(x,y) :- mother(x,z), father(y,z).?- mated(homer,x). % X = marge??- mated(marge,x). % X = homer??- mated(bart,x). Ancestors (broken) ancestor(x,y) :- parent(x,y). ancestor(x,y) :- ancestor(x,z), parent(z,y).?- ancestor(grampa,bart). % true??- ancestor(grampa,marge). % Fatal Error: local stack overflow... Ancestors (fixed) ancestor(x,y) :- parent(x,y). ancestor(x,y) :- parent(z,y), ancestor(x,z).?- ancestor(grampa,bart). % true??- ancestor(grampa,marge). 5
6 Lists member(x,[x _]). member(x,[_ YS]) :- member(x,ys).?- member(b,[a,b,c,d]).?- member(e,[a,b,c,d]). append([],ys,ys). append([x XS],YS,[X ZS]) :- append(xs,ys,zs).?- append([],[c,d],xs). % XS = [c,d]?- append([a,b],[c,d],xs). % XS = [a,b,c,d]?- append(xs,ys,[a,b,c,d]). % XS = [] % YS = [a,b,c,d]? ; % XS = [a] % YS = [b,c,d]? ; % XS = [a,b] % YS = [c,d]? ; % XS = [a,b,c] % YS = [d]? ; % XS = [a,b,c,d] % YS = []? ; 6
7 Insert-1 Insert-2 insert(x,ys,[x YS]). insert(x,[y YS],[Y ZS]) :- insert(x,ys,zs).?- insert(a,[b,c,d],xs). % XS = [a,b,c,d]? ; % XS = [b,a,c,d]? ; % XS = [b,c,a,d]? ; % XS = [b,c,d,a]? ;?- insert(x,ys,[a,b,c,d]). % X = a % YS = [b,c,d]? ; % X = b % YS = [a,c,d]? ; % X = c % YS = [a,b,d]? ; % X = d % YS = [a,b,c]? ; Arithmetic Predicates (<, =<, >, >=)?- 1 < 2.?- X < 2. % uncaught exception: error(instantiation_error,(<)/2) Permutations Permute-1 Permute-2 permute([],[]). permute([x XS],YS) :- permute(xs,zs), insert(x,zs,ys). Derivation tree for permute([a,b],[b,a]). (on following page) 7
8 Sorting (inefficient) sorted([]). sorted([_]). sorted([xa,xb XS]) :- XA =< XB, sorted([xb XS]). sort(xs,ys) :- permute(xs,ys), sorted(ys).?- sort([7,3,1,5,9],xs). % XS = [1,3,5,7,9]? Quick Sort qsort([],[]). qsort([x XS],YS) :- partition(x,xs,vs1,ws1), qsort(vs1,vs2), qsort(ws1,ws2), append(vs2,[x WS2],YS). partition(_,[],[],[]). partition(w,[x XS],[X YS],ZS) :- X < W, partition(w,xs,ys,zs). partition(w,[x XS],YS,[X ZS]) :- X >= W, partition(w,xs,ys,zs). Merge Sort msort([],[]). msort([x],[x]). msort([xa,xb XS],YS) :- split([xa,xb XS],VS1,WS1), msort(vs1,vs2), msort(ws1,ws2), merge(vs2,ws2,ys). split([],[],[]). split([x],[x],[]). split([xa,xb XS],[XA YS],[XB ZS]) :- split(xs,ys,zs). merge([],ys,ys). merge(xs,[],xs). merge([x XS],[Y YS],[X ZS]) :- X < Y, merge(xs,[y YS],ZS). merge([x XS],[Y YS],[Y ZS]) :- X >= Y, merge([x XS],YS,ZS). 8
9 Cut (!) assoc(x,[[x,y] _],Y). assoc(x,[_ YS],Z) :- assoc(x,ys,z). lookup(x,y) :- assoc(x,[[break,statement],[double,type], [int,type],[return,statement]],y),!. lookup(_,identifier). lookup(double,x). % X = type lookup(return,x). % X = statement lookup(filename,x). % X = identifier lookup(x,statement). % X = break What happened to return? 9
CS 360: Programming Languages Lecture 10: Logic Programming with Prolog
CS 360: Programming Languages Lecture 10: Logic Programming with Prolog Geoffrey Mainland Drexel University Section 1 Administrivia Midterm Tuesday Midterm is Tuesday, February 14! Study guide is on the
More informationChapter 5. Pure PROLOG. Foundations of Logic Programming
Chapter 5 1 Outline vs. logic programming Lists in Adding Arithmetics to Adding the Cut to 2 Syntax of Pure Prolog p(x,a) :- q(x), r(x,yi). p(x, a) q(x), r(x,y i ) % Comment Ambivalent syntax: p(p(a,b),
More informationLogic programming I. Henrik Boström Stockholm University. Facts Queries Rules Terms Recursion Lists Negation
Logic programming I Henrik Boström Stockholm University Facts Queries Rules Terms Recursion Lists Negation Logic programs A logic program consists of facts and rules. A logic program is executed by responding
More informationChapter 16. Logic Programming. Topics. Unification. Resolution. Prolog s Search Strategy. Prolog s Search Strategy
Topics Chapter 16 Logic Programming Summary (resolution, unification, Prolog search strategy ) Disjoint goals The cut operator Negative goals Predicate fail Debugger / tracer Lists 2 Resolution Resolution
More informationComputational Logic Prolog Programming Basics
Computational Logic Prolog Programming Basics 1 Overview 1. Using unification 2. Data structures 3. Recursion, backtracking, and search 4. Control of execution 2 Role of Unification in Execution As mentioned
More informationProlog Programming Basics. Computational Logic. Overview. 3. Recursion, backtracking, and search. 2. Data structures. 1.
Computational Logic Prolog Programming Basics 1 Overview 1. Using unification 2. Data structures 3. Recursion, backtracking, and search 4. Control of execution 2 Role of Unification in Execution As mentioned
More information1 / Types and Programming Languages
1 / 65 263-2200 Types and Programming Languages 2 / 65 Outline Control Flow During Execution Tree Traversal A Detailed Trace Search Space Analysis Modelling Equations and Operations Lists 3 / 65 Outline
More informationAn introduction to Prolog. P. Cabalar ( Department Prolog of Computer Science University of Corunna, FebruarySPAIN 8, 2016)
An introduction to Prolog Pedro Cabalar Department of Computer Science University of Corunna, SPAIN February 8, 2016 P. Cabalar ( Department Prolog of Computer Science University of Corunna, FebruarySPAIN
More informationsimplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion procedural and declarative semantics and & or
simplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion simple and/or composition of goals hides complex control patterns not easily represented by traditional
More informationShell CSCE 314 TAMU. Functions continued
1 CSCE 314: Programming Languages Dr. Dylan Shell Functions continued 2 Outline Defining Functions List Comprehensions Recursion 3 A Function without Recursion Many functions can naturally be defined in
More informationLogic Programming: Lecture 1
Logic Programming: Lecture 1 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in PLC, 3 April 2017 Logic programming Programming with relations Variables Names starting with a capital letter
More informationsimplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion procedural and declarative semantics and & or
simplicity hides complexity flow of control, negation, cut, 2 nd order programming, tail recursion simple and/or composition of goals hides complex control patterns not easily represented by traditional
More informationChapter 1. An introduction to Prolog
Chapter 1. An introduction to Prolog Pedro Cabalar Dept. Computación University of Corunna, SPAIN February 7, 2011 P. Cabalar ( Dept. Ch1. Computación Prolog University of Corunna, SPAIN February ) 7,
More informationCOP4020 Programming Languages. Logical programming with Prolog Prof. Xin Yuan
COP4020 Programming Languages Logical programming with Prolog Prof. Xin Yuan Topics Logic programming with Prolog COP4020 Spring 2013 2 Definitions: Prolog Terms Terms are symbolic expressions that are
More informationPROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions
PROGRAMMING IN HASKELL CS-205 - Chapter 6 - Recursive Functions 0 Introduction As we have seen, many functions can naturally be defined in terms of other functions. factorial :: Int Int factorial n product
More informationSymbolic Programming Declarative Programming
CS370 Symbolic Programming Declarative Programming LECTURE 2: Introduction to Prolog park@cs.kaist.ac.kr Computer Science Department Korea Advanced Institute of Science and Technology http://nlp.kaist.ac.kr/~cs370
More informationdocumenting programs, including: A traditional, command line interactive top level.
Computational Logic Developing Programs with a Logic Programming System 1 Our Development Environment: The Ciao System We use the (ISO-Prolog subset of the) Ciao multiparadigm programming system. In particular,
More information10 Recursive Programming in Prolog
10 Recursive Programming in Prolog What's in This Set of Notes? Examples Transforming Recursion to Iteration Recursive Comparison Joining Structures Accumulators Mapping Problems 10.1 Examples select_first(x,xs,ys)
More informationLogic Programming Languages
Logic Programming Languages Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical inferencing process to
More informationProlog. Intro to Logic Programming
Prolog Logic programming (declarative) Goals and subgoals Prolog Syntax Database example rule order, subgoal order, argument invertibility, backtracking model of execution, negation by failure, variables
More informationProgramming Language Concepts: Lecture 22
Programming Language Concepts: Lecture 22 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 22, 15 April 2009 Logic programming
More information10. Logic Programming With Prolog
Copyright (C) R.A. van Engelen, FSU Department of Computer Science, 2000 10. Logic Programming With Overview Logic Programming Logic Programming Logic programming is a form of declarative programming A
More informationChapter 16. Logic Programming Languages
Chapter 16 Logic Programming Languages Chapter 16 Topics Introduction A Brief Introduction to Predicate Calculus Predicate Calculus and Proving Theorems An Overview of Logic Programming The Origins of
More informationIN112 Mathematical Logic
Institut Supérieur de l Aéronautique et de l Espace IN112 Mathematical Logic Lab session on Prolog Christophe Garion DMIA ISAE Christophe Garion IN112 IN112 Mathematical Logic 1/ 31 License CC BY-NC-SA
More informationIntroduction to predicate calculus
Logic Programming Languages Logic programming systems allow the programmer to state a collection of axioms from which theorems can be proven. Express programs in a form of symbolic logic Use a logical
More informationAnnouncements. References. Selinger Optimizer History. More about the Selinger Algorithm. Selinger Algorithm. CSE 444: Database Internals
Announcements CSE 444: Database Internals Lab 2 deadline EXTENDED by 24 hours Lab 2 quiz moved to Monday Lecture 12 Query Optimization (part 3) 1 2 Selinger Optimizer History References 1960 s: first database
More informationCS 4700: Artificial Intelligence
CS 4700: Foundations of Artificial Intelligence Fall 2017 Instructor: Prof. Haym Hirsh Lecture 16 Cornell Cinema Thursday, April 13 7:00pm Friday, April 14 7:00pm Sunday, April 16 4:30pm Cornell Cinema
More informationCOMP219: Artificial Intelligence. Lecture 6: Recursion in Prolog
COMP219: Artificial Intelligence Lecture 6: Recursion in Prolog 1 Overview Last time Introduction to Prolog: facts, rules, queries; family tree program Today: Recursive rules in Prolog; writing and evaluating
More informationIN112 Mathematical Logic
Institut Supérieur de l Aéronautique et de l Espace IN112 Mathematical Logic Lab session on Prolog Christophe Garion DMIA ISAE Christophe Garion IN112 IN112 Mathematical Logic 1/ 31 License CC BY-NC-SA
More informationChapter 16. Logic Programming Languages ISBN
Chapter 16 Logic Programming Languages ISBN 0-321-49362-1 Chapter 16 Topics Introduction A Brief Introduction to Predicate Calculus Predicate Calculus and Proving Theorems An Overview of Logic Programming
More informationChapter 16. Logic Programming Languages ISBN
Chapter 16 Logic Programming Languages ISBN 0-321-49362-1 Chapter 16 Topics Introduction A Brief Introduction to Predicate Calculus Predicate Calculus and Proving Theorems An Overview of Logic Programming
More informationAgenda. CS301 Session 20. A logic programming trick. A simple Prolog program. Introduction to logic programming Examples Semantics
CS301 Session 20 Introduction to logic programming Examples Semantics Agenda 1 2 A logic programming trick A two-way translator in two lines of code: translate([],[]). translate([word Words],[Mot Mots])
More informationThe Idea Underlying Logic Programming. CSci 8980, Fall 2012 Specifying and Reasoning About Computational Systems An Introduction to Logic Programming
The Idea Underlying CSci 8980, Fall 2012 Specifying and Reasoning About Computational Systems An Introduction to Department of Computer Science and Engineering University of Minnesota Lectures in Fall
More information/425 Declarative Methods Assignment 3: (Constraint) Logic Programming
600.325/425 Declarative Methods Assignment 3: (Constraint) Logic Programming Spring 2017 Prof. Jason Eisner Due date: Friday, April 7, 2 pm This assignment consists of some simple programming exercises.
More informationITS336 Lecture 7 Prolog
Lecture 7 Prolog Prolog is a language for logic programming. Its concept is based on the First Order Logic. 7.1 Prolog Syntax Constant Symbols a word starting with a lowercase letter, or numbers e.g. john,
More informationUNIVERSITETET I OSLO
Exam in INF3110, December 12, 2013 Page 1 UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Exam in: INF3110 Programming Languages Day of exam: December 12, 2013 Exam hours: 14:30 18:30
More informationCSC4504/Prolog. : Formal Languages & Applications. J Paul Gibson, D311. An Introduction To Prolog
CSC4504/Prolog. : Formal Languages & Applications J Paul Gibson, D311 paul.gibson@telecom-sudparis.eu http://www-public.telecom-sudparis.eu/~gibson/teaching/csc4504/ An Introduction To Prolog /~gibson/teaching/csc4504/problem8-prolog.pdf
More informationLogic Programming. CITS 3242 Programming Paradigms. Topic 16: Part IV: Advanced Topics
CITS 3242 Programming Paradigms Part IV: Advanced Topics Topic 16: Logic Programming Logic Programming is a paradigm for programming by declaring facts and rules. Programs are executed by querying whether
More informationCPS 506 Comparative Programming Languages. Programming Language Paradigm
CPS 506 Comparative Programming Languages Logic Programming Language Paradigm Topics Introduction A Brief Introduction to Predicate Calculus Predicate Calculus and Proving Theorems An Overview of Logic
More informationFamily Example: Some Facts. respects(barb,dan). respects(barb,katie). respects(dan,brian). respects(dan,barbara).
Family Example: Some Facts respects(barb,dan). respects(barb,katie). respects(dan,brian). respects(dan,barbara). Some Queries?- respects(barb,katie). yes?- respects(barb,x). X=dan; % you type ; and RETURN
More informationProgramming Language Concepts (20013) Preparation for the Final Exam
Programming Language Concepts (20013 Preparation for the Final Exam This is a collection of 12 questions which are close to what is to be expected within the final exams for PLC. Attached are sample solutions.
More informationwill take you everywhere.
Prolog COMP360 Logic will get you from A to B. Imagination will take you everywhere. Albert Einstein Prolog Assignment A programming assignment in Prolog has been posted on Blackboard Upload your.pl file
More informationProlog. Prolog: Programmation en Logique R.A. Kowalski: Predicate logic as a programming language, Proc IFIP 1974, pp.
Prolog Prolog: Programmation en Logique 1974 - R.A. Kowalski: Predicate logic as a programming language, Proc IFIP 1974, pp. 569-574: First-order predicate logic for the specification of data and relationships
More informationCSC384: Intro to Artificial Intelligence Prolog Tutorials 3&4. Hojjat Ghaderi, Fall 2006, University of Toronto
CSC384: Intro to Artificial Intelligence Prolog Tutorials 3&4 1 Debugging Programs in Prolog We talked about the graphical debugger under Windows. Now, the text-based debugger: You can put a breakpoint
More informationProgramming in Prolog. CSE 505 Computing with Logic Stony Brook University
Programming in Prolog CSE 505 Computing with Logic Stony Brook University http://www.cs.stonybrook.edu/~cse505 1 Relations/Predicates Predicates are building-blocks in predicate calculus: p(a 1,a 2,...,a
More informationCSEN403 Concepts of Programming Languages. Topics: Logic Programming Paradigm: PROLOG Search Tree Recursion Arithmetic
CSEN403 Concepts of Programming Languages Topics: Logic Programming Paradigm: PROLOG Search Tree Recursion Arithmetic Prof. Dr. Slim Abdennadher 8.2.2015 c S. Abdennadher 1 Logic Programming versus Prolog
More informationLogic Languages. CSE 307 Principles of Programming Languages Stony Brook University
Logic Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Languages Paradigms of Programming Languages: Imperative = Turing machines Functional
More informationPlan of the lecture. G53RDB: Theory of Relational Databases Lecture 14. Example. Datalog syntax: rules. Datalog query. Meaning of Datalog rules
Plan of the lecture G53RDB: Theory of Relational Databases Lecture 14 Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk More Datalog: Safe queries Datalog and relational algebra Recursive
More informationBrief Introduction to Prolog
CSC384: Intro to Artificial Intelligence Brief Introduction to Prolog Prolog Programming for Artificial Intelligence by Ivan Bratko. Prolog is a language that is useful for doing symbolic and logic based
More informationLecture 9: A closer look at terms
Lecture 9: A closer look at terms Theory Introduce the == predicate Take a closer look at term structure Introduce strings in Prolog Introduce operators Exercises Exercises of LPN: 9.1, 9.2, 9.3, 9.4,
More informationLogic Programming: Recursion, lists, data structures
O Y Logic Programming: ecursion, lists, data structures Alan maill ep 28 2015 Alan maill Logic Programming: ecursion, lists, data structures ep 28 2015 1/28 oday Y ecursion proof search practical concerns
More informationCombining Lists & Built-in Predicates
Combining Lists & Built-in Predicates Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 6 11/10/04 11/10/04 AIPP Lecture 6: Built-in Predicates 1 Collecting Results Last time we
More informationModule 7. Knowledge Representation and Logic (Rule based Systems) Version 2 CSE IIT, Kharagpur
Module 7 Knowledge Representation and Logic (Rule based Systems) Lesson 18 Rule based Systems - II 7.2.5 Programs in PROLOG These minimal notes on Prolog show only some of its flavor. Here are facts plays(ann,fido).
More informationUsing Prolog as a CAS
Using Prolog as a CAS Kharkiv Pedagogical University A. Stolyarevska July 2002 References 1) Robinson J.A. A machine-oriented logic based on the resolution principle. J. ACM, 12, 23-41. 2) Colmerauer A.
More informationCS 321 Programming Languages and Compilers. Prolog
CS 321 Programming Languages and Compilers Prolog Prolog PROgramming LOGic Algorithm = Logic + Control Logic programming deals with computing relations rather than functions. To understand Prolog one must
More informationTopic 1: Introduction to Knowledge- Based Systems (KBSs)
Topic 1: Introduction to Knowledge- Based Systems (KBSs) 1.5 Introduction to Logic Programming (Prolog) 32 Simple example: Algorithm for checking sorted list? We all know how to check if a list is sorted:
More informationA Second Look At ML. Chapter Seven Modern Programming Languages, 2nd ed. 1
A Second Look At ML Chapter Seven Modern Programming Languages, 2nd ed. 1 Outline Patterns Local variable definitions A sorting example Chapter Seven Modern Programming Languages, 2nd ed. 2 Two Patterns
More informationprolog :-in(2016). 1
prolog :-in(2016). 1 Prolog Based on first-order predicate calculus Allow Horn clauses (a subset of predicate calculus) only ExecuEon of a Prolog program is an applicaeon of theorem proving Original moevaeon:
More informationLogic Programming. Efficiency Issues. Temur Kutsia
Logic Programming Efficiency Issues Temur Kutsia Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria kutsia@risc.uni-linz.ac.at Efficiency Issues in Prolog Narrow the
More informationSyntax and Meaning of Prolog Programs
Chapter 2 Syntax and Meaning of Prolog Programs Data Objects Matching Declarative meaning of Prolog programs Procedural meaning Example : monkey and banana Order of clauses and goals The relation between
More informationWeek 7 Prolog overview
Week 7 Prolog overview A language designed for A.I. Logic programming paradigm Programmer specifies relationships among possible data values. User poses queries. What data value(s) will make this predicate
More informationTeaching Prolog and CLP
Teaching Prolog and CLP Ulrich Neumerkel Institut für Computersprachen Technische Universität Wien www.complang.tuwien.ac.at/ulrich/ I The magic of Prolog Common obstacles II Reading of programs III Course
More informationLogic Programming. fac(n-1,m) fac(n,n m) fac(1,1) ex) factorial program query. cf) in procedural programming. ?- fac(5,120). yes?- fac(5,x).
Logic Programming Logic Programming = ex) factorial program query fac(1,1) fac(n-1,m) fac(n,n m)?- fac(5,120). yes?- fac(5,x). X=120 cf) in procedural programming x=1; for (i=1;i
More informationPrinciples of Programming Languages Topic: Logic Programming Professor Lou Steinberg
Principles of Programming Languages Topic: Logic Programming Professor Lou Steinberg 1 Logic Programming True facts: If I was born in year B, then in year Y on my birthday I turned Y-B years old I turned
More informationAdvanced Logic and Functional Programming
Advanced Logic and Functional Programming Lecture 1: Programming paradigms. Declarative programming. From first-order logic to Logic Programming. Programming paradigms Programming paradigm (software engineering)
More informationLecture 16: Logic Programming in Prolog
Lecture 16: Logic Programming in Prolog COMP 524 Programming Language Concepts Stephen Olivier March 26, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts Goal of
More informationFirst-Order Logic (FOL)
First-Order Logic (FOL) FOL consists of the following parts: Objects/terms Quantified variables Predicates Logical connectives Implication Objects/Terms FOL is a formal system that allows us to reason
More informationWhat is all the Fuzz about?
What is all the Fuzz about? Fuzzy Systems: Introduction CPSC 533 Christian Jacob Dept. of Computer Science Dept. of Biochemistry & Molecular Biology University of Calgary Fuzzy Systems in Knowledge Engineering
More informationACSC300: Logic Programming
ACSC300: Logic Programming Lecture 1: Introduction to Logic Programming and Prolog Harris Papadopoulos Course Aims This course aims to help you to: Understand a radically different programming paradigm:
More informationNotes for Chapter 12 Logic Programming. The AI War Basic Concepts of Logic Programming Prolog Review questions
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions The AI War How machines should learn: inductive or deductive? Deductive: Expert => rules =>
More informationProlog. Prolog. Based on first- order predicate calculus
Prolog 1 Prolog Based on first- order predicate calculus Allow Horn clauses (a subset of predicate calculus) only Execu@on of a Prolog program is an applica@on of theorem proving Original mo@va@on: study
More informationProlog. Express programs in a form of symbolic logic and use a logical inferencing process to produce results
Prolog Based on first- order predicate calculus Allow Horn clauses (a subset of predicate calculus) only Execu@on of a Prolog program is an applica@on of theorem proving Prolog Original mo@va@on: study
More information3 Lists. List Operations (I)
3 Lists. List Operations (I) The list is the simplest yet the most useful Prolog structure. A list is a sequence of any number of objects. Example 3.1: L = [1, 2, 3], R = [a, b, c], T = [john, marry, tim,
More informationThe Prolog to Mercury transition guide
The Prolog to Mercury transition guide Version 14.01.1 Thomas Conway Zoltan Somogyi Fergus Henderson Copyright c 1995 2014 The University of Melbourne. Permission is granted to make and distribute verbatim
More informationLogic Languages. Hwansoo Han
Logic Languages Hwansoo Han Logic Programming Based on first-order predicate calculus Operators Conjunction, disjunction, negation, implication Universal and existential quantifiers E A x for all x...
More informationDerived from PROgramming in LOGic (1972) Prolog and LISP - two most popular AI languages. Prolog programs based on predicate logic using Horn clauses
Prolog Programming Derived from PROgramming in LOGic (1972) Good at expressing logical relationships between concepts Prolog and LISP - two most popular AI languages Execution of a Prolog program is a
More informationLecture 11: Feb. 10, 2016
CS323: AI (Hands on with Prolog) Spring 2016 Lecturer: K.R. Chowdhary Lecture 11: Feb. 10, 2016 : Professor of CS (VF) Disclaimer: These notes have not been subjected to the usual scrutiny reserved for
More informationPROgramming in LOGic PROLOG Recursion, Lists & Predicates
PROgramming in LOGic PROLOG Recursion, Lists & Predicates CSC9Y4 1 Recursion Recursion in Prolog means placing in the body of a rule a call to the predicate which occurs in the head of the rule. Here is
More informationLecture Notes on Prolog
Lecture Notes on Prolog 15-317: Constructive Logic Frank Pfenning Lecture 14 October 15, 2009 In this lecture we introduce some simple data structures such as lists, and simple algorithms on them such
More informationConnection between Lists and Terms. Prolog-Lecture 2. Unifying Lists. Unifying Lists. Steps to a Recursive Predicate. List Predicates.
Prolog-Lecture 2 Iqbal Mohomed Connection between Lists and Terms [H T] is just syntactic sugaring for the term.(h,t)?-.(h,t) = [a,b,c]. H = a T = [b, c] ; The dot operator or functor. corresponds to cons
More informationCSc 372 Comparative Programming Languages
CSc 372 Comparative Programming Languages 8 : Haskell Function Examples Christian Collberg collberg+372@gmail.com Department of Computer Science University of Arizona Copyright c 2005 Christian Collberg
More informationArithmetic Terms are Symbolic
Arithmetic Terms are Symbolic Evaluation of an arithmetic term into a numeric value must be forced. That is, 1+2 is an infix representation of the relation +(1,2). This term is not an integer! Therefore?-
More informationRecursion, Structures, and Lists
Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 4 04/10/04 30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists 1 The central ideas of Prolog
More informationCSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona
1/43 CSc 372 Comparative Programming Languages 8 : Haskell Function Examples Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg Functions over Lists
More informationLecture 6: Inductive Logic Programming
Lecture 6: Inductive Logic Programming Cognitive Systems - Machine Learning Part II: Special Aspects of Concept Learning FOIL, Inverted Resolution, Sequential Covering last change November 15, 2010 Ute
More informationSec Negative Goals ( Not ) 21
Sec. 1.11. Negative Goals ( Not ) 21?- non_parent(elmo,cathy). yes? non_parent(sharon,cathy). yes?- non_parent(charles,cathy). yes and non_parent fails if its arguments are in fact a parent and his or
More informationINTRODUCTION TO PROLOG
INTRODUCTION TO PROLOG PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2018 Dalhousie University 1/44 STRUCTURE OF A PROLOG PROGRAM Where, declaratively, Haskell expresses a computation as a system
More informationLecture Notes on Prolog
Lecture Notes on Prolog 15-317: Constructive Logic Frank Pfenning Lecture 14 October 27, 2015 In this lecture we introduce some simple data structures such as lists, and simple algorithms on them such
More informationProlog Programming. Lecture Module 8
Prolog Programming Lecture Module 8 Prolog Language Prolog is unique in its ability to infer facts from the given facts and rules. In Prolog, an order of clauses in the program and goals in the body of
More informationProlog Cut: Summary. CSC324 Logic & Relational Programming Illustrated in Prolog. Prolog Cut: Summary. Non-deterministic Programming
Prolog Cut: Summary CSC324 Logic & Relational Programming Illustrated in Prolog Afsaneh Fazly Cut (! ) can be used to: remove duplicate (& unnecessary) responses. remove incorrect responses. improve efficiency
More informationLogic Programming in Prolog
Cristian Giumale / Lecture Notes 1 Logic Programming in Prolog There are important advantages of using programming systems based on logic: Data are neatly separated from the inference engine, which is
More information6. Inference and resolution
Computer Science and Software Engineering University of Wisconsin - Platteville 6. Inference and resolution CS 3030 Lecture Notes Yan Shi UW-Platteville Read: Textbook Chapter 8 Part of the slides are
More informationLogic Programming: Prolog
Logic Programming: Prolog COMS W4115 Aristotle Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science Logic All Caltech graduates are nerds. Stephen is a Caltech graduate.
More information1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?
Review for Final (Chapter 6 13, 15) 6. Template functions & classes 1) What is the primary purpose of template functions? A. To allow a single function to be used with varying types of arguments B. To
More informationProgramming Languages
CSE 130: Spring 2010 Programming Languages Lecture 2: A Crash Course in ML Ranjit Jhala UC San Diego News On webpage: Suggested HW #1 PA #1 (due next Wed 4/9) Please post questions to WebCT Today: A crash
More informationImplementing Programming Languages for Fun and Profit with OMeta. Alessandro Warth Viewpoints Research Institute & UCLA
Implementing Programming Languages for Fun and Profit with OMeta Alessandro Warth Viewpoints Research Institute & UCLA Who am I? NOT David Simmons NOT Billy Idol !!! programming languages STEPS... toward
More informationLogic Programming. Backtracking and Cut. Temur Kutsia
Logic Programming Backtracking and Cut Temur Kutsia Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria kutsia@risc.uni-linz.ac.at Contents Generating Multiple Solutions
More informationLecture 9. Exercises. Theory. Solutions to exercises LPN 8.1 & 8.2. Patrick Blackburn, Johan Bos & Kristina Striegnitz
Lecture 9 Exercises Solutions to exercises LPN 8.1 & 8.2 Theory Solution to Exercise 8.1 Suppose we add the noun ``men'' (which is plural) and the verb ``shoot''. Then we would want a DCG which says that
More informationThis lecture covers: Prolog s execution strategy explained more precisely. Revision of the elementary Prolog data types
This lecture covers: Prolog s execution strategy explained more precisely The execution strategy has been presented as simply placing all matching clauses onto the stack. In fact, Prolog is slightly more
More informationChapter 16. Logic Programming. Topics. Logic Programming. Logic Programming Paradigm
Topics Chapter 16 Logic Programming Introduction Predicate Calculus Propositions Clausal Form Horn Clauses 2 Logic Programming Paradigm AKA Declarative Paradigm The programmer Declares the goal of the
More information