CSC324 Logic & Relational Programming Illustrated in Prolog
|
|
- Geraldine Hall
- 5 years ago
- Views:
Transcription
1 CSC324 Logic & Relational Programming Illustrated in Prolog Afsaneh Fazly 1 Winter with many thanks to Anya Tafliovich, Gerald Penn and Sheila McIlraith. 1
2 2 admin notes Please check your marks for A1, A2, Midterm on CDF. me if any of the marks is recorded incorrectly. Remember that there will be a lecture/tutorial on Friday March 8, 2 3pm, BA 1190 (by the instructor).
3 Execution of Prolog Programs Unification: variable bindings. Backward Chaining/ Top-Down Reasoning/ Goal-Directed Reasoning: Reduces a goal to one or more subgoals. Backtracking: Systematically searches for all possible solutions that can be obtained via unification and backchaining.
4 Unification: Overview A number/atom unifies only with itself. An uninstantiated variable unifies with any value the variable gets instantiated to that value. Two uninstantiated variables unify the two variables share or co-refer, i.e., as soon as one gets instantiated, so is the other one (to the same value). A term unifies with another term with the same functor, if they have the same number of arguments and all corresponding arguments unify.
5 5 Backward Chaining This is how Prolog satisfies a goal (query): 1. Search the database for a unifying clause. 2. If not found, search fails. 3. Otherwise, mark the place in the database where the unifying clause is found. 4. If unifying clause is a fact instantiate variables (if any). 5. If unifying clause is a rule, instantiate variables, and try to satisfy the subgoals, in order, from left to right.
6 Given the database: male(charlie). male(bob). female(alice). female(eve). Example parent(charlie, bob). parent(eve,bob). parent(charlie,alice). parent(eve,alice). and the query:?- male(charlie). The unifying clause is a fact; no variables returns true. with the query?- male(x). The unifying clause is a fact, with variable X instantiates X to charlie.
7 Given the database & rules: male(charlie). male(bob). female(alice). female(eve). Example parent(charlie, bob). parent(eve,bob). parent(charlie,alice). parent(eve,alice). sibling(x, Y) :- parent(p, X), parent(p, Y). with the query?- sibling(s, bob). The unifying clause is a rule (1) instantiate Y to bob, and X to S (i.e., X and S co-refer), (2) try to satisfy parent(p, S), and then parent(p, bob).
8 8 Backtracking If an attempt to satisfy a goal fails, or if we ask for more answers, Prolog tries to re-satisfy the goal by backtracking, as follows: 1. Move back along the search path to where the unifying clause was found. 2. Un-instantiate any variables that have been instantiated during the search process. 3. Start another search for another unifying clause from where the current unifying clause was found (the place marked in the database).
9 Example male(charlie). parent(charlie, bob). male(bob). parent(eve,bob). female(alice). parent(charlie,alice). female(eve). parent(eve,alice). female(nikki). parent(alice,nikki). grandparent(x, Z) :- parent(x, Y), parent(y, Z).?- grandparent(g, nikki).
10 10?- grandparent(g, nikki). 1. X = G, Z = nikki. Example 2. satisfy parent(g, Y) (2.1) G = charlie, Y = bob. 3. satisfy parent(y=bob, nikki) (3.1) bob = alice. fail 4. uninstantiate G and Y. 5. re-satisfy parent(g, Y) (5.1) G = eve, Y = bob. 6. re-satisfy parent(y=bob, nikki) (6.1) bob = alice. fail 7. re-satisfy parent(g, Y) (7.1) G = charlie, Y = alice. 8. re-satisfy parent(y=alice, nikki) (8.1) alice = alice. success
11 Prolog Search Trees Encapsulate unification, backward chaining, and backtracking. Internal nodes are ordered list of subgoals. Leaves are success nodes or failures, where computation can proceed no further. Edges are labeled with variable bindings that occur by unification. Describe all possible computation paths. There can be many success nodes. There can be infinite branches.
12 Prolog Search Trees 1) male(charlie). 5) parent(charlie,bob). 2) male(bob). 6) parent(eve,bob). 3) female(alice). 7) parent(charlie,alice). 4) female(eve). 8) parent(eve,alice). 9) sibling(x, Y) :- parent(p, X), parent(p, Y).?- sibling(alice, Who). Who = bob ; Who = alice ; Who = bob ; Who = alice.
13 13 Trace it by hand Prolog Search Trees
14 Prolog Search Trees?- trace. Unknown message: query(yes) [trace]?- sibling(alice, Who). Call: (8) sibling(alice, _G306)? Call: (9) parent(_l195, alice)? Exit: (9) parent(charlie, alice)? Call: (9) parent(charlie, _G306)? Exit: (9) parent(charlie, bob)? Exit: (8) sibling(alice, bob)? Who = bob ; Redo: (9) parent(charlie, _G306)? Exit: (9) parent(charlie, alice)? Exit: (8) sibling(alice, alice)? Who = alice ;
15 Prolog Search Trees Redo: (9) parent(_l195, alice)? Exit: (9) parent(eve, alice)? Call: (9) parent(eve, _G306)? Exit: (9) parent(eve, bob)? Exit: (8) sibling(alice, bob)? Who = bob ; Redo: (9) parent(eve, _G306)? Exit: (9) parent(eve, alice)? Exit: (8) sibling(alice, alice)? Who = alice. Notice the recursion in this algorithm: find calls find. This reasoning is recursively applied until we reach rules that are facts.
16 16 Logic Programming vs. Prolog Logic Programming: nondeterministic: Arbitrarily choose rule to expand first. Arbitrarily choose subgoal to explore first. Results don t depend on rule and subgoal ordering. Prolog: deterministic: Expand first rule first. Explore first subgoal first. Results may depend on rule and subgoal ordering.
17 An n-element list in Prolog is: Egs: [a, b, c] [] [a, [b, c], d, [], e] [a, X, c, d] Lists in Prolog [ e 1, e 2,..., e n ] or, equivalently, [ e 1 [ e 2 [... e n ]]] Egs: [a Rest] [a [b, c]] stands for [a, b, c] Remember cons in Scheme, and :: in ML.
18 Lists in Prolog List Unification: two lists unify iff they have the same structure and the corresponding elements unify.?- [X, Y, Z] = [john, likes, fish].?- [cat] = [X Y].?- [1,2] = [X Y].
19 Lists in Prolog?- [a,b,c] = [X Y].?- [a,b Z]=[X Y].?- [X,abc,Y]=[X,abc Y].?- [[the Y] Z] = [[X,there] [is,here]].
20 Some Notation We write mem/2 to specify a predicate mem with 2 arguments. We specify preconditions on arguments using the following notation: +ArgName means ArgName must be instantiated -ArgName means ArgName must be not instantiated?argname means ArgName may or may not be instantiated. E.g., mem(?x,?list) is a predicate with 2 arguments, both may or may not be instantiated when called. Note: the notation is for documentation / clarification purposes, and not a part of Prolog syntax.
21 21 Lists in Prolog % mem(?x,?list) iff X is an element of List In English: mem(x,list) holds iff X is the first element of List, or X is a member of the rest of List. In Prolog: mem(x,[x _]). mem(x,[_ Rest]) :- mem(x,rest).
22 Lists in Prolog % mem(?x,?list) iff X is an element of List mem(x,[x _]). mem(x,[_ Rest]) :- mem(x,rest).?- mem(a, [a,b,c]). true.?- mem(b, [a,c]). false.?- mem(x, [a,b,c]). X = a ; X = b ; X = c ; false.
23 Lists in Prolog?- mem(a, X). X = [a _G236] ; X = [_G235, a _G239] ; X = [_G235, _G238, a _G242] ; X = [_G235, _G238, _G241, a _G245] ; X = [_G235, _G238, _G241, _G244, a _G248].
24 Lists in Prolog?- trace. [trace]?- mem(c,[a,b,c,d]). Call: (7) mem(c, [a, b, c, d])? Call: (8) mem(c, [b, c, d])? Call: (9) mem(c, [c, d])? Exit: (9) mem(c, [c, d])? Exit: (8) mem(c, [b, c, d])? Exit: (7) mem(c, [a, b, c, d])? true
25 Lists in Prolog [trace]?- mem(x,[a,b,c,d]). Call: (7) mem(_g314, [a, b, c, d])? Exit: (7) mem(a, [a, b, c, d])? X = a ; Redo: (7) mem(_g314, [a, b, c, d])? Call: (8) mem(_g314, [b, c, d])? Exit: (8) mem(b, [b, c, d])? Exit: (7) mem(b, [a, b, c, d])? X = b ; Redo: (8) mem(_g314, [b, c, d])? Call: (9) mem(_g314, [c, d])? Exit: (9) mem(c, [c, d])? Exit: (8) mem(c, [b, c, d])? Exit: (7) mem(c, [a, b, c, d])?
26 Lists in Prolog X = c ; Redo: (9) mem(_g314, [c, d])? Call: (10) mem(_g314, [d])? Exit: (10) mem(d, [d])? Exit: (9) mem(d, [c, d])? Exit: (8) mem(d, [b, c, d])? Exit: (7) mem(d, [a, b, c, d])? X = d ; Redo: (10) mem(_g314, [d])? Call: (11) mem(_g314, [])? Fail: (11) mem(_g314, [])? false.
27 27 Lists in Prolog % myappend(?x,?y,?z) iff Z is the result of % appending list Y to list X myappend(x,y,z) holds iff: X is empty list ([]), and Z = Y, or Z is a list containing the first element of X, followed by the result of appending Y to the rest of X.
28 Lists in Prolog % myappend(?x,?y,?z) iff Z is the result of... myappend([],y,y). myappend([h T],Y,[H Z]) :- myappend(t,y,z).?- myappend([a],[b,c],y). Y = [a, b, c].?- myappend(x,[b,c],[a,b,c]). X = [a] ; false?- myappend(x,y,[a,b,c]). X = [], Y = [a, b, c] ; X = [a], Y = [b, c] ; X = [a, b], Y = [c] ; X = [a, b, c], Y = [] ; false
29 Lists in Prolog [trace]?- myappend([a,b,c],[d,e],z). Call: (7) myappend([a, b, c], [d, e], _G319)? Call: (8) myappend([b, c], [d, e], _G385)? Call: (9) myappend([c], [d, e], _G388)? Call: (10) myappend([], [d, e], _G391)? Exit: (10) myappend([], [d, e], [d, e])? Exit: (9) myappend([c], [d, e], [c, d, e])? Exit: (8) myappend([b, c], [d, e], [b, c, d, e])? Exit: (7) myappend([a, b, c], [d, e], [a, b, c, d, e])? Z = [a, b, c, d, e].
30 30 Lists in Prolog % mylength(?l,?n) iff N is the length of list L mylength(l,n) holds iff: L = [] and N = 0, or length of rest of L = N - 1.
31 Lists in Prolog % mylength(?l,?n) iff N is the length of list L mylength([],0). mylength([_ T],N) :- mylength(t,n-1).?- mylength([a,b,c],3). false. Why doesn t this work? Let s trace it.
32 Lists in Prolog [trace]?- mylength([a,b,c],3). Call: (7) mylength([a, b, c], 3)? Call: (8) mylength([b, c], 3-1)? Call: (9) mylength([c], 3-1-1)? Call: (10) mylength([], )? Fail: (10) mylength([], )? Fail: (9) mylength([c], 3-1-1)? Fail: (8) mylength([b, c], 3-1)? Fail: (7) mylength([a, b, c], 3)? false. Do you see what s happening here?
33 Lists in Prolog [trace]?- mylength([a,b,c],3). Call: (7) mylength([a, b, c], 3)? Call: (8) mylength([b, c], 3-1)? Call: (9) mylength([c], 3-1-1)? Call: (10) mylength([], )? Fail: (10) mylength([], )? Fail: (9) mylength([c], 3-1-1)? Fail: (8) mylength([b, c], 3-1)? Fail: (7) mylength([a, b, c], 3)? false. Do you see what s happening here? Prolog looks for a unifying clause for , which is equivalent to the term -(-(-(3,1),1),1). need to explicitly tell Prolog to evaluate this term as an arithmetic expression.
34 34 Arithmetic in Prolog What is the result of these queries:?- X = ?- X = 97-65, Y = 32-0, X = Y.?- X = 97-65, Y = 67, Z = 95-Y, X = Z.
35 35 Arithmetic in Prolog What is the result of these queries:?- X = ?- X = 97-65, Y = 32-0, X = Y.?- X = 97-65, Y = 67, Z = 95-Y, X = Z. Notes: Recall that the symbol = stands for unification: X = Y holds iff X and Y unify. Another useful symbol in Prolog is \=: X \= Y holds iff X cannot unify with Y.
36 36 Arithmetic in Prolog To evaluate arithmetic expressions in Prolog, use: expr 1 is expr 2, where expr 2 is fully instantiated. if expr 1 is instantiated, Prolog evaluates the term returns true or false. if expr1 is a variable, it is bound to the result of evaluating expr 2. expr1 < expr2, expr1 > expr2, expr1 =< expr2, or expr1 => expr2, where both expr1 and expr2 are instantiated. note the symbols =< and => for greater/less than or equal.
37 Arithmetic in Prolog?- 5 is 2+3. true.?- X is 2+3. X = 5.?- 5 < 6. true.?- 2+3 < 3+3. true.
38 38 Arithmetic in Prolog % mylength(?l,?n) iff N is the length of list L mylength([],0). mylength([_ T],N) :- N is NT+1, mylength(t,nt).
39 Arithmetic in Prolog % mylength(?l,?n) iff N is the length of list L mylength([],0). mylength([_ T],N) :- N is NT+1, mylength(t,nt).?- mylength([a,b,c],3). ERROR: is/2: Arguments are not sufficiently instantiated Why? [trace]?- mylength([a,b,c],3). Call: (7) mylength([a, b, c], 3)? ^ Call: (8) 3 is _G358+1? ERROR: is/2: Arguments are not sufficiently instantiated ^ Exception: (8) 3 is _G358+1? Exception: (7) mylength([a, b, c], 3)?
40 Arithmetic in Prolog % mylength(?l,?n) iff N is the length of list L mylength([],0). mylength([_ T],N) :- mylength(t,nt), N is NT+1.?- mylength([a,b,c],3). true Notes: This ordering ensures that NT+1 is instantiated when Prolog tries to assign it to N (in N is NT+1). In general, the ordering of subgoals in a rule may matter!
41 How? Lists in Prolog [trace]?- mylength([a,b,c],3). Call: (8) mylength([a, b, c], 3)? Call: (9) mylength([b, c], _L193)? Call: (10) mylength([c], _L212)? Call: (11) mylength([], _L231)? Exit: (11) mylength([], 0)? ^ Call: (11) _L212 is 0+1? ^ Exit: (11) 1 is 0+1? Exit: (10) mylength([c], 1)? ^ Call: (10) _L193 is 1+1? ^ Exit: (10) 2 is 1+1? Exit: (9) mylength([b, c], 2)? ^ Call: (9) 3 is 2+1? ^ Exit: (9) 3 is 2+1? Exit: (8) mylength([a, b, c], 3)? true
42 Lists in Prolog % mylength(?l,?n) iff N is the length of list L mylength([],0). mylength([_ T],N) :- mylength(t,nt), N is NT+1.?- mylength([a,b,c], L). L = 3.?- mylength([x,y], L). L = 2.?- mylength(x, 1). X = [_G226] ; <-- infinite run
43 Lists in Prolog [trace]?- mylength(x, 1).... X = [_G373] ; Redo: (9) mylength(_g374, _L196)? Call: (10) mylength(_g377, _L215)? Exit: (10) mylength([], 0)? ^ Call: (10) _L196 is 0+1? ^ Exit: (10) 1 is 0+1? Exit: (9) mylength([_g376], 1)? ^ Call: (9) 1 is 1+1? ^ Fail: (9) 1 is 1+1?
44 Lists in Prolog Redo: (10) mylength(_g377, _L215)? Call: (11) mylength(_g380, _L227)? Exit: (11) mylength([], 0)? ^ Call: (11) _L215 is 0+1? ^ Exit: (11) 1 is 0+1? Exit: (10) mylength([_g379], 1)? ^ Call: (10) _L196 is 1+1? ^ Exit: (10) 2 is 1+1? Exit: (9) mylength([_g376, _G379], 2)? ^ Call: (9) 1 is 2+1? ^ Fail: (9) 1 is 2+1? Redo: (11) mylength(_g380, _L227)?...
45 45 Logic Programming vs. Prolog What happens if we change the order of rules: % mylength(?l,?n) iff N is the length of list L mylength([_ T],N) :- mylength(t,nt), N is NT+1. mylength([],0).?- mylength([a,b,c], 3). true.?- mylength([a,b,c], N). N = 3.?- mylength(x, 2). ERROR: Out of local stack
46 46 Classifying Terms in Prolog We may wish to enforce some preconditions on the arguments of a predicate, e.g., to prevent mylength from running forever. Here are a few predicates we can use to classify terms: var(x) succeeds if X is an uninstantiated variable. atom(x) succeeds if X stands for a Prolog atom. number(x) succeeds if X stands for a number. Exercise: use var or nonvar(x) to fix mylength. mylength([],0). mylength(l,n) :- \+ var(l), L=[_ T], mylength(t,nt), N is NT+1.
47 Example: Trip Planning A database of facts to deal with trips: plane(x,y) boat(x,y) % there is a direct flight from X to Y % there is a direct boat trip from X to Y Predicates to compute certain things about the trips: a) cruise(x,y) -- there s a possible boat journey from X to Y. b) trip(x,y) -- there s a possible journey (using plane or boat) from X to Y. c) stopover(x,y,s) -- there s a trip from X to Y with stop in S. d) plane_cruise(x,y) -- there s a trip from X to Y that has at least one plane leg, and at least one boat leg. e) cost(x,y,c) -- there s a trip from X to Y with cost < C.
48 An example database: Example: Trip Planning plane(toronto, rochester). plane(toronto, montreal).... boat(toronto, rochester). boat(montreal, rochester). Predicates: a) cruise(x,y) :- boat(x,y). cruise(x,y) :- boat(x,z), cruise(z,y). b) leg(x,y) :- plane(x,y). leg(x,y) :- boat(x,y). trip(x,y) :- leg(x,y). trip(x,y) :- leg(x,z), trip(z,y).
49 49 c) stopover(x,y,s). Example: Trip Planning First, assume that neither X nor Y can equal S. stopover(x,y,s) :- trip(x,s), trip(s,y). Now, assume S could be X or Y (or even both): hop(x,x). hop(x,y) :- trip(x,y). stopover(x,y,s) :- hop(x,s), hop(s,y). d) plane_cruise(x,y) :- plane(x,z), boat(z,y). plane_cruise(x,y) :- boat(x,z), plane(z,y). plane_cruise(x,y) :- leg(x,z), plane_cruise(z,y). plane_cruise(x,y) :- leg(z,y), plane_cruise(x,z).
50 50 Example: Trip Planning Why do we need to have the second rule of plane cruise be plane_cruise(x,y) :- leg(z,y), plane_cruise(x,z). Instead of: plane_cruise(x,y) :- plane_cruise(x,z), leg(z,y).? The latter, while may be more intuitive, gives an infinite recursion! You must avoid left-recursion because of the way Prolog searches through a database.
51 Example: Trip Planning d) cost(x,y,c) We need to add costs to each of the plane and boat predicates, e.g., plane(toronto, rochester, 300), and redefine trip: leg(x,y,c) :- plane(x,y,c). leg(x,y,c) :- boat(x,y,c). trip(x,y,c) :- leg(x,y,c). trip(x,y,c) :- leg(x,z,c1), trip(z,y,c2), C is C1 + C2. Now cost is simple, because trip is doing the addition for us: cost(x,y,c) :- trip(x,y,c_trip), C_trip < C.
52 52 Let s Write Some Predicates with Arithmetic & Lists 1. factorial(n, Ans). 2. sumlist(list, Total). 3. prefix(pre, N, List).
53 Factorial factorial(0,1). factorial(n,f) :- N1 is N-1, factorial(n1,f1), F is N*F1.?- factorial(3,f). F = 6 ; ERROR: user://3:62: Out of local stack Question: What is the problem? Any preconditions? Exercise: Write a more efficient factorial using an accumulator.
54 Sum of List sumlist([],0). sumlist([x Rest],Ans) :- sumlist(rest,partial), Ans is Partial + X. Question: Why is left-recursion not problematic here?
55 Arithmetic Predicates may not be Invertible We may not be able to invert a predicate that involves arithmetic, e.g., compare:?- sumlist([1,2,3,4], A). A = 10.?- sumlist(l, 10). ERROR: user://1:24: is/2: Arguments are not sufficiently instantiated Tip: Every time you use is, you must be sure that the expression on the right will be fully instantiated before is is executed. If necessary, put a precondition on your predicate.
56 Prefix of a List prefix(pre, N, List) :- append(pre, _, List), length(pre, N).?- prefix(pre, 3, [1,2,3,4,5,6]). Pre = [1, 2, 3] ; false.?- prefix([1,2], 3, [1,2,3,4,5]). false.?- prefix([1,2,3], 3, L). L = [1, 2, 3 _G599].
57 57 Negation as Failure No equivalent of logical negation in Prolog: Prolog can only assert that something is true. Prolog cannot assert that something is false. Prolog can assert that the given facts and rules do not allow something to be proven true. Assuming that something unprovable is false is called negation as failure. (Based on a closed world assumption.)
58 Negation as Failure The goal \+(G) (or not G) succeeds whenever the goal G fails.?- member(b, [a,b,c]). true?- \+ member(b, [a,b,c]). false.?- not(member(b, [a,b,c])). false.?- not(member(b, [a,c])). true.
59 Negation as Failure: Disjoint Sets overlap(s1,s2) :- member(x,s1),member(x,s2). disjoint(s1,s2) :- \+(overlap(s1,s2)).?- overlap([a,b,c],[c,d,e]). true?- overlap([a,b,c],[d,e,f]). false?- disjoint([a,b,c],[c,d,e]). false?- disjoint([a,b,c],[d,e,f]). true?- disjoint([a,b,c],x). false %< Not what we wanted
60 Negation as Failure overlap(s1,s2) :- member(x,s1),member(x,s2). disjoint(s1,s2) :- \+(overlap(s1,s2)). [trace]?- disjoint([a,b,c],x). Call: (7) disjoint([a, b, c], _G293)? creep Call: (8) overlap([a, b, c], _G293)? creep Call: (9) lists:member(_l230, [a, b, c])? creep Exit: (9) lists:member(a, [a, b, c])? creep Call: (9) lists:member(a, _G293)? creep Exit: (9) lists:member(a, [a _G352])? creep Exit: (8) overlap([a, b, c], [a _G352])? creep Fail: (7) disjoint([a, b, c], _G293)? creep false
61 61 Proper Use of Negation as Failure not(g) works properly only in the following cases: 1. When G is fully instantiated at the time prolog processes the goal not(g). (In this case, not(g) is interpreted to mean goal G does not succeed.) 2. When all variables in G are unique to G, i.e., they don t appear elsewhere in the same clause. (In this case, not(g(x,y)) is interpreted to mean There is no values of X, Y that will make G(X,Y) succeed.)
62 Negation as Failure woman(jane). woman(marilyn). famous(marilyn). loves(john,x) :- woman(x), famous(x). hates(john,x) :- \+ loves(john,x). There are infinitely many women that John hates, not just Jane:?- hates(john,jane). true?- hates(john,susan). true?- hates(john,betty). true...
63 63 Negation as Failure woman(jane). woman(marilyn). famous(marilyn). loves(john,x) :- woman(x), famous(x). hates(john,x) :- \+ loves(john,x). Plus John hates many things:?- hates(john,pizza).?- hates(john,john). We say that the rule hates is not safe. Solution: hates(john,x) :- woman(x), \+ loves(john,x). woman(x) is called a guard it protects from making unwanted inferences.
Connection 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 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 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 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 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 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 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 informationProlog-2 nd Lecture. Prolog Predicate - Box Model
Prolog-2 nd Lecture Tracing in Prolog Procedural interpretation of execution Box model of Prolog predicate rule How to follow a Prolog trace? Trees in Prolog use nested terms Unification Informally Formal
More informationIntroduction Prolog Activity! Prolog. Dr. Mattox Beckman. University of Illinois at Urbana-Champaign Department of Computer Science
Prolog Dr. Mattox Beckman University of Illinois at Urbana-Champaign Department of Computer Science Outline Introduction Objectives Logic Prolog Prolog Queries Builtin Structures Activity! Activity Objectives
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 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 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 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 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 informationAn introduction to logic programming with Prolog
An introduction to logic programming with Prolog Dr. Constantinos Constantinides Department of Computer Science and Software Engineering Concordia University A running example: A family genealogy tree
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 informationThe object level in Prolog. Meta-level predicates and operators. Contents. The flow of computation. The meta level in Prolog
Lecture 8 Meta-level predicates and operators Contents Object level vs. meta level Controlling flow of computation Checking and dismantling expressions Comparison operators The object level in Prolog Prolog
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 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 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 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 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 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 informationLogic Programming. Let us have airline flight information of the form: 1. Application Domains: 2. Definitions
Logic Programming 1. Application Domains: Logic programming language application areas include natural language processing, expert systems, specifications checking, theorem proving, and control systems
More informationChapter 6. Predefined Predicates
Advanced Logic Programming https://sewiki.iai.uni-bonn.de/teaching/lectures/alp/2017/ Chapter 6. Predefined Predicates Updated: 12 June, 2017 Reorganized entire chapter Input and output Exception handling
More informationTests, Backtracking, and Recursion
Tests, Backtracking, and Recursion Artificial Intelligence Programming in Prolog Lecture 3 30/09/04 30/09/04 AIPP Lecture 3: Rules, Results, and Backtracking 1 Re-cap A Prolog program consists of predicate
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 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 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 informationProgramming Paradigms
PP 2017/18 Unit 9 Prolog: Accumulators, Order of Goals/Clauses, and the Cut 1/38 Programming Paradigms Unit 9 Prolog: Accumulators, Order of Goals/Clauses, and the Cut J. Gamper Free University of Bozen-Bolzano
More informationOperational Semantics
15-819K: Logic Programming Lecture 4 Operational Semantics Frank Pfenning September 7, 2006 In this lecture we begin in the quest to formally capture the operational semantics in order to prove properties
More informationAnnouncements. The current topic: Prolog. Logic programming. Logic programming. Lab 2 has been marked.
The current topic: Prolog! Introduction! Object-oriented programming: Python! Functional programming: Scheme! Python GUI programming (Tkinter)! Types and values Logic programming: Prolog Next up: Introduction
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 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 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 informationCSC324 Functional Programming Typing, Exceptions in ML
CSC324 Functional Programming Typing, Exceptions in ML Afsaneh Fazly 1 Winter 2013 1 with many thanks to Anya Tafliovich, Gerald Penn, Sheila McIlraith, Wael Aboelsaddat, Tony Bonner, Eric Joanis, Suzanne
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 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 information1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.
1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered
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 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 informationCAP 5602 Summer, Lesson 4: Loops. The topics 1. the cut and some of its uses 2. the while loop 3. the do until loop
CAP 5602 Summer, 2011 Lesson 4: Loops The topics 1. the cut and some of its uses 2. the while loop 3. the do until loop 1. The cut The cut (!) is a way of controlling backtracking. If a rule contains a
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 informationPredicate Calculus. Problems? Syntax. Atomic Sentences. Complex Sentences. Truth
Problems? What kinds of problems exist for propositional logic? Predicate Calculus A way to access the components of an individual assertion Predicate Calculus: used extensively in many AI programs, especially
More informationSummer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define
CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationLecture 21: Relational Programming II. November 15th, 2011
Lecture 21: Relational Programming II November 15th, 2011 Lecture Outline Relational Programming contd The Relational Model of Computation Programming with choice and Solve Search Strategies Relational
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 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 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 informationResearch Report AI A Numerical Equation Solver in Prolog Michael A. Covington Artificial Intelligence Programs The University of Georgia
Research Report AI 1989 02 A Numerical Equation Solver in Prolog Michael A. Covington Artificial Intelligence Programs The University of Georgia Athens, Georgia 30602 U.S.A. A Numerical Equation Solver
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 informationAdvanced Prolog Programming
1 Introduction CIS335, Assignment 4 Advanced Prolog Programming Geraint Wiggins November 12, 2004 This practical is the second self-assessed exercise for MSc students on the Prolog module. It is intended
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 informationBacktracking. Ch. 5 Controlling Backtracking. Backtracking. Backtracking Example. Example. Example
Backtracking Ch. 5 Controlling Backtracking Backtracking is the attempt to (re)satisfy a goal by exploring alternative ways to satisfy it. Chronological backtracking is backtracking in which we always
More informationOutcome-Oriented Programming (5/12/2004)
1 Outcome-Oriented Programming (5/12/2004) Daniel P. Friedman, William E. Byrd, David W. Mack Computer Science Department, Indiana University Bloomington, IN 47405, USA Oleg Kiselyov Fleet Numerical Meteorology
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 informationzebra puzzle continued recap Prolog concepts family relations
zebra puzzle continued recap Prolog concepts family relations 1 recapping the Zebra puzzle 2 ****** the facts ****** There are 5 houses, occupied by politicallyincorrect gentlemen of 5 different nationalities,
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 informationLogic Programming (PLP 11) Prolog Imperative Control Flow: Backtracking, Cut, Fail, Not
Logic Programming (PLP 11) Prolog Imperative Control Flow: Backtracking, Cut, Fail, Not Carlos Varela Rennselaer Polytechnic Institute September 2, 2014 C. Varela 1 Backtracking Forward chaining goes from
More informationLecture 5: Declarative Programming. The Declarative Kernel Language Machine. September 12th, 2011
Lecture 5: Declarative Programming. The Declarative Kernel Language Machine September 12th, 2011 1 Lecture Outline Declarative Programming contd Dataflow Variables contd Expressions and Statements Functions
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 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 informationDeduction Rule System vs Production Rule System. Prof. Bob Berwick. Rules Rule
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.034 Artificial Intelligence, Fall 2003 Recitation 2, September 11/12 Rules Rule Prof. Bob Berwick Agenda
More informationSCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017
SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationCSCC24 Functional Programming Scheme Part 2
CSCC24 Functional Programming Scheme Part 2 Carolyn MacLeod 1 winter 2012 1 Based on slides from Anya Tafliovich, and with many thanks to Gerald Penn and Prabhakar Ragde. 1 The Spirit of Lisp-like Languages
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 informationProgramming Languages Third Edition
Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand
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 informationBacktracking. Backtracking. Backtracking. Backtracking. Backtracking. Backtracking. Functional & Logic Programming - Backtracking October, 01
Functional & Logic Programming - October, 01 already seen how to control execution ordering the clauses and goals can affect the speed of execution and the order of evaluation of the clauses now going
More informationAssignment 1. University of Toronto, CSC384 - Introduction to Artificial Intelligence, Winter
Assignment 1. University of Toronto, CSC384 - Introduction to Artificial Intelligence, Winter 2014 1 Computer Science 384 January 26, 2014 St. George Campus University of Toronto Homework Assignment #1
More information6.034 Notes: Section 11.1
6.034 Notes: Section 11.1 Slide 11.1.1 We've now spent a fair bit of time learning about the language of first-order logic and the mechanisms of automatic inference. And, we've also found that (a) it is
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 informationCOMP 9416, session 1, 2006 p. 1. Datalog. COMP 9416, session 1, 2006
OMP 9416, session 1, 2006 p. 1 Datalog OMP 9416, session 1, 2006 OMP 9416, session 1, 2006 p. 2 Atoms, integers and variables The fact "person(socrates).", the fact "sum(2,3,y)." and the rule "mortal(x)
More informationList of lectures. Lecture content. Symbolic Programming. TDDA69 Data and Program Structure Symbolic and Logic Programming Cyrille Berger
List of lectures TDDA69 Data and Program Structure Symbolic and Logic Programming Cyrille Berger 1Introduction and Functional Programming 2Imperative Programming and Data Structures 3Parsing 4Evaluation
More informationVariables. Substitution
Variables Elements of Programming Languages Lecture 4: Variables, binding and substitution James Cheney University of Edinburgh October 6, 2015 A variable is a symbol that can stand for another expression.
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 informationProgramming Paradigms
PP 2017/18 Unit 6 Prolog Basics 1/42 Programming Paradigms Unit 6 Prolog Basics J. Gamper Free University of Bozen-Bolzano Faculty of Computer Science IDSE PP 2017/18 Unit 6 Prolog Basics 2/42 Outline
More informationChapter 3: Propositional Languages
Chapter 3: Propositional Languages We define here a general notion of a propositional language. We show how to obtain, as specific cases, various languages for propositional classical logic and some non-classical
More informationFundamentals of Prolog
Fundamentals of Prolog Prof. Geraint A. Wiggins Centre for Cognition, Computation and Culture Goldsmiths College, University of London Contents Summary of Lecture 1 What makes a good Prolog program? What
More information1.3. Conditional expressions To express case distinctions like
Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a
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 informationProcessing lists in Prolog - 2
Processing lists in Prolog - 2 This lecture shows that techniques introduced before (analysing terminating conditions and recursive programming) can be used to develop more complex procedures. This lecture
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 informationNotes on Higher Order Programming in Scheme. by Alexander Stepanov
by Alexander Stepanov August 1986 INTRODUCTION Why Scheme? Because it allows us to deal with: 1. Data Abstraction - it allows us to implement ADT (abstact data types) in a very special way. The issue of
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 informationLogic Programming and Resolution Lecture notes for INF3170/4171
Logic Programming and Resolution Lecture notes for INF3170/4171 Leif Harald Karlsen Autumn 2015 1 Introduction This note will explain the connection between logic and computer programming using Horn Clauses
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 informationFunctional Programming. Pure Functional Languages
Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure
More informationProlog. GNU Prolog ( SWI-Prolog (
Logic programming Most computations are directed, progressing from an input to an output. In functional programming, this is made very explicit, as the input is the argument of a function and the output
More informationDATABASE THEORY. Lecture 11: Introduction to Datalog. TU Dresden, 12th June Markus Krötzsch Knowledge-Based Systems
DATABASE THEORY Lecture 11: Introduction to Datalog Markus Krötzsch Knowledge-Based Systems TU Dresden, 12th June 2018 Announcement All lectures and the exercise on 19 June 2018 will be in room APB 1004
More informationFunctional Programming. Pure Functional Languages
Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure
More informationLecture 3: Recursion; Structural Induction
15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion
More informationA Pearl on SAT Solving in Prolog (extended abstract)
A Pearl on SAT Solving in Prolog (extended abstract) Jacob M. Howe and Andy King 1 Introduction The Boolean satisfiability problem, SAT, is of continuing interest because a variety of problems are naturally
More informationLecture Overview Prolog 1. Introduction Interaction Terms 2. Clauses and predicates Clauses Predicates Variables 3.
1 Lecture Overview Prolog 1. Introduction Interaction Terms 2. Clauses and predicates Clauses Predicates Variables 3. Satisfying goals 2 Prolog A standard free Prolog can be downloaded from http://www.swi-prolog.org
More informationc constructor P, Q terms used as propositions G, H hypotheses scope identifier for a notation scope M, module identifiers t, u arbitrary terms
Coq quick reference Meta variables Usage Meta variables Usage c constructor P, Q terms used as propositions db identifier for a hint database s string G, H hypotheses scope identifier for a notation scope
More informationCoq quick reference. Category Example Description. Inductive type with instances defined by constructors, including y of type Y. Inductive X : Univ :=
Coq quick reference Category Example Description Meta variables Usage Meta variables Usage c constructor P, Q terms used as propositions db identifier for a hint database s string G, H hypotheses scope
More informationInductive Logic Programming (ILP)
Inductive Logic Programming (ILP) Brad Morgan CS579 4-20-05 What is it? Inductive Logic programming is a machine learning technique which classifies data through the use of logic programs. ILP algorithms
More informationPart I CHR tutorial. Cambridge University Press Constraint Handling Rules Thom Fruhwirth Excerpt More information
Part I CHR tutorial We present the essentials of the Constraint Handling Rules (CHR) programming language by the use of examples in this Tutorial part. The first chapter Getting started is a step-by-step
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 information