Logic 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).
|
|
- Martha Robbins
- 5 years ago
- Views:
Transcription
1 Logic Programming
2 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<=n;i++) x=x*i;
3 예 ) 타입시스템 Γ n : ι Γ(x) =τ Γ x : τ Γ + x : τ 1 E : τ 2 Γ λx.e : τ 1 τ 2 Γ E 1 : τ 1 τ 2 Γ E 2 : τ 1 Γ E 1 E 2 : τ 2 Γ E 1 : ι Γ E 2 : ι Γ E 1 +E 2 : ι
4 Introduction to Prolog Programming in logic The first and most popular logic programming language First-order predicate logic: Turing complete Apps) natural language processing, theorem proving, expert systems, games, web programming, etc
5 Defining Relations by Facts pam tom ann bob pat liz parent(tom,bob). parent(pam,bob). parent(tom,liz). parent(bob,ann). parent(bob,pat). parent(pat,jim). jim
6 Defining Relations by Facts pam tom bob liz?- parent(bob,pat). yes?- parent(liz,pat). no ann pat?- parent(tom,ben). no jim
7 Defining Relations by Facts pam tom?- parent(x,pat). X=tom bob liz?- parent(bob,x). X=ann X=pat ann jim pat?- parent(x,y). X=pam Y=bob X=tom Y=bob...
8 Defining Relations by Facts pam tom?- parent(y,jim), parent(x,y). X=bob Y=pat bob liz?- parent(x,y), parent(y,jim). X=bob Y=pat ann pat?- parent(tom,x), parent(x,y). X=bob Y=ann jim?- parent(x,ann), parent(x,pat). X=bob
9 Defining Relations by Rules male pam tom ann male bob pat liz (pam). male(tom). male(bob). (liz). (pat). (ann). male(jim). male jim
10 Defining Relations by Rules male pam tom inference rule parent(x,y) male offspring(y,x) bob liz in prolog offspring(y,x):-parent(x,y). ann pat?- offspring(liz,tom). yes male jim offspring(liz,tom):-parent(tom,liz).
11 Defining Relations by Rules male pam ann male bob male tom pat liz inference rule in prolog parent(x,y) parent(y,z) grandparent(x,z) grandparent(x,z):- parent(x,y), parent(y,z). jim
12 Defining Relations by Rules male pam tom inference rule male bob liz parent(z,x) parent(z,y) (X) sister(x,y) in prolog ann male pat sister(x,y):- parent(z,x), parent(z,y), (X). jim
13 Defining Relations by Rules male pam male tom sister(x,y):- parent(z,x), parent(z,y), (X). bob liz?- sister(ann,pat). yes ann male pat?- sister(x,pat). X=ann X=pat jim
14 Defining Relations by Rules male pam male bob tom liz sister(x,y):- parent(z,x), parent(z,y), (X), different(x,y).?- sister(ann,pat). yes ann male pat?- sister(x,pat). X=ann jim
15 Recursive Rules inference rule parent(x,z) predecessor(x,z) parent(x,y) predecessor(y,z) predecessor(x,z) in prolog predecessor(x,z):- parent(x,z). predecessor(x,z):- parent(x,y), predecessor(y,z).?- predecessor(pam,x). X=bob X=ann X=pat X=jim
16 How prolog answers parent(tom,bob). parent(pam,bob). parent(tom,liz). parent(bob,ann). parent(bob,pat). parent(pat,jim). predecessor(x,z):- parent(x,z). predecessor(x,z):- parent(x,y), predecessor(y,z). parent(tom,pat) no predecessor(tom,pat) parent(tom,y) predecessor(y,pat) Y=bob predecessor(bob,pat) parent(bob,pat) yes
17 Declarative/Procedural Meanings Declarative meanings Procedural meanings What is the output of the program? How is this output obtained?
18 Data objects in Prolog data objects (=terms) simple objects structures constants variables X,Y,Z,... atoms numbers tom,bob,nil,x_,x25,... 1, 1313, 0, -97, 3.14,...
19 Structured Objects Structured object = tree Objects that have several components. date date(1, may, 2011) 1 may 2011 functor arguments point(1,1) seg(point(1,1),point(2,3)) triangle(point(4,2),point(6,4),point(7,1)) (a+b)*(c-5) = *(+(a,b), -(c,5))
20 Matching Two terms match if they are unifiable Prolog finds the most general unifier?- date(d, M, 2011) = date(d1, may, Y1). D = D1 M = may Y1 = 2001 D = 1 D = 1 M = may Y1 = 2001?- date(d, M, 2011) = date(d1, may, 2144) fail
21 Prolog and Logic Syntax: first-order predicate logic, clause form Procedural meaning: resolution principle for mechanical theorem proving (Robinson 65) Matching = unification in logic occur check?- X = f(x). X = f(x) or X = f(f(f(f(f(f(f(f(f(...
22 Lists [ann, tennis, tom, skiing] =.(ann,.(tennis,.(tom,.(skiing, [])))) [ann] =.(ann,[])?- Hobbies1 =.(tennis,.(music, [])), Hobbies2 = [skiing, food], L = [ann, Hobbies1, tom, Hobbies2]. Hobbies1 = [tennis, music] Hobbies2 = [skiing, food] L = [ann,[tennis,music],tom,[skiing,food]] [a,b,c] = [a [b,c]] = [a,b, [c]] = [a,b,c []]
23 List operations member(x,l) : X is a member of list L conc(l1,l2,l3) : L3 is the concatenation of L1 and L2 add(x,l1,l2) : add(x,l,[x L) del(x,l,l1) : L1 is equal to L with X removed sublist(s,l) : S is a sublist of L permutation (L,P) : P is a permutation of L
24 Membership member(x,l) is true if X occurs in L member(x,[x Tail]). member(x,[head Tail]) :- member(x,tail).?- member(b,[a,b,c]). yes?- member(b,[a,[b,c]]). no?- member([b,c],[a,[b,c]]). yes
25 Concatenation conc(l1,l2,l3) is true if L1 and L2 are two lists and L3 is their concatenation conc([],l,l). conc([x L1],L2,[X L3]) :- conc(l1,l2,l3). X L1 L2?- conc([a,b],[c,d],[a,b,c,d]). yes L3 [X L3]?- conc([a,b,c],[1,2,3],l). L = [a,b,c,1,2,3]
26 Other uses of conc decompose a given list into two lists?- conc(l1,l2,[a,b,c]). L1 = [] L2 = [a,b,c]; L1 = [a] L2 = [b,c]; L1 = [a,b] L2 = [c]; L1 = [a,b,c] L2 = []
27 Other uses of conc look for a certain pattern in a list?- conc(before,[may After], [jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec]). Before = [jan,feb,mar,apr] After = [jun,jul,aug,sep,oct,nov,dec]?- conc(_,[pred,may,succ _], [jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec]). Pred = apr Succ = jun?- L1 = [a,b,z,z,c,z,z,z,d,e], conc(l2,[zzz, _],L1). L2 = [a,b,z,z,c] L1 = [a,b,z,z,c,z,z,z,d,e]
28 Other uses of conc member(x,l) is true if X occurs in L member(x,l) :- conc(_,[x _],L). vs. member(x,[x Tail]). member(x,[head Tail]) :- member(x,tail).
29 Deleting an item del(x,l,l1) is true if L1 is equal to L with the item X removed del(x,[x Tail],Tail). del(x,[y Tail],[Y,Tail]) :- del(x,tail,tail1)?- del(a,[a,b,a,a],l). L = [b,a,a]; L = [a,b,a]; L = [a,b,a];?- del(a,l,[1,2,3]). L = [a,1,2,3]; L = [1,a,2,3]; L = [1,2,a,3]; L = [1,2,3,a];
30 (Quiz1) Inserting an item Define insert(x,l,l1) : insert(x,l,l1) is true if L1 is equal to L with the item X inserted (at any place)?- insert(a,[b,c],[a,b,c]). yes?- insert(a,[b,c],l). L = [a,b,c]; L = [b,a,c]; L = [b,c,a];?- insert(a,l,[a,b,c]). L = [b,c]
31 Sublist sublist(s,l) is true if S is a sublist of L?- sublist([c,d,e],[a,b,c,d,e]). yes?- sublist([c,e],[a,b,c,d,e,f]). no L L1 S L2 sublist(s,l):- sublist(l1,l3,l), sublist(s,l2,l3). L3
32 Sublist?- sublist (S,[a,b,c]). S = []; S = [a]; S = [a,b]; S = [a,b,c]; S = []; S = [b]; S = [b,c]; S = []; S = [c]; S = [];
33 Permutations permutation(l,p) is true if P is a permutation of L permutation([],[]). permutation([x L],P):- permutation(l,p1), insert(x,p1,p).?- permutation ([a,b,c],p). P = [a,b,c]; P = [b,c,a]; P = [b,c,a]; P = [a,c,b]; P = [c,a,b];
34 (Quiz2). Reverse Define the relation that reverses list. reverse(list,reversedlist)?- reverse([a,b,c,d],[d,c,b,a]). yes
35 (Quiz3). Palindrome Define the predicate palindrome(list) that is true if List is a palindrome. A list is palindrome if it reads the same in the forward and in the backward direction.?- palindrome([m,a,d,a,m]). yes?- permutation([a,a,b,b,c],l), palindrome(l). L = [a,b,c,b,a]; L = [b,a,c,a,b];...
36 The eight queens problem
37 Board template X/Y: a queen sitting at (X,Y) [1/2, 2/4, 3/6, 4/8, 5/3, 6/1, [1/Y1, 2/Y2, 3/Y3, 4/Y4, 5/Y5, 6/Y6, /7, 8/5] 7/Y7, 8/Y8]
38 Solution solution(s) is true if position S is safe solution([x/y Others]):- solution(others), member(y,[1,2,3,4,5,6,7,8]), noattack(x/y,others). noattack(_,[]). noattack(x/y,[x1/y1 Others]):- Y =\= Y1, Y1-Y =\= X1-X, Y1-Y =\= X-X1, noattack(x/y,others). template([1/y1,2/y2,3/y3,4/y4,5/y5,6/y6,7/y7,8/y8]).?- template(s), solution(s). S = [1/4,2/2,3/7,4/3,5/6,6/8,7/5,8/1]...
Symbolic 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 informationLogic Programming and PROLOG (III)
Logic Programming and PROLOG (III) Dr. Antonio L. Bajuelos Note: The most of the information of these slides was extracted and adapted from Bratko s book, Prolog Programming for Artificial Intelligence".
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 informationChapter 16. Logic Programming. Topics. Predicate Calculus and Proving Theorems. Resolution. Resolution: example. Unification and Instantiation
Topics Chapter 16 Logic Programming Proving Theorems Resolution Instantiation and Unification Prolog Terms Clauses Inference Process Backtracking 2 Predicate Calculus and Proving Theorems A use of propositions
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 informationFirst-Order Logic. Cholwich Nattee. Sirindhorn International Institute of Technology Thammasat University. Lecture 9: First-Order Logic 1/60
First-Order Logic Cholwich Nattee Sirindhorn International Institute of Technology Thammasat University Lecture 9: First-Order Logic 1/60 Pros and Cons of Propositional Logic Propositional logic is declarative.
More informationLogic as a Programming Language
Logic as a Programming Language! Logic can be considered the oldest programming language! Aristotle invented propositional logic over 2000 years ago in order to prove properties of formal arguments! Propositions
More information1.2 Commercial Products of AI Robotics device. Vision systems that recognize shapes & objects.
Introduction to Artificial Intelligent 1.1 Artificial Intelligent (AI) Is the study of how to make computers do things which at the moment, people do better. or in specific definition AI is a branch of
More informationOverview. Declarative Languages. operation of del. Deleting an element from a list. functions using del. inserting elements with del
Overview Declarative Languages D7012E: Arithmetic and Backtracking Fredrik Bengtsson Some standard functions Operators Arithmetic The eight queens problem Controlling backtracking cut Deleting an element
More informationPROLOG. First simple Prolog Program. Basic elements of Prolog. Clause. NSSICT/CH/Nov., 2012.
PROLOG Prolog is a programming language for symbolic, n-numeric computations. It is specially well suited for solving problems that involve objects and relation between objects. First simple Prolog Program
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 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 informationPROgramming in LOGic. Part II. By Forrest Pepper 12/7/07
PROgramming in LOGic Part II By Forrest Pepper 12/7/07 Anatomy of a Program We discussed the three main constructs of a Prolog program Facts contain a property or state a relationship between two or more
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 informationProlog. Logic Programming vs Prolog
Language constructs Prolog Facts, rules, queries through examples Horn clauses Goal-oriented semantics Procedural semantics How computation is performed? Comparison to logic programming 1 Logic Programming
More informationFor Wednesday. No reading Chapter 9, exercise 9. Must be proper Horn clauses
For Wednesday No reading Chapter 9, exercise 9 Must be proper Horn clauses Same Variable Exact variable names used in sentences in the KB should not matter. But if Likes(x,FOPC) is a formula in the KB,
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 403: Introduction to logic programming
CS 403: Introduction to logic programming Stefan D. Bruda Fall 2017 KNOWLEDGE REPRESENTATION A proposition is a logical statement that can be either false or true To work with propositions one needs a
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 informationWhat s the problem? fib(1,1). fib(2,1). fib(n,x) :- N>2, N1 is N-1, N2 is N-2, fib(n1,x2), fib(n2,x2).
39 What s the problem? A Fibonacci Implementation fib(1,1). fib(2,1). fib(n,x) :- N>2, N1 is N-1, N2 is N-2, fib(n1,x2), fib(n2,x2). List Concatenation conc([],l,l). conc([x L1], L2, [X L3]) :- conc(l1,l2,l3).
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 informationCS 360: Programming Language Concepts Lecture 15 Logic Programming
Reference: Ch. 12.1-12.5 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,
More informationPROLOG programming for artificial intelligence
Prolog Prolog.1 Textbook and Software Title PROLOG programming for artificial intelligence Author Ivan Bratko Get the software windows Home users: download from the course site Install software to preferred
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 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 informationProlog. Textbook and Software. Title PROLOG programming for artificial intelligence
Tutorial : Prolog Prolog Prolog.1 Textbook and Software Title PROLOG programming for artificial intelligence Author Ivan Bratko Get the software windows Download PL.zip from the course site Extract the
More informationCS 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 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 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 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 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 informationSnakes. Declarative Languages. Relation different. Overview. Negation as failure. Relation different
Snakes Declarative Languages D7012E: Negation and solution gathering Fredrik Bengtsson "Mary like all animals but snakes" likes(mary, X):-snake(X),!,fail. likes(mary, X):-animal(X). observe the cut before
More informationUsing Prolog as a CAS
Using Prolog as a CAS Alla L. Stolyarevska, Kharkiv State Pedagogical University, Ukraine Affiliations: Computer Science & Mathematics Address: Bluchera street, 2, Kharkiv, Ukraine, 310168 phone/fax: (+380)
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 informationCAP 5602 Summer, Lesson 5: Lists. The topics 1. updating a counter 2. the list structure 3. some useful built-in predicates for lists
CAP 5602 Summer, 20 Lesson 5: Lists The topics. updating a counter 2. the list structure 3. some useful built-in predicates for lists. Updating a counter Let us try to implement the increse the counter
More informationProlog Programming. Chapter 5. Controlling Backtracking : 1/16/2010
Prolog Programming Chapter 5 Controlling Backtracking : 1/16/2010 1 Chapter 5 Controlling Backtracking Preventing backtracking Examples using cut Negation as failure Problems with cut and negation 2 5.1
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 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 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 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 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 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 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 informationINDEX. 2. Rational behind the INTELLIGENT SYSTEM lab
LAB MANUAL OF IS INDEX 1. Syllabus 2. Rational behind the INTELLIGENT SYSTEM lab 3. Hardware/Software Requirement 4. Practicals conducted in the lab 5. References 6. New ideas besides University Syllabus
More informationTopic B: Backtracking and Lists
Topic B: Backtracking and Lists 1 Recommended Exercises and Readings From Programming in Prolog (5 th Ed.) Readings: Chapter 3 2 Searching for the Answer In order for a Prolog program to report the correct
More informationLAB MANUAL FOR INTELLIGENT SYSTEM
LAB MANUAL FOR INTELLIGENT SYSTEM INDEX 1. Syllabus 2. Rational behind the INTELLIGENT SYSTEM lab 3. Hardware/Software Requirement 4. Practicals conducted in the lab 5. References 6. New ideas besides
More informationThe current topic: Prolog. Announcements. Meaning of a Prolog rule. Prolog syntax. Reminder: The deadline for Lab 2 re-mark requests is Friday.
The current topic: Prolog! Introduction! Object-oriented programming: Python! Functional programming: Scheme! Python GUI programming (Tkinter)! Types and values Logic programming: Prolog! Introduction
More informationLAB MANUAL FOR IS LAB
LAB MANUAL FOR IS LAB 1 STUDY OF PROLOG Prolog Programming in Logic PROLOG stands for Programming In Logic an idea that emerged in the early 1970s to use logic as programming language. The early developers
More informationcsci 210: Data Structures Stacks and Queues in Solution Searching
csci 210: Data Structures Stacks and Queues in Solution Searching 1 Summary Topics Using Stacks and Queues in searching Applications: In-class problem: missionary and cannibals In-class problem: finding
More informationIKI30820 Logic Programming Negation as Failure Slide 06
IKI30820 Logic Programming Negation as Failure Slide 06 Ari Saptawijaya (slides) Adila A. Krisnadhi (L A T E Xadaptation) Fakultas Ilmu Komputer Universitas Indonesia 2009/2010 Semester Gasal AS,AAK (Fasilkom
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 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 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 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 informationKNOWLEDGE REPRESENTATION SEMANTICS OF THE PREDICATE CALCULUS (CONT)
KNOWLEDGE REPRESENTATION CS 403: Introduction to logic programming Stefan D. Bruda Fall 017 A proposition is a logical statement that can be either false or true To work with propositions one needs a formal
More informationBacktrack control. Chapter 5
Chapter 5 Backtrack control Prolog will automatically backtrack to satisfy a goal. This relieves the programmer of the burden of putting in backtrack explicitly. On the negative side, this might lead to
More informationExercises on the Fundamentals of Prolog
1 Introduction Exercises on the Fundamentals of Prolog These exercises are intended to help reinforce material taught in the lectures of CIS335 course in Prolog. They do not contribute any marks to the
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 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 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 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 informationProlog Introduction. Gunnar Gotshalks PI-1
Prolog Introduction PI-1 Physical Symbol System Hypothesis A physical symbol system has the necessary and sufficient means for general intelligent action. Allen Newell and Herbert A. Simon PI-2 Physical
More informationProlog (cont d) Remark. Using multiple clauses. Intelligent Systems and HCI D7023E
Intelligent Systems and HCI D703E Lecture : More Prolog Paweł Pietrzak Prolog (cont d) 1 Remark The recent version of SWI- Prolog displays true and false rather than and no Using multiple clauses Different
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 informationLecture 6: Recursion RECURSION
Lecture 6: Recursion RECURSION You are now Java experts! 2 This was almost all the Java that we will teach you in this course Will see a few last things in the remainder of class Now will begin focusing
More informationBaby Steps Toward an Implementation of Axiomatic Language
Baby Steps Toward an Implementation of Axiomatic Language Extended Abstract Walter W. Wilson Lockheed Martin, P.O. Box 748, Fort Worth TX 76101, USA wwwilson@acm.org Abstract. This paper describes an initial
More informationLast Week. Today. Prolog: recursion examples. Recursion in Prolog. CSC326 Programming Languages (Week 12,Friday)
Last Week CSC326 Programming Languages (Week 12,Friday) Yilan Gu guyilan@ecf.toronto.edu http://www.cs.toronto.edu/~yilan/326f09/ More on Prolog reasoning mechanism Operators Lists Today Recursion in Prolog
More informationLogic (or Declarative) Programming Foundations: Prolog. Overview [1]
Logic (or Declarative) Programming Foundations: Prolog In Text: Chapter 12 Formal logic Logic programming Prolog Overview [1] N. Meng, S. Arthur 2 1 Logic Programming To express programs in a form of symbolic
More informationProlog - 3 Prolog search trees + traces
Prolog - 3 Prolog search trees + traces 1 Review member(a, [A B]). member(a, [B C]) :- member (A,C). goal-oriented semantics: can get value assignment for goal member(a,[b C]) by showing truth of subgoal
More informationOperators (2A) Young Won Lim 10/5/13
Operators (2A) Copyright (c) 2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version
More informationCS 320: Concepts of Programming Languages
CS 320: Concepts of Programming Languages Wayne Snyder Computer Science Department Boston University Lecture 04: Basic Haskell Continued o Polymorphic Types o Type Inference with Polymorphism o Standard
More informationCombining Static and Dynamic Contract Checking for Curry
Michael Hanus (CAU Kiel) Combining Static and Dynamic Contract Checking for Curry LOPSTR 2017 1 Combining Static and Dynamic Contract Checking for Curry Michael Hanus University of Kiel Programming Languages
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 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 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 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 informationImplementação de Linguagens 2016/2017
Implementação de Linguagens Ricardo Rocha DCC-FCUP, Universidade do Porto ricroc @ dcc.fc.up.pt Ricardo Rocha DCC-FCUP 1 Logic Programming Logic programming languages, together with functional programming
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 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 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 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 informationLast Week COMP219: Artificial Intelligence Lecture 8 Prolog Lecture 2 Recursive Definitions Recursion The Ancestor Relation
COMP219: Artificial Intelligence Lecture 8 Prolog Lecture 2 Recursive Definitions Dr. Annabel Latham Ashton Building Room 2.05 http://www.csc.liv.ac.uk/~alatham/comp219.html Last Week Prolog programs comprised
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 informationComplementary, Supplementary, & Vertical Angles
Unit 4: Lesson 1: Complementary and Supplementary Angles Date: Complementary, Supplementary, & Vertical Angles Type of Angles Definition/Description Complementary Angles Diagram Supplementary Angles Vertical
More informationThe Logic Paradigm. Joseph Spring. 7COM1023 Programming Paradigms
The Logic Paradigm Joseph Spring 7COM1023 Programming Paradigms 1 Discussion The Logic Paradigm Propositional and Predicate Logic See also notes and slides on PP website Horn Clauses Definition, Examples
More informationOperators (2A) Young Won Lim 10/2/13
Operators (2A) Copyright (c) 2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version
More informationArtificial Intelligence. Chapters Reviews. Readings: Chapters 3-8 of Russell & Norvig.
Artificial Intelligence Chapters Reviews Readings: Chapters 3-8 of Russell & Norvig. Topics covered in the midterm Solving problems by searching (Chap. 3) How to formulate a search problem? How to measure
More informationCSE 452: Programming Languages. Prolog Statements. Loading the Knowledge Base. Logical Programming Languages Part 2
CSE 452: Programming Languages Logical Programming Languages Part 2 Prolog Statements Prolog statements consist of facts, rules, and queries. Example of facts (written as headless Horn clauses) male(tony).
More informationWhat are Operators? - 1. Operators. What are Operators? - 2. Properties. » Position» Precedence class» associativity. » x + y * z. » +(x, *(y, z)).
What are Operators? - 1 Functors Introduce operators to improve the readability of programs Operators syntactic sugar Based on Clocksin & Mellish Sections 2.3, 5.5 O-1 O-2 The arithmetic expression:» x
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 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 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 informationContext-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5
Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 1 Not all languages are regular So what happens to the languages which are not regular? Can we still come up with a language recognizer?
More informationOutline. Implementing a basic general game player. Foundations of logic programming. Metagaming: rule optimisation. Logic Programming.
Outline 1 Implementing a basic general game player Foundations of logic programming Metagaming: rule optimisation 2 Uses of Logic Use logical reasoning for game play Computing the legality of moves Computing
More informationWan Hussain Wan Ishak
September 1 st Session 2014/2015 (A141) Wan Hussain Wan Ishak School of Computing UUM College of Arts and Sciences Universiti Utara Malaysia (P) 04-9285150 (E) hussain@uum.edu.my (U) http://wanhussain.com
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 informationLogical reasoning systems
Logical reasoning systems Theorem provers and logic programming languages Production systems Frame systems and semantic networks Description logic systems CS 561, Session 19 1 Logical reasoning systems
More informationConservation of Data. Ian Mackie. Isaac Newton Institute for Mathematical Sciences January 2011
Isaac Newton Institute for Mathematical Sciences January 2011 Conservation of... There are a number of fundamental laws of nature: energy can be neither created nor destroyed mass is neither created nor
More informationThe Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems
The Turing Machine Unsolvable Problems Motivating idea Build a theoretical a human computer Likened to a human with a paper and pencil that can solve problems in an algorithmic way The theoretical machine
More information