├── figures ├── sigmod.ps ├── stack-layout.fig ├── DESC ├── unnamed.fig ├── sigmod-call-graph.fig ├── slgf-owel1.fig ├── approx.fig ├── trapped2.fig ├── call-dep.fig ├── slg-examp.fig ├── slgf-owe1.fig ├── slgf-owe2.fig ├── slgf-owe3.fig ├── slgf-owel2.fig ├── trans-ind.fig ├── xfig.SAVE ├── slg-search-tree.fig ├── trapped1.fig ├── call-dep1.fig ├── slgf-owe4.fig ├── call-dep1d.fig ├── strat-trapped.fig ├── slglattice.fig ├── slglatticed.fig ├── ctp.tex ├── spqr1.fig ├── spqr1d.fig ├── trapped3.fig ├── aug-slg-for.fig ├── trapped3d.fig ├── slgf-owel3.fig ├── cut-diag.fig ├── cut-diagd.fig ├── slglat.fig ├── dump.slide ├── se.tex ├── frst-str.fig ├── slgf-owel4.fig ├── slg-examp3.fig ├── slg-examp4.fig ├── no-cascade.fig ├── no-cascaded.fig ├── m0s1s2s.fig ├── hilog-graph.fig ├── CDG.1.eps ├── lattice.fig ├── multi-cycle.fig ├── slg-examp2.fig ├── alt-slg-examp2.fig ├── cascade.fig ├── cascaded.fig ├── expgraph.fig ├── slg-examp5.fig ├── arch.fig ├── arch.figsav ├── slide-cpstack.fig ├── call-dep.eps.eps ├── dep-graph.eps ├── sigmod-call-graph.eps ├── unnamed.eps ├── new-stack-layout.fig ├── slg-examp.eps ├── stack-layout ├── call-dep.eps ├── opt-of-algo.eps ├── parscc.fig ├── new-stack-layoutd.fig ├── efreem0s1s2s.fig ├── cpstack.fig ├── cpstack1.fig ├── cpstackd.fig ├── forest2.fig ├── trans-ind.eps ├── detm0s1s2s.fig ├── slglattice.eps ├── slglatticed.eps ├── strat-trapped.eps ├── slg-search-tree.eps ├── simp.fig ├── abstract-trie.fig ├── call-dep1.eps ├── call-dep1d.eps ├── slg-examp1.fig ├── spqr1.eps ├── spqr1d.eps ├── Completion.3.eps ├── alt-slg-examp.fig ├── approx.eps ├── slide1.eps ├── trapped2.eps ├── aug-slg-for.eps ├── alt-slg-examp1.fig ├── tree3.fig └── tree4.fig ├── .gitignore ├── exercises.dvi ├── incrtabling.tex ├── automata_stuff ├── FSM.vss └── fsm.txt ├── programs.spec ├── xsbsys.tex ├── ps.sty ├── modules.tex ├── myappend.P ├── twice.P ├── propgram.P ├── hilog.P ├── strat.P ├── incrtabling.P ├── longestpath.P ├── tablebi.tex ├── complex.P ├── firsts.P ├── dynprog_exercises.tex ├── datalog.P ├── complex1.P ├── bottom_up_eval_by_subsump.P ├── texput.log ├── maxtest.P ├── avoids.P ├── abs_trees.P ├── files.P ├── mintest.P ├── seqcomp.P ├── annotatedlog.P ├── grammar1.P ├── bug.P ├── dfsearch.P ├── bookoutl ├── csgram.P ├── grammar_nl.P ├── resolution_example.txt ├── fol.P ├── debugging.tex ├── aggreg2.P ├── mdp.P ├── prolog.P ├── wumpus.P ├── programs.P ├── grammarlrk.P ├── grammarlrk1.P ├── knapsack.P ├── grammar.P ├── negation.P ├── grammarabd.P └── agg.P /figures/sigmod.ps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /figures/stack-layout.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.aux 3 | *.bbl 4 | *.blg 5 | *.dvi 6 | *.log 7 | *.pdf 8 | *.toc 9 | -------------------------------------------------------------------------------- /exercises.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWI-Prolog/tabled-prolog-book/HEAD/exercises.dvi -------------------------------------------------------------------------------- /incrtabling.tex: -------------------------------------------------------------------------------- 1 | \chapter{Incremental Table Maintenance} 2 | 3 | Describe incremental maintenance. 4 | -------------------------------------------------------------------------------- /automata_stuff/FSM.vss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWI-Prolog/tabled-prolog-book/HEAD/automata_stuff/FSM.vss -------------------------------------------------------------------------------- /programs.spec: -------------------------------------------------------------------------------- 1 | 2 | 3 | yrCourse(_1, _2) :- 4 | student(_3, _4, _1), enroll(_3, _5), course(_5, _2). 5 | 6 | -------------------------------------------------------------------------------- /xsbsys.tex: -------------------------------------------------------------------------------- 1 | \chapter{XSB System Facilities} 2 | 3 | compiler options 4 | 5 | Foreign code interface 6 | 7 | Calling XSB from C 8 | -------------------------------------------------------------------------------- /ps.sty: -------------------------------------------------------------------------------- 1 | % postscript inclusion: 2 | %\def\texpsfig#1#2#3{\vbox{\kern #3pt\hbox{\special{psfile=#1}\kern #2pt}}\typeout{(#1)}} 3 | \input psfig 4 | -------------------------------------------------------------------------------- /modules.tex: -------------------------------------------------------------------------------- 1 | \chapter{XSB Modules} 2 | 3 | The XSB module system and how it works. 4 | 5 | Does this deserve a chapter of its own, or should it be under System 6 | Facilities. 7 | -------------------------------------------------------------------------------- /figures/DESC: -------------------------------------------------------------------------------- 1 | 2 | Tabspc.fig 3 | 4 | Schematic of xsb table space 5 | 6 | Forest2.fig 7 | 8 | forest of trees for double recursion example 9 | 10 | cpstack.fig 11 | 12 | cp stack for double recursion. -------------------------------------------------------------------------------- /myappend.P: -------------------------------------------------------------------------------- 1 | append([],L,L). 2 | append([X|L1],L2,[X|L3]) :- 3 | append(L1,L2,L3). 4 | 5 | member(X,[X|_L]). 6 | member(X,[_Y|L]) :- member(X,L). 7 | 8 | reverse([],[]). 9 | reverse([X|T],R) :- 10 | reverse(T,TR), 11 | append(TR,[X],R). 12 | -------------------------------------------------------------------------------- /twice.P: -------------------------------------------------------------------------------- 1 | % twice(successor)(1,X). 2 | % twice(twice(successor))(1,X). 3 | % twice(twice(square))(2,X). 4 | :- hilog twice. 5 | twice(X,twice(X)). 6 | twice(F)(X,R) :- F(X,U), F(U,R). 7 | 8 | :- hilog successor,double,square. 9 | 10 | successor(X,Y) :- Y is X+1. 11 | double(X,Y) :- Y is X+X. 12 | square(X,Y) :- Y is X*X. 13 | -------------------------------------------------------------------------------- /propgram.P: -------------------------------------------------------------------------------- 1 | 2 | 3 | :- auto_table. 4 | sent --> conjsent. 5 | sent --> sent, [or], conjsent. 6 | conjsent --> negsent. 7 | conjsent --> conjsent, [and], negsent. 8 | negsent --> basicsent. 9 | negsent --> [not], negsent. 10 | basicsent --> [PropSym], {atom(PropSym),PropSym\==and,PropSym\==or,PropSym\==(not)}. 11 | basicsent --> ['('], sent, [')']. 12 | -------------------------------------------------------------------------------- /hilog.P: -------------------------------------------------------------------------------- 1 | closure(R)(X,Y) :- R(X,Y). 2 | closure(R)(X,Y) :- R(X,Z), closure(R)(Z,Y). 3 | 4 | :- hilog parent. 5 | parent(able,adam). 6 | parent(able,eve). 7 | parent(cain,adam). 8 | parent(cain,eve). 9 | 10 | map(_F)([],[]). 11 | map(F)([X|Xs],[Y|Ys]) :- F(X,Y), map(F)(Xs,Ys). 12 | 13 | :- hilog successor, double. 14 | successor(X,Y) :- Y is X+1. 15 | double(X,Y) :- Y is X+X. 16 | -------------------------------------------------------------------------------- /strat.P: -------------------------------------------------------------------------------- 1 | :- table strat(_,_,lattice(max(_,_,_))). 2 | 3 | strat(P,A,0). 4 | strat(P,A,L) :- 5 | rule(H,Body), 6 | functor(H,P,A), 7 | comma_member(SubGoal,Body), 8 | (SubGoal = \+(SubAtom) 9 | -> true 10 | ; SubAtom = SubGoal 11 | ), 12 | functor(SubAtom,SP,SA), 13 | strat(SP,SA,SL), 14 | (SubGoal == SubAtom 15 | -> L = SL 16 | ; L is SL+1 17 | ). 18 | -------------------------------------------------------------------------------- /incrtabling.P: -------------------------------------------------------------------------------- 1 | :- table p/2 as incremental. 2 | 3 | p(X,Y) :- q(X,Y), Y =< 5. 4 | 5 | :- dynamic q/2 as incremental. 6 | q(a,1). 7 | q(b,3). 8 | q(c,5). 9 | q(d,7). 10 | 11 | 12 | :- dynamic e/2 as incremental. 13 | e(a,b). 14 | e(b,c). 15 | e(c,d). 16 | e(d,c). 17 | 18 | :- table path/2 as incremental. 19 | path(X,Y) :- e(X,Y). 20 | path(X,Y) :- path(X,Z), e(Z,Y). 21 | 22 | -------------------------------------------------------------------------------- /longestpath.P: -------------------------------------------------------------------------------- 1 | % longest path (without loops) 2 | :- import bagMax/2 from aggregs. 3 | :- import member/2 from basics. 4 | 5 | longpath(X,Y,P)(D) :- edge(X,Y,D), P=[F|R], \+member(F,R). 6 | longpath(X,Y,P)(D) :- 7 | bagMax(longpath(X,Z,[Z|P]),D), edge(Z,Y,D), Y\==Z, \+member(Y,P). 8 | 9 | :- hilog maximum. maximum(X,Y,Z) :- X @< Y -> Z=Y ; Z=X. 10 | 11 | edge(a,b,5). 12 | edge(a,b,6). 13 | edge(a,d,4). 14 | edge(d,b,5). 15 | edge(b,c,3). 16 | edge(b,c,4). 17 | -------------------------------------------------------------------------------- /tablebi.tex: -------------------------------------------------------------------------------- 1 | \chapter{Table Builtins} 2 | 3 | table builtins: get\_calls, get\_returns, abolish\_all\_tables, ... 4 | 5 | trie\_assert, trie\_retract (or maybe in section on large files, or 6 | maybe in a separate chapter on indexing.) 7 | 8 | Do example to extract parses from a table created by recognition of a 9 | string in a CF grammar. (How to do, maybe interpreter.) 10 | 11 | As examples, how about suspend / resume (which Rui has working at least 12 | partly) and the cursors / server example? 13 | 14 | -------------------------------------------------------------------------------- /complex.P: -------------------------------------------------------------------------------- 1 | :- import conset/2,conget/2,coninc/1 from prof_sbp. 2 | :- import load_dyn/1,length/2 from basics. 3 | 4 | :- table i/1. 5 | i(true) :- !,coninc(ctr). 6 | i((A,B)) :- !,coninc(ctr),i(A),coninc(ctr),i(B),coninc(ctr). 7 | i(A) :- coninc(ctr),clause(A,B),coninc(ctr),i(B),coninc(ctr). 8 | 9 | lf(File) :- load_dyn(File). 10 | run(G) :- abolish_all_tables, 11 | conset(ctr,0), 12 | (i(G),fail;true), 13 | conget(ctr,Val), 14 | findall(X,d(X),L),length(L,N), 15 | write('Steps('),write(N),write('): '),writeln(Val). 16 | 17 | -------------------------------------------------------------------------------- /firsts.P: -------------------------------------------------------------------------------- 1 | :- op(1050,xfx,(==>)). 2 | 3 | :- table first/3. 4 | first(_,0,[]). 5 | first([],K,[]) :- K>0. 6 | first([S|R],K,L) :- K>0, 7 | (S ==> B), 8 | first(B,K,L1), 9 | length(L1,K1), 10 | Kr is K - K1, 11 | first(R,Kr,L2), 12 | append(L1,L2,L). 13 | first([S|R],K,[S|L]) :- K>0, 14 | \+ (S ==> _), % S is a terminal 15 | K1 is K-1, 16 | first(R,K1,L). 17 | 18 | 19 | e ==> [e,+,t]. 20 | e ==> [e,-,t]. 21 | e ==> [t]. 22 | t ==> [t,*,f]. 23 | t ==> [t,/,f]. 24 | t ==> [f]. 25 | f ==> [int]. 26 | f ==> ['(',e,')']. 27 | -------------------------------------------------------------------------------- /dynprog_exercises.tex: -------------------------------------------------------------------------------- 1 | \section{Exercises} 2 | 3 | 4 | \begin{enumerate} 5 | \item 6 | Given two sequences A and B, what is the minimal number of operations 7 | to turn A into B? The allowable operations are: insert a new symbol, 8 | delete a symbol, and replace a symbol. Each operation costs one unit. 9 | 10 | Hint: Represent string A as facts a(N,Sym), meaning that the symbol at 11 | position N in string A is Sym. Similarly for B. Then write a 12 | predicate cost(N,M,C) which is true if the minimum cost of turning 13 | a1...aN into b1...bM is C. 14 | \end{enumerate} 15 | -------------------------------------------------------------------------------- /figures/unnamed.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 239 119 239 139 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 7 | 0 0 1.000 4.000 8.000 8 | 239 159 239 179 9999 9999 9 | 3 2 1 1 -1 0 0 0 4.000 1 0 10 | 0 0 1.000 4.000 8.000 11 | 254 194 279 154 254 119 9999 9999 12 | 0.000 0.000 273.100 175.337 279.350 165.337 278.681 143.662 13 | 272.431 134.912 0.000 0.000 14 | 4 0 0 12 0 -1 0 0.00000 4 12 33 219 119 a(a,X) 15 | 4 0 0 12 0 -1 0 0.00000 4 12 33 219 159 a(b,X) 16 | 4 0 0 12 0 -1 0 0.00000 4 12 32 219 199 a(c,X) 17 | -------------------------------------------------------------------------------- /automata_stuff/fsm.txt: -------------------------------------------------------------------------------- 1 | Machine: min(completed(det(efree(m0s1s2s)))) 2 | Transitions: 3 | [sink]--0-->[sink] 4 | [sink]--1-->[sink] 5 | [sink]--2-->[sink] 6 | [[q0],[q0,q1,q2]]--0-->[[q0],[q0,q1,q2]] 7 | [[q0],[q0,q1,q2]]--1-->[[q1,q2]] 8 | [[q0],[q0,q1,q2]]--2-->[[q2]] 9 | [[q1,q2]]--0-->[sink] 10 | [[q1,q2]]--1-->[[q1,q2]] 11 | [[q1,q2]]--2-->[[q2]] 12 | [[q2]]--0-->[sink] 13 | [[q2]]--1-->[sink] 14 | [[q2]]--2-->[[q2]] 15 | Initial States: [[[q0],[q0,q1,q2]]] 16 | Final States: [[[q0],[q0,q1,q2]],[[q2]],[[q1,q2]]] 17 | -------------------------------------------------------------------------------- /datalog.P: -------------------------------------------------------------------------------- 1 | :- table avoids/2. 2 | avoids(Source,Target) :- 3 | owes(Source,Target). 4 | avoids(Source,Target) :- 5 | avoids(Source,Intermediate), 6 | owes(Intermediate,Target). 7 | 8 | owes(X,Y) :- 9 | X>0,X=<4000, 10 | (X =:= 4000 11 | -> Y = 1 12 | ; Y is X+1 13 | ). 14 | end_of_file. 15 | 16 | owes(andy,bill). 17 | owes(bill,andy). 18 | owes(andy,carl). 19 | owes(carl,dave). 20 | 21 | avoids(Source,Target) :- 22 | owes(Source,Intermediate), 23 | avoids(Intermediate,Target). 24 | 25 | 26 | owes(andy,bill). 27 | owes(bill,carl). 28 | owes(carl,bill). 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /figures/sigmod-call-graph.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 239 119 239 139 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 7 | 0 0 1.000 4.000 8.000 8 | 239 159 239 179 9999 9999 9 | 3 2 1 1 -1 0 0 0 4.000 1 0 10 | 0 0 1.000 4.000 8.000 11 | 254 194 279 154 254 119 9999 9999 12 | 0.000 0.000 273.100 175.337 279.350 165.337 278.681 143.662 13 | 272.431 134.912 0.000 0.000 14 | 4 0 0 12 0 -1 0 0.00000 4 12 33 219 119 a(a,X) 15 | 4 0 0 12 0 -1 0 0.00000 4 12 33 219 159 a(b,X) 16 | 4 0 0 12 0 -1 0 0.00000 4 12 32 219 199 a(c,X) 17 | -------------------------------------------------------------------------------- /figures/slgf-owel1.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 4 0 -1 0 0 0 12 0.0000000 4 180 2610 3225 600 avoids(andy,Ya) :- avoids(andy,Ya)\001 13 | 4 0 -1 0 0 0 12 0.0000000 4 180 2520 1125 1200 avoids(andy,Ya) :- owes(andy,Ya)\001 14 | 4 0 -1 0 0 0 12 0.0000000 4 180 1395 1125 1800 avoids(andy,bill) :-\001 15 | 4 0 -1 0 0 0 12 0.0000000 4 180 3630 4350 1200 avoids(andy,Ya) :- avoids(andy,Int), owes(Int,Ya)\001 16 | -------------------------------------------------------------------------------- /complex1.P: -------------------------------------------------------------------------------- 1 | t1 :- p(A,B,C,D),p(B,F,G,A),p(A,C,F,D),p(D,G,A,E),p(A,D,F,G). 2 | 3 | p(A,B,C,D) :- d(A),d(B),d(C),d(D). 4 | p(A,B,C) :- d(A),d(B),d(C). 5 | 6 | d(1). 7 | d(2). 8 | d(3). 9 | d(4). 10 | d(5). 11 | d(6). 12 | d(7). 13 | d(8). 14 | 15 | t2 :- p(A,B,C,D),p(B,F,G,A),p(A,C,F,D),f1(D,G,A),p(A,D,F,G). 16 | f1(D,G,A) :- p(D,G,A,E). 17 | 18 | t3 :- f2(A,B,D,F),p(B,F,G,A),f1(D,G,A),p(A,D,F,G). 19 | f2(A,B,D,F) :- p(A,B,C,D),p(A,C,F,D). 20 | 21 | t4 :- f3(A,D,F,G),f1(D,G,A),p(A,D,F,G). 22 | f3(A,D,F,G) :- f2(A,B,D,F),p(B,F,G,A). 23 | 24 | t5 :- f4(A,D,G),f1(D,G,A). 25 | f4(A,D,G) :- f3(A,D,F,G),p(A,D,F,G). 26 | 27 | q1 :- p(A,B,C),p(B,B,D),p(D,B,C). 28 | 29 | q2 :- p(A,B,C). 30 | -------------------------------------------------------------------------------- /figures/approx.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 244 174 169 239 9999 9999 6 | 3 0 0 1 -1 0 0 0 0.000 1 0 7 | 0 0 1.000 4.000 8.000 8 | 245 173 320 198 320 238 9999 9999 9 | 3 0 0 1 -1 0 0 0 0.000 0 1 10 | 0 0 1.000 4.000 8.000 11 | 244 174 269 249 309 249 9999 9999 12 | 3 2 1 1 -1 0 0 0 4.000 1 0 13 | 0 0 1.000 4.000 8.000 14 | 174 254 249 284 334 259 9999 9999 15 | 0.000 0.000 214.633 275.762 233.383 283.262 266.130 284.810 16 | 287.380 278.560 0.000 0.000 17 | 4 0 12 12 0 -1 0 0.00000 4 12 63 224 169 0. p(X,Y) 18 | 4 0 12 12 0 -1 0 0.00000 4 12 49 154 254 1. q(X) 19 | 4 0 12 12 0 -1 0 0.00000 4 11 49 319 254 2. r(Y) 20 | -------------------------------------------------------------------------------- /figures/trapped2.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 244 174 169 239 9999 9999 6 | 3 0 0 1 -1 0 0 0 0.000 1 0 7 | 0 0 1.000 4.000 8.000 8 | 245 173 320 198 320 238 9999 9999 9 | 3 0 0 1 -1 0 0 0 0.000 0 1 10 | 0 0 1.000 4.000 8.000 11 | 244 174 269 249 309 249 9999 9999 12 | 3 2 1 1 -1 0 0 0 4.000 1 0 13 | 0 0 1.000 4.000 8.000 14 | 174 254 249 284 334 259 9999 9999 15 | 0.000 0.000 214.633 275.762 233.383 283.262 266.130 284.810 16 | 287.380 278.560 0.000 0.000 17 | 4 0 0 12 0 -1 0 0.00000 4 12 50 224 169 0) p(X,Y) 18 | 4 0 0 12 0 -1 0 0.00000 4 12 38 154 254 1) q(X) 19 | 4 0 0 12 0 -1 0 0.00000 4 12 37 319 254 2) r(Y) 20 | -------------------------------------------------------------------------------- /figures/call-dep.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 134 284 134 324 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 7 | 0 0 1.000 4.000 8.000 8 | 134 284 54 324 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 0 1 10 | 0 0 1.000 4.000 8.000 11 | 59 329 129 329 9999 9999 12 | 3 2 0 1 -1 0 0 0 0.000 1 0 13 | 0 0 1.000 4.000 8.000 14 | 49 319 74 274 124 279 9999 9999 15 | 0.000 0.000 56.862 290.946 63.112 279.696 84.628 268.440 16 | 97.128 269.690 0.000 0.000 17 | 4 0 0 12 0 -1 0 0.00000 4 2 7 124 314 ~ 18 | 4 0 0 12 0 -1 0 0.00000 4 12 36 119 274 0) r(X) 19 | 4 0 0 12 0 -1 0 0.00000 4 12 20 54 344 1) p 20 | 4 0 0 12 0 -1 0 0.00000 4 12 20 129 344 3) q 21 | -------------------------------------------------------------------------------- /figures/slg-examp.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 4 | 239 79 179 119 9999 9999 5 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 6 | 239 79 239 119 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 8 | 179 144 179 184 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 10 | 239 144 239 184 9999 9999 11 | 2 1 2 1 -1 0 0 0 3.000 -1 0 0 12 | 239 79 299 119 9999 9999 13 | 4 0 0 12 0 -1 0 0.00000 4 12 22 229 69 r(X) 14 | 4 0 0 12 0 -1 0 0.00000 4 9 27 159 109 X = 1 15 | 4 0 0 12 0 -1 0 0.00000 4 9 27 209 109 X = 2 16 | 4 0 0 12 0 -1 0 0.00000 4 9 13 169 138 ~p 17 | 4 0 0 12 0 -1 0 0.00000 4 12 37 164 209 r(X1),q 18 | 4 0 0 12 0 -1 0 0.00000 4 9 6 234 139 q 19 | 4 0 0 12 0 -1 0 0.00000 4 9 13 229 209 ~p 20 | -------------------------------------------------------------------------------- /bottom_up_eval_by_subsump.P: -------------------------------------------------------------------------------- 1 | /* Bottom-up evaluator, using subsumptive tabling, 2 | when called as interp(X). 3 | Verify that this is the "linear" bottom-up Horn clause algorithm? 4 | Note must separate out interp_and to avoid calling interp((X,Y)), 5 | and generating infinitely many answers. 6 | */ 7 | 8 | :- use_subsumptive_tabling interp/1. 9 | %:- table interp/1. 10 | 11 | interp(true). 12 | interp(A) :- 13 | rule(A,B), 14 | interp_and(B), 15 | writeln(succeed(A)). 16 | 17 | interp_and((A,B)) :- !,interp(A),interp_and(B). 18 | interp_and(A) :- interp(A). 19 | 20 | rule(p,(q,r,s)). 21 | rule(p,(r,t)). 22 | rule(q,(t,u)). 23 | rule(t,s). 24 | rule(s,true). 25 | rule(u,(t,s)). 26 | rule(r,u). 27 | -------------------------------------------------------------------------------- /texput.log: -------------------------------------------------------------------------------- 1 | This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2011.1.29) 7 FEB 2011 16:53 2 | entering extended mode 3 | file:line:error style messages enabled. 4 | %&-line parsing enabled. 5 | **A 6 | 7 | ! Emergency stop. 8 | <*> A 9 | 10 | End of file on the terminal! 11 | 12 | 13 | Here is how much of TeX's memory you used: 14 | 4 strings out of 94501 15 | 92 string characters out of 1176789 16 | 48403 words of memory out of 1000000 17 | 3273 multiletter control sequences out of 10000+50000 18 | 3640 words of font info for 14 fonts, out of 500000 for 2000 19 | 580 hyphenation exceptions out of 1000 20 | 0i,0n,0p,5b,6s stack positions out of 1500i,500n,5000p,200000b,5000s 21 | No pages of output. 22 | -------------------------------------------------------------------------------- /figures/slgf-owe1.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 13 | 5625 1275 5625 1650 14 | 4 0 -1 0 0 0 12 0.0000000 4 180 2610 3225 600 avoids(andy,Ya) :- avoids(andy,Ya)\001 15 | 4 0 -1 0 0 0 12 0.0000000 4 180 2520 1125 1200 avoids(andy,Ya) :- owes(andy,Ya)\001 16 | 4 0 -1 0 0 0 12 0.0000000 4 180 3750 4350 1200 avoids(andy,Ya) :- owes(andy,Intb),avoids(intb,Ya)\001 17 | 4 0 -1 0 0 0 12 0.0000000 4 180 1395 1125 1800 avoids(andy,bill) :-\001 18 | 4 0 -1 0 0 0 12 0.0000000 4 180 2490 4350 1800 avoids(andy,Ya) :- avoids(bill,Ya)\001 19 | -------------------------------------------------------------------------------- /figures/slgf-owe2.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 13 | 5625 1275 5625 1650 14 | 4 0 -1 0 0 0 12 0.0000000 4 165 2370 3225 600 avoids(bill,Ya) :- avoids(bill,Ya)\001 15 | 4 0 -1 0 0 0 12 0.0000000 4 165 2280 1125 1200 avoids(bill,Ya) :- owes(bill,Ya)\001 16 | 4 0 -1 0 0 0 12 0.0000000 4 165 1305 1125 1800 avoids(bill,carl) :-\001 17 | 4 0 -1 0 0 0 12 0.0000000 4 165 3510 4350 1200 avoids(bill,Ya) :- owes(bill,Intb),avoids(intb,Ya)\001 18 | 4 0 -1 0 0 0 12 0.0000000 4 165 2400 4350 1800 avoids(bill,Ya) :- avoids(carl,Ya)\001 19 | -------------------------------------------------------------------------------- /figures/slgf-owe3.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 13 | 5625 1275 5625 1650 14 | 4 0 -1 0 0 0 12 0.0000000 4 165 2430 3225 600 avoids(carl,Ya) :- avoids(carl,Ya)\001 15 | 4 0 -1 0 0 0 12 0.0000000 4 165 2340 1125 1200 avoids(carl,Ya) :- owes(carl,Ya)\001 16 | 4 0 -1 0 0 0 12 0.0000000 4 165 3570 4350 1200 avoids(carl,Ya) :- owes(carl,Intb),avoids(intb,Ya)\001 17 | 4 0 -1 0 0 0 12 0.0000000 4 165 1305 1125 1800 avoids(carl,bill) :-\001 18 | 4 0 -1 0 0 0 12 0.0000000 4 165 2400 4350 1800 avoids(carl,Ya) :- avoids(bill,Ya)\001 19 | -------------------------------------------------------------------------------- /figures/slgf-owel2.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 13 | 5700 1275 4875 1650 14 | 4 0 -1 0 0 0 12 0.0000000 4 180 2610 3225 600 avoids(andy,Ya) :- avoids(andy,Ya)\001 15 | 4 0 -1 0 0 0 12 0.0000000 4 180 2520 1125 1200 avoids(andy,Ya) :- owes(andy,Ya)\001 16 | 4 0 -1 0 0 0 12 0.0000000 4 180 1395 1125 1800 avoids(andy,bill) :-\001 17 | 4 0 -1 0 0 0 12 0.0000000 4 180 3630 4350 1200 avoids(andy,Ya) :- avoids(andy,Int), owes(Int,Ya)\001 18 | 4 0 -1 0 0 0 12 0.0000000 4 180 2400 3600 1800 avoids(andy,Ya) :- owes(bill,Ya)\001 19 | -------------------------------------------------------------------------------- /figures/trans-ind.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 440 260 375 280 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 439 260 504 280 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 368 300 309 319 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 369 300 428 319 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 369 301 369 318 9999 9999 18 | 4 0 14 12 0 -1 0 0.00000 4 12 63 409 254 p(g(X),Y) 19 | 4 0 14 12 0 -1 0 0.00000 4 12 49 485 295 p(X,Y). 20 | 4 0 14 12 0 -1 0 0.00000 4 12 42 410 334 p(b,1) 21 | 4 0 14 12 0 -1 0 0.00000 4 12 42 348 334 p(a,Y) 22 | 4 0 14 12 0 -1 0 0.00000 4 12 63 339 296 p(X,f(Y)) 23 | 4 0 14 12 0 -1 0 0.00000 4 12 42 284 336 p(a,Y) 24 | -------------------------------------------------------------------------------- /figures/xfig.SAVE: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 440 260 375 280 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 439 260 504 280 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 368 300 309 319 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 369 300 428 319 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 369 301 369 318 9999 9999 18 | 4 0 14 12 0 -1 0 0.00000 4 8 28 495 295 true 19 | 4 0 14 12 0 -1 0 0.00000 4 12 63 269 336 p_gf(a,Z) 20 | 4 0 14 12 0 -1 0 0.00000 4 12 63 338 334 p_gf(a,a) 21 | 4 0 14 12 0 -1 0 0.00000 4 12 63 410 334 p_gf(b,1) 22 | 4 0 14 12 0 -1 0 0.00000 4 12 63 409 254 p(g(X),Y) 23 | 4 0 14 12 0 -1 0 0.00000 4 12 77 334 296 p_g(X,f(Z)) 24 | -------------------------------------------------------------------------------- /maxtest.P: -------------------------------------------------------------------------------- 1 | % Find the longest path (without cycles) in a weighted directed graph. 2 | :- import memberchk/2 from basics. 3 | :- import aggregInit/0, bagMax/2 from myaggregs. 4 | :- hilog maximum. maximum(X,Y,Z) :- X @>= Y -> Z=X; Z=Y. 5 | 6 | % top call: 7 | lp(S,T,C) :- aggregInit, bagMax(lp(S,T),C). 8 | 9 | % max of costs over all intermediate nonlooping paths, eliminating 10 | % multiple paths through same set of nodes. 11 | lp(S,T)(C) :- bagMax(lp(S,T,_),C). 12 | 13 | % max cost over any nonlooping path 14 | lp(X,Y,[X,Y])(C) :- edge(X,Y,C). 15 | lp(X,Y,L1)(C) :- 16 | bagMax(lp(X,Z,L),C1), 17 | edge(Z,Y,C2), 18 | \+ memberchk(Y,L), 19 | sort([Y|L],L1), 20 | C is C1+C2. 21 | 22 | edge(a,b,5). 23 | edge(b,d,6). 24 | edge(b,c,1). 25 | edge(c,e,3). 26 | edge(e,d,1). 27 | edge(a,c,7). 28 | edge(c,d,2). 29 | 30 | edge(c,a,1). 31 | edge(d,a,1). 32 | -------------------------------------------------------------------------------- /avoids.P: -------------------------------------------------------------------------------- 1 | :- import member/2 from basics. 2 | 3 | :- table avoids/2. 4 | avoids(X,Y) :- owe(X,Y). 5 | avoids(X,Y) :- owe(X,Z), avoids(Z,Y). 6 | 7 | avoids(X,Y,L) :- owe(X,Y), \+member(Y,L). 8 | avoids(X,Y,L) :- owe(X,Z), \+member(Z,L), avoids(Z,Y,[Z|L]). 9 | 10 | owes(andy,bill). 11 | owes(bill,carl). 12 | owes(carl,bill). 13 | 14 | owe(a,b). 15 | owe(a,b). 16 | owe(b,c). 17 | owe(b,c). 18 | owe(c,d). 19 | owe(c,d). 20 | owe(d,e). 21 | owe(d,e). 22 | owe(e,f). 23 | owe(e,f). 24 | owe(f,g). 25 | owe(f,g). 26 | owe(g,h). 27 | owe(g,h). 28 | owe(h,i). 29 | owe(h,i). 30 | owe(i,j). 31 | owe(i,j). 32 | owe(j,k). 33 | owe(j,k). 34 | owe(k,l). 35 | owe(k,l). 36 | owe(l,m). 37 | owe(l,m). 38 | owe(m,o). 39 | owe(m,o). 40 | owe(o,p). 41 | owe(o,p). 42 | owe(p,q). 43 | owe(p,q). 44 | owe(q,r). 45 | owe(q,r). 46 | owe(r,s). 47 | owe(r,s). 48 | owe(s,t). 49 | owe(s,t). 50 | 51 | -------------------------------------------------------------------------------- /figures/slg-search-tree.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 239 79 239 119 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 7 | 0 0 1.000 4.000 8.000 8 | 239 79 99 119 9999 9999 9 | 2 1 1 1 -1 0 0 0 4.000 7 1 0 10 | 0 0 1.000 4.000 8.000 11 | 239 79 379 119 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 13 | 0 0 1.000 4.000 8.000 14 | 239 139 239 179 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 16 | 0 0 1.000 4.000 8.000 17 | 99 139 99 179 9999 9999 18 | 4 0 12 10 0 -1 0 0.00000 4 9 138 194 69 0) r(X):root:r(X)<-r(X) 19 | 4 0 12 10 0 -1 0 0.00000 4 9 96 204 199 4) q:active:q<-p 20 | 4 0 12 10 0 -1 0 0.00000 4 9 132 29 199 2) p:active:p<-r(X1),q 21 | 4 0 12 10 0 -1 0 0.00000 4 9 138 174 134 3) r(X):active:r(2)<-~q 22 | 4 0 12 10 0 -1 0 0.00000 4 9 108 334 134 r(X):answer:r(3)<- 23 | 4 0 12 10 0 -1 0 0.00000 4 9 132 29 133 1) r(X):active:r(1)<-p 24 | -------------------------------------------------------------------------------- /abs_trees.P: -------------------------------------------------------------------------------- 1 | :- table b/3,g/3,s/3,b_abs/3,g_abs/3. 2 | s(s(P,c)) --> b_abs(P), [c]. 3 | s(s(P,d)) --> g_abs(P), [d]. 4 | 5 | b(b(P1,P2)) --> b_abs(P1), b_abs(P2). 6 | b(a) --> [a]. 7 | 8 | g(g(P)) --> g_abs(P), [a]. 9 | g(a) --> [a]. 10 | 11 | b_abs({X:b(X,S0,S)},S0,S) :- b(_,S0,S). 12 | 13 | g_abs({X:g(X,S0,S)},S0,S) :- g(_,S0,S). 14 | 15 | /** g(g(P),S0,S) :- 16 | g_abs(P,S0,S1), 'C'(S1,a,S). 17 | g(a,S0,S) :- 18 | 'C'(S0,a,S). 19 | 20 | b_abs({X:b(X,S0,S)},S0,S) :- b(_,S0,S). 21 | 22 | g_abs({X:g(X,S0,S)},S0,S) :- g(_,S0,S). 23 | **/ 24 | 25 | eterm(AT,AT) :- var(AT), !. 26 | eterm({X:R},T) :- !, 27 | call(R), 28 | eterm(X,T). 29 | eterm(AT,T) :- 30 | AT =.. [F|As], 31 | eterm_list(As,Ts), 32 | T =.. [F|Ts]. 33 | 34 | eterm_list([],[]). 35 | eterm_list([A|As],[T|Ts]) :- 36 | eterm(A,T), 37 | eterm_list(As,Ts). 38 | 39 | 40 | -------------------------------------------------------------------------------- /figures/trapped1.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 244 174 169 239 9999 9999 6 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 7 | 499 259 499 239 399 239 399 259 499 259 9999 9999 8 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 9 | 499 239 499 219 399 219 399 239 499 239 9999 9999 10 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 11 | 499 219 499 199 399 199 399 219 499 219 9999 9999 12 | 3 0 0 1 -1 0 0 0 0.000 1 0 13 | 0 0 1.000 4.000 8.000 14 | 245 173 320 198 320 238 9999 9999 15 | 3 0 0 1 -1 0 0 0 0.000 0 1 16 | 0 0 1.000 4.000 8.000 17 | 244 174 269 249 309 249 9999 9999 18 | 4 0 12 12 0 -1 0 0.00000 4 12 63 224 169 0) p(X,Y) 19 | 4 0 12 12 0 -1 0 0.00000 4 11 49 319 254 2) r(Y) 20 | 4 0 12 12 0 -1 0 0.00000 4 12 49 154 254 1) q(X) 21 | 4 0 12 10 0 -1 0 0.00000 4 9 78 409 214 (r(Y),2,0,2)  22 | 4 0 12 10 0 -1 0 0.00000 4 9 78 409 234 (q(X),1,1,0)  23 | 4 0 12 10 0 -1 0 0.00000 4 9 90 409 254 (p(X,Y),0,0,0)  24 | -------------------------------------------------------------------------------- /files.P: -------------------------------------------------------------------------------- 1 | between(L,L,H) :- L =< H. 2 | between(L,M,H) :- L < H, L1 is L+1, between(L1,M,H). 3 | 4 | /* create synthetic attr/3 predicate. create_attr(K,L,Ind) where K is 5 | number of objs, L is number of attrs/obj */ 6 | 7 | create_attr(K,L,Index) :- 8 | abolish(attr/3), 9 | dynamic(attr/3), 10 | index(attr/3,Index), 11 | Tot is K*L, 12 | write('Creating '),write(Tot),write(' facts...'), 13 | (between(1,I,K), 14 | between(1,J,L), 15 | asserta(attr(I,J,J)), 16 | fail 17 | ; 18 | true 19 | ), 20 | writeln(completed). 21 | 22 | tcall(Goal,Cnt) :- 23 | cputime(T0), 24 | (between(1,_,Cnt), 25 | call(Goal), 26 | fail 27 | ; 28 | true 29 | ), 30 | cputime(T1), 31 | Time is T1-T0, 32 | writeln(userout,cputime(Time)). 33 | 34 | 35 | %% create_attr(1000,50,0),tcall(attr(1000,50,50),1000). 36 | %% create_attr(1000,50,1),tcall(attr(1000,50,50),1000). 37 | 38 | %% create_attr(10000,500,[1+2]),tcall(attr(1000,50,_),1000). -------------------------------------------------------------------------------- /figures/call-dep1.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 134 284 54 324 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 7 | 0 0 1.000 4.000 8.000 8 | 134 284 134 324 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 10 | 0 0 1.000 4.000 8.000 11 | 59 329 129 329 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 349 264 349 284 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 349 304 349 324 9999 9999 18 | 4 0 12 12 0 -1 0 0.00000 4 11 63 119 274 0. a(a,Z) 19 | 4 0 12 12 0 -1 0 0.00000 4 11 63 29 344 1. a(b,Z) 20 | 4 0 12 12 0 -1 0 0.00000 4 11 63 109 344 2. a(c,Z) 21 | 4 0 12 12 0 -1 0 0.00000 4 11 63 319 259 0. a(a,Z) 22 | 4 0 12 12 0 -1 0 0.00000 4 11 63 319 299 1. a(b,Z) 23 | 4 0 12 12 0 -1 0 0.00000 4 11 63 319 339 2. a(c,Z) 24 | 4 0 0 12 0 -1 0 0.00000 4 12 51 79 394 Program 2 25 | 4 0 0 12 0 -1 0 0.00000 4 12 51 324 394 Program 1 26 | -------------------------------------------------------------------------------- /figures/slgf-owe4.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 13 | 5625 1275 5625 1650 14 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 15 | 5625 1875 5625 2250 16 | 4 0 -1 0 0 0 12 0.0000000 4 180 2610 3225 600 avoids(andy,Ya) :- avoids(andy,Ya)\001 17 | 4 0 -1 0 0 0 12 0.0000000 4 180 2520 1125 1200 avoids(andy,Ya) :- owes(andy,Ya)\001 18 | 4 0 -1 0 0 0 12 0.0000000 4 180 3750 4350 1200 avoids(andy,Ya) :- owes(andy,Intb),avoids(intb,Ya)\001 19 | 4 0 -1 0 0 0 12 0.0000000 4 180 1395 1125 1800 avoids(andy,bill) :-\001 20 | 4 0 -1 0 0 0 12 0.0000000 4 180 2490 4350 1800 avoids(andy,Ya) :- avoids(bill,Ya)\001 21 | 4 0 -1 0 0 0 12 0.0000000 4 180 1425 4350 2400 avoids(andy,carl) :-\001 22 | -------------------------------------------------------------------------------- /figures/call-dep1d.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 134 284 54 324 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 7 | 0 0 1.000 4.000 8.000 8 | 134 284 134 324 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 10 | 0 0 1.000 4.000 8.000 11 | 59 329 129 329 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 349 264 349 284 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 349 304 349 324 9999 9999 18 | 4 0 12 12 0 -1 0 0.00000 4 11 63 119 274 0. a(a,Z) 19 | 4 0 12 12 0 -1 0 0.00000 4 11 63 29 344 1. a(b,Z) 20 | 4 0 12 12 0 -1 0 0.00000 4 11 63 109 344 2. a(c,Z) 21 | 4 0 12 12 0 -1 0 0.00000 4 11 63 319 259 0. a(a,Z) 22 | 4 0 12 12 0 -1 0 0.00000 4 11 63 319 299 1. a(b,Z) 23 | 4 0 0 12 0 -1 0 0.00000 4 12 51 79 394 Program 2 24 | 4 0 0 12 0 -1 0 0.00000 4 12 51 324 394 Program 1 25 | 4 0 12 12 0 -1 0 0.00000 4 14 63 319 339 2. a(c,Z) 26 | -------------------------------------------------------------------------------- /figures/strat-trapped.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 179 74 234 74 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 179 74 234 154 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 274 154 319 124 9999 9999 12 | 3 2 0 1 -1 0 0 0 0.000 1 0 13 | 0 0 1.000 4.000 8.000 14 | 279 74 319 79 334 104 9999 9999 15 | 0.000 0.000 301.824 73.075 311.824 74.325 324.190 82.381 16 | 327.940 88.631 0.000 0.000 17 | 3 2 0 1 -1 0 0 0 0.000 1 0 18 | 0 0 1.000 4.000 8.000 19 | 269 84 289 114 314 114 9999 9999 20 | 0.000 0.000 277.017 102.763 282.017 110.263 293.842 116.591 21 | 300.092 116.591 0.000 0.000 22 | 4 0 0 12 0 -1 0 0.00000 4 12 20 159 79 0) s 23 | 4 0 0 12 0 -1 0 0.00000 4 12 20 319 119 3) q 24 | 4 0 0 12 0 -1 0 0.00000 4 12 38 239 79 1) p(X) 25 | 4 0 0 12 0 -1 0 0.00000 4 12 34 239 159 2) r(1) 26 | 4 0 0 12 0 -1 0 0.00000 4 2 7 284 134 ~ 27 | -------------------------------------------------------------------------------- /figures/slglattice.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 4 | 286 230 9999 9999 5 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 6 | 359 226 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 8 | 0 0 1.000 4.000 8.000 9 | 219 229 324 199 9999 9999 10 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 11 | 0 0 1.000 4.000 8.000 12 | 428 230 323 200 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 14 | 0 0 1.000 4.000 8.000 15 | 324 223 324 200 9999 9999 16 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 17 | 0 0 1.000 4.000 8.000 18 | 324 282 324 242 9999 9999 19 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 20 | 0 0 1.000 4.000 8.000 21 | 323 283 219 239 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 324 284 428 240 9999 9999 25 | 4 0 12 10 0 -1 0 0.00000 4 5 18 319 295 new 26 | 4 0 12 10 0 -1 0 0.00000 4 9 48 304 194 disposed 27 | 4 0 12 10 0 -1 0 0.00000 4 7 36 204 237 active 28 | 4 0 12 10 0 -1 0 0.00000 4 5 36 418 238 answer 29 | 4 0 12 10 0 -1 0 0.00000 4 7 60 297 238 floundered 30 | -------------------------------------------------------------------------------- /figures/slglatticed.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 4 | 286 230 9999 9999 5 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 6 | 359 226 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 8 | 0 0 1.000 4.000 8.000 9 | 219 229 324 199 9999 9999 10 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 11 | 0 0 1.000 4.000 8.000 12 | 428 230 323 200 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 14 | 0 0 1.000 4.000 8.000 15 | 324 223 324 200 9999 9999 16 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 17 | 0 0 1.000 4.000 8.000 18 | 324 282 324 242 9999 9999 19 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 20 | 0 0 1.000 4.000 8.000 21 | 323 283 219 239 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 324 284 428 240 9999 9999 25 | 4 0 12 10 0 -1 0 0.00000 4 5 18 319 295 new 26 | 4 0 12 10 0 -1 0 0.00000 4 9 48 304 194 disposed 27 | 4 0 12 10 0 -1 0 0.00000 4 7 36 204 237 active 28 | 4 0 12 10 0 -1 0 0.00000 4 5 36 418 238 answer 29 | 4 0 12 10 0 -1 0 0.00000 4 7 60 297 238 floundered 30 | -------------------------------------------------------------------------------- /figures/ctp.tex: -------------------------------------------------------------------------------- 1 | 2 | \vspace*{\itemsep} 3 | \longline 4 | \begin{sf} 5 | \begin{tabbing} 6 | foooooo\=fooo\=fooo\=fooo\=fooooooooooooooooooooooooooo\=\kill 7 | \> Algorithm Call\_Tabled\_Predicate({\em Subgoal}) \\ 8 | \> \> If {\em Subgoal} is in table \{ \\ 9 | \> \> \> If {\em Subgoal} has been completed \{ \\ 10 | \> \> \> \> Set up choice point to backtrack through answer clauses; \\ 11 | \> \> \> \} \\ 12 | \> \> \> Otherwise if {\em Subgoal} has not been completed \{ \\ 13 | \> \> \> \> Freeze stacks; \\ 14 | \> \> \> \> Set up choicepoint to backtrack through answer clauses \\ 15 | \> \> \> \> (and to suspend when the answer clauses are exhausted); \\ 16 | \> \> \> \} \\ 17 | \> \> \} \\ 18 | \> \> Otherwise if {\em Subgoal} is not in table \{ \\ 19 | \> \> \> Add {\em Subgoal} to table; \\ 20 | \> \> \} \\ 21 | \> \> Backtrack through program clauses; \\ 22 | \> \} 23 | \end{tabbing} 24 | \end{sf} 25 | \longline 26 | \vspace*{\itemsep} 27 | 28 | 29 | -------------------------------------------------------------------------------- /figures/spqr1.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 319 219 319 264 9999 9999 6 | 3 2 0 1 -1 0 0 0 0.000 1 0 7 | 0 0 1.000 4.000 8.000 8 | 354 304 344 279 324 274 9999 9999 9 | -5.000 0.000 350.883 289.076 348.383 282.826 340.644 276.071 10 | 335.644 274.821 -5.000 0.000 11 | 3 2 0 1 -1 0 0 0 0.000 1 0 12 | 0 0 1.000 4.000 8.000 13 | 309 274 289 289 284 304 9999 9999 14 | 0.000 5.000 296.772 281.404 291.772 285.154 287.247 291.432 15 | 285.997 295.182 0.000 5.000 16 | 3 2 0 1 -1 0 0 0 0.000 1 0 17 | 0 0 1.000 4.000 8.000 18 | 284 325 319 335 359 325 9999 9999 19 | 0.000 6.000 303.521 332.388 312.271 334.888 326.622 335.127 20 | 336.622 332.627 0.000 6.000 21 | 4 0 12 12 0 -1 0 0.00000 4 9 7 314 275 p 22 | 4 0 12 12 0 -1 0 0.00000 4 9 7 279 316 q 23 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 317 r 24 | 4 0 12 12 0 -1 0 0.00000 4 10 14 314 354 \+ 25 | 4 0 12 12 0 -1 0 0.00000 4 10 14 274 284 \+ 26 | 4 0 12 12 0 -1 0 0.00000 4 10 14 354 284 \+ 27 | 4 0 12 12 0 -1 0 0.00000 4 6 7 314 214 s 28 | -------------------------------------------------------------------------------- /figures/spqr1d.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 319 219 319 264 9999 9999 6 | 3 2 0 1 -1 0 0 0 0.000 1 0 7 | 0 0 1.000 4.000 8.000 8 | 354 304 344 279 324 274 9999 9999 9 | -5.000 0.000 350.883 289.076 348.383 282.826 340.644 276.071 10 | 335.644 274.821 -5.000 0.000 11 | 3 2 0 1 -1 0 0 0 0.000 1 0 12 | 0 0 1.000 4.000 8.000 13 | 309 274 289 289 284 304 9999 9999 14 | 0.000 5.000 296.772 281.404 291.772 285.154 287.247 291.432 15 | 285.997 295.182 0.000 5.000 16 | 3 2 0 1 -1 0 0 0 0.000 1 0 17 | 0 0 1.000 4.000 8.000 18 | 284 325 319 335 359 325 9999 9999 19 | 0.000 6.000 303.521 332.388 312.271 334.888 326.622 335.127 20 | 336.622 332.627 0.000 6.000 21 | 4 0 12 12 0 -1 0 0.00000 4 9 7 314 275 p 22 | 4 0 12 12 0 -1 0 0.00000 4 9 7 279 316 q 23 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 317 r 24 | 4 0 12 12 0 -1 0 0.00000 4 10 14 314 354 \+ 25 | 4 0 12 12 0 -1 0 0.00000 4 10 14 274 284 \+ 26 | 4 0 12 12 0 -1 0 0.00000 4 10 14 354 284 \+ 27 | 4 0 12 12 0 -1 0 0.00000 4 14 7 314 214 s 28 | -------------------------------------------------------------------------------- /mintest.P: -------------------------------------------------------------------------------- 1 | :- import aggregInit/0, bagMin/2, bagReduce/4 from myaggregs. 2 | :- import get_calls/3, get_returns/2 from trie_tables. 3 | 4 | % This computes the shortest path in a graph. 5 | % The goal is: sp(a,Y,C). 6 | 7 | sp(X,Y,C) :- aggregInit, bagMin(sp(X,Y),C). 8 | 9 | sp(X,Y)(C) :- edge(X,Y,C). 10 | sp(X,Y)(C) :- bagMin(sp(X,Z),C1), edge(Z,Y,C2), C is C1+C2. 11 | 12 | :- hilog minimum. 13 | minimum(X,Y,Z) :- X @=< Y -> Z = X ; Z = Y. 14 | 15 | 16 | % This computes the minimum cost spanning tree. 17 | % The goal is: mcst(a,S,T). 18 | 19 | mcst(X,F,Z) :- aggregInit, bagReduce(mcst(X,Z),[_C,F],min1,[134000000]). 20 | 21 | mcst(X,Y)([C,X]) :- edge(X,Y,C). 22 | mcst(X,Y)([C,Z]) :- 23 | bagReduce(mcst(X,Z),[C1,_],min1,[134000000]), %works! 24 | edge(Z,Y,C2), 25 | C is C1+C2. 26 | 27 | :- hilog min1. 28 | min1([C1|F1],[C2|F2],[C3|F3]) :- 29 | C1 @=< C2 30 | -> C3 = C1, F3 = F1 31 | ; C3 = C2, F3 = F2. 32 | 33 | edge(a,b,5). 34 | edge(b,d,6). 35 | edge(b,c,1). 36 | edge(c,e,3). 37 | edge(e,d,1). 38 | edge(a,c,7). 39 | edge(c,d,2). 40 | 41 | 42 | -------------------------------------------------------------------------------- /figures/trapped3.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 244 174 169 239 9999 9999 6 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 7 | 559 239 559 219 459 219 459 239 559 239 9999 9999 8 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 9 | 559 259 559 239 459 239 459 259 559 259 9999 9999 10 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 11 | 559 219 559 199 459 199 459 219 559 219 9999 9999 12 | 3 0 0 1 -1 0 0 0 0.000 1 0 13 | 0 0 1.000 4.000 8.000 14 | 245 173 320 198 320 238 9999 9999 15 | 3 0 0 1 -1 0 0 0 0.000 0 1 16 | 0 0 1.000 4.000 8.000 17 | 244 174 269 249 309 249 9999 9999 18 | 4 0 0 10 0 -1 0 0.00000 4 9 43 224 169 0) p(X,Y) 19 | 4 0 0 10 0 -1 0 0.00000 4 9 32 154 254 1) q(X) 20 | 4 0 0 10 0 -1 0 0.00000 4 9 31 319 254 2) r(Y) 21 | 4 0 12 10 0 -1 0 0.00000 4 9 36 419 254 p(X,Y) 22 | 4 0 12 10 0 -1 0 0.00000 4 9 24 419 233 q(X) 23 | 4 0 12 10 0 -1 0 0.00000 4 9 24 418 216 r(Y) 24 | 4 0 12 10 0 -1 0 0.00000 4 9 48 469 214 (2,0,2)  25 | 4 0 12 10 0 -1 0 0.00000 4 9 48 469 234 (1,1,0)  26 | 4 0 12 10 0 -1 0 0.00000 4 9 48 469 254 (0,0,0)  27 | -------------------------------------------------------------------------------- /figures/aug-slg-for.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 399 269 534 339 4 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 5 | 0 0 1.000 4.000 8.000 6 | 454 284 454 324 9999 9999 7 | 4 0 12 10 0 -1 0 0.00000 4 9 66 424 278 p:root:p<-p 8 | 4 0 12 10 0 -1 0 0.00000 4 9 132 399 339 2) p:active:p<-r(X1),q 9 | -6 10 | 6 579 269 679 339 11 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 12 | 0 0 1.000 4.000 8.000 13 | 624 284 624 324 9999 9999 14 | 4 0 12 10 0 -1 0 0.00000 4 9 66 589 279 q:root:q<-q 15 | 4 0 12 10 0 -1 0 0.00000 4 9 96 579 339 4) q:active:q<-p 16 | -6 17 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 18 | 0 0 1.000 4.000 8.000 19 | 195 281 75 341 9999 9999 20 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 21 | 0 0 1.000 4.000 8.000 22 | 194 284 194 324 9999 9999 23 | 2 1 1 1 -1 0 0 0 4.000 7 1 0 24 | 0 0 1.000 4.000 8.000 25 | 196 283 316 343 9999 9999 26 | 4 0 12 10 0 -1 0 0.00000 4 9 138 124 339 3) r(X):active:r(2)<-~q 27 | 4 0 12 10 0 -1 0 0.00000 4 9 108 269 359 r(X):answer:r(3)<- 28 | 4 0 12 10 0 -1 0 0.00000 4 9 132 9 359 1) r(X):active:r(1)<-p 29 | 4 0 12 10 0 -1 0 0.00000 4 9 138 129 279 0) r(X):root:r(X)<-r(X) 30 | -------------------------------------------------------------------------------- /figures/trapped3d.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 244 174 169 239 9999 9999 6 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 7 | 559 239 559 219 459 219 459 239 559 239 9999 9999 8 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 9 | 559 259 559 239 459 239 459 259 559 259 9999 9999 10 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 11 | 559 219 559 199 459 199 459 219 559 219 9999 9999 12 | 3 0 0 1 -1 0 0 0 0.000 1 0 13 | 0 0 1.000 4.000 8.000 14 | 245 173 320 198 320 238 9999 9999 15 | 3 0 0 1 -1 0 0 0 0.000 0 1 16 | 0 0 1.000 4.000 8.000 17 | 244 174 269 249 309 249 9999 9999 18 | 4 0 12 10 0 -1 0 0.00000 4 11 42 154 254 1. q(X) 19 | 4 0 12 10 0 -1 0 0.00000 4 11 54 224 169 0. p(X,Y) 20 | 4 0 12 10 0 -1 0 0.00000 4 11 42 319 254 2. r(Y) 21 | 4 0 12 10 0 -1 0 0.00000 4 11 24 418 216 r(Y) 22 | 4 0 12 10 0 -1 0 0.00000 4 11 24 419 233 q(X) 23 | 4 0 12 10 0 -1 0 0.00000 4 11 36 419 254 p(X,Y) 24 | 4 0 12 10 0 -1 0 0.00000 4 11 48 469 214 (2,0,2)  25 | 4 0 12 10 0 -1 0 0.00000 4 11 48 469 234 (1,1,0)  26 | 4 0 12 10 0 -1 0 0.00000 4 11 48 469 254 (0,0,0)  27 | -------------------------------------------------------------------------------- /figures/slgf-owel3.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 13 | 5700 1275 4875 1650 14 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 15 | 4800 1875 4800 2250 16 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 17 | 5775 1275 7650 1650 18 | 4 0 -1 0 0 0 12 0.0000000 4 180 2610 3225 600 avoids(andy,Ya) :- avoids(andy,Ya)\001 19 | 4 0 -1 0 0 0 12 0.0000000 4 180 2520 1125 1200 avoids(andy,Ya) :- owes(andy,Ya)\001 20 | 4 0 -1 0 0 0 12 0.0000000 4 180 1395 1125 1800 avoids(andy,bill) :-\001 21 | 4 0 -1 0 0 0 12 0.0000000 4 180 3630 4350 1200 avoids(andy,Ya) :- avoids(andy,Int), owes(Int,Ya)\001 22 | 4 0 -1 0 0 0 12 0.0000000 4 180 2400 3600 1800 avoids(andy,Ya) :- owes(bill,Ya)\001 23 | 4 0 -1 0 0 0 12 0.0000000 4 180 1425 3975 2400 avoids(andy,carl) :-\001 24 | 4 0 -1 0 0 0 12 0.0000000 4 180 2430 6450 1800 avoids(andy,Ya) :- owes(carl,Ya)\001 25 | -------------------------------------------------------------------------------- /seqcomp.P: -------------------------------------------------------------------------------- 1 | /* sequence comparisons. How to change one sequence into another. 2 | A=a_1 a_2 ... a_n 3 | B=b_1 b_2 b_3 ... b_m 4 | Change A into B using 3 operations: insert, delete, replace each cost 1. 5 | */ 6 | 7 | % c(N,M,C) if C is minimum cost of changing a_1...a_N into b_1...b_M 8 | :- table c/3. 9 | c(0,0,0). 10 | c(0,M,M) :- M > 0. 11 | c(N,0,N) :- N > 0. 12 | c(N,M,C) :- N > 0, M > 0, 13 | N1 is N-1, M1 is M-1, 14 | c(N1,M,C1), C1a is C1+1, % insert last of A to make B 15 | c(N,M1,C2), C2a is C2+1, % delete last of A to make B 16 | % replace last of A to make B 17 | c(N1,M1,C3), a(N,A), b(M,B), (A==B -> C3a=C3; C3a is C3+1), 18 | min(C1a,C2a,Cm1), min(Cm1,C3a,C). 19 | 20 | min(X,Y,Z) :- X =< Y -> Z=X ; Z=Y. 21 | 22 | a(1,a). 23 | a(2,b). 24 | a(3,b). 25 | a(4,c). 26 | a(5,b). 27 | a(6,a). 28 | a(7,b). 29 | 30 | b(1,b). 31 | b(2,a). 32 | b(3,b). 33 | b(4,b). 34 | b(5,a). 35 | b(6,b). 36 | b(7,b). 37 | 38 | time(G) :- 39 | abolish_all_tables, 40 | cputime(T0), 41 | (call(G),writeln(G),fail; true), 42 | cputime(T1), 43 | Time is T1-T0, 44 | write('Cputime: '),writeln(Time), 45 | fail. 46 | -------------------------------------------------------------------------------- /figures/cut-diag.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 199 319 299 319 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 199 159 299 159 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 199 159 199 319 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 299 159 299 319 9999 9999 15 | 4 0 12 12 0 -1 0 0.00000 4 8 7 159 159 P 16 | 4 0 12 12 0 -1 0 0.00000 4 8 7 159 316 P 17 | 4 0 12 12 0 -1 0 0.00000 4 8 7 329 324 T 18 | 4 0 12 12 0 -1 0 0.00000 4 8 7 169 166 T 19 | 4 0 12 12 0 -1 0 0.00000 4 8 7 169 323 T 20 | 4 0 12 12 0 -1 0 0.00000 4 8 7 329 165 T 21 | 4 0 12 12 0 -1 0 0.00000 4 8 14 319 158 P' 22 | 4 0 12 12 0 -1 0 0.00000 4 8 21 169 309 SLD 23 | 4 0 12 12 0 -1 0 0.00000 4 8 21 329 311 SLD 24 | 4 0 12 12 0 -1 0 0.00000 4 8 14 319 315 P' 25 | 4 0 13 12 0 -1 0 0.00000 4 12 91 204 154 Cut_Transform 26 | 4 0 13 12 0 -1 0 0.00000 4 12 91 204 314 Cut_Transform 27 | 4 0 13 12 0 -1 0 0.00000 4 12 98 309 239 SLD-Equivalent 28 | 4 0 13 12 0 -1 0 0.00000 4 12 98 99 239 SLD-Equivalent 29 | -------------------------------------------------------------------------------- /figures/cut-diagd.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 199 319 299 319 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 199 159 299 159 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 199 159 199 319 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 299 159 299 319 9999 9999 15 | 4 0 12 12 0 -1 0 0.00000 4 8 7 159 159 P 16 | 4 0 12 12 0 -1 0 0.00000 4 8 7 159 316 P 17 | 4 0 12 12 0 -1 0 0.00000 4 8 7 329 324 T 18 | 4 0 12 12 0 -1 0 0.00000 4 8 7 169 166 T 19 | 4 0 12 12 0 -1 0 0.00000 4 8 7 169 323 T 20 | 4 0 12 12 0 -1 0 0.00000 4 8 7 329 165 T 21 | 4 0 12 12 0 -1 0 0.00000 4 8 14 319 158 P' 22 | 4 0 12 12 0 -1 0 0.00000 4 8 21 169 309 SLD 23 | 4 0 12 12 0 -1 0 0.00000 4 8 21 329 311 SLD 24 | 4 0 12 12 0 -1 0 0.00000 4 8 14 319 315 P' 25 | 4 0 13 12 0 -1 0 0.00000 4 12 91 204 154 Cut_Transform 26 | 4 0 13 12 0 -1 0 0.00000 4 12 91 204 314 Cut_Transform 27 | 4 0 13 12 0 -1 0 0.00000 4 12 98 309 239 SLD-Equivalent 28 | 4 0 13 12 0 -1 0 0.00000 4 14 98 99 239 SLD-Equivalent 29 | -------------------------------------------------------------------------------- /figures/slglat.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 327 286 419 240 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 329 285 358 239 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 328 285 286 241 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 326 284 222 240 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 223 226 324 198 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 19 | 286 230 9999 9999 20 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 21 | 359 226 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 357 228 327 203 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 286 229 323 203 9999 9999 28 | 4 0 12 10 0 -1 0 0.00000 4 5 18 319 295 new 29 | 4 0 12 10 0 -1 0 0.00000 4 9 48 304 194 disposed 30 | 4 0 12 10 0 -1 0 0.00000 4 7 36 204 237 active 31 | 4 0 12 10 0 -1 0 0.00000 4 9 54 263 237 generator 32 | 4 0 12 10 0 -1 0 0.00000 4 7 48 331 236 interior 33 | 4 0 12 10 0 -1 0 0.00000 4 5 36 405 236 answer 34 | -------------------------------------------------------------------------------- /annotatedlog.P: -------------------------------------------------------------------------------- 1 | :- import bagMin/2 from aggregs. 2 | :- hilog minimum. 3 | minimum(X,Y,Z) :- X =< Y -> Z=X ; Z=Y. 4 | 5 | :- op(500,xfx,@). 6 | 7 | /*********** 8 | G:D :- bagMin(andFun(G),D). 9 | 10 | andFun(G)(D) :- G@L,sumlist(L,D). 11 | 12 | sumlist([],0). 13 | sumlist([X|L],S) :- sumlist(L,S1), S is S1+X. 14 | 15 | p(X,Y)@[D] :- edge(X,Y):D. 16 | p(X,Y)@[D1,D2] :- p(X,Z):D1,edge(Z,Y):D2. 17 | 18 | edge(a,b)@[5]. 19 | edge(b,d)@[6]. 20 | edge(b,c)@[1]. 21 | edge(c,e)@[3]. 22 | edge(e,d)@[1]. 23 | edge(a,c)@[7]. 24 | edge(c,d)@[2]. 25 | /******************/ 26 | :- import bagMax/2 from aggregs. 27 | :- hilog maximum. 28 | maximum(X,Y,Z) :- X >= Y -> Z=X ; Z=Y. 29 | 30 | not(G)@[D] :- 31 | G@D1, 32 | minList(D1,D2), 33 | D is 1000-D2. % confidence is between 0 and 1000 34 | 35 | G:D :- bagMax(andFun(G),D). 36 | 37 | andFun(G)(D) :- G@L, minList(L,D). 38 | 39 | minList([X],X). 40 | minList([X,Y|L],M) :- minList([Y|L],M1), (X < M1 -> M = X ; M = M1). 41 | 42 | h4@[D] :- h1:D. 43 | h4@[D] :- h2:D. 44 | 45 | h5@[D1,D2] :- not(h4):D1, h3:D2. 46 | 47 | c1@[D] :- h4:D. 48 | c1@[D1,D2] :- h5:D1, s4:D2. 49 | 50 | h1@[315]. 51 | h2@[125]. 52 | h3@[500]. 53 | s4@[1000]. 54 | -------------------------------------------------------------------------------- /grammar1.P: -------------------------------------------------------------------------------- 1 | at :- abolish_all_tables. 2 | % Test-grammar: 3 | % :- auto_table. 4 | 5 | :- table b/2, g/2. 6 | s --> b, [c]. 7 | s --> g, [d]. 8 | 9 | b --> b, b. 10 | b --> [a]. 11 | 12 | g --> g, [a]. 13 | g --> [a]. 14 | 15 | 16 | s(s(P,c),S0,S) :- 17 | b(S0,S1), 'C'(S1,c,S), 18 | b(P,S0,S1), 'C'(S1,c,S). 19 | 20 | s(s(P,d),S0,S) :- 21 | g(S0,S1), 'C'(S1,d,S), 22 | g(P,S0,S1), 'C'(S1,d,S). 23 | 24 | b(b(P1,P2),S0,S) :- 25 | b(S0,S1), b(S1,S), 26 | b(P1,S0,S1), b(P2,S1,S). 27 | b(a,S0,S) :- 28 | 'C'(S0,a,S), 29 | 'C'(S0,a,S). 30 | 31 | g(g(P),S0,S) :- 32 | g(S0,S1), 'C'(S1,a,S), 33 | g(P,S0,S1), 'C'(S1,a,S). 34 | g(a,S0,S) :- 35 | 'C'(S0,a,S), 36 | 'C'(S0,a,S). 37 | 38 | 'C'(X,W,Y) :- word(X,W), Y is X+1. 39 | 40 | word(1,a). 41 | word(2,a). 42 | word(3,a). 43 | word(4,a). 44 | word(5,a). 45 | word(6,a). 46 | word(7,a). 47 | word(8,a). 48 | word(9,a). 49 | word(10,a). 50 | word(11,a). 51 | word(12,a). 52 | word(13,a). 53 | word(14,a). 54 | word(15,a). 55 | word(16,a). 56 | word(17,d). 57 | 58 | -------------------------------------------------------------------------------- /figures/dump.slide: -------------------------------------------------------------------------------- 1 | \documentstyle{article} 2 | 3 | \begin{document} 4 | \begin{tabular} 5 | {\tt 6 | p/2: & switchontype & C1a, L1, fail, fail \\ 7 | & switchoncon & [a: C1, b: C2] \\ 8 | \\ 9 | C1a: & trymeelse C2a, 2 & {\em \% p(} \\ 10 | C1: & getcon r1, a & {\em \% a,} \\ 11 | & getcon r2, b & {\em \% b} \\ 12 | & proceed & {\em \% ).} \\ 13 | \\ 14 | C2a: & trustme 2 & {\em \% p(} \\ 15 | C2: & getcon r1, b & {\em \% b,} \\ 16 | & getcon r2, c & {\em \% c} \\ 17 | & proceed & {\em \% ).} \\ 18 | 19 | a/2: & switchontype & C3a, C3a, C3a, C3a \\ 20 | \\ 21 | C3a: & trymeelse C4a, 2 \\ 22 | C3: & allocate & {\em \% a(} \\ 23 | & getpvar v2, r2 & {\em \% X,Y):-} \\ 24 | & putpvar v3, r2 & {\em \% a(X,Z}\\ 25 | & call 4, a/2 & {\em \% ),} \\ 26 | & putdval v3, r1 & {\em \% a(Z,} \\ 27 | & putdval v2, r2 & {\em \% Y} \\ 28 | & deallocate & {\em \% )} \\ 29 | & execute a/2 & {\em \% .} \\ 30 | \\ 31 | C4a: & trustme 2 \\ 32 | C4: & execute p/2 & {\em \% a(X,Y):-p(X,Y).} \\ 33 | } 34 | \begin{center} 35 | WAM code for program 2. 36 | \end{center} 37 | \end{tabular} 38 | \end{document} -------------------------------------------------------------------------------- /figures/se.tex: -------------------------------------------------------------------------------- 1 | 2 | \vspace*{\itemsep} 3 | \longline 4 | \begin{sf} 5 | \begin{tabbing} 6 | foooooo\=fooo\=fooo\=fooo\=fooooooooooooooooooooooooooo\=\kill 7 | \> Algorithm Switch\_envs({\em old\_breg,new\_breg}) \\ 8 | \> \> {\em Start\_trreg} := choice\_point\_trreg({\em old\_breg}); \\ 9 | \> \> {\em End\_trreg} := choice\_point\_trreg({\em new\_breg}); \\ 10 | \> \> {\em trreg} := choice\_point\_trreg({\em new\_breg}); \\ 11 | \> \> while ({\em Start\_trreg} != {\em End\_trreg}) \{ \\ 12 | \> \> \> while ({\em Start\_trreg} $>$ {\em End\_trreg}) \{ \\ 13 | \> \> \> \> untrail(trail\_var({\em Start\_trreg})); \\ 14 | \> \> \> \> {\em Start\_trreg} := trail\_parent({\em Start\_trreg}); \\ 15 | \> \> \> \} \\ 16 | \> \> \> while ({\em End\_trreg} $>$ {\em Start\_trreg}) \{ \\ 17 | \> \> \> \> {\em End\_trreg} := trail\_parent({\em End\_trreg}); \\ 18 | \> \> \> \} \\ 19 | \> \> \} \\ 20 | \> \> {\em End\_trreg} := choice\_point\_trreg({\em tbreg}); \\ 21 | \> \> while ({\em End\_trreg} $>$ {\em Start\_trreg}) \{ \\ 22 | \> \> \> * trail\_var({\em End\_trreg}) := trail\_val({\em End\_trreg}); \\ 23 | \> \> \} 24 | \end{tabbing} 25 | \end{sf} 26 | \longline 27 | \vspace*{\itemsep} 28 | 29 | -------------------------------------------------------------------------------- /figures/frst-str.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 329 149 379 179 4 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 5 | 0 0 1.000 4.000 8.000 6 | 329 174 354 174 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 8 | 0 0 1.000 4.000 8.000 9 | 329 173 354 158 9999 9999 10 | 4 0 0 12 0 -1 0 0.00000 4 6 6 359 179 a 11 | 4 0 0 12 0 -1 0 0.00000 4 6 16 359 159 var 12 | -6 13 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 14 | 0 0 1.000 4.000 8.000 15 | 249 194 274 194 9999 9999 16 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 17 | 0 0 1.000 4.000 8.000 18 | 249 194 269 209 274 214 9999 9999 19 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 20 | 0 0 1.000 4.000 8.000 21 | 249 194 274 179 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 289 194 314 194 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 289 174 314 174 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 29 | 0 0 1.000 4.000 8.000 30 | 329 194 354 194 9999 9999 31 | 4 0 0 12 0 -1 0 0.00000 4 9 6 239 199 g 32 | 4 0 0 12 0 -1 0 0.00000 4 6 6 279 179 a 33 | 4 0 0 12 0 -1 0 0.00000 4 9 6 279 199 b 34 | 4 0 0 12 0 -1 0 0.00000 4 6 16 279 219 var 35 | 4 0 0 12 0 -1 0 0.00000 4 9 3 319 179 f 36 | 4 0 0 12 0 -1 0 0.00000 4 9 6 359 199 1 37 | 4 0 0 12 0 -1 0 0.00000 4 9 3 319 199 f 38 | -------------------------------------------------------------------------------- /figures/slgf-owel4.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7 | 4500 675 2400 1050 8 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9 | 4500 675 5700 1050 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11 | 2400 1275 2400 1650 12 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 13 | 5700 1275 4875 1650 14 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 15 | 4800 1875 4800 2250 16 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 17 | 5775 1275 7650 1650 18 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 19 | 7800 1875 7800 2250 20 | 4 0 -1 0 0 0 12 0.0000000 4 180 2610 3225 600 avoids(andy,Ya) :- avoids(andy,Ya)\001 21 | 4 0 -1 0 0 0 12 0.0000000 4 180 2520 1125 1200 avoids(andy,Ya) :- owes(andy,Ya)\001 22 | 4 0 -1 0 0 0 12 0.0000000 4 180 1395 1125 1800 avoids(andy,bill) :-\001 23 | 4 0 -1 0 0 0 12 0.0000000 4 180 3630 4350 1200 avoids(andy,Ya) :- avoids(andy,Int), owes(Int,Ya)\001 24 | 4 0 -1 0 0 0 12 0.0000000 4 180 2400 3600 1800 avoids(andy,Ya) :- owes(bill,Ya)\001 25 | 4 0 -1 0 0 0 12 0.0000000 4 180 1425 3975 2400 avoids(andy,carl) :-\001 26 | 4 0 -1 0 0 0 12 0.0000000 4 180 2430 6450 1800 avoids(andy,Ya) :- owes(carl,Ya)\001 27 | 4 0 -1 0 0 0 12 0.0000000 4 180 1395 6975 2400 avoids(andy,bill) :-\001 28 | -------------------------------------------------------------------------------- /bug.P: -------------------------------------------------------------------------------- 1 | :- auto_table. 2 | 3 | mis(min(Mach),IS) :- 4 | mis(Mach,Bis), 5 | setof(S,indistinguishable(Mach,Bis,S),IS). 6 | 7 | m(dfa,a,0,b). 8 | m(dfa,a,1,f). 9 | m(dfa,b,0,g). 10 | m(dfa,b,1,c). 11 | m(dfa,c,0,a). 12 | m(dfa,c,1,c). 13 | m(dfa,d,0,c). 14 | m(dfa,d,1,g). 15 | m(dfa,e,0,h). 16 | m(dfa,e,1,f). 17 | m(dfa,f,0,c). 18 | m(dfa,f,1,g). 19 | m(dfa,g,0,g). 20 | m(dfa,g,1,e). 21 | m(dfa,h,0,g). 22 | m(dfa,h,1,c). 23 | 24 | mis(dfa,a). 25 | mfs(dfa,c). 26 | 27 | indistinguishable(Mach,S1,S2) :- 28 | m(Mach,S1,_,_), 29 | m(Mach,S2,_,_), 30 | tnot(distinguishable(Mach,S1,S2)). 31 | 32 | % Assume Mach is a completed deterministic machine 33 | % S1 and S2 are distinquishable if S1 is final and S2 is not. 34 | distinguishable(Mach,S1,S2) :- 35 | mfs(Mach,S1), 36 | m(Mach,S2,_,_), 37 | tnot(mfs(Mach,S2)). 38 | % S1 and S2 are distinquishable if S2 is final and S1 is not. 39 | distinguishable(Mach,S1,S2) :- 40 | mfs(Mach,S2), 41 | m(Mach,S1,_,_), 42 | tnot(mfs(Mach,S1)). 43 | % S1 and S2 are distinguishable if some symbol Sy takes them to states that 44 | % are distinguishable. 45 | distinguishable(Mach,S1,S2) :- 46 | m(Mach,S1,Sy,T1), 47 | m(Mach,S2,Sy,T2), 48 | distinguishable(Mach,T1,T2). 49 | -------------------------------------------------------------------------------- /dfsearch.P: -------------------------------------------------------------------------------- 1 | :- import aggregInit/0, bagMin/2 from myaggregs. 2 | :- import conset/2, conget/2, coninc/1 from prof_sbp. 3 | 4 | search(N,C) :- aggregInit, bagMin(search(N,_),C). 5 | search(N,Co)(Ci) :- 6 | writeln(p(N,Ci)), 7 | findall(M,edge(N,M),L), 8 | Cm is Ci+1, 9 | mapsearch(L,Cm,Co). 10 | 11 | mapsearch([],C,C). 12 | mapsearch([N|Ns],Ci,Co) :- magMin(search(N,Cm),Ci), mapsearch(Ns,Cm,Co). 13 | 14 | searchbu :- aggregInit, bagMin(search(a),_). 15 | search(N)(C) :- 16 | conget(ctr,C), coninc(ctr), 17 | writeln([N,C]), 18 | findall(M,edge(N,M),L), 19 | mapsearch(L). 20 | 21 | mapsearch([]). 22 | mapsearch([N|Ns]) :- bagMin(search(N),_), mapsearch(Ns). 23 | 24 | /***** 25 | :- table search/1. 26 | search(N) :- 27 | writeln(N), 28 | findall(M,edge(N,M),L), 29 | mapsearch(L). 30 | 31 | mapsearch([]). 32 | mapsearch([N|Ns]) :- search(N), mapsearch(Ns). 33 | /*********/ 34 | edge(a,b). 35 | edge(a,m). 36 | edge(b,c). 37 | edge(b,h). 38 | edge(c,d). 39 | edge(c,g). 40 | edge(d,e). 41 | edge(d,f). 42 | edge(h,i). 43 | edge(i,j). 44 | edge(j,k). 45 | edge(j,l). 46 | edge(m,n). 47 | edge(n,o). 48 | edge(n,p). 49 | 50 | /************/ 51 | edge(e,b). 52 | edge(f,c). 53 | edge(g,b). 54 | edge(h,a). 55 | edge(k,i). 56 | edge(l,i). 57 | edge(n,a). 58 | edge(p,a). 59 | /*************/ 60 | -------------------------------------------------------------------------------- /bookoutl: -------------------------------------------------------------------------------- 1 | Programming in XSB -- an outline 2 | 3 | (Should be organized by kind of application, so someone can turn 4 | to chapter that describes something like what they want to do.) 5 | 6 | 7 | Intro 8 | Review of Prolog programming 9 | Prolog as nondeterministic procedural language with assign-once 10 | variables 11 | 12 | Datalog programming 13 | "pure" deductive database examples 14 | 15 | Grammars and parsing 16 | CFG's, (Earley recognition) 17 | first and follow 18 | PTQ example 19 | 20 | Dynamic programming 21 | 22 | Searching (games? see Bratko) 23 | 24 | HiLog programming 25 | generic "Higher order programming": map, closure 26 | "Object oriented" programming, C-Logic variants 27 | 28 | Aggregation and optimization - shortest path 29 | annotated logics and approximate reasoning 30 | 31 | Metaprogramming - 32 | metainterpreters 33 | abstract interpretation examples - e.g. prop 34 | 35 | Using XSB modules 36 | 37 | Managing large extensional relations 38 | load_dyn, load_dync, cvt_canonical. 39 | Database interface, heterogeneous databases 40 | (defining views to merge DB's) 41 | 42 | More on indexing 43 | 44 | Table builtins - get_calls, get_returns 45 | 46 | Extending XSB - foreign language interface 47 | calling XSB from C 48 | 49 | Compiler options 50 | -------------------------------------------------------------------------------- /figures/slg-examp3.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 5 1 2 1 -1 0 0 0 3.000 0 0 0 227.056 400.389 264 264 314 289 349 329 4 | 5 1 2 1 -1 0 0 0 3.000 0 0 0 139.357 378.643 109 269 184 274 244 334 5 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 6 | 99 279 39 319 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 8 | 99 279 99 319 9999 9999 9 | 2 1 2 1 -1 0 0 0 3.000 -1 0 0 10 | 99 279 159 319 9999 9999 11 | 2 2 2 1 -1 0 0 0 3.000 0 0 0 12 | 164 344 149 344 149 329 164 329 164 344 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 14 | 359 279 359 319 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 16 | 259 279 259 319 9999 9999 17 | 3 2 2 1 -1 0 0 0 3.000 0 0 18 | 364 269 414 374 244 419 104 349 9999 9999 19 | 0.000 0.000 414.375 319.956 426.875 346.206 388.042 430.038 20 | 290.060 423.735 213.252 415.839 178.252 398.339 0.000 0.000 21 | 3 2 2 1 -1 0 0 0 3.000 0 0 22 | 244 264 114 224 39 319 9999 9999 23 | 0.000 0.000 178.059 224.168 145.559 214.168 85.916 232.749 24 | 67.166 256.499 0.000 0.000 25 | 4 0 0 12 0 -1 0 0.00000 4 12 22 89 274 r(X) 26 | 4 0 0 12 0 -1 0 0.00000 4 9 6 99 339 q 27 | 4 0 0 12 0 -1 0 0.00000 4 9 13 354 339 ~p 28 | 4 0 0 12 0 -1 0 0.00000 4 12 37 244 339 r(X1),q 29 | 4 0 0 12 0 -1 0 0.00000 4 9 6 354 269 q 30 | 4 0 0 12 0 -1 0 0.00000 4 9 6 29 338 p 31 | 4 0 0 12 0 -1 0 0.00000 4 9 9 249 268 p 32 | -------------------------------------------------------------------------------- /figures/slg-examp4.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 2 2 1 -1 0 0 0 3.000 0 0 0 4 | 304 144 289 144 289 129 304 129 304 144 9999 9999 5 | 2 1 2 1 -1 0 0 0 3.000 7 1 0 6 | 0 0 1.000 4.000 8.000 7 | 239 79 239 119 9999 9999 8 | 2 1 2 1 -1 0 0 0 3.000 7 1 0 9 | 0 0 1.000 4.000 8.000 10 | 239 79 299 119 9999 9999 11 | 2 1 2 1 -1 0 0 0 3.000 7 1 0 12 | 0 0 1.000 4.000 8.000 13 | 239 79 179 119 9999 9999 14 | 2 1 2 1 -1 0 0 0 3.000 7 1 0 15 | 0 0 1.000 4.000 8.000 16 | 179 144 179 184 9999 9999 17 | 2 1 2 1 -1 0 0 0 3.000 7 1 0 18 | 0 0 1.000 4.000 8.000 19 | 239 144 239 184 9999 9999 20 | 2 1 2 1 -1 0 0 0 3.000 -1 1 1 21 | 0 0 1.000 4.000 8.000 22 | 0 0 1.000 4.000 8.000 23 | 179 144 239 184 9999 9999 24 | 3 2 2 1 -1 0 0 0 3.000 1 1 25 | 0 0 1.000 4.000 8.000 26 | 0 0 1.000 4.000 8.000 27 | 179 179 119 79 239 79 9999 9999 28 | 0.000 0.000 122.323 124.625 107.323 99.625 131.016 57.777 29 | 161.016 57.777 0.000 0.000 30 | 4 0 0 12 0 -1 0 0.00000 4 12 22 229 69 r(X) 31 | 4 0 0 12 0 -1 0 0.00000 4 9 27 159 109 X = 1 32 | 4 0 0 12 0 -1 0 0.00000 4 9 27 209 109 X = 2 33 | 4 0 0 12 0 -1 0 0.00000 4 12 37 164 209 r(X1),q 34 | 4 0 0 12 0 -1 0 0.00000 4 9 27 299 109 X = 3 35 | 4 0 0 12 0 -1 0 0.00000 4 9 9 169 138 p 36 | 4 0 0 12 0 -1 0 0.00000 4 9 9 229 209 p 37 | 4 0 0 12 0 -1 0 0.00000 4 9 13 234 139 ~q 38 | -------------------------------------------------------------------------------- /csgram.P: -------------------------------------------------------------------------------- 1 | /* a simple context sensitive grammar: 2 | 3 | S --> aSBC 4 | S --> aBC 5 | CB --> BC 6 | aB --> ab 7 | bB --> bb 8 | bC --> bc 9 | cC --> cc 10 | 11 | */ 12 | 13 | :- auto_table. 14 | 15 | % S --> aSBC 16 | s(S0,S) :- word(S0,a,S1),s(S1,S2),b(S2,S3),c(S3,S). 17 | 18 | % S --> aBC 19 | s(S0,S) :- word(S0,a,S1),b(S1,S2),c(S2,S). 20 | 21 | % CB --> BC 22 | c(S0,p0(S0,S)) :- b(S0,S1),c(S1,S). 23 | b(p0(S0,S),S) :- b(S0,S1),c(S1,S). 24 | 25 | % aB --> ab 26 | word(S0,a,p1(S0,S)) :- word(S0,a,S1),word(S1,b,S). 27 | b(p1(S0,S),S) :- word(S0,a,S1),word(S1,b,S). 28 | 29 | % bB --> bb 30 | word(S0,b,p2(S0,S)) :- word(S0,b,S1),word(S1,b,S). 31 | b(p2(S0,S),S) :- word(S0,b,S1),word(S1,b,S). 32 | 33 | % bC --> bc 34 | word(S0,b,p3(S0,S)) :- word(S0,b,S1),word(S1,c,S). 35 | c(p3(S0,S),S) :- word(S0,b,S1),word(S1,c,S). 36 | 37 | % cC --> cc 38 | word(S0,c,p4(S0,S)) :- word(S0,c,S1),word(S1,c,S). 39 | c(p4(S0,S),S) :- word(S0,c,S1),word(S1,c,S). 40 | 41 | % word can also be a base_word 42 | word(X,Y,Z) :- base_word(X,Y,Z). 43 | 44 | % driver to assert base_word's and call the recognizer. 45 | parse(String) :- 46 | abolish_all_tables, 47 | retractall(base_word(_,_,_)), 48 | assertlist(String,0,Len), 49 | s(0,Len). 50 | 51 | assertlist([],N,N). 52 | assertlist([Sym|Syms],N,M) :- 53 | N1 is N+1, 54 | assert(base_word(N,Sym,N1)), 55 | assertlist(Syms,N1,M). 56 | -------------------------------------------------------------------------------- /grammar_nl.P: -------------------------------------------------------------------------------- 1 | /* simple NL grammar, chapter 1 */ 2 | 3 | s(S0,S) :- np(S0,S1), vp(S1,S). 4 | 5 | np(S0,S) :- det(S0,S1), n(S1,S). 6 | 7 | vp(S0,S) :- tv(S0,S1), np(S1,S). 8 | vp(S0,S) :- v(S0,S). 9 | 10 | det(S0,S) :- S0=[the|S]. 11 | det(S0,S) :- S0=[a|S]. 12 | det(S0,S) :- S0=[every|S]. 13 | 14 | n(S0,S) :- S0=[man|S]. 15 | n(S0,S) :- S0=[woman|S]. 16 | n(S0,S) :- S0=[park|S]. 17 | 18 | tv(S0,S) :- S0=[loves|S]. 19 | tv(S0,S) :- S0=[likes|S]. 20 | 21 | v(S0,S) :- S0=[walks|S]. 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | /********************** 51 | 52 | s --> np, vp. 53 | 54 | np --> det, n. 55 | 56 | vp --> tv, np. 57 | vp --> v. 58 | 59 | det --> [the]. 60 | det --> [a]. 61 | det --> [every]. 62 | 63 | n --> [man]. 64 | n --> [woman]. 65 | n --> [park]. 66 | 67 | tv --> [loves]. 68 | tv --> [likes]. 69 | 70 | v --> [walks]. 71 | 72 | **********************/ 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | /************************** 87 | 88 | expr --> term, addterm. 89 | addterm --> []. 90 | addterm --> [+], expr. 91 | term --> factor, multfactor. 92 | multfactor --> []. 93 | multfactor --> [*], term. 94 | factor --> [I], {integer(I)}. 95 | factor --> ['('], expr, [')']. 96 | 97 | **************************/ 98 | -------------------------------------------------------------------------------- /figures/no-cascade.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 359 104 359 124 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 359 104 309 124 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 359 104 414 124 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 304 144 284 169 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 304 144 319 169 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 19 | 0 0 1.000 4.000 8.000 20 | 359 144 344 164 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 22 | 0 0 1.000 4.000 8.000 23 | 359 144 374 164 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 25 | 0 0 1.000 4.000 8.000 26 | 339 184 339 209 9999 9999 27 | 3 2 0 1 -1 0 0 0 0.000 1 0 28 | 0 0 1.000 4.000 8.000 29 | 279 169 274 144 304 144 9999 9999 30 | 0.000 0.000 271.023 155.406 269.773 149.156 278.974 137.933 31 | 286.474 137.933 0.000 0.000 32 | 4 0 12 12 0 -1 0 0.00000 4 9 7 314 179 g 33 | 4 0 12 12 0 -1 0 0.00000 4 9 7 339 180 h 34 | 4 0 12 12 0 -1 0 0.00000 4 12 7 334 222 j 35 | 4 0 12 12 0 -1 0 0.00000 4 9 7 299 139 b 36 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 99 a 37 | 4 0 12 12 0 -1 0 0.00000 4 6 7 279 179 e 38 | 4 0 12 12 0 -1 0 0.00000 4 9 7 374 179 i 39 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 139 c 40 | 4 0 12 12 0 -1 0 0.00000 4 9 7 414 139 d 41 | -------------------------------------------------------------------------------- /figures/no-cascaded.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 359 104 359 124 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 359 104 309 124 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 359 104 414 124 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 304 144 284 169 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 304 144 319 169 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 19 | 0 0 1.000 4.000 8.000 20 | 359 144 344 164 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 22 | 0 0 1.000 4.000 8.000 23 | 359 144 374 164 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 25 | 0 0 1.000 4.000 8.000 26 | 339 184 339 209 9999 9999 27 | 3 2 0 1 -1 0 0 0 0.000 1 0 28 | 0 0 1.000 4.000 8.000 29 | 279 169 274 144 304 144 9999 9999 30 | 0.000 0.000 271.023 155.406 269.773 149.156 278.974 137.933 31 | 286.474 137.933 0.000 0.000 32 | 4 0 12 12 0 -1 0 0.00000 4 9 7 314 179 g 33 | 4 0 12 12 0 -1 0 0.00000 4 9 7 339 180 h 34 | 4 0 12 12 0 -1 0 0.00000 4 9 7 299 139 b 35 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 99 a 36 | 4 0 12 12 0 -1 0 0.00000 4 6 7 279 179 e 37 | 4 0 12 12 0 -1 0 0.00000 4 9 7 374 179 i 38 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 139 c 39 | 4 0 12 12 0 -1 0 0.00000 4 9 7 414 139 d 40 | 4 0 12 12 0 -1 0 0.00000 4 14 7 334 222 j 41 | -------------------------------------------------------------------------------- /resolution_example.txt: -------------------------------------------------------------------------------- 1 | (from: 2 | http://www.rci.rutgers.edu/~cfs/305_html/Deduction/ResolutionTP.html 3 | adapted from E. Rich and K Knight, Artificial Intelligence. Second 4 | Edition.NY: McGraw Hill, 1991) 5 | 6 | Marcus is a man: 7 | 1. man(marcus) 8 | 9 | Marcus is a pompeian 10 | 2. pompeian(marcus) 11 | 12 | All Pompeians are Romans 13 | forall(x,pompeian(x)->Roman(x)) 14 | 3. ~pompeian(x) \/ roman(x) 15 | 16 | Caesar is a ruler 17 | 4. ruler(caeser) 18 | 19 | All Romans are either loyal to Caesar or hate Caesar 20 | forall(x,roman(x)-> loyalto(x,caesar)\/hate(x,caesar)) 21 | 5. ~roman(x) \/ loyalto(x,caesar) \/ hate(x,caesar) 22 | 23 | Everyone is loyal to someone 24 | forall(x,thereis(y,loyalto(x,y))) 25 | 6. loyalto(x,f1(x)) 26 | 27 | People only try to assassinate rules they are not loyal to. 28 | forall(x,forall(y,person(x)/\ruler(y)/\tryassassinate(x,y)->~loyalto(x,y))) 29 | 7. ~man(x)\/~ruler(y)\/~tryassassinate(x,y)\/~loyalto(x,y) 30 | 31 | Marcus tries to assassinate Caesar 32 | 8. tryassassinate(marcus,caesar) 33 | 34 | ============== 35 | try to prove: Marcus hates Caesar: 36 | 37 | add 9. ~hates(marcus,caesar) 38 | and use resolution to try to show unsatisfiable. 39 | 40 | 9 5 41 | | / 42 | <> 3 43 | | / 44 | <> 2 45 | | / 46 | <> 7 47 | | / 48 | <> 1 49 | | / 50 | <> 4 51 | | / 52 | <> 8 53 | 54 | Linear resolution. 55 | 56 | -------------------------------------------------------------------------------- /fol.P: -------------------------------------------------------------------------------- 1 | /* propositional logic: Use p/\q\/not(r). 2 | TA = [p=t,q=f]. 3 | */ 4 | 5 | tv(P,TA,TV) :- 6 | atomic(P),!, 7 | once(member(p=TV,TA)). 8 | tv(P/\Q,TA,TV) :- 9 | tv(P,TA,TV1), 10 | tv(Q,TA,TV2), 11 | and(TV1,TV2,TV). 12 | tv(P\/Q,TA,TV) :- 13 | tv(P,TA,TV1), 14 | tv(Q,TA,TV2), 15 | or(TV1,TV2,TV). 16 | 17 | and(t,t,t). 18 | and(t,f,f). 19 | and(f,t,f). 20 | and(f,f,f). 21 | 22 | or(t,t,t). 23 | or(t,f,t). 24 | or(f,t,t). 25 | or(f,f,f). 26 | 27 | /********************************/ 28 | :- import append/3 from basics. 29 | 30 | clausalform(F,[[F]]) :- atomic(F), !. 31 | clausalform(not(F),[[not(F)]]) :- atomic(F), !. 32 | clausalform(not(A/\B),CF) :- clausalform(not(A)\/not(B),CF). 33 | clausalform(not(A\/B),CF) :- clausalform(not(A)/\not(B),CF). 34 | clausalform(not(not(A)),CF) :- clausalform(A,CF). 35 | clausalform(A/\B,CF) :- 36 | clausalform(A,CFA), 37 | clausalform(B,CFB), 38 | union(CFA,CFB,CF). 39 | 40 | clausalform(A\/B,CF) :- 41 | clausalform(A,CFA), 42 | clausalform(B,CFB), 43 | disjoin_clauses(CFA,CFB,CF). 44 | 45 | disjoin_clauses([],_,[]). 46 | disjoin_clauses([C1|Cs],C2s,RCs) :- 47 | disjoin_one_clause(C1,C2s,C3s), 48 | disjoin_clauses(Cs,C2s,C4s), 49 | union(C3s,C4s,RCs). 50 | 51 | disjoin_one_clause(_L,[],[]). 52 | disjoin_one_clause(L,[L1|Ls],[L1a|Lsa]) :- 53 | union(L,L1,L1a), 54 | disjoin_one_clause(L,Ls,Lsa). 55 | 56 | union(SA,SB,S) :- 57 | append(SA,SB,DS), 58 | sort(DS,S). 59 | 60 | -------------------------------------------------------------------------------- /figures/m0s1s2s.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Landscape 3 | Center 4 | Inches 5 | 1200 2 6 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 2332.633 859.181 1350 1950 2250 2325 3225 2025 7 | 1 1 1.00 60.00 120.00 8 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 4687.500 862.500 3675 2025 4800 2400 5700 2025 9 | 1 1 1.00 60.00 120.00 10 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 1261.824 1089.527 1350 1575 1200 600 900 1425 11 | 1 1 1.00 60.00 120.00 12 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3661.824 1089.527 3750 1575 3600 600 3300 1425 13 | 1 1 1.00 60.00 120.00 14 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 5948.864 1107.955 6150 1575 5925 600 5625 1500 15 | 1 1 1.00 60.00 120.00 16 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3450 1725 335 335 3450 1725 3750 1875 17 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 5850 1725 335 335 5850 1725 6150 1875 18 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 1050 1725 335 335 1050 1725 1350 1875 19 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 5887 1725 263 263 5625 1725 6150 1725 20 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 21 | 1 1 1.00 60.00 120.00 22 | 300 1650 675 1725 23 | 4 0 -1 0 0 0 20 0.0000000 4 300 300 900 1800 q0\001 24 | 4 0 -1 0 0 0 20 0.0000000 4 300 300 3300 1800 q1\001 25 | 4 0 -1 0 0 0 20 0.0000000 4 300 300 5700 1800 q2\001 26 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 1575 600 0\001 27 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 4050 675 1\001 28 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 6450 825 2\001 29 | 4 0 -1 0 0 0 16 0.0000000 4 90 150 1875 2175 ''\001 30 | 4 0 -1 0 0 0 16 0.0000000 4 90 150 4275 2250 ''\001 31 | -------------------------------------------------------------------------------- /figures/hilog-graph.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 329 149 379 179 4 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 5 | 0 0 1.000 4.000 8.000 6 | 329 174 354 174 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 8 | 0 0 1.000 4.000 8.000 9 | 329 173 354 158 9999 9999 10 | 4 0 0 12 0 -1 0 0.00000 4 6 6 359 179 a 11 | 4 0 0 12 0 -1 0 0.00000 4 6 16 359 159 var 12 | -6 13 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 14 | 0 0 1.000 4.000 8.000 15 | 249 194 274 194 9999 9999 16 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 17 | 0 0 1.000 4.000 8.000 18 | 249 194 269 209 274 214 9999 9999 19 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 20 | 0 0 1.000 4.000 8.000 21 | 249 194 274 179 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 289 194 314 194 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 289 174 314 174 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 29 | 0 0 1.000 4.000 8.000 30 | 329 194 354 194 9999 9999 31 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 32 | 0 0 1.000 4.000 8.000 33 | 209 224 234 204 9999 9999 34 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 35 | 0 0 1.000 4.000 8.000 36 | 209 224 234 244 9999 9999 37 | 4 0 0 12 0 -1 0 0.00000 4 9 6 239 199 g 38 | 4 0 0 12 0 -1 0 0.00000 4 6 6 279 179 a 39 | 4 0 0 12 0 -1 0 0.00000 4 9 6 279 199 b 40 | 4 0 0 12 0 -1 0 0.00000 4 6 16 279 219 var 41 | 4 0 0 12 0 -1 0 0.00000 4 9 3 319 179 f 42 | 4 0 0 12 0 -1 0 0.00000 4 9 6 359 199 1 43 | 4 0 0 12 0 -1 0 0.00000 4 9 3 319 199 f 44 | 4 0 0 12 0 -1 0 0.00000 4 12 27 179 229 apply 45 | 4 0 0 12 0 -1 0 0.00000 4 12 22 239 254 path 46 | -------------------------------------------------------------------------------- /debugging.tex: -------------------------------------------------------------------------------- 1 | \chapter{Debugging Tabled Programs} 2 | 3 | 4-port Table Debugger. 4 | 5 | The names may not be the best, but they should be clear. 6 | 7 | \begin{enumerate} 8 | \item Call 9 | \begin{itemize} 10 | \item Call Untabled 11 | 12 | \item Call Tabled: New Subgoal 13 | 14 | \item Call Tabled: Use Incomplete Table 15 | 16 | \item Call Tabled: Use Completed Table 17 | \end{itemize} 18 | \item Exit 19 | \begin{itemize} 20 | \item Exit Untabled 21 | \item Check/Insert Answer followed by 22 | \begin{itemize} 23 | \item Redundant Answer - fail 24 | \item Insert Answer -- succeed 25 | \end{itemize} 26 | \end{itemize} 27 | 28 | \item Redo 29 | \begin{itemize} 30 | \item Retry Program Clause 31 | \item Retry Answer Clause 32 | \end{itemize} 33 | 34 | \item Fail 35 | \begin{itemize} 36 | \item Fail Untabled 37 | \item Check Complete followed by 38 | \begin{itemize} 39 | \item Completing tables (table list) 40 | \item Rescheduling Answers for (table list) 41 | \end{itemize} 42 | \end{itemize} 43 | \end{enumerate} 44 | 45 | How does tabling affect the debugger commands 46 | 47 | Old commands : 48 | 49 | Abort cleans up uncompleted tables. 50 | 51 | Skip , Leap should work. 52 | 53 | Break allows tables to be partially visible. 54 | 55 | 56 | New Commands: 57 | 58 | Ancestors. At least for tables. 59 | 60 | Various Table examination mechanisms built upon Table builtins. 61 | 62 | Show incomplete tabled subgoals. 63 | 64 | Show returns for a table. 65 | 66 | Show ancestors for each suspension of an incomplete tabled subgoal. 67 | 68 | -------------------------------------------------------------------------------- /figures/CDG.1.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig001386 3 | %%Creator: fig2dev 4 | %%CreationDate: Mon Sep 26 15:52:25 1994 5 | %%For: juliana@sbproud6 (Juliana Lima,stu,123195,warren,sun,5,) 6 | %%BoundingBox: 0 0 37 120 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -63.0 185.0 translate 0.675 -0.675 scale 38 | 0.500 setlinewidth 39 | n 128.929 257.497 m 134.000 264.000 l 126.465 260.649 l gs 2 setlinejoin col-1 s gr 40 | n 198.166 181.917 104.187 -131.595 128.015 arcn 41 | gs col-1 s gr 42 | /Times-Roman findfont 15.00 scalefont setfont 43 | 134 109 m 44 | gs 1 -1 scale (P) col-1 show gr 45 | /Times-Roman findfont 15.00 scalefont setfont 46 | 134 274 m 47 | gs 1 -1 scale (Q) col-1 show gr 48 | $F2psEnd 49 | -------------------------------------------------------------------------------- /figures/lattice.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 329 285 358 239 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 328 285 286 241 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 326 284 222 240 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 13 | 286 230 9999 9999 14 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 15 | 359 226 9999 9999 16 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 17 | 0 0 1.000 4.000 8.000 18 | 329 284 149 244 9999 9999 19 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 20 | 0 0 1.000 4.000 8.000 21 | 155 227 216 205 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 222 189 318 159 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 221 228 318 159 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 29 | 0 0 1.000 4.000 8.000 30 | 285 229 320 160 9999 9999 31 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 32 | 0 0 1.000 4.000 8.000 33 | 360 226 320 160 9999 9999 34 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 35 | 0 0 1.000 4.000 8.000 36 | 329 285 435 242 9999 9999 37 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 38 | 0 0 1.000 4.000 8.000 39 | 439 228 323 160 9999 9999 40 | 4 0 12 10 0 -1 0 0.00000 4 5 18 319 295 new 41 | 4 0 12 10 0 -1 0 0.00000 4 9 54 263 237 generator 42 | 4 0 12 10 0 -1 0 0.00000 4 7 48 331 236 interior 43 | 4 0 12 10 0 -1 0 0.00000 4 9 48 299 154 disposed 44 | 4 0 12 10 0 -1 0 0.00000 4 7 36 139 237 active 45 | 4 0 12 10 0 -1 0 0.00000 4 7 60 189 238 floundered 46 | 4 0 12 10 0 -1 0 0.00000 4 9 54 194 199 suspended 47 | 4 0 12 10 0 -1 0 0.00000 4 5 36 418 237 answer 48 | -------------------------------------------------------------------------------- /figures/multi-cycle.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 299 99 229 129 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 299 99 354 129 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 299 99 299 124 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 294 179 234 139 9999 9999 15 | 3 2 0 1 -1 0 0 0 0.000 1 0 16 | 0 0 1.000 4.000 8.000 17 | 294 139 289 159 294 174 9999 9999 18 | 80.000 0.000 290.102 150.141 288.852 155.141 289.114 161.959 19 | 290.364 165.709 80.000 0.000 20 | 3 2 0 1 -1 0 0 0 0.000 1 0 21 | 0 0 1.000 4.000 8.000 22 | 214 139 209 159 214 174 9999 9999 23 | 0.000 0.000 210.102 150.141 208.852 155.141 209.114 161.959 24 | 210.364 165.709 0.000 0.000 25 | 3 2 0 1 -1 0 0 0 0.000 1 0 26 | 0 0 1.000 4.000 8.000 27 | 229 174 234 154 229 139 9999 9999 28 | 443.000 313.000 232.898 162.859 234.148 157.859 233.886 151.041 29 | 232.636 147.291 443.000 313.000 30 | 3 2 0 1 -1 0 0 0 0.000 1 0 31 | 0 0 1.000 4.000 8.000 32 | 310 173 315 153 310 138 9999 9999 33 | 524.000 312.000 313.898 161.859 315.148 156.859 314.886 150.041 34 | 313.636 146.291 524.000 312.000 35 | 4 0 0 12 0 -1 0 0.00000 4 9 6 219 139 p 36 | 4 0 0 12 0 -1 0 0.00000 4 6 4 299 139 r 37 | 4 0 0 12 0 -1 0 0.00000 4 9 6 219 179 q 38 | 4 0 0 12 0 -1 0 0.00000 4 7 4 299 179 t 39 | 4 0 0 12 0 -1 0 0.00000 4 6 6 299 99 s 40 | 4 0 0 12 0 -1 0 0.00000 4 6 9 359 139 m 41 | 4 0 0 12 0 -1 0 0.00000 4 2 7 224 159 ~ 42 | 4 0 0 12 0 -1 0 0.00000 4 2 7 279 159 ~ 43 | 4 0 0 12 0 -1 0 0.00000 4 2 7 249 164 ~ 44 | -------------------------------------------------------------------------------- /aggreg2.P: -------------------------------------------------------------------------------- 1 | /********* minimal strolls through the park***************/ 2 | :- import member/2 from basics. 3 | 4 | 5 | subset([],_L). 6 | subset([X|L1],L2) :- member(X,L2), subset(L1,L2). 7 | 8 | :- table walk(_,_,subset/2). 9 | walk(X,Y,[Y,X]) :- edge(X,Y). 10 | walk(X,Y,[Y|P]) :- walk(X,Z,P), edge(Z,Y). 11 | 12 | 13 | edge(a,b). 14 | edge(b,c). 15 | edge(b,d). 16 | edge(c,b). 17 | edge(c,d). 18 | edge(d,e). 19 | edge(a,f). 20 | edge(f,g). 21 | edge(g,e). 22 | 23 | /************************************************************/ 24 | 25 | maximum(X,Y,Z) :- Z is max(X,Y). 26 | 27 | 28 | % small_cap(BigSize,BigCap) if there is some item with ISize and IVal 29 | % such that the capacity of a knapsack of size (BigSize-ISize) has 30 | % capacity (BigCap-Ival). 31 | :- table cap(_,maximum/3- (-1000)). 32 | :- table cap/2. 33 | cap(BigSize,BigCap) :- 34 | BigSize >= 0, 35 | item(ISize,IVal), 36 | SmallSize is BigSize-ISize, 37 | cap(SmallSize,SmallCap), 38 | BigCap is IVal+SmallCap. 39 | % every knapsack (>=0) has capacity of 0. 40 | cap(BigSize,0) :- BigSize >= 0. 41 | 42 | item(10,15). 43 | item(8,14). 44 | item(6,10). 45 | item(4,6). 46 | item(2,2). 47 | /*********************************************************/ 48 | 49 | 50 | :- table grid(_,_,lattice(max(_,_),0)). 51 | 52 | grid(_,1,X) :- !, X = 1. 53 | grid(_,5,X) :- !, X = 5. 54 | grid(1,J,X) :- !, X = J. 55 | grid(5,J,X) :- !, X = J. 56 | grid(I,J,X) :- 57 | Ip1 is I+1, Im1 is I-1, 58 | Jp1 is J+1, Jm1 is J-1, 59 | grid(Ip1,J,X1), 60 | grid(Im1,J,X2), 61 | grid(I,Jp1,X3), 62 | grid(I,Jm1,X4), 63 | X is (X1+X2+X3+X4) / 4. 64 | grid(_,_,0). 65 | 66 | max(X,Y,M) :- (Y > X -> M = Y ; M = X). 67 | -------------------------------------------------------------------------------- /mdp.P: -------------------------------------------------------------------------------- 1 | :- import for/3 from basics. 2 | 3 | u(State,Action,Reward) :- 4 | I = 10, 5 | u_i(I,State,_Action0,Reward0), 6 | iterate(State,10,Reward0,Action,Reward). 7 | 8 | iterate(State,I,OldReward,Action,Reward) :- 9 | NextI is I+10, 10 | u_i(NextI,State,NewAction,NewReward), 11 | (NewReward - OldReward < 0.000000000001 12 | -> Action = NewAction, 13 | Reward = NewReward 14 | ; iterate(State,NextI,NewReward,Action,Reward) 15 | ). 16 | 17 | %u_i(Iteration,State,Action,Reward) 18 | u_i(1,State,none,Reward) :- 19 | r(State,Reward). 20 | u_i(I,State,Act,Reward) :- 21 | I>1,Iminus1 is I-1, 22 | argmax_sum_rewards_i(Iminus1,State,SumActRew), 23 | SumActRew = argmax(Act,SumRew), 24 | g(Disc), 25 | r(State,Rew0), 26 | Reward is Rew0 + Disc*SumRew. 27 | 28 | %argmax_sum_rewards(Iteration,State,argmax(Action,Reward)). 29 | :- table argmax_sum_rewards_i(_,_,lattice(argmax/3)). 30 | argmax_sum_rewards_i(I,State,argmax(Action,Reward)) :- 31 | sum_rewards_i(I,State,Action,Reward). 32 | 33 | %sum_rewards_i(Iteration,State,Action,SumReward) 34 | :- table sum_rewards_i(_,_,_,fold(sum/3,0.0)). 35 | sum_rewards_i(I,St0,Act,Rew) :- 36 | t(St0,Act,St,Prob), 37 | u_i(I,St,_PAct,Rew0), 38 | Rew is Prob*Rew0. 39 | 40 | sum(X,Y,Z) :- Z is X+Y. 41 | argmax(X,Y,Z) :- 42 | X = argmax(_,R1), 43 | Y = argmax(_,R2), 44 | (R1 >= R2 -> Z = X ; Z = Y). 45 | 46 | %t(Sou,Act,Tar,Prob). 47 | t(a,a1,a,0.5). 48 | t(a,a1,b,0.5). 49 | t(a,a2,c,1.0). 50 | t(b,b1,a,0.25). 51 | t(b,b1,b,0.75). 52 | t(c,c1,c,0.5). 53 | t(c,c1,b,0.5). 54 | 55 | %r(State,Val) 56 | r(a,12.0). 57 | r(b,-4.0). 58 | r(c,2.0). 59 | 60 | %g(Discount) 61 | g(0.9). 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /figures/slg-examp2.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 4 | 239 79 179 119 9999 9999 5 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 6 | 99 279 39 319 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 8 | 99 279 99 319 9999 9999 9 | 2 1 2 1 -1 0 0 0 3.000 -1 0 0 10 | 99 279 159 319 9999 9999 11 | 2 2 2 1 -1 0 0 0 3.000 0 0 0 12 | 164 344 149 344 149 329 164 329 164 344 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 14 | 359 279 359 319 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 16 | 259 279 259 319 9999 9999 17 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 18 | 239 79 239 119 9999 9999 19 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 20 | 179 144 179 184 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 22 | 239 144 239 184 9999 9999 23 | 2 1 2 1 -1 0 0 0 3.000 -1 0 0 24 | 239 79 299 119 9999 9999 25 | 2 2 2 1 -1 0 0 0 3.000 0 0 0 26 | 304 144 289 144 289 129 304 129 304 144 9999 9999 27 | 4 0 0 12 0 -1 0 0.00000 4 12 22 89 274 r(X) 28 | 4 0 0 12 0 -1 0 0.00000 4 9 27 14 314 X = 1 29 | 4 0 0 12 0 -1 0 0.00000 4 9 27 64 314 X = 2 30 | 4 0 0 12 0 -1 0 0.00000 4 9 27 149 304 X = 3 31 | 4 0 0 12 0 -1 0 0.00000 4 12 37 244 339 r(X1),q 32 | 4 0 0 12 0 -1 0 0.00000 4 9 6 354 269 q 33 | 4 0 0 12 0 -1 0 0.00000 4 9 9 29 338 p 34 | 4 0 0 12 0 -1 0 0.00000 4 9 9 249 268 p 35 | 4 0 0 12 0 -1 0 0.00000 4 12 22 229 69 r(X) 36 | 4 0 0 12 0 -1 0 0.00000 4 9 27 159 109 X = 1 37 | 4 0 0 12 0 -1 0 0.00000 4 9 27 209 109 X = 2 38 | 4 0 0 12 0 -1 0 0.00000 4 12 37 164 209 r(X1),q 39 | 4 0 0 12 0 -1 0 0.00000 4 9 27 299 109 X = 3 40 | 4 0 0 12 0 -1 0 0.00000 4 9 9 169 138 p 41 | 4 0 0 12 0 -1 0 0.00000 4 9 13 234 139 ~q 42 | 4 0 0 12 0 -1 0 0.00000 4 9 13 99 339 ~q 43 | 4 0 0 12 0 -1 0 0.00000 4 9 6 354 339 p 44 | 4 0 0 12 0 -1 0 0.00000 4 9 6 229 209 p 45 | -------------------------------------------------------------------------------- /figures/alt-slg-examp2.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 4 | 239 79 179 119 9999 9999 5 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 6 | 99 279 39 319 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 8 | 99 279 99 319 9999 9999 9 | 2 1 2 1 -1 0 0 0 3.000 -1 0 0 10 | 99 279 159 319 9999 9999 11 | 2 2 2 1 -1 0 0 0 3.000 0 0 0 12 | 164 344 149 344 149 329 164 329 164 344 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 14 | 359 279 359 319 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 16 | 259 279 259 319 9999 9999 17 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 18 | 239 79 239 119 9999 9999 19 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 20 | 179 144 179 184 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 22 | 239 144 239 184 9999 9999 23 | 2 1 2 1 -1 0 0 0 3.000 -1 0 0 24 | 239 79 299 119 9999 9999 25 | 2 2 2 1 -1 0 0 0 3.000 0 0 0 26 | 304 144 289 144 289 129 304 129 304 144 9999 9999 27 | 4 0 0 12 0 -1 0 0.00000 4 12 22 89 274 r(X) 28 | 4 0 0 12 0 -1 0 0.00000 4 9 27 14 314 X = 1 29 | 4 0 0 12 0 -1 0 0.00000 4 9 27 64 314 X = 2 30 | 4 0 0 12 0 -1 0 0.00000 4 9 27 149 304 X = 3 31 | 4 0 0 12 0 -1 0 0.00000 4 12 37 244 339 r(X1),q 32 | 4 0 0 12 0 -1 0 0.00000 4 9 6 354 269 q 33 | 4 0 0 12 0 -1 0 0.00000 4 9 9 29 338 p 34 | 4 0 0 12 0 -1 0 0.00000 4 9 9 249 268 p 35 | 4 0 0 12 0 -1 0 0.00000 4 12 22 229 69 r(X) 36 | 4 0 0 12 0 -1 0 0.00000 4 9 27 159 109 X = 1 37 | 4 0 0 12 0 -1 0 0.00000 4 9 27 209 109 X = 2 38 | 4 0 0 12 0 -1 0 0.00000 4 12 37 164 209 r(X1),q 39 | 4 0 0 12 0 -1 0 0.00000 4 9 27 299 109 X = 3 40 | 4 0 0 12 0 -1 0 0.00000 4 9 9 169 138 p 41 | 4 0 0 12 0 -1 0 0.00000 4 9 13 234 139 ~q 42 | 4 0 0 12 0 -1 0 0.00000 4 9 13 99 339 ~q 43 | 4 0 0 12 0 -1 0 0.00000 4 9 6 354 339 p 44 | 4 0 0 12 0 -1 0 0.00000 4 9 6 229 209 p 45 | -------------------------------------------------------------------------------- /figures/cascade.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 359 104 359 124 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 359 104 309 124 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 359 104 414 124 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 304 144 284 169 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 304 144 319 169 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 19 | 0 0 1.000 4.000 8.000 20 | 359 144 344 164 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 22 | 0 0 1.000 4.000 8.000 23 | 359 144 374 164 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 25 | 0 0 1.000 4.000 8.000 26 | 339 184 339 209 9999 9999 27 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 28 | 0 0 1.000 4.000 8.000 29 | 329 219 289 184 9999 9999 30 | 3 2 0 1 -1 0 0 0 0.000 1 0 31 | 0 0 1.000 4.000 8.000 32 | 279 169 274 144 304 144 9999 9999 33 | 0.000 0.000 271.023 155.406 269.773 149.156 278.974 137.933 34 | 286.474 137.933 0.000 0.000 35 | 3 2 0 1 -1 0 0 0 0.000 1 0 36 | 0 0 1.000 4.000 8.000 37 | 419 144 399 199 349 184 9999 9999 38 | 0.000 0.000 418.824 177.807 413.824 191.557 385.777 205.639 39 | 373.277 201.889 0.000 0.000 40 | 4 0 12 12 0 -1 0 0.00000 4 9 7 314 179 g 41 | 4 0 12 12 0 -1 0 0.00000 4 9 7 339 180 h 42 | 4 0 12 12 0 -1 0 0.00000 4 12 7 334 222 j 43 | 4 0 12 12 0 -1 0 0.00000 4 9 7 299 139 b 44 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 99 a 45 | 4 0 12 12 0 -1 0 0.00000 4 6 7 279 179 e 46 | 4 0 12 12 0 -1 0 0.00000 4 9 7 374 179 i 47 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 139 c 48 | 4 0 12 12 0 -1 0 0.00000 4 9 7 414 139 d 49 | 4 0 12 12 0 -1 0 0.00000 4 3 7 424 179 ~ 50 | 4 0 12 12 0 -1 0 0.00000 4 3 7 304 209 ~ 51 | -------------------------------------------------------------------------------- /figures/cascaded.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 359 104 359 124 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 359 104 309 124 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 359 104 414 124 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 304 144 284 169 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 304 144 319 169 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 19 | 0 0 1.000 4.000 8.000 20 | 359 144 344 164 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 22 | 0 0 1.000 4.000 8.000 23 | 359 144 374 164 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 25 | 0 0 1.000 4.000 8.000 26 | 339 184 339 209 9999 9999 27 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 28 | 0 0 1.000 4.000 8.000 29 | 329 219 289 184 9999 9999 30 | 3 2 0 1 -1 0 0 0 0.000 1 0 31 | 0 0 1.000 4.000 8.000 32 | 279 169 274 144 304 144 9999 9999 33 | 0.000 0.000 271.023 155.406 269.773 149.156 278.974 137.933 34 | 286.474 137.933 0.000 0.000 35 | 3 2 0 1 -1 0 0 0 0.000 1 0 36 | 0 0 1.000 4.000 8.000 37 | 419 144 399 199 349 184 9999 9999 38 | 0.000 0.000 418.824 177.807 413.824 191.557 385.777 205.639 39 | 373.277 201.889 0.000 0.000 40 | 4 0 12 12 0 -1 0 0.00000 4 9 7 314 179 g 41 | 4 0 12 12 0 -1 0 0.00000 4 9 7 339 180 h 42 | 4 0 12 12 0 -1 0 0.00000 4 9 7 299 139 b 43 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 99 a 44 | 4 0 12 12 0 -1 0 0.00000 4 6 7 279 179 e 45 | 4 0 12 12 0 -1 0 0.00000 4 9 7 374 179 i 46 | 4 0 12 12 0 -1 0 0.00000 4 6 7 354 139 c 47 | 4 0 12 12 0 -1 0 0.00000 4 9 7 414 139 d 48 | 4 0 12 12 0 -1 0 0.00000 4 3 7 424 179 ~ 49 | 4 0 12 12 0 -1 0 0.00000 4 3 7 304 209 ~ 50 | 4 0 12 12 0 -1 0 0.00000 4 14 7 334 222 j 51 | -------------------------------------------------------------------------------- /prolog.P: -------------------------------------------------------------------------------- 1 | 2 | 3 | expr --> term, [+], expr. 4 | expr --> term. 5 | term --> factor, [*], term. 6 | term --> factor. 7 | factor --> [I], {integer(I)}. 8 | factor --> ['('], expr, [')']. 9 | 10 | % tests 11 | % expr([4,*,5,+,1],[]). 12 | % expr([1,+,3,*,'(',2,+,4,')'],[]). 13 | % expr([4,5,*],[]). 14 | 15 | % build parse tree 16 | 17 | /* 18 | expr(+(T,E)) --> term(T), [+], expr(E). 19 | expr(T) --> term(T). 20 | term(*(F,T)) --> factor(F), [*], term(T). 21 | term(F) --> factor(F). 22 | factor(I) --> [I], {integer(I)}. 23 | factor(E) --> ['('], expr(E), [')']. 24 | */ 25 | 26 | 27 | 28 | % evaluate expression 29 | expr(V) --> term(T), [+], expr(E), {V is T+E}. 30 | expr(T) --> term(T). 31 | term(V) --> factor(F), [*], term(T), {V is F*T}. 32 | term(F) --> factor(F). 33 | factor(I) --> [I], {integer(I)}. 34 | factor(E) --> ['('], expr(E), [')']. 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | emp_info(EmployeeNum,Lastname,Firstname) :- 64 | employee(EmployeeNum, Lastname, Firstname, _StreetAddress, _City, _State, _Zipcode, _DepartmentNum, _Hiredate, _Salary). 65 | 66 | 67 | %EmployeenUM, Lastname, Firstname, StreetAddress, City, State, Zipcode, DepartmentNum, Hiredate, Salary 68 | employee(193,'Jones','John','173 Elm St.','Hoboken','NJ',1,1,'25 Jun 93',25500). 69 | employee(181,'Doe','Betty','11 Spring St.','Paterson','NJ',2,3,'12 May 91',28500). 70 | employee(198,'Smith','Al','2 Ace Ave.','Paterson','NJ',3,3,'12 Sep 93',27000). 71 | 72 | %DeptNum, DeptName, Manager 73 | department(1,'Grocery',181). 74 | department(3,'Deli',193). 75 | department(5,'Produce',199). 76 | 77 | 78 | 79 | f(david,iv). 80 | f(david,tessa). 81 | f(iv,david). 82 | 83 | fof(X,Y) :- f(X,Y). 84 | fof(X,Y) :- f(X,Z), fof(Z,Y). 85 | -------------------------------------------------------------------------------- /figures/expgraph.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 6 1800 450 7800 1275 7 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 8 | 0 0 1.00 60.00 120.00 9 | 2251 751 2626 601 10 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 11 | 0 0 1.00 60.00 120.00 12 | 2251 901 2626 1051 13 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 14 | 0 0 1.00 60.00 120.00 15 | 3001 601 3526 751 16 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 17 | 0 0 1.00 60.00 120.00 18 | 3076 1126 3526 901 19 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 20 | 0 0 1.00 60.00 120.00 21 | 3976 751 4426 601 22 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 23 | 0 0 1.00 60.00 120.00 24 | 4951 1126 5401 901 25 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 26 | 0 0 1.00 60.00 120.00 27 | 3976 901 4501 1126 28 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 29 | 0 0 1.00 60.00 120.00 30 | 4876 601 5401 826 31 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 32 | 0 0 1.00 60.00 120.00 33 | 5776 826 6226 601 34 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 35 | 0 0 1.00 60.00 120.00 36 | 5776 901 6226 1051 37 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 38 | 0 0 1.00 60.00 120.00 39 | 6676 601 7126 751 40 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 41 | 0 0 1.00 60.00 120.00 42 | 6751 1126 7201 901 43 | 4 0 -1 0 0 0 12 0.0000000 4 180 405 1801 901 Andy\001 44 | 4 0 -1 0 0 0 12 0.0000000 4 135 255 2701 601 Bill\001 45 | 4 0 -1 0 0 0 12 0.0000000 4 135 300 2701 1201 Bob\001 46 | 4 0 -1 0 0 0 12 0.0000000 4 135 300 3601 901 Carl\001 47 | 4 0 -1 0 0 0 12 0.0000000 4 135 300 4501 601 Dan\001 48 | 4 0 -1 0 0 0 12 0.0000000 4 135 375 4501 1201 Dave\001 49 | 4 0 -1 0 0 0 12 0.0000000 4 135 360 5401 901 Evan\001 50 | 4 0 -1 0 0 0 12 0.0000000 4 135 330 6301 601 Fred\001 51 | 4 0 -1 0 0 0 12 0.0000000 4 135 420 6301 1201 Frank\001 52 | 4 0 -1 0 0 0 12 0.0000000 4 180 525 7201 901 George\001 53 | -6 54 | -------------------------------------------------------------------------------- /wumpus.P: -------------------------------------------------------------------------------- 1 | 2 | %% grid provides the size of the grid. 3 | grid(4,4). 4 | 5 | %% A neighbor is a square to either side or above or below the current 6 | %% square (and still on the grid.) 7 | neighbor(I,J,NI,J) :- NI is I+1, grid(MI,_), NI =< MI. 8 | neighbor(I,J,NI,J) :- NI is I-1, NI >= 1. 9 | neighbor(I,J,I,NJ) :- NJ is J+1, grid(_,MJ), NJ =< MJ. 10 | neighbor(I,J,I,NJ) :- NJ is J-1, NJ >= 1. 11 | 12 | %% feel(I,J,Sense) if the hunter has felt "Sense" on square I,J 13 | 14 | :- table feel/3. 15 | %% the hunter can feel only one of breeze and no_breeze 16 | feel(I,J,breeze) :- tnot(feel(I,J,no_breeze)). 17 | feel(I,J,no_breeze) :- tnot(feel(I,J,breeze)). 18 | 19 | :- table safe/2. 20 | %% A square is safe if it is not a pit 21 | safe(I,J) :- tnot(pit(I,J)). 22 | %% A square is safe if the hunter has visited it 23 | safe(I,J) :- visited(I,J). 24 | %% A square is safe if the hunter feels no breeze on some neighbor. 25 | safe(I,J) :- 26 | neighbor(I,J,NI,NJ), 27 | visited(NI,NJ), 28 | feel(NI,NJ,no_breeze). 29 | 30 | :- table pit/2. 31 | %% A square is a pit if it is not safe 32 | pit(I,J) :- tnot(safe(I,J)). 33 | %% A square is a pit if some neighbor feels a breeze but no other of 34 | %% its neighbors is unsafe. 35 | pit(I,J) :- 36 | neighbor(I,J,NI,NJ), 37 | feel(NI,NJ,breeze), 38 | tnot(another_neighbor_unsafe(NI,NJ,I,J)). 39 | 40 | %% Another neighbor (not (NI,NJ) is a pit. 41 | :- table another_neighbor_unsafe/4. 42 | another_neighbor_unsafe(I,J,NI,NJ) :- 43 | neighbor(I,J,PI,PJ), 44 | (PI =\= NI ; PJ =\= NJ), 45 | tnot(safe(PI,PJ)). 46 | 47 | feel(1,1,breeze). 48 | feel(1,2,breeze). 49 | %:- table visited/2. 50 | visited(1,1). 51 | visited(1,2). 52 | 53 | pq(Query) :- 54 | (call(Query), 55 | fail 56 | ; 57 | get_residual(Query,Resid), 58 | writeln(Query:Resid), 59 | fail 60 | ; 61 | true 62 | ). 63 | -------------------------------------------------------------------------------- /programs.P: -------------------------------------------------------------------------------- 1 | /**** 2 | :- table reachable/2. 3 | reachable(Source,Target) :- edge(Source,Target). 4 | reachable(Source,Target) :- 5 | reachable(Source,Intermediate), 6 | edge(Intermediate,Target). 7 | /****************/ 8 | /* 9 | edge(a,b). 10 | edge(b,c). 11 | edge(c,b). 12 | */ 13 | /****** 14 | edge(1,2). 15 | edge(2,3). 16 | edge(3,4). 17 | edge(4,5). 18 | edge(5,6). 19 | edge(6,7). 20 | edge(7,8). 21 | edge(8,9). 22 | edge(9,10). 23 | edge(10,1). 24 | /**********/ 25 | /****************** 26 | :- table expr/2, term/2. 27 | 28 | expr --> expr, [+], term. 29 | expr --> term. 30 | term --> term, [*], factor. 31 | term --> factor. 32 | factor --> ['('], expr, [')']. 33 | factor --> [Int], {integer(Int)}. 34 | 35 | 36 | :- table expr/3, term/3. 37 | 38 | expr(Val) --> expr(Eval), [+], term(Tval), {Val is Eval+Tval}. 39 | expr(Val) --> term(Val). 40 | term(Val) --> term(Tval), [*], factor(Fval), {Val is Tval*Fval}. 41 | term(Val) --> factor(Val). 42 | factor(Val) --> ['('], expr(Val), [')']. 43 | factor(Int) --> [Int], {integer(Int)}. 44 | /***********************/ 45 | /**************** 46 | :- table expr/3, term/3. 47 | 'C'(I1,W,I) :- word(I1,W,I). 48 | 49 | set_string(String) :- 50 | retractall(word(_,_,_)), 51 | assert_words(String,0). 52 | 53 | assert_words([],_). 54 | assert_words([Word|Words],N) :- 55 | N1 is N+1, assert(word(N,Word,N1)), assert_words(Words,N1). 56 | 57 | expr(Val) --> expr(Eval), [+], term(Tval), {Val is Eval+Tval}. 58 | expr(Val) --> term(Val). 59 | term(Val) --> term(Tval), [*], factor(Fval), {Val is Tval*Fval}. 60 | term(Val) --> factor(Val). 61 | factor(Val) --> ['('], expr(Val), [')']. 62 | factor(Int) --> [Int], {integer(Int)}. 63 | /******************/ 64 | :- suppl_table(2). 65 | :- edb student/3, enroll/2, course/2. 66 | yrCourse(Yr,CrsName) :- 67 | student(StdId,_,Yr), enroll(StdId,CrsId), course(CrsId,CrsName). 68 | -------------------------------------------------------------------------------- /figures/slg-examp5.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 224 499 284 539 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 7 | 0 0 1.000 4.000 8.000 8 | 223 498 163 538 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 10 | 0 0 1.000 4.000 8.000 11 | 224 439 224 479 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 13 | 0 0 1.000 4.000 8.000 14 | 224 359 224 419 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 16 | 0 0 1.000 4.000 8.000 17 | 299 299 239 339 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 19 | 0 0 1.000 4.000 8.000 20 | 299 299 359 339 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 22 | 0 0 1.000 4.000 8.000 23 | 299 239 299 279 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 25 | 0 0 1.000 4.000 8.000 26 | 299 179 299 219 9999 9999 27 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 28 | 0 0 1.000 4.000 8.000 29 | 299 119 299 159 9999 9999 30 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 31 | 0 0 1.000 4.000 8.000 32 | 299 59 299 99 9999 9999 33 | 3 2 0 1 -1 0 0 0 0.000 1 1 34 | 0 0 1.000 4.000 8.000 35 | 0 0 1.000 4.000 8.000 36 | 269 559 479 559 479 169 339 169 9999 9999 37 | 0.000 0.000 383.188 602.312 435.688 602.312 586.248 451.752 38 | 586.248 276.248 450.126 140.126 415.126 140.126 0.000 0.000 39 | 4 0 0 12 0 -1 0 0.00000 4 12 104 244 114 q(X,Y),~r(Y),~s(Y) 40 | 4 0 0 12 0 -1 0 0.00000 4 12 59 274 174 ~r(2),~s(2) 41 | 4 0 0 12 0 -1 0 0.00000 4 12 50 274 234 s(2),,p(2) 42 | 4 0 0 12 0 -1 0 0.00000 4 12 120 249 294 q(2,X1),eq(2,X1),p(X1) 43 | 4 0 0 12 0 -1 0 0.00000 4 12 96 184 354 q(2,2),eq(2,2),p(2) 44 | 4 0 0 12 0 -1 0 0.00000 4 12 99 324 354 q(2,1),eq(2,1),p(2)  45 | 4 0 0 12 0 -1 0 0.00000 4 12 22 289 54 p(1) 46 | 4 0 0 12 0 -1 0 0.00000 4 12 22 219 429 p(2) 47 | 4 0 0 12 0 -1 0 0.00000 4 12 99 184 494 q(2,X),~r(X),~s(X) 48 | 4 0 0 12 0 -1 0 0.00000 4 12 59 249 554 ~r(2).~s(2) 49 | 4 0 0 12 0 -1 0 0.00000 4 12 59 139 554 ~r(1),~s(1) 50 | -------------------------------------------------------------------------------- /figures/arch.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 229 399 469 579 4 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 5 | 0 0 1.000 4.000 8.000 6 | 349 399 279 479 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 8 | 0 0 1.000 4.000 8.000 9 | 349 399 419 479 9999 9999 10 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 11 | 329 579 329 479 229 479 229 579 329 579 9999 9999 12 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 13 | 469 579 469 479 369 479 369 579 469 579 9999 9999 14 | 4 0 0 14 0 -1 0 0.00000 4 13 43 259 519 System 15 | 4 0 0 14 0 -1 0 0.00000 4 10 56 249 540 Functions 16 | 4 0 0 14 0 -1 0 0.00000 4 10 31 404 519 User  17 | 4 0 0 14 0 -1 0 0.00000 4 13 56 389 540 Programs 18 | -6 19 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 429 129 50 50 429 79 429 179 20 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 269 129 50 50 269 79 269 179 21 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 109 129 50 50 109 79 109 179 22 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 589 129 50 50 589 79 589 179 23 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 24 | 399 339 399 239 299 239 299 339 399 339 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 589 179 349 239 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 29 | 0 0 1.000 4.000 8.000 30 | 113 178 353 238 9999 9999 31 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 32 | 0 0 1.000 4.000 8.000 33 | 269 179 349 239 9999 9999 34 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 35 | 0 0 1.000 4.000 8.000 36 | 431 178 351 238 9999 9999 37 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 38 | 0 0 1.000 4.000 8.000 39 | 349 339 349 399 9999 9999 40 | 4 0 0 14 0 -1 0 0.00000 4 13 63 399 134 Interpreter 41 | 4 0 0 14 0 -1 0 0.00000 4 13 53 79 134 Compiler 42 | 4 0 0 14 0 -1 0 0.00000 4 13 56 564 140 Programs 43 | 4 0 0 14 0 -1 0 0.00000 4 10 31 574 119 User  44 | 4 0 0 14 0 -1 0 0.00000 4 13 43 249 119 System 45 | 4 0 0 14 0 -1 0 0.00000 4 13 40 329 294 Engine 46 | 4 0 0 14 0 -1 0 0.00000 4 10 61 239 140 Predicates 47 | 4 0 0 14 0 -1 0 0.00000 4 10 64 359 379 C interface 48 | -------------------------------------------------------------------------------- /figures/arch.figsav: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 229 399 469 579 4 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 5 | 0 0 1.000 4.000 8.000 6 | 349 399 279 479 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 8 | 0 0 1.000 4.000 8.000 9 | 349 399 419 479 9999 9999 10 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 11 | 329 579 329 479 229 479 229 579 329 579 9999 9999 12 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 13 | 469 579 469 479 369 479 369 579 469 579 9999 9999 14 | 4 0 0 14 0 -1 0 0.00000 4 13 43 259 519 System 15 | 4 0 0 14 0 -1 0 0.00000 4 10 56 249 540 Functions 16 | 4 0 0 14 0 -1 0 0.00000 4 10 31 404 519 User  17 | 4 0 0 14 0 -1 0 0.00000 4 13 56 389 540 Programs 18 | -6 19 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 429 129 50 50 429 79 429 179 20 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 269 129 50 50 269 79 269 179 21 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 109 129 50 50 109 79 109 179 22 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 589 129 50 50 589 79 589 179 23 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 24 | 399 339 399 239 299 239 299 339 399 339 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 589 179 349 239 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 29 | 0 0 1.000 4.000 8.000 30 | 113 178 353 238 9999 9999 31 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 32 | 0 0 1.000 4.000 8.000 33 | 269 179 349 239 9999 9999 34 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 35 | 0 0 1.000 4.000 8.000 36 | 431 178 351 238 9999 9999 37 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 38 | 0 0 1.000 4.000 8.000 39 | 349 339 349 399 9999 9999 40 | 4 0 0 14 0 -1 0 0.00000 4 13 63 399 134 Interpreter 41 | 4 0 0 14 0 -1 0 0.00000 4 13 53 79 134 Compiler 42 | 4 0 0 14 0 -1 0 0.00000 4 13 56 564 140 Programs 43 | 4 0 0 14 0 -1 0 0.00000 4 10 31 574 119 User  44 | 4 0 0 14 0 -1 0 0.00000 4 13 43 249 119 System 45 | 4 0 0 14 0 -1 0 0.00000 4 13 40 329 294 Engine 46 | 4 0 0 14 0 -1 0 0.00000 4 10 61 239 140 Predicates 47 | 4 0 0 14 0 -1 0 0.00000 4 10 64 359 379 C interface 48 | -------------------------------------------------------------------------------- /grammarlrk.P: -------------------------------------------------------------------------------- 1 | /* parse with tabling to get a lr(k)-like algorithm. This passes a 2 | single follow-ing string instead of a set of strings as follows. */ 3 | 4 | :- import length/2,append/3,member/2 from basics. 5 | at :- abolish_all_tables. 6 | 7 | :- table parse/4. 8 | parse(Sym,Follow,Str0,Str) :- 9 | word(Str0,Sym,Str), 10 | next_str(Follow,Str). 11 | parse(Sym,Follow,Str0,Str) :- 12 | rule(Sym,RB), 13 | parseSF(RB,Follow,Str0,Str), 14 | writeln(p((Sym-->RB),Str0,Str)). 15 | 16 | parseSF([],Follow,Str,Str) :- 17 | next_str(Follow,Str). 18 | parseSF([Sym|SF],Follow,Str0,Str) :- 19 | firstK(SF,Follow,SymFollow), 20 | parse(Sym,SymFollow,Str0,Str1), 21 | parseSF(SF,Follow,Str1,Str). 22 | 23 | next_str([],_). 24 | next_str(['$'|_],S) :- \+ word(S,_,_). % end of string 25 | next_str([Sym|Syms],S) :- word(S,Sym,S1),next_str(Syms,S1). 26 | 27 | :- table firstK/3. 28 | % firstK(+SF,+Follow,-First), where K = length(Follow) 29 | firstK([],Follow,Follow). 30 | firstK([Sym|SF],Follow,First) :- 31 | firstK(SF,Follow,SymFollow), 32 | (nonterminal(Sym) 33 | -> rule(Sym,Body), 34 | firstK(Body,SymFollow,First) 35 | ; append(FirstT,[_],SymFollow), 36 | First = [Sym|FirstT] 37 | ). 38 | 39 | nonterminal(S) :- rule(S,_),!. 40 | 41 | %%| ?- parse(s,['$','$'],0,14),writeln(yes),fail. 42 | 43 | /* S -> A B. 44 | A -> aA | a. 45 | B -> Bb | b. 46 | 47 | rule(s,[an,bn]). 48 | rule(an,[a,an]). 49 | rule(an,[a]). 50 | rule(bn,[bn,b]). 51 | rule(bn,[b]). 52 | 53 | word(0,a,1). 54 | word(1,a,2). 55 | word(2,a,3). 56 | word(3,a,4). 57 | word(4,a,5). 58 | word(5,a,6). 59 | word(6,a,7). 60 | word(7,a,8). 61 | word(8,a,9). 62 | word(9,a,10). 63 | word(10,a,11). 64 | word(11,a,12). 65 | word(12,b,13). 66 | word(13,b,14). 67 | %word(14,'$',15). 68 | %word(15,'$',16). 69 | */ 70 | 71 | rule(e,[e,+,t]). 72 | rule(e,[e,-,t]). 73 | rule(e,[t]). 74 | rule(t,[t,*,f]). 75 | rule(t,[t,/,f]). 76 | rule(t,[f]). 77 | rule(f,[n]). 78 | rule(f,['(',e,')']). 79 | 80 | -------------------------------------------------------------------------------- /figures/slide-cpstack.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 4 | 399 259 399 199 239 199 239 259 399 259 9999 9999 5 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 6 | 399 199 399 139 239 139 239 199 399 199 9999 9999 7 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 8 | 399 179 479 179 479 524 9999 9999 9 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 10 | 399 239 419 239 419 279 399 279 9999 9999 11 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 12 | 399 299 419 299 419 339 399 339 9999 9999 13 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 14 | 399 359 419 359 419 399 399 399 9999 9999 15 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 16 | 399 419 459 419 459 519 399 519 9999 9999 17 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 18 | 399 479 439 479 439 579 419 579 9999 9999 19 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 20 | 399 539 419 539 419 579 399 579 9999 9999 21 | 2 1 0 2 -1 0 0 0 0.000 7 0 0 22 | 479 519 479 529 399 529 9999 9999 23 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 24 | 399 319 399 259 239 259 239 319 399 319 9999 9999 25 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 26 | 399 379 399 319 239 319 239 379 399 379 9999 9999 27 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 28 | 399 439 399 379 239 379 239 439 399 439 9999 9999 29 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 30 | 399 499 399 439 239 439 239 499 399 499 9999 9999 31 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 32 | 399 559 399 499 239 499 239 559 399 559 9999 9999 33 | 2 2 0 2 -1 0 0 0 0.000 7 0 0 34 | 399 619 399 559 239 559 239 619 399 619 9999 9999 35 | 4 0 2 14 0 -1 0 0.00000 4 13 98 254 295 a(b,Z) <- a(c,Z) 36 | 4 0 2 14 0 -1 0 0.00000 4 13 140 254 234 a(c,Z) <- a(c,Y),a(Y,Z) 37 | 4 0 2 14 0 -1 0 0.00000 4 13 97 254 174 a(a,Z) <- a(c,Z) 38 | 4 0 2 14 0 -1 0 0.00000 4 10 50 179 199 freeze 4 39 | 4 0 2 14 0 -1 0 0.00000 4 10 50 179 259 freeze 3 40 | 4 0 2 14 0 -1 0 0.00000 4 10 50 179 379 freeze 2 41 | 4 0 2 14 0 -1 0 0.00000 4 10 50 179 499 freeze 1 42 | 4 0 2 14 0 -1 0 0.00000 4 13 97 254 589 a(a,Z) <- a(a,Z) 43 | 4 0 2 14 0 -1 0 0.00000 4 13 144 254 534 a(a,Z) <- a(a,Y), a(Y,Z) 44 | 4 0 2 14 0 -1 0 0.00000 4 13 127 254 474 a(a,Z) <- p(a,Z),q(Z) 45 | 4 0 2 14 0 -1 0 0.00000 4 13 98 254 413 a(a,Z) <- a(b,Z) 46 | 4 0 2 14 0 -1 0 0.00000 4 13 142 254 359 a(b,Z) <- a(b,Y),a(Y,Z) 47 | -------------------------------------------------------------------------------- /figures/call-dep.eps.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig008829 3 | %%Creator: fig2dev 4 | %%CreationDate: Tue Jul 27 17:49:28 1993 5 | %%For: tswift@sbpub10 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 95 61 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -45.0 297.0 translate 0.900 -0.900 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 134 284 m 134 324 l gs col-1 s gr 41 | n 136.000 316.000 m 134.000 324.000 l 132.000 316.000 l gs 2 setlinejoin col-1 s gr 42 | % Polyline 43 | n 134 284 m 54 324 l gs col-1 s gr 44 | n 62.050 322.211 m 54.000 324.000 l 60.261 318.633 l gs 2 setlinejoin col-1 s gr 45 | n 67.000 331.000 m 59.000 329.000 l 67.000 327.000 l gs 2 setlinejoin col-1 s gr 46 | % Polyline 47 | n 59 329 m 129 329 l gs col-1 s gr 48 | % Interpolated spline 49 | n 49 319 m 50 | 56.862 290.946 63.112 279.696 74 274 curveto 51 | 84.628 268.440 97.128 269.690 124 279 curveto 52 | gs col-1 s gr 53 | n 117.096 274.491 m 124.000 279.000 l 115.786 278.271 l gs 2 setlinejoin col-1 s gr 54 | /Times-Roman findfont 12.00 scalefont setfont 55 | 119 274 m 56 | gs 1 -1 scale (1\) r\(X\)) col-1 show gr 57 | /Times-Roman findfont 12.00 scalefont setfont 58 | 124 314 m 59 | gs 1 -1 scale (~) col-1 show gr 60 | $F2psEnd 61 | -------------------------------------------------------------------------------- /figures/dep-graph.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig001386 3 | %%Creator: fig2dev 4 | %%CreationDate: Mon Sep 26 15:19:57 1994 5 | %%For: juliana@sbproud6 (Juliana Lima,stu,123195,warren,sun,5,) 6 | %%BoundingBox: 0 0 31 68 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | /DrawSplineSection { 31 | /y3 exch def 32 | /x3 exch def 33 | /y2 exch def 34 | /x2 exch def 35 | /y1 exch def 36 | /x1 exch def 37 | /xa x1 x2 x1 sub 0.666667 mul add def 38 | /ya y1 y2 y1 sub 0.666667 mul add def 39 | /xb x3 x2 x3 sub 0.666667 mul add def 40 | /yb y3 y2 y3 sub 0.666667 mul add def 41 | x1 y1 lineto 42 | xa ya xb yb x3 y3 curveto 43 | } def 44 | 45 | end 46 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 47 | /$F2psEnd {$F2psEnteredState restore end} def 48 | %%EndProlog 49 | 50 | $F2psBegin 51 | 0 setlinecap 0 setlinejoin 52 | -36.0 184.0 translate 0.900 -0.900 scale 53 | 0.500 setlinewidth 54 | % Open spline 55 | n 59.000 139.000 m 66.500 139.000 l 56 | 66.500 139.000 74.000 139.000 74.000 169.000 DrawSplineSection 57 | 74.000 169.000 74.000 199.000 66.500 199.000 DrawSplineSection 58 | 59.000 199.000 l gs col-1 s gr 59 | n 67.000 201.000 m 59.000 199.000 l 67.000 197.000 l gs 2 setlinejoin col-1 s gr 60 | /Times-Roman findfont 12.00 scalefont setfont 61 | 39 144 m 62 | gs 1 -1 scale (P) col-1 show gr 63 | /Times-Roman findfont 12.00 scalefont setfont 64 | 39 204 m 65 | gs 1 -1 scale (Q) col-1 show gr 66 | $F2psEnd 67 | -------------------------------------------------------------------------------- /figures/sigmod-call-graph.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig001986 3 | %%Creator: fig2dev 4 | %%CreationDate: Mon Oct 4 16:52:39 1993 5 | %%For: tswift@sblapis2 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 54 83 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -198.0 180.0 translate 0.900 -0.900 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 239 119 m 239 139 l gs col-1 s gr 41 | n 241.000 131.000 m 239.000 139.000 l 237.000 131.000 l gs 2 setlinejoin col-1 s gr 42 | % Polyline 43 | n 239 159 m 239 179 l gs col-1 s gr 44 | n 241.000 171.000 m 239.000 179.000 l 237.000 171.000 l gs 2 setlinejoin col-1 s gr 45 | [4.000000] 0 setdash 46 | % Interpolated spline 47 | n 254 194 m 48 | 273.100 175.337 279.350 165.337 279 154 curveto 49 | 278.681 143.662 272.431 134.912 254 119 curveto 50 | gs col-1 s gr 51 | [] 0 setdash 52 | n 258.749 125.742 m 254.000 119.000 l 261.362 122.714 l gs 2 setlinejoin col-1 s gr 53 | /Times-Roman findfont 12.00 scalefont setfont 54 | 219 119 m 55 | gs 1 -1 scale (a\(a,X\)) col-1 show gr 56 | /Times-Roman findfont 12.00 scalefont setfont 57 | 219 159 m 58 | gs 1 -1 scale (a\(b,X\)) col-1 show gr 59 | /Times-Roman findfont 12.00 scalefont setfont 60 | 219 199 m 61 | gs 1 -1 scale (a\(c,X\)) col-1 show gr 62 | $F2psEnd 63 | -------------------------------------------------------------------------------- /grammarlrk1.P: -------------------------------------------------------------------------------- 1 | /* parse with tabling to get a lr(k)-like algorithm. This passes a 2 | set of follow-ing strings as the follow set. */ 3 | 4 | :- import length/2,append/3,member/2 from basics. 5 | at :- abolish_all_tables. 6 | 7 | :- table parse/4. 8 | parse(Sym,Follows,Str0,Str) :- 9 | rule(Sym,RB), 10 | parseSF(RB,Follows,Str0,Str), 11 | writeln(p((Sym-->RB),Str0,Str)). 12 | 13 | parseSF([],Follows,Str0,Str) :- !,Str0=Str, 14 | member(Follow,Follows), 15 | next_str(Follow,Str). 16 | parseSF([Sym|SF],Follows,Str0,Str) :- 17 | nonterminal(Sym), 18 | firstKs(SF,Follows,FollowsSym), 19 | parse(Sym,FollowsSym,Str0,Str1), 20 | parseSF(SF,Follows,Str1,Str). 21 | parseSF([Term|SF],Follows,Str0,Str) :- 22 | word(Str0,Term,Str1), 23 | parseSF(SF,Follows,Str1,Str). 24 | 25 | 26 | firstKs(SF,Follows,Firsts) :- 27 | findall(First, 28 | (member(Follow,Follows), 29 | same_length(Follow,First), 30 | firstK(SF,Follow,First)), 31 | Firsts). 32 | 33 | next_str([],_). 34 | next_str(['$'|_],S) :- \+ word(S,_,_). % end of string 35 | next_str([Sym|Syms],S) :- word(S,Sym,S1),next_str(Syms,S1). 36 | 37 | :- table firstK/3. 38 | % firstK(SF,Follow,First) 39 | firstK(_,_,[]). 40 | firstK([],[S|Follows],[S|Firsts]) :- append(Firsts,_,Follows). 41 | firstK([NT|SF],Follow,First) :- 42 | nonterminal(NT), 43 | same_length(Follow,NTFollow), 44 | firstK(SF,Follow,NTFollow), 45 | rule(NT,Body), 46 | firstK(Body,NTFollow,First). 47 | firstK([T|SF],Follows,[T|Firsts]) :- 48 | \+ nonterminal(T), 49 | firstK(SF,Follows,Firsts). 50 | 51 | same_length([],[]). 52 | same_length([_|I],[_|O]) :- same_length(I,O). 53 | 54 | nonterminal(S) :- rule(S,_),!. 55 | 56 | %%| ?- parse(s,[['$','$']],0,14). 57 | 58 | /* S -> A B. 59 | A -> aA | a. 60 | B -> Bb | b. 61 | */ 62 | rule(s,[an,bn]). 63 | rule(an,[a,an]). 64 | rule(an,[a]). 65 | rule(bn,[bn,b]). 66 | rule(bn,[b]). 67 | 68 | word(0,a,1). 69 | word(1,a,2). 70 | word(2,a,3). 71 | word(3,a,4). 72 | word(4,a,5). 73 | word(5,a,6). 74 | word(6,a,7). 75 | word(7,a,8). 76 | word(8,a,9). 77 | word(9,a,10). 78 | word(10,a,11). 79 | word(11,a,12). 80 | word(12,b,13). 81 | word(13,b,14). 82 | %word(14,'$',15). 83 | %word(15,'$',16). 84 | -------------------------------------------------------------------------------- /figures/unnamed.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig009797 3 | %%Creator: fig2dev 4 | %%CreationDate: Fri Oct 15 16:42:34 1993 5 | %%For: tswift@sblapis1 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 452 424 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | /DrawEllipse { 31 | /endangle exch def 32 | /startangle exch def 33 | /yrad exch def 34 | /xrad exch def 35 | /y exch def 36 | /x exch def 37 | /savematrix mtrx currentmatrix def 38 | x y translate xrad yrad scale 0 0 1 startangle endangle arc 39 | savematrix setmatrix 40 | } def 41 | 42 | end 43 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 44 | /$F2psEnd {$F2psEnteredState restore end} def 45 | %%EndProlog 46 | 47 | $F2psBegin 48 | 0 setlinecap 0 setlinejoin 49 | -20.0 -34.0 translate 90 rotate 0.900 -0.900 scale 50 | /AvantGarde-Demi findfont 100.00 scalefont setfont 51 | 479 294 m 52 | gs 1 -1 scale 9.0 rotate (XSB) col4 show gr 53 | 0.500 setlinewidth 54 | % Ellipse 55 | n 154 139 117 117 0 360 DrawEllipse gs col3 s gr 56 | % Ellipse 57 | n 134 174 54 54 0 360 DrawEllipse gs col4 s gr 58 | % Ellipse 59 | n 189 259 67 67 0 360 DrawEllipse gs col4 0.75 graycol fill gr gs col4 s gr 60 | /AvantGarde-Demi findfont 100.00 scalefont setfont 61 | 484 429 m 62 | gs 1 -1 scale (XSB) col4 show gr 63 | /AvantGarde-Demi findfont 300.00 scalefont setfont 64 | 389 524 m 65 | gs 1 -1 scale (XSB) col4 show gr 66 | % Ellipse 67 | n 326 174 70 70 0 360 DrawEllipse gs col3 s gr 68 | $F2psEnd 69 | -------------------------------------------------------------------------------- /knapsack.P: -------------------------------------------------------------------------------- 1 | % knapsack problem 2 | at :- abolish_all_tables. 3 | 4 | :- table ks/2. 5 | % ks(+I,+K) if there is a subset of items 1,...,I that sums to K. 6 | ks(0,0). % the empty set sums to 0 7 | ks(I,K) :- I>0, % don't include this Ith element in the knapsack 8 | I1 is I-1, ks(I1,K). 9 | ks(I,K) :- I>0, % do include this Ith element in the knapsack 10 | item(I,Ki), K1 is K-Ki, K1 >= 0, I1 is I-1, ks(I1,K1). 11 | 12 | %item(X,1) :- X>=1. % every item is of size 1. 13 | 14 | item(X,Y) :- X > 0, X < 20, exp(2,X,Y). 15 | 16 | exp(_X,0,1). 17 | exp(X,N,Y) :- N>0, N1 is N-1, exp(X,N1,Y1), Y is X*Y1. 18 | /** 19 | item(1,1). 20 | item(2,2). 21 | item(3,4). 22 | item(4,8). 23 | item(5,16). 24 | item(6,32). 25 | item(7,64). 26 | /**/ 27 | 28 | 29 | % ks(+I,+K,-F) if there is a subset of items 1,...,I that sums to K; F 30 | % is 1 if a subset includes the Ith item and 0 if not. 31 | :- table ks/3. 32 | ks(0,0,0). % the empty set sums to 0 33 | ks(I,K,0) :- I>0, % don't include this Ith element in the knapsack 34 | I1 is I-1, ks(I1,K,_). 35 | ks(I,K,1) :- I>0, % do include this Ith element in the knapsack 36 | item(I,Ki), K1 is K-Ki, K1 >= 0, I1 is I-1, ks(I1,K1,_). 37 | 38 | 39 | :- import get_calls/3, get_returns/2 from trie_tables. 40 | % Go back through table to find actual sets that will fill the pack 41 | findpack(I,K,S) :- 42 | get_calls(ks(I,K),_C,_S) 43 | -> findpack0(I,K,S) 44 | ; write('Error: '), write(ks(I,K)), writeln(' not in table'), 45 | fail. 46 | 47 | findpack0(0,0,[]). 48 | findpack0(I,K,[I|Set]) :- I>0, 49 | get_calls(ks(I,K),C,S), 50 | get_returns(C,S), 51 | I1 is I-1, 52 | item(I,Ki), K1 is K-Ki, 53 | findpack0(I1,K1,Set). 54 | findpack0(I,K,Set) :- I>0, 55 | get_calls(ks(I,K),C,S), 56 | get_returns(C,S), 57 | I1 is I-1, 58 | findpack0(I1,K,Set). 59 | 60 | 61 | 62 | :- table sks/3. 63 | % ks(+I,+K,-Set) if Set is a subset of items 1,...,I that sums to K. 64 | sks(0,0,[]). % the empty set sums to 0 65 | sks(I,K,Set) :- I>0, % don't include this Ith element in the knapsack 66 | I1 is I-1, sks(I1,K,Set). 67 | sks(I,K,[I|Set]) :- I>0, % do include this Ith element in the knapsack 68 | item(I,Ki), K1 is K-Ki, K1 >= 0, I1 is I-1, sks(I1,K1,Set). 69 | -------------------------------------------------------------------------------- /figures/new-stack-layout.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 259 449 539 449 4 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 5 | 259 449 539 449 9999 9999 6 | -6 7 | 6 539 179 539 449 8 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 9 | 539 179 539 449 9999 9999 10 | -6 11 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 12 | 259 179 259 449 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 7 1 1 14 | 0 0 1.000 4.000 8.000 15 | 0 0 1.000 4.000 8.000 16 | 399 299 399 359 9999 9999 17 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 18 | 0 0 1.000 4.000 8.000 19 | 259 94 259 179 9999 9999 20 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 21 | 0 0 1.000 4.000 8.000 22 | 539 94 539 179 9999 9999 23 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 24 | 259 149 539 149 9999 9999 25 | 2 1 1 1 -1 0 0 0 4.000 7 0 1 26 | 0 0 1.000 4.000 8.000 27 | 399 209 399 269 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 29 | 259 239 539 239 9999 9999 30 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 31 | 259 359 539 359 9999 9999 32 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 33 | 259 299 539 299 9999 9999 34 | 2 1 0 1 -1 0 0 0 0.000 7 1 1 35 | 0 0 1.000 4.000 8.000 36 | 0 0 1.000 4.000 8.000 37 | 399 389 399 449 9999 9999 38 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 39 | 259 449 539 449 9999 9999 40 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 41 | 259 389 539 389 9999 9999 42 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 43 | 259 329 539 329 9999 9999 44 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 45 | 259 419 539 419 9999 9999 46 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 47 | 259 269 539 269 9999 9999 48 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 49 | 259 209 539 209 9999 9999 50 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 51 | 0 0 1.000 4.000 8.000 52 | 399 149 399 179 9999 9999 53 | 2 1 1 1 -1 0 0 0 4.000 -1 0 0 54 | 259 179 539 179 9999 9999 55 | 4 0 13 10 0 -1 0 0.00000 4 7 30 59 320 trail 56 | 4 0 13 10 0 -1 0 0.00000 4 7 102 59 437 unification stack 57 | 4 0 13 10 0 -1 0 0.00000 4 9 24 59 407 heap 58 | 4 0 13 10 0 -1 0 0.00000 4 7 66 59 349 local stack 59 | 4 0 13 10 0 -1 0 0.00000 4 9 108 59 261 choice point stack 60 | 4 0 13 10 0 -1 0 0.00000 4 7 36 59 233 unused 61 | 4 0 12 10 0 -1 0 0.00000 4 8 78 269 114 Program Space 62 | 4 0 12 10 0 -1 0 0.00000 4 9 72 359 114 Symbol Table 63 | 4 0 12 10 0 -1 0 0.00000 4 9 66 444 114 Table Space 64 | 4 0 13 10 0 -1 0 0.00000 4 9 96 59 169 completion stack 65 | -------------------------------------------------------------------------------- /figures/slg-examp.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig007724 3 | %%Creator: fig2dev 4 | %%CreationDate: Thu Jul 22 19:03:34 1993 5 | %%For: tswift@sbpub4 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 82 137 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -144.0 189.0 translate 0.900 -0.900 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 239 79 m 179 119 l gs col-1 s gr 41 | % Polyline 42 | n 239 79 m 239 119 l gs col-1 s gr 43 | % Polyline 44 | n 179 144 m 179 184 l gs col-1 s gr 45 | % Polyline 46 | n 239 144 m 239 184 l gs col-1 s gr 47 | /Times-Roman findfont 12.00 scalefont setfont 48 | 229 69 m 49 | gs 1 -1 scale (r\(X\)) col-1 show gr 50 | /Times-Roman findfont 12.00 scalefont setfont 51 | 159 109 m 52 | gs 1 -1 scale (X = 1) col-1 show gr 53 | /Times-Roman findfont 12.00 scalefont setfont 54 | 209 109 m 55 | gs 1 -1 scale (X = 2) col-1 show gr 56 | /Times-Roman findfont 12.00 scalefont setfont 57 | 169 138 m 58 | gs 1 -1 scale (~p) col-1 show gr 59 | /Times-Roman findfont 12.00 scalefont setfont 60 | 234 134 m 61 | gs 1 -1 scale (q) col-1 show gr 62 | /Times-Roman findfont 12.00 scalefont setfont 63 | 164 209 m 64 | gs 1 -1 scale (r\(X1\),q) col-1 show gr 65 | /Times-Roman findfont 12.00 scalefont setfont 66 | 229 204 m 67 | gs 1 -1 scale (~p) col-1 show gr 68 | $F2psEnd 69 | -------------------------------------------------------------------------------- /figures/stack-layout: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 4 | 399 514 399 54 119 54 119 514 399 514 9999 9999 5 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 6 | 0 0 1.000 4.000 8.000 7 | 259 379 259 359 9999 9999 8 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 9 | 0 0 1.000 4.000 8.000 10 | 259 459 259 439 9999 9999 11 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 12 | 0 0 1.000 4.000 8.000 13 | 259 299 259 279 9999 9999 14 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 15 | 0 0 1.000 4.000 8.000 16 | 259 219 259 199 9999 9999 17 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 18 | 0 0 1.000 4.000 8.000 19 | 259 139 259 119 9999 9999 20 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 21 | 0 0 1.000 4.000 8.000 22 | 259 164 259 184 9999 9999 23 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 24 | 0 0 1.000 4.000 8.000 25 | 259 244 259 264 9999 9999 26 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 27 | 0 0 1.000 4.000 8.000 28 | 259 324 259 344 9999 9999 29 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 30 | 0 0 1.000 4.000 8.000 31 | 259 404 259 424 9999 9999 32 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 33 | 0 0 1.000 4.000 8.000 34 | 119 514 119 599 9999 9999 35 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 36 | 0 0 1.000 4.000 8.000 37 | 399 514 399 599 9999 9999 38 | 4 0 13 10 0 -1 0 0.00000 4 9 42 59 454 opentab 39 | 4 0 13 10 0 -1 0 0.00000 4 9 48 59 418 tabtrreg 40 | 4 0 13 10 0 -1 0 0.00000 4 9 24 59 376 breg 41 | 4 0 13 10 0 -1 0 0.00000 4 9 30 59 335 trreg 42 | 4 0 13 10 0 -1 0 0.00000 4 7 24 59 299 ereg 43 | 4 0 13 10 0 -1 0 0.00000 4 9 24 59 257 hreg 44 | 4 0 13 10 0 -1 0 0.00000 4 9 36 59 214 tabreg 45 | 4 0 13 10 0 -1 0 0.00000 4 9 30 59 179 threg 46 | 4 0 13 10 0 -1 0 0.00000 4 9 18 59 136 pdl 47 | 4 0 12 10 0 -1 0 0.00000 4 9 126 189 479 main_thread -> memend 48 | 4 0 12 10 0 -1 0 0.00000 4 9 144 189 397 main_thread -> opentable 49 | 4 0 12 10 0 -1 0 0.00000 4 9 132 189 240 main_thread -> maxsusp 50 | 4 0 12 10 0 -1 0 0.00000 4 9 108 189 159 main_thread -> pdl 51 | 4 0 12 10 0 -1 0 0.00000 4 9 126 189 77 main_thread -> memory 52 | 4 0 12 10 0 -1 0 0.00000 4 9 258 134 316 main_thread -> lstack ; main_thread ->trail 53 | 4 0 12 10 0 -1 0 0.00000 4 8 78 219 534 Program Space 54 | 4 0 12 10 0 -1 0 0.00000 4 9 192 164 574 Program Clauses, Table Info Strs 55 | 4 0 12 10 0 -1 0 0.00000 4 9 78 224 554 Symbol Table, 56 | -------------------------------------------------------------------------------- /grammar.P: -------------------------------------------------------------------------------- 1 | 'C'(I,W,I1) :- 2 | nonvar(I) 3 | -> word(I,W), I1 is I+1 4 | ; I is I1-1, word(I,W). 5 | 6 | assert_words([],N,N). 7 | assert_words([Word|Words],N,M) :- 8 | assert(word(N,Word)), N1 is N+1, assert_words(Words,N1,M). 9 | 10 | init_words(String,N) :- 11 | retractall(word(_,_)), 12 | assert_words(String,1,N), 13 | abolish_all_tables. 14 | /**************************************** 15 | :- table expr/3, term/3. 16 | 17 | eval_string(String,Val) :- 18 | init_words(String,N), 19 | expr(Val,1,N). 20 | 21 | expr(Val) --> expr(Eval), [+], term(Tval), {Val is Eval+Tval}. 22 | expr(Val) --> term(Val). 23 | term(Val) --> term(Tval), [*], factor(Fval), {Val is Tval*Fval}. 24 | term(Val) --> factor(Val). 25 | factor(Val) --> prime(Num), [^], factor(Exp), {Val is floor(exp(log(Num)*Exp)+0.5)}. 26 | factor(Val) --> prime(Val). 27 | prime(Val) --> ['('], expr(Val), [')']. 28 | prime(Int) --> [Int], {integer(Int)}. 29 | /***************************************************/ 30 | 31 | :- table 'C'/3. 32 | :- table s/2, b/2, g/2. 33 | s --> b, [c]. 34 | s --> g, [d]. 35 | 36 | b --> b, b. 37 | b --> [a]. 38 | 39 | g --> g, [a]. 40 | g --> [a]. 41 | 42 | eval_string(String) :- 43 | init_words(String,N), 44 | s(1,N). 45 | 46 | /* to extract the parses */ 47 | :- import get_calls/3, get_returns/2 from trie_tables. 48 | 49 | e_parse_lit('C'(N,Word,M),Word) :- 'C'(N,Word,M). 50 | e_parse_lit(Goal,Parse) :- 51 | rule(Goal,Body), 52 | goal_in_table(Body), 53 | e_parse_goal(Body,Subparses), 54 | functor(Goal,Sym,_), 55 | Parse =.. [Sym|Subparses]. 56 | 57 | goal_in_table((Lit,Rest)) :- !, 58 | lit_in_table(Lit), 59 | goal_in_table(Rest). 60 | goal_in_table(Lit) :- 61 | lit_in_table(Lit). 62 | 63 | lit_in_table('C'(N,W,M)) :- !, 'C'(N,W,M). 64 | lit_in_table(Lit) :- get_calls(Lit,Cs,Rt), get_returns(Cs,Rt). 65 | 66 | e_parse_goal((Lit,Rest),[P|Ps]) :- !, 67 | e_parse_lit(Lit,P), 68 | e_parse_goal(Rest,Ps). 69 | e_parse_goal(Lit,[P]) :- !, 70 | e_parse_lit(Lit,P). 71 | 72 | ldg(Filename) :- 73 | abolish(rule/2), 74 | see(Filename), 75 | repeat, 76 | read(Term), 77 | (Term == end_of_file 78 | -> seen,!,fail 79 | ; expand_term(Term,Term1), 80 | (Term1 = (H:-B) -> true ; H=Term1,B=true), 81 | assert(rule(H,B)), 82 | fail 83 | ). -------------------------------------------------------------------------------- /figures/call-dep.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig008829 3 | %%Creator: fig2dev 4 | %%CreationDate: Tue Jul 27 18:52:27 1993 5 | %%For: tswift@sbpub10 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 95 74 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -45.0 310.0 translate 0.900 -0.900 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 134 284 m 134 324 l gs col-1 s gr 41 | n 136.000 316.000 m 134.000 324.000 l 132.000 316.000 l gs 2 setlinejoin col-1 s gr 42 | % Polyline 43 | n 134 284 m 54 324 l gs col-1 s gr 44 | n 62.050 322.211 m 54.000 324.000 l 60.261 318.633 l gs 2 setlinejoin col-1 s gr 45 | n 67.000 331.000 m 59.000 329.000 l 67.000 327.000 l gs 2 setlinejoin col-1 s gr 46 | % Polyline 47 | n 59 329 m 129 329 l gs col-1 s gr 48 | % Interpolated spline 49 | n 49 319 m 50 | 56.862 290.946 63.112 279.696 74 274 curveto 51 | 84.628 268.440 97.128 269.690 124 279 curveto 52 | gs col-1 s gr 53 | n 117.096 274.491 m 124.000 279.000 l 115.786 278.271 l gs 2 setlinejoin col-1 s gr 54 | /Times-Roman findfont 12.00 scalefont setfont 55 | 124 314 m 56 | gs 1 -1 scale (~) col-1 show gr 57 | /Times-Roman findfont 12.00 scalefont setfont 58 | 119 274 m 59 | gs 1 -1 scale (0\) r\(X\)) col-1 show gr 60 | /Times-Roman findfont 12.00 scalefont setfont 61 | 54 344 m 62 | gs 1 -1 scale (1\) p) col-1 show gr 63 | /Times-Roman findfont 12.00 scalefont setfont 64 | 129 344 m 65 | gs 1 -1 scale (3\) q) col-1 show gr 66 | $F2psEnd 67 | -------------------------------------------------------------------------------- /figures/opt-of-algo.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig001386 3 | %%Creator: fig2dev 4 | %%CreationDate: Mon Sep 26 16:12:28 1994 5 | %%For: juliana@sbproud6 (Juliana Lima,stu,123195,warren,sun,5,) 6 | %%BoundingBox: 0 0 301 100 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -9.0 198.0 translate 0.900 -0.900 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 33 124 m 344 124 l gs col-1 s gr 41 | % Polyline 42 | n 33 189 m 344 189 l gs col-1 s gr 43 | % Polyline 44 | n 79 124 m 84 129 l 129 129 l 134 134 l 45 | 139 129 l 184 129 l 189 124 l gs col-1 s gr 46 | % Polyline 47 | n 189 124 m 194 129 l 239 129 l 244 134 l 48 | 249 129 l 294 129 l 299 124 l gs col-1 s gr 49 | % Polyline 50 | n 99 189 m 104 194 l 149 194 l 154 199 l 51 | 159 194 l 204 194 l 209 189 l gs col-1 s gr 52 | % Polyline 53 | n 209 189 m 214 194 l 259 194 l 264 199 l 54 | 269 194 l 314 194 l 319 189 l gs col-1 s gr 55 | /Times-Roman findfont 12.00 scalefont setfont 56 | 109 149 m 57 | gs 1 -1 scale (Read) col-1 show gr 58 | /Times-Roman findfont 12.00 scalefont setfont 59 | 144 219 m 60 | gs 1 -1 scale (Read) col-1 show gr 61 | /Times-Roman findfont 12.00 scalefont setfont 62 | 224 149 m 63 | gs 1 -1 scale (Write) col-1 show gr 64 | /Times-Roman findfont 12.00 scalefont setfont 65 | 244 219 m 66 | gs 1 -1 scale (Write) col-1 show gr 67 | /Times-Roman findfont 12.00 scalefont setfont 68 | 9 124 m 69 | gs 1 -1 scale (Q) col-1 show gr 70 | /Times-Roman findfont 12.00 scalefont setfont 71 | 9 194 m 72 | gs 1 -1 scale (P) col-1 show gr 73 | $F2psEnd 74 | -------------------------------------------------------------------------------- /negation.P: -------------------------------------------------------------------------------- 1 | :- table reach/2. 2 | edge(a,b). 3 | edge(b,a). 4 | edge(c,b). 5 | edge(c,a). 6 | edge(a,a). 7 | edge(b,b). 8 | edge(c,c). 9 | reach(X,Y) :- edge(X,Y). 10 | reach(X,Y) :- reach(X,Z), edge(Z,Y). 11 | 12 | end_of_file. 13 | 14 | 15 | 16 | :- table p/0,q/0,r/0,s/0,t/0,u/0. 17 | p :- r, tnot(t). 18 | q :- r, tnot(s), tnot(u). 19 | r :- s. 20 | r. 21 | s :- tnot(q), r. 22 | t. 23 | 24 | u :- fail. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | bachelor(X) :- \+ married(X), male(X). 56 | 57 | male(bill). 58 | male(jim). 59 | 60 | married(bill). 61 | married(mary). 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | end_of_file. 74 | bachelor(X) :- \+ married(X), male(X). 75 | 76 | 77 | /***************************************/ 78 | 79 | :- table reachable/2. 80 | reachable(X,Y) :- reduce(X,Y). 81 | %reachable(X,X). 82 | reachable(X,Y) :- reachable(X,Z), reduce(Z,Y). 83 | 84 | reducible(X) :- reachable(X,Y), tnot(reachable(Y,X)). 85 | 86 | :- table reducible/1. 87 | fullyReduce(X,Y) :- reachable(X,Y),tnot(reducible(Y)). 88 | 89 | fullyReduceRep(X,Y) :- fullyReduce(X,Y), tnot(smallerequiv(Y)). 90 | 91 | :- table smallerequiv/1. 92 | smallerequiv(X) :- reachable(X,Y), Y@0,I<64,(J is 2*I ; J is 2*I+1). 111 | reduce(I,J) :- I>=0,I<128, J is I // 2. 112 | *******/ 113 | /***************************************/ 114 | :- import get_calls/3, get_returns/2 from tables. 115 | 116 | fill_table(X) :- reachable(X,Y),reachable(Y,_),fail. 117 | 118 | intab(X) :- get_calls(X,R,C),get_returns(R,C). 119 | 120 | tfullyReduce(X,_Y) :- fill_table(X). 121 | tfullyReduce(X,Y) :- 122 | intab(reachable(X,Y)), 123 | \+ (intab(reachable(Y,Z)), \+ intab(reachable(Z,Y))). 124 | 125 | 126 | even(0). 127 | even(succ(X)) :- \+even(X). 128 | 129 | odd(X) :- \+even(X). 130 | 131 | funny(X) :- \+odd(X), \+even(X). 132 | 133 | -------------------------------------------------------------------------------- /figures/parscc.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 4 | 0 0 1.000 4.000 8.000 5 | 199 159 199 179 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 7 | 0 0 1.000 4.000 8.000 8 | 159 159 179 139 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 10 | 0 0 1.000 4.000 8.000 11 | 179 199 159 179 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 13 | 0 0 1.000 4.000 8.000 14 | 359 139 319 159 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 16 | 0 0 1.000 4.000 8.000 17 | 361 139 400 159 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 19 | 0 0 1.000 4.000 8.000 20 | 199 159 179 139 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 22 | 0 0 1.000 4.000 8.000 23 | 179 199 199 179 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 25 | 0 0 1.000 4.000 8.000 26 | 159 159 159 179 9999 9999 27 | 3 2 0 1 -1 0 0 0 0.000 1 0 28 | 0 0 1.000 4.000 8.000 29 | 314 159 299 169 294 179 9999 9999 30 | 55.000 -120.000 304.953 164.004 301.203 166.504 297.634 170.548 31 | 296.384 173.048 55.000 -120.000 32 | 3 2 0 1 -1 0 0 0 0.000 1 0 33 | 0 0 1.000 4.000 8.000 34 | 299 184 319 189 339 184 9999 9999 35 | 60.000 -115.000 310.224 187.750 315.224 189.000 322.776 189.000 36 | 327.776 187.750 60.000 -115.000 37 | 3 2 0 1 -1 0 0 0 0.000 0 1 38 | 0 0 1.000 4.000 8.000 39 | 405 163 410 173 405 183 9999 9999 40 | 664.000 -76.000 408.750 168.103 410.000 170.603 410.000 175.397 41 | 408.750 177.897 664.000 -76.000 42 | 3 2 0 1 -1 0 0 0 0.000 1 0 43 | 0 0 1.000 4.000 8.000 44 | 393 162 388 172 393 182 9999 9999 45 | 134.000 -77.000 389.250 167.103 388.000 169.603 388.000 174.397 46 | 389.250 176.897 134.000 -77.000 47 | 3 2 0 1 -1 0 0 0 0.000 0 1 48 | 0 0 1.000 4.000 8.000 49 | 322 161 337 171 342 181 9999 9999 50 | 581.000 -118.000 331.047 166.004 334.797 168.504 338.366 172.548 51 | 339.616 175.048 581.000 -118.000 52 | 4 0 12 12 0 -1 0 0.00000 4 14 7 149 154 q 53 | 4 0 12 12 0 -1 0 0.00000 4 14 7 149 189 r 54 | 4 0 12 12 0 -1 0 0.00000 4 14 7 209 189 u 55 | 4 0 12 12 0 -1 0 0.00000 4 14 7 209 159 t 56 | 4 0 12 12 0 -1 0 0.00000 4 14 7 179 134 p 57 | 4 0 12 12 0 -1 0 0.00000 4 14 7 176 212 s 58 | 4 0 12 12 0 -1 0 0.00000 4 14 7 359 130 p 59 | 4 0 12 12 0 -1 0 0.00000 4 14 7 313 150 q 60 | 4 0 12 12 0 -1 0 0.00000 4 14 7 287 194 r 61 | 4 0 12 12 0 -1 0 0.00000 4 14 7 348 193 s 62 | 4 0 12 12 0 -1 0 0.00000 4 14 7 396 150 t 63 | 4 0 12 12 0 -1 0 0.00000 4 14 7 396 197 u 64 | 4 0 2 12 0 -1 0 0.00000 4 17 6 172 252 a 65 | 4 0 2 12 0 -1 0 0.00000 4 17 7 353 255 b 66 | -------------------------------------------------------------------------------- /figures/new-stack-layoutd.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 199 104 479 459 4 | 6 199 104 479 459 5 | 6 199 104 479 459 6 | 6 199 104 479 459 7 | 6 199 104 479 459 8 | 6 199 104 479 459 9 | 2 1 0 1 -1 0 0 0 0.000 7 1 1 10 | 0 0 1.000 4.000 8.000 11 | 0 0 1.000 4.000 8.000 12 | 339 309 339 369 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 14 | 0 0 1.000 4.000 8.000 15 | 479 104 479 189 9999 9999 16 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 17 | 199 159 479 159 9999 9999 18 | 2 1 1 1 -1 0 0 0 4.000 7 0 1 19 | 0 0 1.000 4.000 8.000 20 | 339 219 339 279 9999 9999 21 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 22 | 199 309 479 309 9999 9999 23 | 2 1 0 1 -1 0 0 0 0.000 7 1 1 24 | 0 0 1.000 4.000 8.000 25 | 0 0 1.000 4.000 8.000 26 | 339 399 339 459 9999 9999 27 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 28 | 199 339 479 339 9999 9999 29 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 30 | 199 429 479 429 9999 9999 31 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 32 | 199 279 479 279 9999 9999 33 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 34 | 0 0 1.000 4.000 8.000 35 | 339 159 339 189 9999 9999 36 | 2 1 1 1 -1 0 0 0 4.000 -1 0 0 37 | 199 189 479 189 9999 9999 38 | 4 0 12 10 0 -1 0 0.00000 4 8 78 209 124 Program Space 39 | 4 0 12 10 0 -1 0 0.00000 4 9 72 299 124 Symbol Table 40 | 4 0 12 10 0 -1 0 0.00000 4 9 66 384 124 Table Space 41 | -6 42 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 43 | 199 369 479 369 9999 9999 44 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 45 | 199 219 479 219 9999 9999 46 | -6 47 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 48 | 199 249 479 249 9999 9999 49 | -6 50 | -6 51 | 6 199 189 204 459 52 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 53 | 199 189 199 459 9999 9999 54 | -6 55 | -6 56 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 57 | 0 0 1.000 4.000 8.000 58 | 199 104 199 189 9999 9999 59 | -6 60 | 6 199 399 479 459 61 | 6 199 399 479 459 62 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 63 | 199 459 479 459 9999 9999 64 | 2 1 1 1 -1 0 0 0 4.000 7 0 0 65 | 199 399 479 399 9999 9999 66 | -6 67 | -6 68 | 6 199 459 479 459 69 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 70 | 199 459 479 459 9999 9999 71 | -6 72 | 6 479 189 479 459 73 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 74 | 479 189 479 459 9999 9999 75 | -6 76 | 4 0 13 10 0 -1 0 0.00000 4 7 30 59 320 trail 77 | 4 0 13 10 0 -1 0 0.00000 4 9 24 59 407 heap 78 | 4 0 13 10 0 -1 0 0.00000 4 7 66 59 349 local stack 79 | 4 0 13 10 0 -1 0 0.00000 4 9 108 59 261 choice point stack 80 | 4 0 13 10 0 -1 0 0.00000 4 7 36 59 233 unused 81 | 4 0 13 10 0 -1 0 0.00000 4 9 96 59 169 completion stack 82 | 4 0 13 10 0 -1 0 0.00000 4 11 102 59 437 unification stack 83 | -------------------------------------------------------------------------------- /figures/efreem0s1s2s.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 2332.633 859.181 1350 1950 2250 2325 3225 2025 7 | 1 1 1.00 60.00 120.00 8 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 4687.500 862.500 3675 2025 4800 2400 5700 2025 9 | 1 1 1.00 60.00 120.00 10 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 1261.824 1089.527 1350 1575 1200 600 900 1425 11 | 1 1 1.00 60.00 120.00 12 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3661.824 1089.527 3750 1575 3600 600 3300 1425 13 | 1 1 1.00 60.00 120.00 14 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 5948.864 1107.955 6150 1575 5925 600 5625 1500 15 | 1 1 1.00 60.00 120.00 16 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3602.335 -447.093 1200 2025 3600 3000 5925 2100 17 | 1 1 1.00 60.00 120.00 18 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3562.500 1058.152 1050 2025 3600 3750 6075 2025 19 | 1 1 1.00 60.00 120.00 20 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 2370.536 -72.321 1425 1800 2400 2025 3150 1875 21 | 1 1 1.00 60.00 120.00 22 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 4795.588 127.941 3750 1800 4800 2100 5550 1950 23 | 1 1 1.00 60.00 120.00 24 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3513.753 1545.121 825 2025 3600 4275 6225 1875 25 | 1 1 1.00 60.00 120.00 26 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3450 1725 335 335 3450 1725 3750 1875 27 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 5850 1725 335 335 5850 1725 6150 1875 28 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 1050 1725 335 335 1050 1725 1350 1875 29 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 5887 1725 263 263 5625 1725 6150 1725 30 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3487 1762 266 266 3225 1725 3750 1800 31 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 1087 1725 263 263 825 1725 1350 1725 32 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 33 | 1 1 1.00 60.00 120.00 34 | 300 1650 675 1725 35 | 4 0 -1 0 0 0 20 0.0000000 4 300 300 900 1800 q0\001 36 | 4 0 -1 0 0 0 20 0.0000000 4 300 300 3300 1800 q1\001 37 | 4 0 -1 0 0 0 20 0.0000000 4 300 300 5700 1800 q2\001 38 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 1575 600 0\001 39 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 4050 675 1\001 40 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 6450 825 2\001 41 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 1800 2175 0\001 42 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 4200 2250 1\001 43 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 1500 2550 0\001 44 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 1200 2700 1\001 45 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 1575 1875 1\001 46 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 4050 1950 2\001 47 | 4 0 -1 0 0 0 16 0.0000000 4 195 120 750 2475 2\001 48 | -------------------------------------------------------------------------------- /figures/cpstack.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 239 559 399 619 4 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 5 | 399 619 399 559 239 559 239 619 399 619 9999 9999 6 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 589 a(a,Z) <- a(a,Z) 7 | -6 8 | 6 239 499 399 559 9 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 10 | 399 559 399 499 239 499 239 559 399 559 9999 9999 11 | 4 0 12 10 0 -1 0 0.00000 4 9 144 254 534 a(a,Z) <- a(a,Y), a(Y,Z) 12 | -6 13 | 6 239 439 399 499 14 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 15 | 399 499 399 439 239 439 239 499 399 499 9999 9999 16 | 4 0 12 10 0 -1 0 0.00000 4 9 126 254 474 a(a,Z) <- p(a,Z),q(Z) 17 | -6 18 | 6 239 379 399 439 19 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 20 | 399 439 399 379 239 379 239 439 399 439 9999 9999 21 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 413 a(a,Z) <- a(b,Z) 22 | -6 23 | 6 239 319 399 379 24 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 25 | 399 379 399 319 239 319 239 379 399 379 9999 9999 26 | 4 0 12 10 0 -1 0 0.00000 4 9 138 254 359 a(b,Z) <- a(b,Y),a(Y,Z) 27 | -6 28 | 6 239 259 399 319 29 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 30 | 399 319 399 259 239 259 239 319 399 319 9999 9999 31 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 295 a(b,Z) <- a(c,Z) 32 | -6 33 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 34 | 0 0 1.000 4.000 8.000 35 | 399 359 419 359 419 399 399 399 9999 9999 36 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 37 | 0 0 1.000 4.000 8.000 38 | 399 539 419 539 419 579 399 579 9999 9999 39 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 40 | 0 0 1.000 4.000 8.000 41 | 399 479 439 479 439 579 419 579 9999 9999 42 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 43 | 0 0 1.000 4.000 8.000 44 | 399 419 459 419 459 519 399 519 9999 9999 45 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 46 | 0 0 1.000 4.000 8.000 47 | 399 299 419 299 419 339 399 339 9999 9999 48 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 49 | 0 0 1.000 4.000 8.000 50 | 399 239 419 239 419 279 399 279 9999 9999 51 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 52 | 399 259 399 199 239 199 239 259 399 259 9999 9999 53 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 54 | 399 199 399 139 239 139 239 199 399 199 9999 9999 55 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 56 | 0 0 1.000 4.000 8.000 57 | 479 519 479 529 399 529 9999 9999 58 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 59 | 399 179 479 179 479 524 9999 9999 60 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 499 freeze 1 61 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 379 freeze 2 62 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 259 freeze 3 63 | 4 0 12 10 0 -1 0 0.00000 4 9 138 254 234 a(c,Z) <- a(c,Y),a(Y,Z) 64 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 199 freeze 4 65 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 174 a(a,Z) <- a(c,Z) 66 | -------------------------------------------------------------------------------- /figures/cpstack1.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 239 559 399 619 4 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 5 | 399 619 399 559 239 559 239 619 399 619 9999 9999 6 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 589 a(a,Z) <- a(a,Z) 7 | -6 8 | 6 239 499 399 559 9 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 10 | 399 559 399 499 239 499 239 559 399 559 9999 9999 11 | 4 0 12 10 0 -1 0 0.00000 4 9 144 254 534 a(a,Z) <- a(a,Y), a(Y,Z) 12 | -6 13 | 6 239 439 399 499 14 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 15 | 399 499 399 439 239 439 239 499 399 499 9999 9999 16 | 4 0 12 10 0 -1 0 0.00000 4 9 126 254 474 a(a,Z) <- p(a,Z),q(Z) 17 | -6 18 | 6 239 379 399 439 19 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 20 | 399 439 399 379 239 379 239 439 399 439 9999 9999 21 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 413 a(a,Z) <- a(b,Z) 22 | -6 23 | 6 239 319 399 379 24 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 25 | 399 379 399 319 239 319 239 379 399 379 9999 9999 26 | 4 0 12 10 0 -1 0 0.00000 4 9 138 254 359 a(b,Z) <- a(b,Y),a(Y,Z) 27 | -6 28 | 6 239 259 399 319 29 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 30 | 399 319 399 259 239 259 239 319 399 319 9999 9999 31 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 295 a(b,Z) <- a(c,Z) 32 | -6 33 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 34 | 0 0 1.000 4.000 8.000 35 | 399 359 419 359 419 399 399 399 9999 9999 36 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 37 | 0 0 1.000 4.000 8.000 38 | 399 539 419 539 419 579 399 579 9999 9999 39 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 40 | 0 0 1.000 4.000 8.000 41 | 399 479 439 479 439 579 419 579 9999 9999 42 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 43 | 0 0 1.000 4.000 8.000 44 | 399 419 459 419 459 519 399 519 9999 9999 45 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 46 | 0 0 1.000 4.000 8.000 47 | 399 299 419 299 419 339 399 339 9999 9999 48 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 49 | 0 0 1.000 4.000 8.000 50 | 399 239 419 239 419 279 399 279 9999 9999 51 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 52 | 399 259 399 199 239 199 239 259 399 259 9999 9999 53 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 54 | 399 199 399 139 239 139 239 199 399 199 9999 9999 55 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 56 | 0 0 1.000 4.000 8.000 57 | 479 519 479 529 399 529 9999 9999 58 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 59 | 399 179 479 179 479 524 9999 9999 60 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 499 freeze 1 61 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 379 freeze 2 62 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 259 freeze 3 63 | 4 0 12 10 0 -1 0 0.00000 4 9 138 254 234 a(c,Z) <- a(c,Y),a(Y,Z) 64 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 199 freeze 4 65 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 174 a(a,Z) <- a(c,Z) 66 | -------------------------------------------------------------------------------- /figures/cpstackd.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 239 559 399 619 4 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 5 | 399 619 399 559 239 559 239 619 399 619 9999 9999 6 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 589 a(a,Z) <- a(a,Z) 7 | -6 8 | 6 239 499 399 559 9 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 10 | 399 559 399 499 239 499 239 559 399 559 9999 9999 11 | 4 0 12 10 0 -1 0 0.00000 4 9 144 254 534 a(a,Z) <- a(a,Y), a(Y,Z) 12 | -6 13 | 6 239 439 399 499 14 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 15 | 399 499 399 439 239 439 239 499 399 499 9999 9999 16 | 4 0 12 10 0 -1 0 0.00000 4 9 126 254 474 a(a,Z) <- p(a,Z),q(Z) 17 | -6 18 | 6 239 379 399 439 19 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 20 | 399 439 399 379 239 379 239 439 399 439 9999 9999 21 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 413 a(a,Z) <- a(b,Z) 22 | -6 23 | 6 239 319 399 379 24 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 25 | 399 379 399 319 239 319 239 379 399 379 9999 9999 26 | 4 0 12 10 0 -1 0 0.00000 4 9 138 254 359 a(b,Z) <- a(b,Y),a(Y,Z) 27 | -6 28 | 6 239 259 399 319 29 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 30 | 399 319 399 259 239 259 239 319 399 319 9999 9999 31 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 295 a(b,Z) <- a(c,Z) 32 | -6 33 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 34 | 0 0 1.000 4.000 8.000 35 | 399 359 419 359 419 399 399 399 9999 9999 36 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 37 | 0 0 1.000 4.000 8.000 38 | 399 539 419 539 419 579 399 579 9999 9999 39 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 40 | 0 0 1.000 4.000 8.000 41 | 399 479 439 479 439 579 419 579 9999 9999 42 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 43 | 0 0 1.000 4.000 8.000 44 | 399 419 459 419 459 519 399 519 9999 9999 45 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 46 | 0 0 1.000 4.000 8.000 47 | 399 299 419 299 419 339 399 339 9999 9999 48 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 49 | 0 0 1.000 4.000 8.000 50 | 399 239 419 239 419 279 399 279 9999 9999 51 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 52 | 399 259 399 199 239 199 239 259 399 259 9999 9999 53 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 54 | 399 199 399 139 239 139 239 199 399 199 9999 9999 55 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 56 | 0 0 1.000 4.000 8.000 57 | 479 519 479 529 399 529 9999 9999 58 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 59 | 399 179 479 179 479 524 9999 9999 60 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 379 freeze 2 61 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 259 freeze 3 62 | 4 0 12 10 0 -1 0 0.00000 4 9 138 254 234 a(c,Z) <- a(c,Y),a(Y,Z) 63 | 4 0 12 10 0 -1 0 0.00000 4 7 48 179 199 freeze 4 64 | 4 0 12 10 0 -1 0 0.00000 4 9 96 254 174 a(a,Z) <- a(c,Z) 65 | 4 0 12 10 0 -1 0 0.00000 4 11 48 179 499 freeze 1 66 | -------------------------------------------------------------------------------- /grammarabd.P: -------------------------------------------------------------------------------- 1 | /* A metainterpreter that does lookahead. Before it calls a 2 | subroutine it computes, abducing K extensional DB atoms. Then it 3 | checks to see that the abduced facts are true. If not, it fails. 4 | Then it abduces K EDB atoms starting as though the about-to-be-called 5 | predicate succeeded and then passes those K atoms to the called 6 | subroutine. Just before the called subroutine returns, it checks to 7 | see that those abduced facts are true, failing if not, and returning 8 | successfully if they are. 9 | */ 10 | % query: interp(t(0,6),[true]),writeln(yes),fail. 11 | % query: interp(t(0,6),[true,true]),writeln(yes),fail. 12 | 13 | :- import append/3,length/2 from basics. 14 | :- import get_calls/3, get_returns/2, trie_assert/1 from tables. 15 | :- op(1050,xfx,(<-)). 16 | at :- abolish_all_tables. 17 | pt(G) :- get_calls(G,C,R),writeln(G),get_returns(C,R),tab(2),writeln(G),fail. 18 | 19 | % interp(Goal,Follow) 20 | interp(true,Follow) :- !,is_true(Follow). 21 | interp((G1,G2),Follow) :- !, 22 | abdK(G2,Follow,FollowG1), 23 | interpG(G1,FollowG1), 24 | interp(G2,Follow). 25 | interp(G,Follow) :- 26 | interpG(G,Follow). 27 | 28 | :- table interpG/2. 29 | interpG(G,Follow) :- 30 | (G <- B), 31 | interp(B,Follow), 32 | is_true(Follow). 33 | 34 | is_true([]). 35 | is_true([true|Gs]) :- is_true(Gs). 36 | is_true([G|Gs]) :- (G<-true),is_true(Gs). 37 | 38 | 39 | :- table abdK/3. 40 | abdK(true,Follow,Follow). 41 | abdK((G1,G2),Follow,ABD) :- 42 | abdK(G2,Follow,FollowG1), 43 | abdK(G1,FollowG1,ABD). 44 | abdK(G,Follow,[G|ABD]) :- abducible(G), !, 45 | append(ABD,[_],Follow). 46 | abdK(G,Follow,ABD) :- 47 | (G <- Body), 48 | abdK(Body,Follow,ABD). 49 | 50 | abducible(word(_,_,_)). 51 | 52 | t(S0,S) <- s(S0,S1),word(S1,'$',S). 53 | s(S0,S) <- a(S0,S1),b(S1,S). 54 | a(S0,S) <- word(S0,a,S1),a(S1,S). 55 | a(S0,S) <- word(S0,a,S). 56 | b(S0,S) <- b(S0,S1),word(S1,b,S). 57 | b(S0,S) <- word(S0,b,S). 58 | 59 | /**/ 60 | word(0,a,1) <- true. 61 | word(1,a,2) <- true. 62 | word(2,a,3) <- true. 63 | word(3,a,4) <- true. 64 | word(4,b,5) <- true. 65 | word(5,'$',6) <- true. 66 | /** 67 | word(0,a,1) <- true. 68 | word(1,a,2) <- true. 69 | word(2,a,3) <- true. 70 | word(3,a,4) <- true. 71 | word(4,a,5) <- true. 72 | word(5,a,6) <- true. 73 | word(6,a,7) <- true. 74 | word(7,a,8) <- true. 75 | word(8,a,9) <- true. 76 | word(9,a,10) <- true. 77 | word(10,a,11) <- true. 78 | word(11,a,12) <- true. 79 | word(12,b,13) <- true. 80 | word(13,b,14) <- true. 81 | word(14,'$',15) <- true. 82 | /**/ 83 | -------------------------------------------------------------------------------- /figures/forest2.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 299 19 419 59 4 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 5 | 0 0 1.000 4.000 8.000 6 | 299 59 359 19 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 8 | 0 0 1.000 4.000 8.000 9 | 419 59 359 19 9999 9999 10 | -6 11 | 6 299 244 419 284 12 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 13 | 0 0 1.000 4.000 8.000 14 | 299 284 359 244 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 16 | 0 0 1.000 4.000 8.000 17 | 419 284 359 244 9999 9999 18 | -6 19 | 6 379 79 459 119 20 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 21 | 0 0 1.000 4.000 8.000 22 | 419 79 379 119 9999 9999 23 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 24 | 0 0 1.000 4.000 8.000 25 | 419 79 459 119 9999 9999 26 | -6 27 | 6 189 469 569 544 28 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 29 | 0 0 1.000 4.000 8.000 30 | 359 489 259 529 9999 9999 31 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 32 | 0 0 1.000 4.000 8.000 33 | 359 489 459 529 9999 9999 34 | 4 0 13 10 0 -1 0 0.00000 4 9 96 319 479 a(c,Z) <- a(c,Z) 35 | 4 0 14 10 0 -1 0 0.00000 4 9 162 189 544 13. a(c,Z) <- a(c,Y),a(Y,Z) 36 | 4 0 12 10 0 -1 0 0.00000 4 9 150 419 544 14. a(c,Z) <- p(c,Y),q(Y) 37 | -6 38 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 39 | 0 0 1.000 4.000 8.000 40 | 419 364 419 404 9999 9999 41 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 42 | 0 0 1.000 4.000 8.000 43 | 419 304 419 344 9999 9999 44 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 45 | 0 0 1.000 4.000 8.000 46 | 299 304 299 344 9999 9999 47 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 48 | 0 0 1.000 4.000 8.000 49 | 379 139 379 179 9999 9999 50 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 51 | 0 0 1.000 4.000 8.000 52 | 299 79 239 119 9999 9999 53 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 54 | 0 0 1.000 4.000 8.000 55 | 219 139 219 179 9999 9999 56 | 2 5 0 1 -1 0 0 0 0.000 0 0 0 57 | 0 58 | 79 -1 629 -1 629 604 79 604 79 -1 9999 9999 59 | 4 0 13 10 0 -1 0 0.00000 4 9 96 314 14 a(a,Z) <- a(a,Z) 60 | 4 0 12 10 0 -1 0 0.00000 4 9 78 349 199 4. a(a,b) <-  61 | 4 0 12 10 0 -1 0 0.00000 4 9 102 339 134 3. a(a,b) <- q(b) 62 | 4 0 12 10 0 -1 0 0.00000 4 9 150 374 74 2. a(a,Z) <- p(a,Z),q(Z)) 63 | 4 0 12 10 0 -1 0 0.00000 4 9 102 384 359 8. a(b,c) <- q(c) 64 | 4 0 12 10 0 -1 0 0.00000 4 9 78 389 419 10. a(b,c) <- 65 | 4 0 13 10 0 -1 0 0.00000 4 9 96 314 239 a(b,Z) <- a(b,Z) 66 | 4 0 12 10 0 -1 0 0.00000 4 9 150 374 299 7. a(b,Z) <- p(b,Z).q(Z) 67 | 4 0 14 10 0 -1 0 0.00000 4 9 120 239 359 11. a(b,Z) <- a(c,Z) 68 | 4 0 14 10 0 -1 0 0.00000 4 9 156 199 74 1. a(a,Z) <- a(a,Y),a(Y,Z) 69 | 4 0 14 10 0 -1 0 0.00000 4 9 114 184 134 5. a(a,X) <- a(b,Z) 70 | 4 0 12 10 0 -1 0 0.00000 4 9 78 184 194 15 a(a,c) <- 71 | 4 0 14 10 0 -1 0 0.00000 4 9 150 209 299 6 a(b,Z) <- a(b,Y),a(Y,Z) 72 | -------------------------------------------------------------------------------- /figures/trans-ind.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig016686 3 | %%Creator: fig2dev 4 | %%CreationDate: Fri Aug 26 13:38:05 1994 5 | %%For: tswift@sblapis2 (Terrance Swift,stu,060195,warren,sun,5,) 6 | %%BoundingBox: 0 0 183 67 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -194.0 242.0 translate 0.720 -0.720 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 440 260 m 375 280 l gs col-1 s gr 41 | n 383.234 279.559 m 375.000 280.000 l 382.058 275.736 l gs 2 setlinejoin col-1 s gr 42 | % Polyline 43 | n 439 260 m 504 280 l gs col-1 s gr 44 | n 496.942 275.736 m 504.000 280.000 l 495.766 279.559 l gs 2 setlinejoin col-1 s gr 45 | % Polyline 46 | n 368 300 m 309 319 l gs col-1 s gr 47 | n 317.228 318.451 m 309.000 319.000 l 316.002 314.644 l gs 2 setlinejoin col-1 s gr 48 | % Polyline 49 | n 369 300 m 428 319 l gs col-1 s gr 50 | n 420.998 314.644 m 428.000 319.000 l 419.772 318.451 l gs 2 setlinejoin col-1 s gr 51 | % Polyline 52 | n 369 301 m 369 318 l gs col-1 s gr 53 | n 371.000 310.000 m 369.000 318.000 l 367.000 310.000 l gs 2 setlinejoin col-1 s gr 54 | /Courier-Bold findfont 12.00 scalefont setfont 55 | 409 254 m 56 | gs 1 -1 scale (p\(g\(X\),Y\)) col-1 show gr 57 | /Courier-Bold findfont 12.00 scalefont setfont 58 | 495 295 m 59 | gs 1 -1 scale (true) col-1 show gr 60 | /Courier-Bold findfont 12.00 scalefont setfont 61 | 334 296 m 62 | gs 1 -1 scale (p_g\(X,f\(Z\)\)) col-1 show gr 63 | /Courier-Bold findfont 12.00 scalefont setfont 64 | 269 336 m 65 | gs 1 -1 scale (p_gf\(a,Z\)) col-1 show gr 66 | /Courier-Bold findfont 12.00 scalefont setfont 67 | 338 334 m 68 | gs 1 -1 scale (p_gf\(a,a\)) col-1 show gr 69 | /Courier-Bold findfont 12.00 scalefont setfont 70 | 410 334 m 71 | gs 1 -1 scale (p_gf\(b,1\)) col-1 show gr 72 | $F2psEnd 73 | -------------------------------------------------------------------------------- /figures/detm0s1s2s.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.1 2 | Portrait 3 | Center 4 | Inches 5 | 1200 2 6 | 5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 2232.955 3930.682 1350 1500 2400 1350 3300 1575 7 | 1 1 1.00 60.00 120.00 8 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3450.000 -3056.250 1275 1950 3600 2400 5625 1950 9 | 1 1 1.00 60.00 120.00 10 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 4537.500 -7040.625 1125 2100 5100 2700 7950 2100 11 | 1 1 1.00 60.00 120.00 12 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3562.500 1132.500 3675 1500 3525 750 3450 1500 13 | 1 1 1.00 60.00 120.00 14 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 5850.000 1139.062 6000 1425 5775 825 5700 1425 15 | 1 1 1.00 60.00 120.00 16 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 8046.983 1219.397 8325 1500 8025 825 7875 1575 17 | 1 1 1.00 60.00 120.00 18 | 5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 4687.500 2912.500 3900 1725 4875 1500 5475 1725 19 | 1 1 1.00 60.00 120.00 20 | 5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 5812.500 -2125.000 3825 2025 5925 2475 7800 2025 21 | 1 1 1.00 60.00 120.00 22 | 5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 6975.000 3900.000 6150 1725 7050 1575 7800 1725 23 | 1 1 1.00 60.00 120.00 24 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 5850 1725 335 335 5850 1725 6150 1875 25 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 1050 1725 335 335 1050 1725 1350 1875 26 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 5887 1725 263 263 5625 1725 6150 1725 27 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 1087 1725 263 263 825 1725 1350 1725 28 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 8137 1800 263 263 7875 1800 8400 1800 29 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 8100 1800 335 335 8100 1800 8400 1950 30 | 1 4 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3525 1800 263 263 3263 1800 3788 1800 31 | 1 3 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3550 1794 335 335 3550 1794 3850 1944 32 | 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 33 | 1 1 1.00 60.00 120.00 34 | 300 1650 675 1725 35 | 4 0 -1 0 0 0 12 0.0000000 4 180 180 975 1800 q0\001 36 | 4 0 -1 0 0 0 12 0.0000000 4 180 180 3375 1725 q0\001 37 | 4 0 -1 0 0 0 12 0.0000000 4 180 180 3375 1875 q1\001 38 | 4 0 -1 0 0 0 12 0.0000000 4 180 180 3450 2025 q2\001 39 | 4 0 -1 0 0 0 12 0.0000000 4 180 180 5775 1650 q1\001 40 | 4 0 -1 0 0 0 12 0.0000000 4 180 180 5775 1875 q2\001 41 | 4 0 -1 0 0 0 12 0.0000000 4 180 180 8025 1875 q2\001 42 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 1425 1425 0\001 43 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 1575 2025 1\001 44 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 1275 2325 2\001 45 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 3750 1350 0\001 46 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 3975 1650 1\001 47 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 3975 2025 2\001 48 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 6000 1350 1\001 49 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 6300 1650 2\001 50 | 4 0 -1 0 0 0 12 0.0000000 4 135 90 8250 1425 2\001 51 | -------------------------------------------------------------------------------- /figures/slglattice.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig007982 3 | %%Creator: fig2dev 4 | %%CreationDate: Thu Apr 28 17:41:32 1994 5 | %%For: tswift@sblapis4 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 158 69 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -129.0 186.0 translate 0.630 -0.630 scale 38 | 0.500 setlinewidth 39 | n 286 230 m 286 230 l gs col-1 s gr 40 | n 359 226 m 359 226 l gs col-1 s gr 41 | % Polyline 42 | n 219 229 m 324 199 l gs col-1 s gr 43 | n 315.758 199.275 m 324.000 199.000 l 316.857 203.121 l gs 2 setlinejoin col-1 s gr 44 | % Polyline 45 | n 428 230 m 323 200 l gs col-1 s gr 46 | n 330.143 204.121 m 323.000 200.000 l 331.242 200.275 l gs 2 setlinejoin col-1 s gr 47 | % Polyline 48 | n 324 223 m 324 200 l gs col-1 s gr 49 | n 322.000 208.000 m 324.000 200.000 l 326.000 208.000 l gs 2 setlinejoin col-1 s gr 50 | % Polyline 51 | n 324 282 m 324 242 l gs col-1 s gr 52 | n 322.000 250.000 m 324.000 242.000 l 326.000 250.000 l gs 2 setlinejoin col-1 s gr 53 | % Polyline 54 | n 323 283 m 219 239 l gs col-1 s gr 55 | n 225.588 243.959 m 219.000 239.000 l 227.147 240.275 l gs 2 setlinejoin col-1 s gr 56 | % Polyline 57 | n 324 284 m 428 240 l gs col-1 s gr 58 | n 419.853 241.275 m 428.000 240.000 l 421.412 244.959 l gs 2 setlinejoin col-1 s gr 59 | /Courier findfont 10.00 scalefont setfont 60 | 319 295 m 61 | gs 1 -1 scale (new) col-1 show gr 62 | /Courier findfont 10.00 scalefont setfont 63 | 304 194 m 64 | gs 1 -1 scale (disposed) col-1 show gr 65 | /Courier findfont 10.00 scalefont setfont 66 | 204 237 m 67 | gs 1 -1 scale (active) col-1 show gr 68 | /Courier findfont 10.00 scalefont setfont 69 | 418 238 m 70 | gs 1 -1 scale (answer) col-1 show gr 71 | /Courier findfont 10.00 scalefont setfont 72 | 297 238 m 73 | gs 1 -1 scale (floundered) col-1 show gr 74 | $F2psEnd 75 | -------------------------------------------------------------------------------- /figures/slglatticed.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig001684 3 | %%Creator: fig2dev 4 | %%CreationDate: Thu Dec 8 15:52:19 1994 5 | %%For: tswift@sbproud3 (Terrance Swift,stu,060195,warren,sun,5,) 6 | %%BoundingBox: 0 0 225 99 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -184.0 266.0 translate 0.900 -0.900 scale 38 | 0.500 setlinewidth 39 | n 286 230 m 286 230 l gs col-1 s gr 40 | n 359 226 m 359 226 l gs col-1 s gr 41 | % Polyline 42 | n 219 229 m 324 199 l gs col-1 s gr 43 | n 315.758 199.275 m 324.000 199.000 l 316.857 203.121 l gs 2 setlinejoin col-1 s gr 44 | % Polyline 45 | n 428 230 m 323 200 l gs col-1 s gr 46 | n 330.143 204.121 m 323.000 200.000 l 331.242 200.275 l gs 2 setlinejoin col-1 s gr 47 | % Polyline 48 | n 324 223 m 324 200 l gs col-1 s gr 49 | n 322.000 208.000 m 324.000 200.000 l 326.000 208.000 l gs 2 setlinejoin col-1 s gr 50 | % Polyline 51 | n 324 282 m 324 242 l gs col-1 s gr 52 | n 322.000 250.000 m 324.000 242.000 l 326.000 250.000 l gs 2 setlinejoin col-1 s gr 53 | % Polyline 54 | n 323 283 m 219 239 l gs col-1 s gr 55 | n 225.588 243.959 m 219.000 239.000 l 227.147 240.275 l gs 2 setlinejoin col-1 s gr 56 | % Polyline 57 | n 324 284 m 428 240 l gs col-1 s gr 58 | n 419.853 241.275 m 428.000 240.000 l 421.412 244.959 l gs 2 setlinejoin col-1 s gr 59 | /Courier findfont 10.00 scalefont setfont 60 | 304 194 m 61 | gs 1 -1 scale (disposed) col-1 show gr 62 | /Courier findfont 10.00 scalefont setfont 63 | 204 237 m 64 | gs 1 -1 scale (active) col-1 show gr 65 | /Courier findfont 10.00 scalefont setfont 66 | 418 238 m 67 | gs 1 -1 scale (answer) col-1 show gr 68 | /Courier findfont 10.00 scalefont setfont 69 | 297 238 m 70 | gs 1 -1 scale (floundered) col-1 show gr 71 | /Courier findfont 10.00 scalefont setfont 72 | 319 295 m 73 | gs 1 -1 scale (new) col-1 show gr 74 | $F2psEnd 75 | -------------------------------------------------------------------------------- /figures/strat-trapped.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig004151 3 | %%Creator: fig2dev 4 | %%CreationDate: Fri Jul 30 18:05:04 1993 5 | %%For: tswift@sblapis1 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 162 83 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -144.0 144.0 translate 0.900 -0.900 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 179 74 m 234 74 l gs col-1 s gr 41 | n 226.000 72.000 m 234.000 74.000 l 226.000 76.000 l gs 2 setlinejoin col-1 s gr 42 | % Polyline 43 | n 179 74 m 234 154 l gs col-1 s gr 44 | n 231.116 146.275 m 234.000 154.000 l 227.820 148.541 l gs 2 setlinejoin col-1 s gr 45 | % Polyline 46 | n 274 154 m 319 124 l gs col-1 s gr 47 | n 311.234 126.774 m 319.000 124.000 l 313.453 130.102 l gs 2 setlinejoin col-1 s gr 48 | % Interpolated spline 49 | n 279 74 m 50 | 301.824 73.075 311.824 74.325 319 79 curveto 51 | 324.190 82.381 327.940 88.631 334 104 curveto 52 | gs col-1 s gr 53 | n 332.926 95.824 m 334.000 104.000 l 329.205 97.291 l gs 2 setlinejoin col-1 s gr 54 | % Interpolated spline 55 | n 269 84 m 56 | 277.017 102.763 282.017 110.263 289 114 curveto 57 | 293.842 116.591 300.092 116.591 314 114 curveto 58 | gs col-1 s gr 59 | n 305.769 113.499 m 314.000 114.000 l 306.502 117.431 l gs 2 setlinejoin col-1 s gr 60 | /Times-Roman findfont 12.00 scalefont setfont 61 | 159 79 m 62 | gs 1 -1 scale (0\) s) col-1 show gr 63 | /Times-Roman findfont 12.00 scalefont setfont 64 | 319 119 m 65 | gs 1 -1 scale (3\) q) col-1 show gr 66 | /Times-Roman findfont 12.00 scalefont setfont 67 | 239 79 m 68 | gs 1 -1 scale (1\) p\(X\)) col-1 show gr 69 | /Times-Roman findfont 12.00 scalefont setfont 70 | 239 159 m 71 | gs 1 -1 scale (2\) r\(1\)) col-1 show gr 72 | /Times-Roman findfont 12.00 scalefont setfont 73 | 284 134 m 74 | gs 1 -1 scale (~) col-1 show gr 75 | $F2psEnd 76 | -------------------------------------------------------------------------------- /figures/slg-search-tree.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig000747 3 | %%Creator: fig2dev 4 | %%CreationDate: Wed Dec 15 15:15:27 1993 5 | %%For: tswift@sblapis4 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 298 100 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -21.0 144.0 translate 0.720 -0.720 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 239 79 m 239 119 l gs col-1 s gr 41 | n 241.000 111.000 m 239.000 119.000 l 237.000 111.000 l gs 2 setlinejoin col-1 s gr 42 | % Polyline 43 | n 239 79 m 99 119 l gs col-1 s gr 44 | n 107.242 118.725 m 99.000 119.000 l 106.143 114.879 l gs 2 setlinejoin col-1 s gr 45 | [4.000000] 0 setdash 46 | % Polyline 47 | n 239 79 m 379 119 l gs col-1 s gr 48 | [] 0 setdash 49 | n 371.857 114.879 m 379.000 119.000 l 370.758 118.725 l gs 2 setlinejoin col-1 s gr 50 | % Polyline 51 | n 239 139 m 239 179 l gs col-1 s gr 52 | n 241.000 171.000 m 239.000 179.000 l 237.000 171.000 l gs 2 setlinejoin col-1 s gr 53 | % Polyline 54 | n 99 139 m 99 179 l gs col-1 s gr 55 | n 101.000 171.000 m 99.000 179.000 l 97.000 171.000 l gs 2 setlinejoin col-1 s gr 56 | /Courier findfont 10.00 scalefont setfont 57 | 194 69 m 58 | gs 1 -1 scale (0\) r\(X\):root:r\(X\)<-r\(X\)) col-1 show gr 59 | /Courier findfont 10.00 scalefont setfont 60 | 204 199 m 61 | gs 1 -1 scale (4\) q:active:q<-p) col-1 show gr 62 | /Courier findfont 10.00 scalefont setfont 63 | 29 199 m 64 | gs 1 -1 scale (2\) p:active:p<-r\(X1\),q) col-1 show gr 65 | /Courier findfont 10.00 scalefont setfont 66 | 174 134 m 67 | gs 1 -1 scale (3\) r\(X\):active:r\(2\)<-~q) col-1 show gr 68 | /Courier findfont 10.00 scalefont setfont 69 | 334 134 m 70 | gs 1 -1 scale (r\(X\):answer:r\(3\)<-) col-1 show gr 71 | /Courier findfont 10.00 scalefont setfont 72 | 29 133 m 73 | gs 1 -1 scale (1\) r\(X\):active:r\(1\)<-p) col-1 show gr 74 | $F2psEnd 75 | -------------------------------------------------------------------------------- /figures/simp.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 4 | 0 0 1.000 4.000 8.000 5 | 79 319 654 319 9999 9999 6 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 7 | 0 0 1.000 4.000 8.000 8 | 139 319 139 219 9999 9999 9 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 10 | 0 0 1.000 4.000 8.000 11 | 139 319 139 414 9999 9999 12 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 13 | 0 0 1.000 4.000 8.000 14 | 184 419 659 419 659 319 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 16 | 0 0 1.000 4.000 8.000 17 | 299 419 299 379 9999 9999 18 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 19 | 0 0 1.000 4.000 8.000 20 | 299 419 299 459 9999 9999 21 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 22 | 0 0 1.000 4.000 8.000 23 | 214 219 659 219 659 309 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 25 | 0 0 1.000 4.000 8.000 26 | 299 219 299 179 9999 9999 27 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 28 | 0 0 1.000 4.000 8.000 29 | 299 219 299 259 9999 9999 30 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 31 | 0 0 1.000 4.000 8.000 32 | 339 264 419 264 9999 9999 33 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 34 | 0 0 1.000 4.000 8.000 35 | 519 159 519 119 139 119 139 214 9999 9999 36 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 37 | 0 0 1.000 4.000 8.000 38 | 519 479 519 519 139 519 139 424 9999 9999 39 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 40 | 519 359 559 359 9999 9999 41 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 42 | 559 359 559 379 9999 9999 43 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 44 | 0 0 1.000 4.000 8.000 45 | 339 359 419 359 9999 9999 46 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 47 | 0 0 1.000 4.000 8.000 48 | 339 469 419 469 9999 9999 49 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 50 | 0 0 1.000 4.000 8.000 51 | 334 154 409 154 9999 9999 52 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 53 | 0 0 1.000 4.000 8.000 54 | 559 264 559 99 119 99 119 414 129 414 9999 9999 55 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 56 | 0 0 1.000 4.000 8.000 57 | 559 464 559 539 99 539 99 219 124 219 9999 9999 58 | 4 0 14 12 0 -1 0 0.00000 4 9 70 139 219 successful 59 | 4 0 14 12 0 -1 0 0.00000 4 9 42 139 419 failed 60 | 4 0 14 12 0 -1 0 0.00000 4 9 98 419 359 atom-failure-L 61 | 4 0 14 12 0 -1 0 0.00000 4 8 98 419 159 atom success-L 62 | 4 0 14 12 0 -1 0 0.00000 4 12 126 419 469 negation-success-L 63 | 4 0 14 12 0 -1 0 0.00000 4 12 126 424 269 negation failure-l 64 | 4 0 13 12 0 -1 0 0.00000 4 14 56 279 359 positive 65 | 4 0 13 12 0 -1 0 0.00000 4 14 42 279 484 delays 66 | 4 0 13 12 0 -1 0 0.00000 4 14 42 279 174 delays 67 | 4 0 13 12 0 -1 0 0.00000 4 14 56 274 159 positive 68 | 4 0 13 12 0 -1 0 0.00000 4 14 63 279 469 negative  69 | 4 0 13 12 0 -1 0 0.00000 4 14 63 274 274 negative  70 | 4 0 13 12 0 -1 0 0.00000 4 14 42 279 289 delays 71 | 4 0 13 12 0 -1 0 0.00000 4 14 42 284 374 delays 72 | 4 0 14 12 0 -1 0 0.00000 4 12 77 19 309 Completion  73 | 4 0 13 12 0 -1 0 0.00000 4 14 28 664 319 done 74 | -------------------------------------------------------------------------------- /figures/abstract-trie.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 314 229 344 299 4 | 6 314 264 344 299 5 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 6 | 314 264 344 299 9999 9999 7 | -6 8 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 9 | 314 264 344 229 9999 9999 10 | -6 11 | 6 309 64 339 134 12 | 6 309 99 339 134 13 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 14 | 309 99 339 134 9999 9999 15 | -6 16 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 17 | 309 99 339 64 9999 9999 18 | -6 19 | 6 409 29 434 84 20 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 21 | 411 58 431 83 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 23 | 411 58 431 33 9999 9999 24 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 25 | 414 59 434 59 9999 9999 26 | -6 27 | 6 359 284 389 309 28 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 29 | 362 299 387 309 9999 9999 30 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 31 | 364 298 389 288 9999 9999 32 | -6 33 | 6 354 134 384 159 34 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 35 | 357 149 382 159 9999 9999 36 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 37 | 359 148 384 138 9999 9999 38 | -6 39 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 40 | 239 189 289 264 9999 9999 41 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 42 | 239 189 289 104 9999 9999 43 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 44 | 409 284 429 284 9999 9999 45 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 46 | 409 314 429 314 9999 9999 47 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 48 | 354 59 384 59 9999 9999 49 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 50 | 409 134 429 124 9999 9999 51 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 52 | 410 135 430 145 9999 9999 53 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 54 | 414 164 434 164 9999 9999 55 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 56 | 354 224 384 224 9999 9999 57 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 58 | 409 224 429 214 9999 9999 59 | 2 1 0 1 -1 0 0 0 0.000 7 0 0 60 | 410 225 430 235 9999 9999 61 | 4 0 0 14 0 -1 0 0.00000 4 10 7 344 154 6 62 | 4 0 0 14 0 -1 0 0.00000 4 12 18 389 289 c/1 63 | 4 0 0 14 0 -1 0 0.00000 4 12 18 389 319 h/1 64 | 4 0 0 14 0 -1 0 0.00000 4 10 7 349 229 2 65 | 4 0 0 14 0 -1 0 0.00000 4 10 7 349 304 9 66 | 4 0 0 14 0 -1 0 0.00000 4 10 7 344 59 1 67 | 4 0 0 14 0 -1 0 0.00000 4 12 18 289 104 c/1 68 | 4 0 0 14 0 -1 0 0.00000 4 12 18 294 269 o/1 69 | 4 0 0 14 0 -1 0 0.00000 4 13 114 119 194 methoxymethanol/2 70 | 4 0 0 14 0 -1 0 0.00000 4 12 18 389 64 h/1 71 | 4 0 0 14 0 -1 0 0.00000 4 10 7 444 34 3 72 | 4 0 0 14 0 -1 0 0.00000 4 10 7 444 64 4 73 | 4 0 0 14 0 -1 0 0.00000 4 10 7 444 89 5 74 | 4 0 0 14 0 -1 0 0.00000 4 12 18 394 164 c/1 75 | 4 0 0 14 0 -1 0 0.00000 4 12 18 394 139 h/1 76 | 4 0 0 12 0 -1 0 0.00000 4 9 6 439 169 1 77 | 4 0 0 12 0 -1 0 0.00000 4 9 6 439 289 6 78 | 4 0 0 12 0 -1 0 0.00000 4 9 12 439 319 10 79 | 4 0 0 14 0 -1 0 0.00000 4 10 7 439 149 7 80 | 4 0 0 14 0 -1 0 0.00000 4 10 7 439 129 8 81 | 4 0 0 14 0 -1 0 0.00000 4 12 18 389 229 c/1 82 | 4 0 0 14 0 -1 0 0.00000 4 10 7 439 219 1 83 | 4 0 0 14 0 -1 0 0.00000 4 10 7 439 244 6 84 | -------------------------------------------------------------------------------- /figures/call-dep1.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig000899 3 | %%Creator: fig2dev 4 | %%CreationDate: Wed May 11 19:08:44 1994 5 | %%For: tswift@sblapis1 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 222 92 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -19.0 249.0 translate 0.630 -0.630 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 134 284 m 54 324 l gs col-1 s gr 41 | n 62.050 322.211 m 54.000 324.000 l 60.261 318.633 l gs 2 setlinejoin col-1 s gr 42 | n 132.000 292.000 m 134.000 284.000 l 136.000 292.000 l gs 2 setlinejoin col-1 s gr 43 | % Polyline 44 | n 134 284 m 134 324 l gs col-1 s gr 45 | % Polyline 46 | n 59 329 m 129 329 l gs col-1 s gr 47 | n 121.000 327.000 m 129.000 329.000 l 121.000 331.000 l gs 2 setlinejoin col-1 s gr 48 | % Polyline 49 | n 349 264 m 349 284 l gs col-1 s gr 50 | n 351.000 276.000 m 349.000 284.000 l 347.000 276.000 l gs 2 setlinejoin col-1 s gr 51 | % Polyline 52 | n 349 304 m 349 324 l gs col-1 s gr 53 | n 351.000 316.000 m 349.000 324.000 l 347.000 316.000 l gs 2 setlinejoin col-1 s gr 54 | /Courier findfont 12.00 scalefont setfont 55 | 119 274 m 56 | gs 1 -1 scale (0. a\(a,Z\)) col-1 show gr 57 | /Courier findfont 12.00 scalefont setfont 58 | 29 344 m 59 | gs 1 -1 scale (1. a\(b,Z\)) col-1 show gr 60 | /Courier findfont 12.00 scalefont setfont 61 | 109 344 m 62 | gs 1 -1 scale (2. a\(c,Z\)) col-1 show gr 63 | /Courier findfont 12.00 scalefont setfont 64 | 319 259 m 65 | gs 1 -1 scale (0. a\(a,Z\)) col-1 show gr 66 | /Courier findfont 12.00 scalefont setfont 67 | 319 299 m 68 | gs 1 -1 scale (1. a\(b,Z\)) col-1 show gr 69 | /Courier findfont 12.00 scalefont setfont 70 | 319 339 m 71 | gs 1 -1 scale (2. a\(c,Z\)) col-1 show gr 72 | /Times-Roman findfont 12.00 scalefont setfont 73 | 79 394 m 74 | gs 1 -1 scale (Program 2) col-1 show gr 75 | /Times-Roman findfont 12.00 scalefont setfont 76 | 324 394 m 77 | gs 1 -1 scale (Program 1) col-1 show gr 78 | $F2psEnd 79 | -------------------------------------------------------------------------------- /figures/call-dep1d.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig000903 3 | %%Creator: fig2dev 4 | %%CreationDate: Thu Dec 8 16:56:33 1994 5 | %%For: tswift@sbproud9 (Terrance Swift,stu,060195,warren,sun,5,) 6 | %%BoundingBox: 0 0 267 110 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -22.0 298.0 translate 0.756 -0.756 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 134 284 m 54 324 l gs col-1 s gr 41 | n 62.050 322.211 m 54.000 324.000 l 60.261 318.633 l gs 2 setlinejoin col-1 s gr 42 | n 132.000 292.000 m 134.000 284.000 l 136.000 292.000 l gs 2 setlinejoin col-1 s gr 43 | % Polyline 44 | n 134 284 m 134 324 l gs col-1 s gr 45 | % Polyline 46 | n 59 329 m 129 329 l gs col-1 s gr 47 | n 121.000 327.000 m 129.000 329.000 l 121.000 331.000 l gs 2 setlinejoin col-1 s gr 48 | % Polyline 49 | n 349 264 m 349 284 l gs col-1 s gr 50 | n 351.000 276.000 m 349.000 284.000 l 347.000 276.000 l gs 2 setlinejoin col-1 s gr 51 | % Polyline 52 | n 349 304 m 349 324 l gs col-1 s gr 53 | n 351.000 316.000 m 349.000 324.000 l 347.000 316.000 l gs 2 setlinejoin col-1 s gr 54 | /Courier findfont 12.00 scalefont setfont 55 | 119 274 m 56 | gs 1 -1 scale (0. a\(a,Z\)) col-1 show gr 57 | /Courier findfont 12.00 scalefont setfont 58 | 29 344 m 59 | gs 1 -1 scale (1. a\(b,Z\)) col-1 show gr 60 | /Courier findfont 12.00 scalefont setfont 61 | 109 344 m 62 | gs 1 -1 scale (2. a\(c,Z\)) col-1 show gr 63 | /Courier findfont 12.00 scalefont setfont 64 | 319 259 m 65 | gs 1 -1 scale (0. a\(a,Z\)) col-1 show gr 66 | /Courier findfont 12.00 scalefont setfont 67 | 319 299 m 68 | gs 1 -1 scale (1. a\(b,Z\)) col-1 show gr 69 | /Times-Roman findfont 12.00 scalefont setfont 70 | 79 394 m 71 | gs 1 -1 scale (Program 2) col-1 show gr 72 | /Times-Roman findfont 12.00 scalefont setfont 73 | 324 394 m 74 | gs 1 -1 scale (Program 1) col-1 show gr 75 | /Courier findfont 12.00 scalefont setfont 76 | 319 339 m 77 | gs 1 -1 scale (2. a\(c,Z\)) col-1 show gr 78 | $F2psEnd 79 | -------------------------------------------------------------------------------- /figures/slg-examp1.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 34 239 59 259 4 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 46 249 9 9 39 244 54 254 5 | 4 0 0 12 0 -1 0 0.00000 4 9 6 44 254 1 6 | -6 7 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 286 249 9 9 279 244 294 254 8 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 46 369 9 9 39 364 54 374 9 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 166 369 9 9 159 364 174 374 10 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 166 249 9 9 157 240 175 258 11 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 12 | 239 79 179 119 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 14 | 239 79 239 119 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 16 | 179 144 179 184 9999 9999 17 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 18 | 239 144 239 184 9999 9999 19 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 20 | 379 279 379 299 299 299 299 279 379 279 9999 9999 21 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 22 | 139 379 139 399 59 399 59 379 139 379 9999 9999 23 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 24 | 139 399 139 419 59 419 59 399 139 399 9999 9999 25 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 26 | 259 379 259 399 179 399 179 379 259 379 9999 9999 27 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 28 | 259 399 259 419 179 419 179 399 259 399 9999 9999 29 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 30 | 139 299 139 319 59 319 59 299 139 299 9999 9999 31 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 32 | 259 279 259 299 179 299 179 279 259 279 9999 9999 33 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 34 | 379 299 379 319 299 319 299 299 379 299 9999 9999 35 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 36 | 259 299 259 319 179 319 179 299 259 299 9999 9999 37 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 38 | 139 419 139 439 59 439 59 419 139 419 9999 9999 39 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 40 | 259 419 259 439 179 439 179 419 259 419 9999 9999 41 | 4 0 0 12 0 -1 0 0.00000 4 9 27 159 109 X = 1 42 | 4 0 0 12 0 -1 0 0.00000 4 9 27 209 109 X = 2 43 | 4 0 0 12 0 -1 0 0.00000 4 12 34 229 69 1: r(X) 44 | 4 0 0 12 0 -1 0 0.00000 4 12 49 164 209 3: r(X1),q 45 | 4 0 0 12 0 -1 0 0.00000 4 12 18 169 138 2: p 46 | 4 0 0 12 0 -1 0 0.00000 4 9 6 164 254 2 47 | 4 0 0 12 0 -1 0 0.00000 4 9 6 284 254 3 48 | 4 0 0 12 0 -1 0 0.00000 4 9 6 164 374 5 49 | 4 0 0 12 0 -1 0 0.00000 4 9 6 44 374 4 50 | 4 0 0 12 0 -1 0 0.00000 4 12 18 229 204 5: p 51 | 4 0 0 12 0 -1 0 0.00000 4 12 25 234 134 4: ~q 52 | 4 0 0 12 0 -1 0 0.00000 4 12 62 69 314 (r, 1, 1, MI ) 53 | 4 0 0 12 0 -1 0 0.00000 4 12 61 189 294 (p, 2, 2, MI) 54 | 4 0 0 12 0 -1 0 0.00000 4 12 62 189 314 (r, 1, 1, MI ) 55 | 4 0 0 12 0 -1 0 0.00000 4 12 61 69 394 (q, 3, 3, MI) 56 | 4 0 0 12 0 -1 0 0.00000 4 12 59 309 314 (r, 1, 1, MI) 57 | 4 0 0 12 0 -1 0 0.00000 4 12 61 309 294 (p, 2, 1, MI) 58 | 4 0 0 12 0 -1 0 0.00000 4 12 61 69 414 (p, 2, 1, MI) 59 | 4 0 0 12 0 -1 0 0.00000 4 12 62 69 434 (r, 1, 1, MI ) 60 | 4 0 0 12 0 -1 0 0.00000 4 12 61 189 414 (p, 2, 1, MI) 61 | 4 0 0 12 0 -1 0 0.00000 4 12 59 189 434 (r, 1, 1, MI) 62 | 4 0 0 12 0 -1 0 0.00000 4 12 52 189 394 (q, 3, 3, 2) 63 | -------------------------------------------------------------------------------- /figures/spqr1.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig018089 3 | %%Creator: fig2dev 4 | %%CreationDate: Mon Jun 27 14:58:56 1994 5 | %%For: tswift@sblapis2 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 55 86 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -161.0 208.0 translate 0.585 -0.585 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 319 219 m 319 264 l gs col-1 s gr 41 | n 321.000 256.000 m 319.000 264.000 l 317.000 256.000 l gs 2 setlinejoin col-1 s gr 42 | % Interpolated spline 43 | n 354 304 m 44 | 350.883 289.076 348.383 282.826 344 279 curveto 45 | 340.644 276.071 335.644 274.821 324 274 curveto 46 | gs col-1 s gr 47 | n 331.840 276.558 m 324.000 274.000 l 332.121 272.568 l gs 2 setlinejoin col-1 s gr 48 | % Interpolated spline 49 | n 309 274 m 50 | 296.772 281.404 291.772 285.154 289 289 curveto 51 | 287.247 291.432 285.997 295.182 284 304 curveto 52 | gs col-1 s gr 53 | n 287.718 296.639 m 284.000 304.000 l 283.816 295.756 l gs 2 setlinejoin col-1 s gr 54 | % Interpolated spline 55 | n 284 325 m 56 | 303.521 332.388 312.271 334.888 319 335 curveto 57 | 326.622 335.127 336.622 332.627 359 325 curveto 58 | gs col-1 s gr 59 | n 350.783 325.688 m 359.000 325.000 l 352.073 329.474 l gs 2 setlinejoin col-1 s gr 60 | /Courier findfont 12.00 scalefont setfont 61 | 314 275 m 62 | gs 1 -1 scale (p) col-1 show gr 63 | /Courier findfont 12.00 scalefont setfont 64 | 279 316 m 65 | gs 1 -1 scale (q) col-1 show gr 66 | /Courier findfont 12.00 scalefont setfont 67 | 354 317 m 68 | gs 1 -1 scale (r) col-1 show gr 69 | /Courier findfont 12.00 scalefont setfont 70 | 314 354 m 71 | gs 1 -1 scale (\\+) col-1 show gr 72 | /Courier findfont 12.00 scalefont setfont 73 | 274 284 m 74 | gs 1 -1 scale (\\+) col-1 show gr 75 | /Courier findfont 12.00 scalefont setfont 76 | 354 284 m 77 | gs 1 -1 scale (\\+) col-1 show gr 78 | /Courier findfont 12.00 scalefont setfont 79 | 314 214 m 80 | gs 1 -1 scale (s) col-1 show gr 81 | $F2psEnd 82 | -------------------------------------------------------------------------------- /figures/spqr1d.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig000903 3 | %%Creator: fig2dev 4 | %%CreationDate: Thu Dec 8 17:01:44 1994 5 | %%For: tswift@sbproud9 (Terrance Swift,stu,060195,warren,sun,5,) 6 | %%BoundingBox: 0 0 71 116 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -208.0 268.0 translate 0.756 -0.756 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 319 219 m 319 264 l gs col-1 s gr 41 | n 321.000 256.000 m 319.000 264.000 l 317.000 256.000 l gs 2 setlinejoin col-1 s gr 42 | % Interpolated spline 43 | n 354 304 m 44 | 350.883 289.076 348.383 282.826 344 279 curveto 45 | 340.644 276.071 335.644 274.821 324 274 curveto 46 | gs col-1 s gr 47 | n 331.840 276.558 m 324.000 274.000 l 332.121 272.568 l gs 2 setlinejoin col-1 s gr 48 | % Interpolated spline 49 | n 309 274 m 50 | 296.772 281.404 291.772 285.154 289 289 curveto 51 | 287.247 291.432 285.997 295.182 284 304 curveto 52 | gs col-1 s gr 53 | n 287.718 296.639 m 284.000 304.000 l 283.816 295.756 l gs 2 setlinejoin col-1 s gr 54 | % Interpolated spline 55 | n 284 325 m 56 | 303.521 332.388 312.271 334.888 319 335 curveto 57 | 326.622 335.127 336.622 332.627 359 325 curveto 58 | gs col-1 s gr 59 | n 350.783 325.688 m 359.000 325.000 l 352.073 329.474 l gs 2 setlinejoin col-1 s gr 60 | /Courier findfont 12.00 scalefont setfont 61 | 314 275 m 62 | gs 1 -1 scale (p) col-1 show gr 63 | /Courier findfont 12.00 scalefont setfont 64 | 279 316 m 65 | gs 1 -1 scale (q) col-1 show gr 66 | /Courier findfont 12.00 scalefont setfont 67 | 354 317 m 68 | gs 1 -1 scale (r) col-1 show gr 69 | /Courier findfont 12.00 scalefont setfont 70 | 314 354 m 71 | gs 1 -1 scale (\\+) col-1 show gr 72 | /Courier findfont 12.00 scalefont setfont 73 | 274 284 m 74 | gs 1 -1 scale (\\+) col-1 show gr 75 | /Courier findfont 12.00 scalefont setfont 76 | 354 284 m 77 | gs 1 -1 scale (\\+) col-1 show gr 78 | /Courier findfont 12.00 scalefont setfont 79 | 314 214 m 80 | gs 1 -1 scale (s) col-1 show gr 81 | $F2psEnd 82 | -------------------------------------------------------------------------------- /figures/Completion.3.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig001386 3 | %%Creator: fig2dev 4 | %%CreationDate: Tue Sep 27 13:39:10 1994 5 | %%For: juliana@sbproud6 (Juliana Lima,stu,123195,warren,sun,5,) 6 | %%BoundingBox: 0 0 309 123 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | /DrawEllipse { 31 | /endangle exch def 32 | /startangle exch def 33 | /yrad exch def 34 | /xrad exch def 35 | /y exch def 36 | /x exch def 37 | /savematrix mtrx currentmatrix def 38 | x y translate xrad yrad scale 0 0 1 startangle endangle arc 39 | savematrix setmatrix 40 | } def 41 | 42 | end 43 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 44 | /$F2psEnd {$F2psEnteredState restore end} def 45 | %%EndProlog 46 | 47 | $F2psBegin 48 | 0 setlinecap 0 setlinejoin 49 | -45.0 184.0 translate 0.900 -0.900 scale 50 | 0.500 setlinewidth 51 | % Ellipse 52 | n 159 136 6 6 0 360 DrawEllipse gs col-1 s gr 53 | % Ellipse 54 | n 359 134 5 5 0 360 DrawEllipse gs col-1 s gr 55 | % Polyline 56 | n 359 189 m 359 139 l gs col-1 s gr 57 | n 357.000 147.000 m 359.000 139.000 l 361.000 147.000 l gs 2 setlinejoin col-1 s gr 58 | % Polyline 59 | n 147 189 m 162 144 l gs col-1 s gr 60 | n 157.573 150.957 m 162.000 144.000 l 161.368 152.222 l gs 2 setlinejoin col-1 s gr 61 | % Polyline 62 | n 151 124 m 144 124 144 137 7 arcto 4 {pop} repeat 144 144 362 144 7 arcto 4 {pop} repeat 369 144 369 131 7 arcto 4 {pop} repeat 369 124 151 124 7 arcto 4 {pop} repeat clp gs col-1 s gr 63 | /Times-Roman findfont 15.00 scalefont setfont 64 | 214 89 m 65 | gs 1 -1 scale (\(4\)\(5\)\(6\)\(7\)) col-1 show gr 66 | /Times-Roman findfont 15.00 scalefont setfont 67 | 49 84 m 68 | gs 1 -1 scale (Q: ) col-1 show gr 69 | /Times-Roman findfont 15.00 scalefont setfont 70 | 49 154 m 71 | gs 1 -1 scale (P: \(A\)\(B\) ) col-1 show gr 72 | /Times-Roman findfont 15.00 scalefont setfont 73 | 244 139 m 74 | gs 1 -1 scale (C) col-1 show gr 75 | /Times-Roman findfont 12.00 scalefont setfont 76 | 109 204 m 77 | gs 1 -1 scale (check p.FLAG=intermidiate) col-1 show gr 78 | /Times-Roman findfont 12.00 scalefont setfont 79 | 289 204 m 80 | gs 1 -1 scale (check q.FLAG=done) col-1 show gr 81 | $F2psEnd 82 | -------------------------------------------------------------------------------- /figures/alt-slg-examp.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 34 239 59 259 4 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 46 249 9 9 39 244 54 254 5 | 4 0 0 12 0 -1 0 0.00000 4 9 6 44 254 1 6 | -6 7 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 286 249 9 9 279 244 294 254 8 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 46 369 9 9 39 364 54 374 9 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 166 369 9 9 159 364 174 374 10 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 166 249 9 9 157 240 175 258 11 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 12 | 239 79 179 119 9999 9999 13 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 14 | 239 79 239 119 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 16 | 179 144 179 184 9999 9999 17 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 18 | 239 144 239 184 9999 9999 19 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 20 | 379 279 379 299 299 299 299 279 379 279 9999 9999 21 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 22 | 139 379 139 399 59 399 59 379 139 379 9999 9999 23 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 24 | 139 399 139 419 59 419 59 399 139 399 9999 9999 25 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 26 | 259 379 259 399 179 399 179 379 259 379 9999 9999 27 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 28 | 259 399 259 419 179 419 179 399 259 399 9999 9999 29 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 30 | 139 299 139 319 59 319 59 299 139 299 9999 9999 31 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 32 | 259 279 259 299 179 299 179 279 259 279 9999 9999 33 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 34 | 259 299 259 319 179 319 179 299 259 299 9999 9999 35 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 36 | 379 299 379 319 299 319 299 299 379 299 9999 9999 37 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 38 | 139 419 139 439 59 439 59 419 139 419 9999 9999 39 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 40 | 259 419 259 439 179 439 179 419 259 419 9999 9999 41 | 4 0 0 12 0 -1 0 0.00000 4 9 27 159 109 X = 1 42 | 4 0 0 12 0 -1 0 0.00000 4 9 27 209 109 X = 2 43 | 4 0 0 12 0 -1 0 0.00000 4 12 34 229 69 1: r(X) 44 | 4 0 0 12 0 -1 0 0.00000 4 12 49 164 209 3: r(X1),q 45 | 4 0 0 12 0 -1 0 0.00000 4 12 18 169 138 2: p 46 | 4 0 0 12 0 -1 0 0.00000 4 9 6 164 254 2 47 | 4 0 0 12 0 -1 0 0.00000 4 9 6 284 254 3 48 | 4 0 0 12 0 -1 0 0.00000 4 9 6 164 374 5 49 | 4 0 0 12 0 -1 0 0.00000 4 9 6 44 374 4 50 | 4 0 0 12 0 -1 0 0.00000 4 12 18 229 204 5: p 51 | 4 0 0 12 0 -1 0 0.00000 4 12 25 234 134 4: ~q 52 | 4 0 0 12 0 -1 0 0.00000 4 12 61 189 394 (q, 3, 1, MI) 53 | 4 0 0 12 0 -1 0 0.00000 4 12 62 69 314 (r, 1, 1, MI ) 54 | 4 0 0 12 0 -1 0 0.00000 4 12 64 189 294 (p, 2, 2, MI ) 55 | 4 0 0 12 0 -1 0 0.00000 4 12 62 189 314 (r, 1, 1, MI ) 56 | 4 0 0 12 0 -1 0 0.00000 4 12 64 309 294 (p, 2, 1, MI ) 57 | 4 0 0 12 0 -1 0 0.00000 4 12 62 309 314 (r, 1, 1, MI ) 58 | 4 0 0 12 0 -1 0 0.00000 4 12 64 69 394 (q, 3, 3, MI ) 59 | 4 0 0 12 0 -1 0 0.00000 4 12 64 69 414 (p, 2, 1, MI ) 60 | 4 0 0 12 0 -1 0 0.00000 4 12 62 69 434 (r, 1, 1, MI ) 61 | 4 0 0 12 0 -1 0 0.00000 4 12 64 189 414 (p, 2, 1, MI ) 62 | 4 0 0 12 0 -1 0 0.00000 4 12 53 189 434 (r, 1, 1, 1 ) 63 | -------------------------------------------------------------------------------- /figures/approx.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig024436 3 | %%Creator: fig2dev 4 | %%CreationDate: Wed Apr 27 17:46:46 1994 5 | %%For: tswift@sblapis1 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 145 86 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | /DrawSplineSection { 31 | /y3 exch def 32 | /x3 exch def 33 | /y2 exch def 34 | /x2 exch def 35 | /y1 exch def 36 | /x1 exch def 37 | /xa x1 x2 x1 sub 0.666667 mul add def 38 | /ya y1 y2 y1 sub 0.666667 mul add def 39 | /xb x3 x2 x3 sub 0.666667 mul add def 40 | /yb y3 y2 y3 sub 0.666667 mul add def 41 | x1 y1 lineto 42 | xa ya xb yb x3 y3 curveto 43 | } def 44 | 45 | end 46 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 47 | /$F2psEnd {$F2psEnteredState restore end} def 48 | %%EndProlog 49 | 50 | $F2psBegin 51 | 0 setlinecap 0 setlinejoin 52 | -104.0 192.0 translate 0.675 -0.675 scale 53 | 0.500 setlinewidth 54 | % Polyline 55 | n 244 174 m 169 239 l gs col-1 s gr 56 | n 176.355 235.272 m 169.000 239.000 l 173.736 232.249 l gs 2 setlinejoin col-1 s gr 57 | % Open spline 58 | n 245.000 173.000 m 282.500 185.500 l 59 | 282.500 185.500 320.000 198.000 320.000 218.000 DrawSplineSection 60 | 320.000 238.000 l gs col-1 s gr 61 | n 322.000 230.000 m 320.000 238.000 l 318.000 230.000 l gs 2 setlinejoin col-1 s gr 62 | n 244.632 182.222 m 244.000 174.000 l 248.427 180.957 l gs 2 setlinejoin col-1 s gr 63 | % Open spline 64 | n 244.000 174.000 m 256.500 211.500 l 65 | 256.500 211.500 269.000 249.000 289.000 249.000 DrawSplineSection 66 | 309.000 249.000 l gs col-1 s gr 67 | [4.000000] 0 setdash 68 | % Interpolated spline 69 | n 174 254 m 70 | 214.633 275.762 233.383 283.262 249 284 curveto 71 | 266.130 284.810 287.380 278.560 334 259 curveto 72 | gs col-1 s gr 73 | [] 0 setdash 74 | n 325.849 260.251 m 334.000 259.000 l 327.397 263.939 l gs 2 setlinejoin col-1 s gr 75 | /Courier findfont 12.00 scalefont setfont 76 | 224 169 m 77 | gs 1 -1 scale (0. p\(X,Y\)) col-1 show gr 78 | /Courier findfont 12.00 scalefont setfont 79 | 154 254 m 80 | gs 1 -1 scale (1. q\(X\)) col-1 show gr 81 | /Courier findfont 12.00 scalefont setfont 82 | 319 254 m 83 | gs 1 -1 scale (2. r\(Y\)) col-1 show gr 84 | $F2psEnd 85 | -------------------------------------------------------------------------------- /figures/slide1.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig009812 3 | %%Creator: fig2dev 4 | %%CreationDate: Fri Oct 15 16:58:29 1993 5 | %%For: tswift@sblapis1 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 424 377 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | /DrawEllipse { 31 | /endangle exch def 32 | /startangle exch def 33 | /yrad exch def 34 | /xrad exch def 35 | /y exch def 36 | /x exch def 37 | /savematrix mtrx currentmatrix def 38 | x y translate xrad yrad scale 0 0 1 startangle endangle arc 39 | savematrix setmatrix 40 | } def 41 | 42 | end 43 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 44 | /$F2psEnd {$F2psEnteredState restore end} def 45 | %%EndProlog 46 | 47 | $F2psBegin 48 | 0 setlinecap 0 setlinejoin 49 | -14.0 479.0 translate 0.900 -0.900 scale 50 | 0.500 setlinewidth 51 | % Ellipse 52 | n 226 191 78 78 0 360 DrawEllipse gs col1 0.25 graycol fill gr gs col1 s gr 53 | % Ellipse 54 | n 64 364 49 49 0 360 DrawEllipse gs col1 0.55 graycol fill gr gs col1 s gr 55 | % Ellipse 56 | n 211 409 58 58 0 360 DrawEllipse gs col1 0.70 graycol fill gr gs col1 s gr 57 | % Ellipse 58 | n 446 394 40 40 0 360 DrawEllipse gs col1 0.75 graycol fill gr gs col1 s gr 59 | % Ellipse 60 | n 274 241 53 53 0 360 DrawEllipse gs col6 0.75 graycol fill gr gs col6 s gr 61 | % Ellipse 62 | n 124 381 59 59 0 360 DrawEllipse gs col5 0.75 graycol fill gr gs col5 s gr 63 | % Ellipse 64 | n 209 321 24 24 0 360 DrawEllipse gs col5 0.95 graycol fill gr gs col5 s gr 65 | % Ellipse 66 | n 301 364 40 40 0 360 DrawEllipse gs col3 0.95 graycol fill gr gs col3 s gr 67 | % Ellipse 68 | n 361 411 18 18 0 360 DrawEllipse gs col3 0.05 graycol fill gr gs col3 s gr 69 | % Ellipse 70 | n 294 511 21 21 0 360 DrawEllipse gs col3 0.30 graycol fill gr gs col3 s gr 71 | /Helvetica-Narrow findfont 100.00 scalefont setfont 72 | 399 169 m 73 | gs 1 -1 scale (XSB) col4 show gr 74 | /AvantGarde-Book findfont 12.00 scalefont setfont 75 | 424 219 m 76 | gs 1 -1 scale (XSB) col3 show gr 77 | /AvantGarde-Book findfont 100.00 scalefont setfont 78 | 459 294 m 79 | gs 1 -1 scale (XSB) col3 show gr 80 | /AvantGarde-Book findfont 100.00 scalefont setfont 81 | 364 324 m 82 | gs 1 -1 scale (XSB) col2 show gr 83 | $F2psEnd 84 | -------------------------------------------------------------------------------- /figures/trapped2.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig003483 3 | %%Creator: fig2dev 4 | %%CreationDate: Thu Jul 29 17:27:47 1993 5 | %%For: tswift@sblapis1 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 182 114 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | /DrawSplineSection { 31 | /y3 exch def 32 | /x3 exch def 33 | /y2 exch def 34 | /x2 exch def 35 | /y1 exch def 36 | /x1 exch def 37 | /xa x1 x2 x1 sub 0.666667 mul add def 38 | /ya y1 y2 y1 sub 0.666667 mul add def 39 | /xb x3 x2 x3 sub 0.666667 mul add def 40 | /yb y3 y2 y3 sub 0.666667 mul add def 41 | x1 y1 lineto 42 | xa ya xb yb x3 y3 curveto 43 | } def 44 | 45 | end 46 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 47 | /$F2psEnd {$F2psEnteredState restore end} def 48 | %%EndProlog 49 | 50 | $F2psBegin 51 | 0 setlinecap 0 setlinejoin 52 | -139.0 256.0 translate 0.900 -0.900 scale 53 | 0.500 setlinewidth 54 | % Polyline 55 | n 244 174 m 169 239 l gs col-1 s gr 56 | n 176.355 235.272 m 169.000 239.000 l 173.736 232.249 l gs 2 setlinejoin col-1 s gr 57 | % Open spline 58 | n 245.000 173.000 m 282.500 185.500 l 59 | 282.500 185.500 320.000 198.000 320.000 218.000 DrawSplineSection 60 | 320.000 238.000 l gs col-1 s gr 61 | n 322.000 230.000 m 320.000 238.000 l 318.000 230.000 l gs 2 setlinejoin col-1 s gr 62 | n 244.632 182.222 m 244.000 174.000 l 248.427 180.957 l gs 2 setlinejoin col-1 s gr 63 | % Open spline 64 | n 244.000 174.000 m 256.500 211.500 l 65 | 256.500 211.500 269.000 249.000 289.000 249.000 DrawSplineSection 66 | 309.000 249.000 l gs col-1 s gr 67 | [4.000000] 0 setdash 68 | % Interpolated spline 69 | n 174 254 m 70 | 214.633 275.762 233.383 283.262 249 284 curveto 71 | 266.130 284.810 287.380 278.560 334 259 curveto 72 | gs col-1 s gr 73 | [] 0 setdash 74 | n 325.849 260.251 m 334.000 259.000 l 327.397 263.939 l gs 2 setlinejoin col-1 s gr 75 | /Times-Roman findfont 12.00 scalefont setfont 76 | 224 169 m 77 | gs 1 -1 scale (0\) p\(X,Y\)) col-1 show gr 78 | /Times-Roman findfont 12.00 scalefont setfont 79 | 154 254 m 80 | gs 1 -1 scale (1\) q\(X\)) col-1 show gr 81 | /Times-Roman findfont 12.00 scalefont setfont 82 | 319 254 m 83 | gs 1 -1 scale (2\) r\(Y\)) col-1 show gr 84 | $F2psEnd 85 | -------------------------------------------------------------------------------- /figures/aug-slg-for.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF 2 | %%Title: /tmp/xfig-fig000736 3 | %%Creator: fig2dev 4 | %%CreationDate: Wed Dec 15 14:57:05 1993 5 | %%For: tswift@sblapis4 (Terrance Swift,stu,123191,pegi,sun,5,) 6 | %%BoundingBox: 0 0 479 65 7 | %%Pages: 0 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /l {lineto} bind def 13 | /m {moveto} bind def 14 | /s {stroke} bind def 15 | /n {newpath} bind def 16 | /gs {gsave} bind def 17 | /gr {grestore} bind def 18 | /clp {closepath} bind def 19 | /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 20 | 4 -2 roll mul setrgbcolor} bind def 21 | /col-1 {} def 22 | /col0 {0 0 0 setrgbcolor} bind def 23 | /col1 {0 0 1 setrgbcolor} bind def 24 | /col2 {0 1 0 setrgbcolor} bind def 25 | /col3 {0 1 1 setrgbcolor} bind def 26 | /col4 {1 0 0 setrgbcolor} bind def 27 | /col5 {1 0 1 setrgbcolor} bind def 28 | /col6 {1 1 0 setrgbcolor} bind def 29 | /col7 {1 1 1 setrgbcolor} bind def 30 | end 31 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 32 | /$F2psEnd {$F2psEnteredState restore end} def 33 | %%EndProlog 34 | 35 | $F2psBegin 36 | 0 setlinecap 0 setlinejoin 37 | -7.0 259.0 translate 0.720 -0.720 scale 38 | 0.500 setlinewidth 39 | % Polyline 40 | n 454 284 m 454 324 l gs col-1 s gr 41 | n 456.000 316.000 m 454.000 324.000 l 452.000 316.000 l gs 2 setlinejoin col-1 s gr 42 | /Courier findfont 10.00 scalefont setfont 43 | 424 278 m 44 | gs 1 -1 scale (p:root:p<-p) col-1 show gr 45 | /Courier findfont 10.00 scalefont setfont 46 | 399 339 m 47 | gs 1 -1 scale (2\) p:active:p<-r\(X1\),q) col-1 show gr 48 | % Polyline 49 | n 624 284 m 624 324 l gs col-1 s gr 50 | n 626.000 316.000 m 624.000 324.000 l 622.000 316.000 l gs 2 setlinejoin col-1 s gr 51 | /Courier findfont 10.00 scalefont setfont 52 | 589 279 m 53 | gs 1 -1 scale (q:root:q<-q) col-1 show gr 54 | /Courier findfont 10.00 scalefont setfont 55 | 579 339 m 56 | gs 1 -1 scale (4\) q:active:q<-p) col-1 show gr 57 | % Polyline 58 | n 195 281 m 75 341 l gs col-1 s gr 59 | n 83.050 339.211 m 75.000 341.000 l 81.261 335.633 l gs 2 setlinejoin col-1 s gr 60 | % Polyline 61 | n 194 284 m 194 324 l gs col-1 s gr 62 | n 196.000 316.000 m 194.000 324.000 l 192.000 316.000 l gs 2 setlinejoin col-1 s gr 63 | [4.000000] 0 setdash 64 | % Polyline 65 | n 196 283 m 316 343 l gs col-1 s gr 66 | [] 0 setdash 67 | n 309.739 337.633 m 316.000 343.000 l 307.950 341.211 l gs 2 setlinejoin col-1 s gr 68 | /Courier findfont 10.00 scalefont setfont 69 | 124 339 m 70 | gs 1 -1 scale (3\) r\(X\):active:r\(2\)<-~q) col-1 show gr 71 | /Courier findfont 10.00 scalefont setfont 72 | 269 359 m 73 | gs 1 -1 scale (r\(X\):answer:r\(3\)<-) col-1 show gr 74 | /Courier findfont 10.00 scalefont setfont 75 | 9 359 m 76 | gs 1 -1 scale (1\) r\(X\):active:r\(1\)<-p) col-1 show gr 77 | /Courier findfont 10.00 scalefont setfont 78 | 129 279 m 79 | gs 1 -1 scale (0\) r\(X\):root:r\(X\)<-r\(X\)) col-1 show gr 80 | $F2psEnd 81 | -------------------------------------------------------------------------------- /figures/alt-slg-examp1.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 59 299 139 319 4 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 5 | 139 299 139 319 59 319 59 299 139 299 9999 9999 6 | 4 0 0 12 0 -1 0 0.00000 4 12 53 69 314 (r, 1, 1, 1 ) 7 | -6 8 | 6 179 299 259 319 9 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 10 | 259 299 259 319 179 319 179 299 259 299 9999 9999 11 | 4 0 0 12 0 -1 0 0.00000 4 12 53 189 314 (r, 1, 1, 1 ) 12 | -6 13 | 6 299 299 379 319 14 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 15 | 379 299 379 319 299 319 299 299 379 299 9999 9999 16 | 4 0 0 12 0 -1 0 0.00000 4 12 53 309 314 (r, 1, 1, 1 ) 17 | -6 18 | 6 59 419 139 439 19 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 20 | 139 419 139 439 59 439 59 419 139 419 9999 9999 21 | 4 0 0 12 0 -1 0 0.00000 4 12 53 69 434 (r, 1, 1, 1 ) 22 | -6 23 | 6 179 419 259 439 24 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 25 | 259 419 259 439 179 439 179 419 259 419 9999 9999 26 | 4 0 0 12 0 -1 0 0.00000 4 12 53 189 434 (r, 1, 1, 1 ) 27 | -6 28 | 6 179 279 259 299 29 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 30 | 259 279 259 299 179 299 179 279 259 279 9999 9999 31 | 4 0 0 12 0 -1 0 0.00000 4 12 52 189 294 (p, 2, 2, 2) 32 | -6 33 | 6 34 239 59 259 34 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 46 249 9 9 39 244 54 254 35 | 4 0 0 12 0 -1 0 0.00000 4 9 6 44 254 1 36 | -6 37 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 286 249 9 9 279 244 294 254 38 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 46 369 9 9 39 364 54 374 39 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 166 369 9 9 159 364 174 374 40 | 1 4 0 1 -1 0 0 0 0.00000 1 0.000 166 249 9 9 157 240 175 258 41 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 42 | 239 79 179 119 9999 9999 43 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 44 | 239 79 239 119 9999 9999 45 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 46 | 179 144 179 184 9999 9999 47 | 2 1 0 1 -1 0 0 0 0.000 -1 0 0 48 | 239 144 239 184 9999 9999 49 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 50 | 379 279 379 299 299 299 299 279 379 279 9999 9999 51 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 52 | 139 379 139 399 59 399 59 379 139 379 9999 9999 53 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 54 | 139 399 139 419 59 419 59 399 139 399 9999 9999 55 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 56 | 259 379 259 399 179 399 179 379 259 379 9999 9999 57 | 2 2 0 1 -1 0 0 0 0.000 0 0 0 58 | 259 399 259 419 179 419 179 399 259 399 9999 9999 59 | 4 0 0 12 0 -1 0 0.00000 4 9 27 159 109 X = 1 60 | 4 0 0 12 0 -1 0 0.00000 4 9 27 209 109 X = 2 61 | 4 0 0 12 0 -1 0 0.00000 4 12 34 229 69 1: r(X) 62 | 4 0 0 12 0 -1 0 0.00000 4 12 49 164 209 3: r(X1),q 63 | 4 0 0 12 0 -1 0 0.00000 4 12 18 169 138 2: p 64 | 4 0 0 12 0 -1 0 0.00000 4 12 52 309 294 (p, 2, 1, 2) 65 | 4 0 0 12 0 -1 0 0.00000 4 12 52 69 414 (p, 2, 1, 2) 66 | 4 0 0 12 0 -1 0 0.00000 4 12 52 69 394 (q, 3, 3, 3) 67 | 4 0 0 12 0 -1 0 0.00000 4 12 52 189 414 (p, 2, 1, 2) 68 | 4 0 0 12 0 -1 0 0.00000 4 12 52 189 394 (q, 3, 3, 1) 69 | 4 0 0 12 0 -1 0 0.00000 4 9 6 164 254 2 70 | 4 0 0 12 0 -1 0 0.00000 4 9 6 284 254 3 71 | 4 0 0 12 0 -1 0 0.00000 4 9 6 164 374 5 72 | 4 0 0 12 0 -1 0 0.00000 4 9 6 44 374 4 73 | 4 0 0 12 0 -1 0 0.00000 4 12 18 229 204 5: p 74 | 4 0 0 12 0 -1 0 0.00000 4 12 25 234 134 4: ~q 75 | -------------------------------------------------------------------------------- /figures/tree3.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 104 219 224 259 4 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 5 | 0 0 1.000 4.000 8.000 6 | 104 259 164 219 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 8 | 0 0 1.000 4.000 8.000 9 | 224 259 164 219 9999 9999 10 | -6 11 | 6 349 24 469 64 12 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 13 | 0 0 1.000 4.000 8.000 14 | 349 64 409 24 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 16 | 0 0 1.000 4.000 8.000 17 | 469 64 409 24 9999 9999 18 | -6 19 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 20 | 0 0 1.000 4.000 8.000 21 | 474 144 474 184 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 239 294 319 334 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 329 349 329 394 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 29 | 0 0 1.000 4.000 8.000 30 | 104 389 104 439 9999 9999 31 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 32 | 0 0 1.000 4.000 8.000 33 | 104 464 44 514 9999 9999 34 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 35 | 0 0 1.000 4.000 8.000 36 | 106 466 216 516 9999 9999 37 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 38 | 0 0 1.000 4.000 8.000 39 | 239 144 304 199 9999 9999 40 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 41 | 0 0 1.000 4.000 8.000 42 | 239 144 164 199 9999 9999 43 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 44 | 0 0 1.000 4.000 8.000 45 | 539 84 469 119 9999 9999 46 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 47 | 0 0 1.000 4.000 8.000 48 | 539 84 614 119 9999 9999 49 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 50 | 0 0 1.000 4.000 8.000 51 | 99 299 99 339 9999 9999 52 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 53 | 0 0 1.000 4.000 8.000 54 | 300 86 245 121 9999 9999 55 | 4 0 12 10 0 -1 0 0.00000 4 9 228 174 79 1. a(a,Z):act:a(a,Z)<-a(a,Y),a(Y,Z) 56 | 4 0 12 10 0 -1 0 0.00000 4 9 234 424 79 2. a(a,Z):int:a(a,Z)<-p(a,Z),q(Z)) 57 | 4 0 12 10 0 -1 0 0.00000 4 9 156 249 214 15 a(a,Z):ans:a(a,c)<- 58 | 4 0 12 10 0 -1 0 0.00000 4 9 150 419 199 4. a(a,Z):ans:a(a,b)<- 59 | 4 0 12 10 0 -1 0 0.00000 4 9 156 389 139 3. a(a,Z):int:a(a,b)<-q(b) 60 | 4 0 12 10 0 -1 0 0.00000 4 9 114 189 289 a(b,Z)<-p(b,Z).q(Z) 61 | 4 0 12 10 0 -1 0 0.00000 4 9 84 64 374 a(b,Z)<-a(c,Z) 62 | 4 0 12 10 0 -1 0 0.00000 4 9 198 154 139 5. a(a,Z):act:a(a,Z) <- a(b,Z) 63 | 4 0 12 10 0 -1 0 0.00000 4 9 126 44 289 a(b,Z)<-a(b,Y),a(Y,Z) 64 | 4 0 12 10 0 -1 0 0.00000 4 9 114 164 549 a(c,Z)<-p(c,Y),q(Y) 65 | 4 0 12 10 0 -1 0 0.00000 4 9 126 4 549 a(c,Z)<-a(c,Y),a(Y,Z) 66 | 4 0 12 10 0 -1 0 0.00000 4 9 162 569 139 14. a(a,Z):int:a(a,d)<-q(d) 67 | 4 0 12 10 0 -1 0 0.00000 4 9 78 69 274 7 a(b,Z):act: 68 | 4 0 12 10 0 -1 0 0.00000 4 9 84 204 274 8. a(b,Z):int: 69 | 4 0 12 10 0 -1 0 0.00000 4 9 156 249 344 9. a(b,Z):int:a(b,c)<-q(c) 70 | 4 0 12 10 0 -1 0 0.00000 4 9 138 259 409 10. a(b,Z):ans:a(b,c)<- 71 | 4 0 12 10 0 -1 0 0.00000 4 9 90 64 359 11. a(b,Z):act: 72 | 4 0 12 10 0 -1 0 0.00000 4 9 120 49 454 12 a(c,Z):gen:a(c,Z) 73 | 4 0 12 10 0 -1 0 0.00000 4 9 84 19 534 13 a(c,Z):act: 74 | 4 0 12 10 0 -1 0 0.00000 4 9 84 174 534 14 a(c,Z):act: 75 | 4 0 12 10 0 -1 0 0.00000 4 9 120 94 214 6. a(b,Z):gen:a(b,Z) 76 | 4 0 12 10 0 -1 0 0.00000 4 9 120 349 19 0. a(a,Z):gen:a(a,Z) 77 | -------------------------------------------------------------------------------- /figures/tree4.fig: -------------------------------------------------------------------------------- 1 | #FIG 2.1 2 | 80 2 3 | 6 104 219 224 259 4 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 5 | 0 0 1.000 4.000 8.000 6 | 104 259 164 219 9999 9999 7 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 8 | 0 0 1.000 4.000 8.000 9 | 224 259 164 219 9999 9999 10 | -6 11 | 6 349 24 469 64 12 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 13 | 0 0 1.000 4.000 8.000 14 | 349 64 409 24 9999 9999 15 | 2 1 0 1 -1 0 0 0 0.000 7 0 1 16 | 0 0 1.000 4.000 8.000 17 | 469 64 409 24 9999 9999 18 | -6 19 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 20 | 0 0 1.000 4.000 8.000 21 | 474 144 474 184 9999 9999 22 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 23 | 0 0 1.000 4.000 8.000 24 | 239 294 319 334 9999 9999 25 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 26 | 0 0 1.000 4.000 8.000 27 | 329 349 329 394 9999 9999 28 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 29 | 0 0 1.000 4.000 8.000 30 | 104 389 104 439 9999 9999 31 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 32 | 0 0 1.000 4.000 8.000 33 | 104 464 44 514 9999 9999 34 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 35 | 0 0 1.000 4.000 8.000 36 | 106 466 216 516 9999 9999 37 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 38 | 0 0 1.000 4.000 8.000 39 | 239 144 304 199 9999 9999 40 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 41 | 0 0 1.000 4.000 8.000 42 | 239 144 164 199 9999 9999 43 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 44 | 0 0 1.000 4.000 8.000 45 | 539 84 469 119 9999 9999 46 | 2 1 0 1 -1 0 0 0 0.000 -1 1 0 47 | 0 0 1.000 4.000 8.000 48 | 539 84 614 119 9999 9999 49 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 50 | 0 0 1.000 4.000 8.000 51 | 99 299 99 339 9999 9999 52 | 2 1 0 1 -1 0 0 0 0.000 7 1 0 53 | 0 0 1.000 4.000 8.000 54 | 300 86 245 121 9999 9999 55 | 4 0 12 10 0 -1 0 0.00000 4 9 228 174 79 1. a(a,Z):act:a(a,Z)<-a(a,Y),a(Y,Z) 56 | 4 0 12 10 0 -1 0 0.00000 4 9 234 424 79 2. a(a,Z):int:a(a,Z)<-p(a,Z),q(Z)) 57 | 4 0 12 10 0 -1 0 0.00000 4 9 156 249 214 15 a(a,Z):ans:a(a,c)<- 58 | 4 0 12 10 0 -1 0 0.00000 4 9 150 419 199 4. a(a,Z):ans:a(a,b)<- 59 | 4 0 12 10 0 -1 0 0.00000 4 9 156 389 139 3. a(a,Z):int:a(a,b)<-q(b) 60 | 4 0 12 10 0 -1 0 0.00000 4 9 114 189 289 a(b,Z)<-p(b,Z).q(Z) 61 | 4 0 12 10 0 -1 0 0.00000 4 9 84 64 374 a(b,Z)<-a(c,Z) 62 | 4 0 12 10 0 -1 0 0.00000 4 9 198 154 139 5. a(a,Z):act:a(a,Z) <- a(b,Z) 63 | 4 0 12 10 0 -1 0 0.00000 4 9 126 44 289 a(b,Z)<-a(b,Y),a(Y,Z) 64 | 4 0 12 10 0 -1 0 0.00000 4 9 114 164 549 a(c,Z)<-p(c,Y),q(Y) 65 | 4 0 12 10 0 -1 0 0.00000 4 9 126 4 549 a(c,Z)<-a(c,Y),a(Y,Z) 66 | 4 0 12 10 0 -1 0 0.00000 4 9 162 569 139 14. a(a,Z):int:a(a,d)<-q(d) 67 | 4 0 12 10 0 -1 0 0.00000 4 9 78 69 274 7 a(b,Z):act: 68 | 4 0 12 10 0 -1 0 0.00000 4 9 84 204 274 8. a(b,Z):int: 69 | 4 0 12 10 0 -1 0 0.00000 4 9 156 249 344 9. a(b,Z):int:a(b,c)<-q(c) 70 | 4 0 12 10 0 -1 0 0.00000 4 9 138 259 409 10. a(b,Z):ans:a(b,c)<- 71 | 4 0 12 10 0 -1 0 0.00000 4 9 90 64 359 11. a(b,Z):act: 72 | 4 0 12 10 0 -1 0 0.00000 4 9 120 49 454 12 a(c,Z):gen:a(c,Z) 73 | 4 0 12 10 0 -1 0 0.00000 4 9 84 19 534 13 a(c,Z):act: 74 | 4 0 12 10 0 -1 0 0.00000 4 9 84 174 534 14 a(c,Z):act: 75 | 4 0 12 10 0 -1 0 0.00000 4 9 120 94 214 6. a(b,Z):gen:a(b,Z) 76 | 4 0 12 10 0 -1 0 0.00000 4 9 120 349 19 0. a(a,Z):gen:a(a,Z) 77 | -------------------------------------------------------------------------------- /agg.P: -------------------------------------------------------------------------------- 1 | testi :- for(I,1,7),nl,for(J,1,7),grid_i(I,J,X),write(X),write('\t'),fail. 2 | 3 | :- table grid_i(_,_,lattice(max(_,_,_))). 4 | grid_i(I,1,X) :- !, X is I*1000000. 5 | grid_i(I,7,X) :- !, X is 8000000 - I*1000000. 6 | grid_i(1,J,X) :- !, X is J*1000000. 7 | grid_i(7,J,X) :- !, X is 8000000 - J*1000000. 8 | grid_i(I,J,X) :- 9 | Ip1 is I+1, Im1 is I-1, 10 | Jp1 is J+1, Jm1 is J-1, 11 | grid_i(Ip1,J,X1), 12 | grid_i(Im1,J,X2), 13 | grid_i(I,Jp1,X3), 14 | grid_i(I,Jm1,X4), 15 | X is (X1+X2+X3+X4) // 4. 16 | grid_i(_,_,1000000). 17 | 18 | 19 | 20 | :- import for/3 from basics. 21 | 22 | test :- for(I,1,7),nl,for(J,1,7),grid(I,J,X),write(X),write('\t'),fail. 23 | 24 | :- table grid(_,_,lattice(max(_,_,_))). 25 | 26 | grid(I,1,X) :- !, X is float(I). 27 | grid(I,7,X) :- !, X is 8.0 - float(I). 28 | grid(1,J,X) :- !, X is float(J). 29 | grid(7,J,X) :- !, X is 8.0 - float(J). 30 | grid(I,J,X) :- 31 | Ip1 is I+1, Im1 is I-1, 32 | Jp1 is J+1, Jm1 is J-1, 33 | grid(Ip1,J,X1), 34 | grid(Im1,J,X2), 35 | grid(I,Jp1,X3), 36 | grid(I,Jm1,X4), 37 | X is (X1+X2+X3+X4) / 4. 38 | grid(_,_,1.0). 39 | 40 | max(X,Y,M) :- (Y > X -> M = Y ; M = X). 41 | 42 | 43 | 44 | 45 | 46 | 47 | end_of_file. 48 | % shortest path 49 | 50 | e(a,b,4). 51 | e(a,c,7). 52 | e(b,c,2). 53 | e(b,d,8). 54 | e(d,a,1). 55 | e(d,b,1). 56 | e(d,e,3). 57 | e(c,d,1). 58 | e(c,e,5). 59 | 60 | :- table sp(_,_,lattice(min(_,_,_))). 61 | sp(X,Y,D) :- e(X,Y,D). 62 | sp(X,Y,D) :- sp(X,Z,D1),e(Z,Y,D2), D is D1+D2. 63 | 64 | 65 | min(X,Y,Min) :- (Y < X -> Min = Y ; Min = X). 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | % simple example of lattice (max) 75 | 76 | :- table p_max2(_,lattice(max(_,_,_))). 77 | 78 | p_max2(X,Y) :- p(X,Y). 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | end_of_file. 92 | 93 | 94 | % simple example of fold(sum) 95 | p(1,1). p(1,2). p(1,3). p(1,4). p(1,5). p(1,6). 96 | p(2,2). p(2,4). p(2,6). p(2,8). p(2,10). p(2,12). 97 | 98 | :- table p_sum2(_,fold(sum(_,_,_),0)). 99 | p_sum2(X,Y) :- p(X,Y). 100 | 101 | sum(X,Y,Z) :- Z is X+Y, writeln(sum(X,Y,Z)). 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | end_of_file. 122 | 123 | 124 | 125 | 126 | 127 | /* A company Cm is said to have bought another company Cs if Cm 128 | controls more than 50% of the stock of Cs. Cm controls the stock it 129 | directly owns. Cm also controls stock controlled by any other company 130 | Cm has bought. */ 131 | 132 | set_owns(a,b,51.0). 133 | set_owns(a,c,11.0). 134 | set_owns(b,c,40.0). 135 | set_owns(c,d,45.0). 136 | set_owns(d,a,51.0). 137 | 138 | :- table all_controls(_,_,fold(sum(_,_,_),0.0)). 139 | 140 | all_controls(Cm, Cs, S) :- set_owns(Cm, Cs, S). 141 | all_controls(Cm, Cs, S) :- set_bought(Cm, Ci), Cm \== Ci, all_controls(Ci, Cs, S), writeln(ac(Cm,Cs,S,Ci)). 142 | 143 | set_bought(Cm, Cs) :- all_controls(Cm, Cs, S), S > 50.0, writeln(sb(Cm,Cs)). --------------------------------------------------------------------------------