├── .gitignore ├── COPYING ├── Makefile ├── README.md ├── scripts ├── BeautifulSoup.py ├── _generate_html ├── _run ├── lpn_get_body.py └── splitindex.perl ├── text ├── LPN.isty ├── LPNindex.tex ├── LPNmacros.tex ├── all.tex ├── append.eps ├── appendix0.tex ├── appendix1.tex ├── appendix2.tex ├── chap10-pspic1.tex ├── chap10-pspic2.tex ├── chap10-pspic3.tex ├── chap10-pspic4.tex ├── chap10-pspic5.tex ├── chap10-pspic6.tex ├── chap2-pspic1.tex ├── chap2-pspic2.tex ├── chap2-pspic3.tex ├── chap2-pspic4.tex ├── chap2-pspic5.tex ├── chap3-pspic1.tex ├── chap3-pspic2.tex ├── chap3-pspic3.tex ├── chap6-pspic1.tex ├── chapter1.tex ├── chapter10.tex ├── chapter11.tex ├── chapter12.tex ├── chapter2.tex ├── chapter3.tex ├── chapter4.tex ├── chapter5.tex ├── chapter6.tex ├── chapter7.tex ├── chapter8.tex ├── chapter9.tex ├── crosswd2.eps ├── current_lpn.ps ├── dolls.eps ├── frontmatter.tex ├── introduction.tex ├── kcp-template.ps ├── kcp-template.tex ├── kcp-template.toc ├── kcp-texts.sty ├── kcp.sty ├── listtree.eps ├── lpn-html.cfg ├── lpn-html.tex ├── lpn.idx ├── lpn.ilg ├── lpn.ind ├── lpn.pdf ├── lpn.ps ├── lpn.tex ├── lpn.toc ├── main.tex ├── main.toc ├── old_search_trees.txt ├── page2.ps ├── page21.ps ├── page5.ps ├── page9.ps ├── parse.eps ├── parse2.eps ├── pencil.eps ├── preface.tex ├── preface2.tex ├── prolog.idx ├── prolog.ilg ├── prolog.ind ├── splitindex.perl_orig.txt ├── sublist.eps ├── termtypes.eps ├── test_frontmatter.ps └── test_frontmatter.tex └── www ├── LPN_french_cover.jpg ├── bibtex.php ├── bibtex_french.php ├── contact.php ├── cover_front.gif ├── cover_front.jpg ├── cover_front_small.jpg ├── errata.php ├── french.php ├── handheld.php ├── implementations.php ├── index.php ├── info_email.jpg ├── links.php ├── lpn_reds2.css ├── lpnpage.php ├── lpnpage.php.mine ├── lpnpage.php.r36 ├── lpnpage.php.r37 ├── manuals.php ├── navbar.php ├── online.php ├── teaching.php ├── test.html ├── thanks.php ├── toc.php └── top.php /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.log 3 | *.pyc 4 | text/lpn-html.* 5 | text/chap*-*.ps 6 | www/html 7 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | The Learn Prolog Now! sources are available under the Creative Commons 2 | Attribution-ShareAlike license [1] 3 | 4 | The authors would like to maintain backwards compatibility with the 5 | printed, published version of LPN. That is, ideally numbers of chapters 6 | and exercises shouldn't change, but still allow for the possibilities to 7 | add new exercises, sections or even chapters. 8 | 9 | [1] http://creativecommons.org/licenses/by-sa/4.0/ 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | html: 2 | LANG=C scripts/_generate_html 3 | 4 | server: 5 | (cd www && php -S localhost:8000) 6 | 7 | clean: 8 | rm -f scripts/BeautifulSoup.pyc 9 | rm -f text/*.log 10 | rm -f text/lpn-html.{4ct,4tc,css,idv,idx,lg,log,tmp,xref} 11 | 12 | distclean: clean 13 | rm -rf www/html 14 | rm -f text/chap*-*.ps 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learn Prolog Now! source text 2 | 3 | 4 | ## Directories 5 | 6 | archive contains old stuff (just for the record) 7 | web_site contains sources of OLD website 8 | prolog example prolog databases 9 | text contains latex sources and produced ps and pdf files 10 | scripts contains shell/perl scripts for conversion and pdf production 11 | www contains sources of current website 12 | 13 | ## Scripts 14 | 15 | scripts/_generate_html converts html from latex sources 16 | scripts/_run produces lpn.ps and lpn.pdf 17 | 18 | ## Character set 19 | 20 | The sources are ISO-Latin-1 files. They do not compile after conversion 21 | to UTF-8. The scripts must be executed under non-UTF-8 locale. 22 | -------------------------------------------------------------------------------- /scripts/_generate_html: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INDIR=text 4 | OUTDIR="`pwd`/www/html/" 5 | SCRIPTSDIR="`pwd`/scripts" 6 | 7 | init() 8 | { 9 | echo ${OUTDIR} 10 | mkdir -p ${OUTDIR} 11 | } 12 | 13 | convertpix() 14 | { 15 | for p in ${INDIR}/*.eps; do 16 | echo "Converting eps file $p" 17 | convert -density 150 $p -flatten $p.png 18 | mv $p.png ${OUTDIR} 19 | done 20 | pushd . 21 | cd ${INDIR} 22 | for p in chap*pspic*.tex; do 23 | latex $p 24 | done 25 | for p in chap*pspic*.dvi; do 26 | dvips -E $p 27 | done 28 | popd 29 | for p in ${INDIR}/chap*pspic*.ps; do 30 | echo "Converting ps file $p" 31 | convert -density 150 $p -flatten $p.png 32 | mv $p.png ${OUTDIR} 33 | done 34 | } 35 | 36 | convertlatex() 37 | { 38 | pushd . 39 | cd ${INDIR} 40 | cp LPNmacros.tex LPNtempmacros1.tex 41 | echo "\renewcommand{\Thischapter}[2]{\setcounter{length}{#1}#2}" > LPNtempmacros2.tex 42 | cat LPNtempmacros1.tex LPNtempmacros2.tex > LPNmacros.tex 43 | cat lpn.tex | grep -v kcp | grep -v bbheadings | grep -v bbanswers | grep -v appendix > lpn-html.tex 44 | htlatex lpn-html.tex "lpn-html,xhtml,3,info" "" "-d${OUTDIR}" 45 | cp LPNtempmacros1.tex LPNmacros.tex 46 | rm -f LPNtempmacros?.tex 47 | popd 48 | } 49 | 50 | adjusthtml() 51 | { 52 | pushd . 53 | cd ${OUTDIR} 54 | for HTML in `ls ${OUTDIR}*.html`; do 55 | echo "Adjusting: ${HTML}" 56 | cat ${HTML} | ${SCRIPTSDIR}/lpn_get_body.py > temp.html 57 | cat temp.html \ 58 | | tr "\n" " " \ 59 | | tr -s " " \ 60 | | sed "s/Exercise<\/strong>/g' \ 65 | > ${HTML} 66 | rm -f temp.html 67 | done 68 | # Generating a new online.php file 69 | cat lpn-html.html \ 70 | | tr "\n" " " \ 71 | | sed 's//chapterToc">Chapter/' > ../online.php 77 | popd 78 | } 79 | 80 | 81 | finit() 82 | { 83 | pushd . 84 | cd ${INDIR} 85 | rm -f lpn-html*.html 86 | rm -f *.aux 87 | rm -f *.dvi 88 | popd 89 | } 90 | 91 | init 92 | convertpix 93 | convertlatex 94 | adjusthtml 95 | finit 96 | 97 | exit 0 98 | -------------------------------------------------------------------------------- /scripts/_run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEXT=text 4 | 5 | finit() 6 | { 7 | rm -f ${TEXT}/*.aux 8 | rm -f ${TEXT}/*.dvi 9 | } 10 | 11 | main() 12 | { 13 | pushd . 14 | cd ${TEXT} 15 | latex lpn 16 | popd 17 | scripts/splitindex.perl 18 | pushd . 19 | cd ${TEXT} 20 | makeindex -s LPN.isty lpn.idx 21 | makeindex -s LPN.isty prolog.idx 22 | latex lpn 23 | latex lpn 24 | 25 | dvips lpn.dvi -o -Pwww 26 | # dvips -Pwww -t a4 lpn.dvi -o 27 | # dvips -Ppdf to make nice ps for pdf conversion 28 | # dvips -D 2540 to make nice ps for pdf conversion 29 | 30 | ps2pdf lpn.ps lpn.pdf 31 | # ps2pdf -dPDFSETTINGS=/printer -dCompatibilityLevel=1.3 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sPAPERSIZE=a4 lpn.ps lpn.pdf 32 | # ps2pdf13 nice conversion (try 14 too) 33 | 34 | popd 35 | } 36 | 37 | main 38 | finit 39 | exit 0 40 | 41 | -------------------------------------------------------------------------------- /scripts/lpn_get_body.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from BeautifulSoup import BeautifulSoup 4 | import sys 5 | 6 | print BeautifulSoup(sys.stdin.read()).contents[6].contents[2].prettify()[7:-8] 7 | 8 | 9 | -------------------------------------------------------------------------------- /scripts/splitindex.perl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | open(MAININDEX, ">text/tmplpn.idx"); 4 | open(PROLOGINDEX, ">text/prolog.idx"); 5 | open(FILE, ") { 8 | if ($_ =~ /indexentry\{PROLOG (.*)\}\{(.*)\}/) { 9 | $PROLOG = $1; 10 | $PAGE = $2; 11 | $PROLOG =~ s/ +/ /g; 12 | $PROLOG =~ s/^ //g; 13 | print PROLOGINDEX "\\indexentry{$PROLOG}{$PAGE}\n"; 14 | } elsif ($_ =~ /indexentry\{CITATION (.*)\}\{(.*)\}/) { 15 | my $CITE = $1; 16 | my $PAGE = $2; 17 | my $FoundAuthor = 0; 18 | my $FoundEditor = 0; 19 | my $AUTHOR = ""; 20 | my $EDITOR = ""; 21 | 22 | open(BIB, ") { 26 | if ($_ =~ /@/ && $LookForAuthor eq 1) { 27 | $LookForAuthor = 0; 28 | $LookForEditor = 0; 29 | } 30 | if ($_ =~ /$CITE,/) { 31 | $LookForAuthor = 1; 32 | $LookForEditor = 1; 33 | } 34 | if ($_ =~ /author\s*=(.*\w.*)/ && $LookForAuthor eq 1) { 35 | $AUTHOR = $1; 36 | $AUTHOR =~ s/\\\"/QUOTE/g; 37 | $AUTHOR =~ s/\{\\o\}/OOOOO/g; 38 | $AUTHOR =~ s/\{\\aa\}/AAAAA/g; 39 | $AUTHOR =~ s/\"//g; 40 | $AUTHOR =~ s/,\s*$//g; 41 | $AUTHOR =~ s/\{//g; 42 | $AUTHOR =~ s/\}//g; 43 | $AUTHOR =~ s/^\s*//g; 44 | $AUTHOR =~ s/QUOTE/\\\"/g; 45 | $AUTHOR =~ s/OOOOO/\{\\o\}/g; 46 | $AUTHOR =~ s/AAAAA/\{\\aa\}/g; 47 | $LookForAuthor = 0; 48 | $FoundAuthor = 1; 49 | } 50 | if ($_ =~ /editor\s*=(.*\w.*)/ && $LookForAuthor eq 1 && $LookForEditor eq 1) { 51 | $EDITOR = $1; 52 | $EDITOR =~ s/\\\"/QUOTE/g; 53 | $EDITOR =~ s/\{\\o\}/OOOOO/g; 54 | $EDITOR =~ s/\{\\aa\}/AAAAA/g; 55 | $EDITOR =~ s/\"//g; 56 | $EDITOR =~ s/,\s*$//g; 57 | $EDITOR =~ s/\{//g; 58 | $EDITOR =~ s/\}//g; 59 | $EDITOR =~ s/^\s*//g; 60 | $EDITOR =~ s/QUOTE/\\\"/g; 61 | $EDITOR =~ s/OOOOO/\{\\o\}/g; 62 | $EDITOR =~ s/AAAAA/\{\\aa\}/g; 63 | $LookForEditor = 0; 64 | $FoundEditor = 1; 65 | } 66 | } 67 | close(BIB); 68 | } else { 69 | s/ +/ /g; 70 | print MAININDEX $_; 71 | 72 | } 73 | } 74 | 75 | close(FILE); 76 | close(PROLOGINDEX); 77 | close(MAININDEX); 78 | 79 | system("mv text/tmplpn.idx text/lpn.idx"); 80 | -------------------------------------------------------------------------------- /text/LPN.isty: -------------------------------------------------------------------------------- 1 | preamble 2 | "\\begin{theindex}\n\\thispagestyle{empty}\n" 3 | 4 | heading_prefix 5 | "\\textbf{" 6 | 7 | heading_suffix 8 | "} \\nopagebreak" 9 | 10 | headings_flag 11 | 1 12 | 13 | -------------------------------------------------------------------------------- /text/LPNindex.tex: -------------------------------------------------------------------------------- 1 | 2 | % splitindex.perl (creates a new names.idx and prolog.idx files) 3 | % makeindex -s LPN.isty lpn.idx 4 | % makeindex -s LPN.isty prolog.idx 5 | 6 | %\renewcommand*{\indexname}{Author Index} 7 | %\input{names.ind} 8 | 9 | \cleardoublepage 10 | \renewcommand*{\indexname}{\hfill Predicate Index} 11 | \addcontentsline{toc}{chapter}{Predicate Index} 12 | \pagestyle{bbpindex} 13 | \thispagestyle{empty} 14 | \input{prolog.ind} 15 | 16 | \cleardoublepage 17 | \renewcommand*{\indexname}{\hfill Subject Index} 18 | \addcontentsline{toc}{chapter}{Subject Index} 19 | \pagestyle{bbsindex} 20 | \printindex 21 | -------------------------------------------------------------------------------- /text/LPNmacros.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/LPNmacros.tex -------------------------------------------------------------------------------- /text/append.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: append.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:18:25 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 271 92 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 92 moveto 0 0 lineto 271 0 lineto 271 92 lineto closepath clip newpath 49 | -67.5 216.7 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0 slj 0 slc 89 | 0.06000 0.06000 sc 90 | % 91 | % Fig objects follow 92 | % 93 | % 94 | % here starts figure with depth 100 95 | % Polyline 96 | 7.500 slw 97 | n 4200 2100 m 5625 2100 l 5625 2400 l 4200 2400 l 98 | cp gs col15 1.00 shd ef gr gs col7 s gr 99 | % Polyline 100 | n 4050 2700 m 5475 2700 l 5475 3000 l 4050 3000 l 101 | cp gs col15 1.00 shd ef gr gs col7 s gr 102 | % Polyline 103 | n 2700 2100 m 3825 2100 l 3825 2400 l 2700 2400 l 104 | cp gs col15 1.00 shd ef gr gs col7 s gr 105 | % Polyline 106 | n 2925 2700 m 4050 2700 l 4050 3000 l 2925 3000 l 107 | cp gs col15 1.00 shd ef gr gs col7 s gr 108 | % Polyline 109 | n 2925 3300 m 5475 3300 l 5475 3600 l 2925 3600 l 110 | cp gs col15 1.00 shd ef gr gs col7 s gr 111 | % Polyline 112 | n 2400 2100 m 2700 2100 l 2700 2400 l 2400 2400 l 113 | cp gs col16 1.00 shd ef gr gs col7 s gr 114 | % Polyline 115 | n 2625 3300 m 2925 3300 l 2925 3600 l 2625 3600 l 116 | cp gs col16 1.00 shd ef gr gs col7 s gr 117 | /Times-Bold ff 210.00 scf sf 118 | 2475 2325 m 119 | gs 1 -1 sc (H) col0 sh gr 120 | /Times-Bold ff 210.00 scf sf 121 | 3150 2325 m 122 | gs 1 -1 sc (T) col0 sh gr 123 | /Times-Bold ff 210.00 scf sf 124 | 3975 2325 m 125 | gs 1 -1 sc (+) col0 sh gr 126 | /Times-Bold ff 210.00 scf sf 127 | 4800 2325 m 128 | gs 1 -1 sc (L2) col0 sh gr 129 | /Times-Bold ff 210.00 scf sf 130 | 3600 2925 m 131 | gs 1 -1 sc (L3 = T + L2) col0 sh gr 132 | /Times-Bold ff 210.00 scf sf 133 | 2700 3525 m 134 | gs 1 -1 sc (H) col0 sh gr 135 | /Times-Bold ff 210.00 scf sf 136 | 1650 2325 m 137 | gs 1 -1 sc (Input:) col0 sh gr 138 | /Times-Bold ff 210.00 scf sf 139 | 1125 2925 m 140 | gs 1 -1 sc (What L3 is:) col0 sh gr 141 | /Times-Bold ff 210.00 scf sf 142 | 1500 3525 m 143 | gs 1 -1 sc (Result:) col0 sh gr 144 | /Times-Bold ff 210.00 scf sf 145 | 3975 3525 m 146 | gs 1 -1 sc (L3) col0 sh gr 147 | % here ends figure; 148 | $F2psEnd 149 | rs 150 | showpage 151 | -------------------------------------------------------------------------------- /text/appendix0.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/appendix0.tex -------------------------------------------------------------------------------- /text/appendix1.tex: -------------------------------------------------------------------------------- 1 | 2 | \chapter*{Further Reading}\label{Appendix:books} 3 | 4 | While we think \textit{Learn Prolog Now!} is a good first book on Prolog, it 5 | certainly shouldn't be the last one you look at. To help you take the next 6 | step, we have listed, with comments, some of our favourite Prolog textbooks, 7 | and Prolog-based books on Artificial Intelligence (AI) and Natural Language 8 | Processing (NLP). 9 | 10 | 11 | \subsection*{Prolog textbooks} 12 | 13 | \begin{itemize} 14 | 15 | \item Bratko (1990): \textit{Prolog Programming for Artificial 16 | Intelligence}. Addison-Wesley. We strongly recommend this book. If you liked 17 | \textit{Learn Prolog Now!} we think you'll find this a natural followup. Its 18 | strong point is the wide variety of programming styles and applications it 19 | considers. This is a big book, and it will take you quite a while to work 20 | through it. But if you do so, you'll soon be writing very substantial Prolog 21 | programs indeed, and you'll learn a lot about AI along the way. 22 | 23 | \item Clocksin (2003): \textit{Clause and Effect: Prolog Programming 24 | for the Working Programmer}. Springer. Strongly recommended. If you 25 | want a concise practically oriented follow up to \textit{Learn Prolog 26 | Now!} that will really hone your Prolog skills, you can't do better 27 | than this. It explains some interesting theory, but its real strength 28 | is that it is based around a collection of worksheets. Solve the 29 | problems they contain, and you'll soon be flying. 30 | 31 | \item Clocksin and Mellish (1987): \textit{Programming in Prolog}. Springer. 32 | This was one of the earliest, if not the earliest, textbook on Prolog 33 | programming. It won't take you far beyond \textit{Learn Prolog Now!}, but it 34 | is clearly written, and its discussions of DCGs, and of the link between 35 | logic and Prolog, are accessible and worth looking at. 36 | 37 | 38 | \item O'Keefe (1990): \textit{Craft of Prolog}. MIT Press. This is the book 39 | you should read when you're convinced that you know all about Prolog and have 40 | nothing left to learn. Unless you truly are a Prolog guru, you will swiftly 41 | learn that there are far deeper levels of Prolog expertise than you suspected, 42 | and that you still have a great deal to master. Superb. 43 | 44 | \item Sterling (1994): \textit{The Art of Prolog}. MIT Press. In \textit{Learn 45 | Prolog Now!} we don't say much about the abstract idea of logic programming. If 46 | the little we have said has wakened your interest, this is the 47 | book to go for next. Clearly written, it will give you a good grounding in the 48 | basic theory of logic programming, and link it to the practical world of 49 | Prolog. 50 | 51 | \end{itemize} 52 | 53 | 54 | 55 | 56 | 57 | 58 | \subsection*{Applying Prolog in AI and NLP} 59 | 60 | \begin{itemize} 61 | 62 | \item Blackburn and Bos (2005): \textit{Representation and Inference 63 | for Natural Language. A First Course in Computational 64 | Semantics}. CSLI Lecture Notes. Introduces natural language 65 | semantics from a computational perspective using Prolog as the 66 | implementation language. \textit{Learn Prolog Now!} was 67 | originally intended to be an appendix to this book. 68 | 69 | 70 | \item Covington (1994): \textit{Natural Language Processing for Prolog 71 | Programmers}. Prentice-Hall. Solid, well-written book on NLP that uses Prolog 72 | as the implementation language. If you haven't done any NLP before, and want to 73 | put your Prolog to work, this is a good place to start. 74 | 75 | \item Pereira and Shieber (1987): \textit{Prolog and Natural Language 76 | Analysis}. CSLI Lecture Notes. A classic. Several generations of PhD 77 | students have cut their teeth on this one. Required reading. 78 | 79 | \item Reiter (2001): \textit{Knowledge in Action: Logical Foundations for 80 | Specifying and Implementing Dynamical Systems}. MIT Press. This book 81 | examines, extends, and implements the Situation Calculus, a well known AI 82 | formalism for representing and reasoning about changing information. It's an 83 | important book, and may not be completely accessible if you don't have some 84 | theoretical background. But as an example of how Prolog can be put to work, it 85 | takes some beating. 86 | 87 | \item Shoham (1994): \textit{Artificial Intelligence Techniques in 88 | Prolog}. Morgan Kaufman. Discusses and implements a wide range of AI 89 | problem-solving techniques and concepts, including depth-first search, 90 | breadth-first search, best-first search, alpha-beta minimax, forward chaining, 91 | production systems, reasoning with uncertainty, and STRIPS. 92 | 93 | \end{itemize} 94 | -------------------------------------------------------------------------------- /text/appendix2.tex: -------------------------------------------------------------------------------- 1 | 2 | \chapter*{Prolog Environments}\label{Appendix:prologs} 3 | 4 | 5 | Several Prolog environments are available, and probably the best idea 6 | is simply to google what's available. But we list here four of the 7 | more widely used systems. 8 | 9 | \begin{itemize} 10 | 11 | \item \textbf{SWI-Prolog}\\ 12 | A Free Software Prolog environment, licensed under the Lesser GNU public 13 | license. This popular interpreter was developed by Jan 14 | Wielemaker. \\ \url{http://www.swi-prolog.org/} 15 | 16 | \item \textbf{SICStus Prolog}\\ 17 | Industrial strength Prolog environment from the Swedish Institute of 18 | Computer Science.\\ \url{http://www.sics.se/sicstus/} 19 | 20 | \item \textbf{YAP Prolog}\\ 21 | A Prolog compiler developed at the Universidade do Porto and Universidade 22 | Federa do Rio de Janeiro. Free for use in academic environments. \\ 23 | \url{http://www.ncc.up.pt/~vsc/Yap/} 24 | 25 | \item \textbf{Ciao Prolog}\\ 26 | Another Prolog environment available under the GNU public license, 27 | developed at the Universidad Polit\'{e}cnica de Madrid.\\ 28 | \url{http://clip.dia.fi.upm.es/Software/Ciao/} 29 | 30 | \end{itemize} 31 | -------------------------------------------------------------------------------- /text/chap10-pspic1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | %\newcommand{\stelabel}[1]{\parbox[c]{40mm}{\texttt{#1}}} 9 | \newcommand{\stelabel}[1]{\texttt{#1}} 10 | 11 | %\newcommand{\stnode}[1]{\TR{\psframebox{#1}}} 12 | %\newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{#1}\hspace*{-2.5em}} 13 | 14 | \begin{document} 15 | 16 | \pstree[levelsep=1.5cm]{\stnode{?- p(X)}} 17 | { 18 | \pstree[levelsep=1.5cm]{\stnode{?- a(\_G1)}\tlput{\stelabel{X = \_G1}}} 19 | { 20 | \stnode{}\trput{\stelabel{\_G1 = 1}} 21 | } 22 | \pstree{\stnode{?- b(\_G2),c(\_G2),d(\_G2),e(\_G2)}\tlput{\stelabel{X = \_G2}}} 23 | { 24 | \pstree[levelsep=1cm]{\stnode{?- c(1),d(1),e(1)}\tlput{\stelabel{\_G2 = 1}}} 25 | { 26 | \pstree[levelsep=2cm]{\stnode{?- d(1),e(1)}} 27 | {\psset{linestyle=none}\TR{~}\tvput{\huge \dag}} 28 | } 29 | \pstree[levelsep=1cm]{\stnode{?- c(2),d(2),e(2)}\trput{\stelabel{\_G2 = 2}}} 30 | { 31 | \pstree{\stnode{?- d(2),e(2)}} 32 | { 33 | \pstree{\stnode{?- e(2)}} 34 | { 35 | \stnode{} 36 | } 37 | } 38 | } 39 | } 40 | \pstree[levelsep=1.5cm]{\stnode{?- f(\_G3)}\trput{\stelabel{X = \_G3}}} 41 | { 42 | \stnode{}\tlput{\stelabel{\_G3 = 3}} 43 | } 44 | } 45 | 46 | \end{document} 47 | -------------------------------------------------------------------------------- /text/chap10-pspic2.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[2][]{\TR{\psframebox[#1]{#2}}} 8 | \newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{#1}\hspace*{-2.5em}} 9 | 10 | \begin{document} 11 | 12 | \pstree[levelsep=1.5cm]{\stnode[fillstyle=vlines]{{\tt p(X)}}} 13 | { 14 | \pstree[levelsep=1cm]{\stnode{{\tt a(\_G111)}}\tlput{\stelabel{\tt X = \_G111}}} 15 | { 16 | \stnode{}\tlput{\stelabel{\tt \_G111 = 1}} 17 | } 18 | \pstree{\stnode[fillstyle=vlines]{{\tt b(\_G112),c(\_G112), !, d(\_G112),e(\_G112)}}\tlput{\stelabel{\tt X = \_G112}}} 19 | { 20 | \pstree[levelsep=1cm]{\stnode[fillstyle=vlines]{{\tt c(1), !, d(1),e(1)}}\tlput{\stelabel{\tt \_G112 = 1}}} 21 | { 22 | \pstree{\stnode{{\tt !, d(1),e(1)}}} 23 | { 24 | \stnode{{\tt d(1),e(1)}} 25 | } 26 | } 27 | } 28 | } 29 | 30 | \end{document} 31 | -------------------------------------------------------------------------------- /text/chap10-pspic3.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[2][]{\TR{\psframebox[#1]{#2}}} 8 | \newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{#1}\hspace*{-2.5em}} 9 | 10 | \begin{document} 11 | 12 | \pstree[levelsep=1.5cm]{\stnode{{\tt s(X,Y)}}} 13 | { 14 | \pstree[levelsep=1.5cm]{\stnode[fillcolor=red,fillstyle=vlines]{{\tt q(\_G111,\_G112)}}\tlput{\stelabel{\tt X=\_G111, Y=\_G112}}} 15 | { 16 | \pstree{\stnode[fillcolor=red,fillstyle=vlines]{{\tt i(\_G111),!,j(\_G112)}}} 17 | { 18 | \pstree{\stnode{{\tt !,j(\_G112)}}\tlput{\stelabel{\tt \_G111=1}}} 19 | { 20 | \pstree[levelsep=2cm]{\stnode{{\tt j(\_G112)}}} 21 | { 22 | \stnode{}\tlput{\stelabel{\tt \_G112=1}}\strut\hspace{0.5cm}\strut 23 | \stnode{}\tlput{\raisebox{-3ex}{\stelabel{\tt \_G112=2}}}\strut\hspace{0.5cm}\strut 24 | \stnode{}\tlput{\stelabel{\tt \_G112=3}\hspace*{-2.5em}} 25 | } 26 | } 27 | } 28 | } 29 | \stnode{}\tlput{\stelabel{\tt X=0,Y=0}\hspace*{-2em}} 30 | } 31 | 32 | \end{document} 33 | -------------------------------------------------------------------------------- /text/chap10-pspic4.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | %\newcommand{\stelabel}[1]{\parbox[c]{40mm}{\texttt{#1}}} 9 | \newcommand{\stelabel}[1]{\texttt{#1}} 10 | 11 | %\newcommand{\stnode}[1]{\TR{\psframebox{#1}}} 12 | %\newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{#1}\hspace*{-2.5em}} 13 | 14 | \begin{document} 15 | 16 | \pstree[levelsep=1.5cm]{\stnode{?- p(X)}} 17 | { 18 | \pstree[levelsep=1.5cm]{\stnode{?- a(\_G1)}\tlput{\stelabel{X = \_G1}}} 19 | { 20 | \stnode{}\trput{\stelabel{\_G1 = 1}} 21 | } 22 | \pstree{\stnode{?- b(\_G2),c(\_G2),!,d(\_G2),e(\_G2)}\tlput{\stelabel{X = \_G2}}} 23 | { 24 | \pstree[levelsep=1cm]{\stnode{?- c(1),!,d(1),e(1)}\tlput{\stelabel{\_G2 = 1}}} 25 | { 26 | \pstree[levelsep=1cm]{\stnode{?- !, d(1),e(1)}} 27 | {\pstree[levelsep=2cm]{\stnode{?- d(1),e(1)}} 28 | {\psset{linestyle=none}\TR{~}\tvput{\huge \dag}}} 29 | } 30 | \psset{linestyle=dashed}\stnode{$\ldots$}\tvput{\huge $\times$}} 31 | 32 | \psset{linestyle=dashed}\stnode{$\ldots$}\tvput{\huge $\times$} 33 | } 34 | 35 | \end{document} 36 | -------------------------------------------------------------------------------- /text/chap10-pspic5.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | %\newcommand{\stelabel}[1]{\parbox[c]{40mm}{\texttt{#1}}} 9 | \newcommand{\stelabel}[1]{\texttt{#1}} 10 | 11 | 12 | \begin{document} 13 | 14 | \pstree[levelsep=1.5cm]{\stnode{?- s(X,Y)}} 15 | { 16 | \pstree[levelsep=1cm]{\stnode{?- q(\_G4,\_G5)}\tlput{\stelabel{X = \_G4, Y = \_G5}}} 17 | { 18 | \pstree[levelsep=1.5cm]{\stnode{?- i(\_G4),j(\_G5)}} 19 | { 20 | \pstree[levelsep=1.5cm]{\stnode{?- j(\_G5)}\tlput{\stelabel{\_G4 = 1}}} 21 | { 22 | \stnode{\strut\hspace{0.3cm}\strut}\tlput{\stelabel{\_G5 = 1}} 23 | \stnode{\strut\hspace{0.3cm}\strut}\tvput{\stelabel{\_G5 = 2}} 24 | \stnode{\strut\hspace{0.3cm}\strut}\trput{\stelabel{\_G5 = 3}} 25 | } 26 | \pstree[levelsep=2.5cm]{\stnode{?- j(\_G5)}\trput{\stelabel{\_G4 = 2}}} 27 | { 28 | \stnode{\strut\hspace{0.3cm}\strut}\tlput{\stelabel{\_G5 = 1}} 29 | \stnode{\strut\hspace{0.3cm}\strut}\tvput{\stelabel{\_G5 = 2}} 30 | \stnode{\strut\hspace{0.3cm}\strut}\trput{\stelabel{\_G5 = 3}} 31 | } 32 | } 33 | } 34 | %\psset{linestyle=dashed}\stnode{$\ldots$}\tvput{\huge $\times$} 35 | \stnode{\strut\hspace{0.3cm}\strut}\trput{\stelabel{X = 0, Y = 0}} 36 | } 37 | 38 | \end{document} 39 | -------------------------------------------------------------------------------- /text/chap10-pspic6.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | %\newcommand{\stelabel}[1]{\parbox[c]{40mm}{\texttt{#1}}} 9 | \newcommand{\stelabel}[1]{\texttt{#1}} 10 | 11 | 12 | \begin{document} 13 | 14 | \pstree[levelsep=1.3cm]{\stnode{?- s(X,Y)}} 15 | { 16 | \pstree[levelsep=1.3cm]{\stnode{?- q(\_G4,\_G5)}\tlput{\stelabel{X = \_G4, Y = \_G5}}} 17 | { 18 | \pstree[levelsep=1.3cm]{\stnode{?- i(\_G4),!,j(\_G5)}} 19 | { 20 | \pstree[levelsep=1.3cm]{\stnode{?- !,j(\_G5)}\tlput{\stelabel{\_G4 = 1}}} 21 | { 22 | \pstree[levelsep=1.3cm]{\stnode{?- j(\_G5)}} 23 | { 24 | \stnode{\strut\hspace{0.3cm}\strut}\tlput{\stelabel{\_G5 = 1}} 25 | \stnode{\strut\hspace{0.3cm}\strut}\tvput{\stelabel{\_G5 = 2}} 26 | \stnode{\strut\hspace{0.3cm}\strut}\trput{\stelabel{\_G5 = 3}} 27 | } 28 | } 29 | \psset{linestyle=dashed}\stnode{$\ldots$}\tvput{\huge $\times$} 30 | } 31 | } 32 | \stnode{\strut\hspace{0.3cm}\strut}\trput{\stelabel{X = 0, Y = 0}} 33 | } 34 | 35 | \end{document} 36 | -------------------------------------------------------------------------------- /text/chap2-pspic1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | \newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{\texttt{#1}}} 9 | 10 | \begin{document} 11 | 12 | \pstree[levelsep=16mm]{\stnode{?- k(Y)}} 13 | { 14 | \stnode{?- f(\_G34),g(\_G34),h(\_G34)}\tlput{\stelabel{Y = \_G34}} 15 | } 16 | 17 | \end{document} 18 | -------------------------------------------------------------------------------- /text/chap2-pspic2.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | \newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{\texttt{#1}}} 9 | 10 | \begin{document} 11 | 12 | \pstree[levelsep=16mm]{\stnode{?- k(Y)}} 13 | { 14 | \pstree{\stnode{?- f(\_G34),g(\_G34),h(\_G34)}\tlput{\stelabel{Y = \_G34}}} 15 | { 16 | \stnode{{\tt ?- g(a),h(a)}}\tlput{\stelabel{\_G34 = a}} 17 | } 18 | } 19 | 20 | \end{document} 21 | -------------------------------------------------------------------------------- /text/chap2-pspic3.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | 8 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 9 | \newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{\texttt{#1}}} 10 | 11 | \begin{document} 12 | 13 | \pstree[levelsep=16mm]{\stnode{?- k(Y)}} 14 | { 15 | \pstree{\stnode{?- f(\_G34),g(\_G34),h(\_G34)}\tlput{\stelabel{X = \_G34}}} 16 | { 17 | \pstree[levelsep=1.5cm]{\stnode{?- g(a),h(a)}\tlput{\stelabel{\_G34 = a}}} 18 | { 19 | \stnode{?- h(a)} 20 | } 21 | } 22 | } 23 | 24 | \end{document} 25 | -------------------------------------------------------------------------------- /text/chap2-pspic4.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | \newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{\texttt{#1}}} 9 | 10 | \begin{document} 11 | 12 | \pstree[levelsep=16mm]{\stnode{?- k(Y)}} 13 | { 14 | \pstree{\stnode{?- f(\_G34),g(\_G34),h(\_G34)}\tlput{\stelabel{Y = \_G34}}} 15 | { 16 | \pstree{\stnode{?- g(a),h(a)}\tlput{\stelabel{\_G34 = a}}} 17 | { 18 | 19 | \pstree{\stnode{?- h(a)}} 20 | {\psset{linestyle=none}\TR{~}\tvput{\huge \dag} 21 | } 22 | } 23 | \pstree{\stnode{?- g(b),h(b)}\trput{\stelabel{\_G34 = b}}} 24 | { 25 | \pstree{\stnode{?- h(b)}} 26 | { 27 | \stnode{\strut\hspace{0.4cm}\strut} 28 | } 29 | } 30 | } 31 | } 32 | 33 | \end{document} 34 | -------------------------------------------------------------------------------- /text/chap2-pspic5.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 7 | \newcommand{\stelabel}[1]{\texttt{#1}} 8 | 9 | \begin{document} 10 | 11 | \pstree[levelsep=18mm]{\stnode{?- jealous(X,Y)}} 12 | { 13 | \pstree{\stnode{?- loves(\_G5,\_G6),loves(\_G7,\_G6)} 14 | \tlput{\stelabel{\parbox{2cm}{X = \_G5,\\Y = \_G7}}}} 15 | { 16 | \pstree[levelsep=12mm]{\stnode{?- loves(\_G7,mia)} 17 | \tlput{\stelabel{\parbox{30mm}{\_G5 = vincent,\\\_G6 = mia}}}} 18 | { 19 | \stnode{\strut\hspace{0.3cm}\strut}\tlput{\stelabel{\_G7 = vincent}} 20 | \stnode{\strut\hspace{0.3cm}\strut}\trput{\stelabel{\_G7 = marcellus}} 21 | } 22 | \pstree[levelsep=28mm]{\stnode{?- loves(\_G7,mia)} 23 | \trput{\stelabel{\parbox{30mm}{\_G5 = marcellus,\\\_G6 = mia}}}} 24 | { 25 | \stnode{\strut\hspace{0.3cm}\strut}\tlput{\stelabel{\_G7 = vincent}} 26 | \stnode{\strut\hspace{0.3cm}\strut}\trput{\stelabel{\_G7 = marcellus}} 27 | } 28 | } 29 | } 30 | 31 | \end{document} 32 | -------------------------------------------------------------------------------- /text/chap3-pspic1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 7 | \newcommand{\stelabel}[1]{\texttt{#1}} 8 | 9 | \begin{document} 10 | 11 | {\small 12 | \pstree[levelsep=16mm,treesep=5mm]{\stnode{?- descend(anne,donna)}} 13 | { 14 | \pstree{\stnode{?- child(anne,donna)}} 15 | {\psset{linestyle=none}\TR{~}\tvput{\huge \dag}} 16 | 17 | \pstree{\stnode{?- \parbox[t]{31mm}{child(anne,\_G43),\\ descend(\_G43,donna)}}} 18 | { 19 | \pstree{\stnode{?- descend(bridget,donna)}\tlput{\stelabel{\_G43 = bridget}}} 20 | { 21 | \pstree{\stnode{?- child(bridget,donna)}} 22 | {\psset{linestyle=none}\TR{~}\tvput{\huge \dag}} 23 | \pstree{\stnode{?- \parbox[t]{36mm}{child(bridget,\_G44),\\ descend(\_G44,donna)}}} 24 | { 25 | \pstree{\stnode{?- descend(caroline,donna)}\tlput{\stelabel{\_G44 = caroline}}} 26 | { 27 | \pstree{\stnode{?- child(caroline,donna)}} 28 | { 29 | \stnode{} 30 | } 31 | } 32 | } 33 | } 34 | } 35 | } 36 | } 37 | \end{document} 38 | -------------------------------------------------------------------------------- /text/chap3-pspic2.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 6 | \newcommand{\stelabel}[1]{\psframebox[fillstyle=solid,fillcolor=white,linestyle=none]{\texttt{#1}}} 7 | 8 | \begin{document} 9 | 10 | \pstree{\stnode{?- add(succ(succ(succ(0))), succ(succ(0)), R)}} 11 | { 12 | \pstree{\stnode{?- add(succ(succ(0)), succ(succ(0)), \_G648)}\tlput{\stelabel{R = succ(\rnode{A1}{\_G648})}}} 13 | { 14 | \pstree{\stnode{?- add(succ(0), succ(succ(0)), \_G650)}\tlput{\stelabel{\rnode{A2}{\_G648} = succ(\rnode{B1}{\_G650})}}} 15 | { 16 | \pstree{\stnode{?- add(0, succ(succ(0)), \_G652)}\tlput{\stelabel{\rnode{B2}{\_G650} = succ(\rnode{C1}{\_G652})}}} 17 | { 18 | \stnode{}\tlput{\stelabel{\rnode{C2}{\_G652} = succ(succ(0))}} 19 | } 20 | } 21 | } 22 | } 23 | \nccurve[nodesep=3pt,linestyle=dotted,dotsep=1pt,angleA=-90,angleB=90]{<->}{A1}{A2} 24 | \nccurve[nodesep=3pt,linestyle=dotted,dotsep=1pt,angleA=-90,angleB=90]{<->}{B1}{B2} 25 | \nccurve[nodesep=3pt,linestyle=dotted,dotsep=1pt,angleA=-90,angleB=90]{<->}{C1}{C2} 26 | 27 | \end{document} 28 | -------------------------------------------------------------------------------- /text/chap3-pspic3.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \begin{document} 8 | 9 | \rnode{X1}{X}\hspace{2cm}\rnode{Y1}{Y}\hspace{3cm} 10 | \rnode{X2}{X}\hspace{1.5cm}\rnode{Z2}{Z}\hspace{1.5cm}\rnode{Y2}{Y} 11 | \nccurve[nodesep=3pt,angleA=45,angleB=150,ncurv=0.5]{->}{X1}{Y1}\lput{:U}{\rput[l]{N}(0,0.4){just\_ate}} 12 | \nccurve[nodesep=3pt,linestyle=dotted,dotsep=3pt,angleA=-45,angleB=-150,ncurv=0.5]{->}{X1}{Y1}\lput{:U}{\rput[l]{N}(0,-0.4){is\_digesting}} 13 | \nccurve[nodesep=3pt,linestyle=dotted,dotsep=3pt,angleA=-45,angleB=-150,ncurv=0.5]{->}{X2}{Y2}\lput{:U}{\rput[l]{N}(0,-0.4){is\_digesting}} 14 | \nccurve[nodesep=3pt,angleA=45,angleB=150,ncurv=0.5]{->}{X2}{Z2}\lput{:U}{\rput[l]{N}(0,0.4){just\_ate}} 15 | \nccurve[nodesep=3pt,angleA=45,angleB=150,ncurv=0.5]{->}{Z2}{Y2}\lput{:U}{\rput[l]{N}(0,0.4){is\_digesting}} 16 | 17 | \end{document} 18 | -------------------------------------------------------------------------------- /text/chap6-pspic1.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{pstricks,pst-tree,pst-node} 3 | 4 | \pagestyle{empty} 5 | 6 | 7 | \newcommand{\stnode}[1]{\TR{\psframebox{\texttt{#1}}}} 8 | \newcommand{\stelabel}[1]{\parbox[c]{40mm}{\texttt{#1}}} 9 | 10 | 11 | \begin{document} 12 | 13 | \pstree{\stnode{?- append([a,b,c],[1,2,3],\_G518)}} 14 | { 15 | \pstree{\stnode{?- append([b,c],[1,2,3],\_G587)}\tlput{\stelabel{\_G518 = [a|\_G587]}}} 16 | { 17 | \pstree[levelsep=26mm]{\stnode{?- append([c],[1,2,3],\_G590)}\tlput{\stelabel{\_G587 = [b|\_G590]\\\_G518 = [a,b|\_G590]}}} 18 | { 19 | \pstree[levelsep=26mm]{\stnode{?- append([],[1,2,3],\_G593)}\tlput{\stelabel{\_G590 = [c|\_G593]\\\_G587 = [b,c|\_G593]\\\_G518 = [a,b,c|\_G593]}}} 20 | { 21 | \stnode{}\tlput{\stelabel{\_G593 = [1,2,3]\\\_G590 = [c,1,2,3]\\\_G587 = [b,c,1,2,3]\\\_G518 = [a,b,c,1,2,3]}} 22 | } 23 | } 24 | } 25 | } 26 | 27 | \end{document} 28 | -------------------------------------------------------------------------------- /text/chapter1.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter1.tex -------------------------------------------------------------------------------- /text/chapter10.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter10.tex -------------------------------------------------------------------------------- /text/chapter11.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter11.tex -------------------------------------------------------------------------------- /text/chapter12.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter12.tex -------------------------------------------------------------------------------- /text/chapter2.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter2.tex -------------------------------------------------------------------------------- /text/chapter3.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter3.tex -------------------------------------------------------------------------------- /text/chapter4.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter4.tex -------------------------------------------------------------------------------- /text/chapter5.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter5.tex -------------------------------------------------------------------------------- /text/chapter6.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter6.tex -------------------------------------------------------------------------------- /text/chapter7.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter7.tex -------------------------------------------------------------------------------- /text/chapter8.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter8.tex -------------------------------------------------------------------------------- /text/chapter9.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/chapter9.tex -------------------------------------------------------------------------------- /text/crosswd2.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: crosswd2.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:11:22 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 150 140 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0.5 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | /col32 {0.000 0.000 0.010 srgb} bind def 46 | 47 | end 48 | save 49 | newpath 0 140 moveto 0 0 lineto 150 0 lineto 150 140 lineto closepath clip newpath 50 | -139.5 379.3 translate 51 | 1 -1 scale 52 | 53 | /cp {closepath} bind def 54 | /ef {eofill} bind def 55 | /gr {grestore} bind def 56 | /gs {gsave} bind def 57 | /sa {save} bind def 58 | /rs {restore} bind def 59 | /l {lineto} bind def 60 | /m {moveto} bind def 61 | /rm {rmoveto} bind def 62 | /n {newpath} bind def 63 | /s {stroke} bind def 64 | /sh {show} bind def 65 | /slc {setlinecap} bind def 66 | /slj {setlinejoin} bind def 67 | /slw {setlinewidth} bind def 68 | /srgb {setrgbcolor} bind def 69 | /rot {rotate} bind def 70 | /sc {scale} bind def 71 | /sd {setdash} bind def 72 | /ff {findfont} bind def 73 | /sf {setfont} bind def 74 | /scf {scalefont} bind def 75 | /sw {stringwidth} bind def 76 | /tr {translate} bind def 77 | /tnt {dup dup currentrgbcolor 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 80 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 81 | bind def 82 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 83 | 4 -2 roll mul srgb} bind def 84 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 85 | /$F2psEnd {$F2psEnteredState restore end} def 86 | 87 | $F2psBegin 88 | 10 setmiterlimit 89 | 0 slj 0 slc 90 | 0.06000 0.06000 sc 91 | % 92 | % Fig objects follow 93 | % 94 | % 95 | % here starts figure with depth 100 96 | % Polyline 97 | 10.000 slw 98 | n 2700 4500 m 4800 4500 l 4800 4800 l 2700 4800 l 99 | cp gs col-1 10.00 shd ef gr gs col0 s gr 100 | % Polyline 101 | n 2700 5100 m 4800 5100 l 4800 5400 l 2700 5400 l 2700 5250 l 102 | cp gs col-1 10.00 shd ef gr gs col0 s gr 103 | % Polyline 104 | n 2700 5700 m 4800 5700 l 4800 6000 l 2700 6000 l 2700 5775 l 105 | cp gs col-1 10.00 shd ef gr gs col0 s gr 106 | % Polyline 107 | n 3000 4200 m 3000 6300 l 3300 6300 l 3300 4200 l 3075 4200 l 108 | cp gs col-1 10.00 shd ef gr gs col0 s gr 109 | % Polyline 110 | n 3600 4200 m 3600 6300 l 3900 6300 l 3900 4200 l 3750 4200 l 111 | cp gs col-1 10.00 shd ef gr gs col0 s gr 112 | % Polyline 113 | n 4200 4200 m 4200 6300 l 4500 6300 l 4500 4200 l 114 | cp gs col-1 10.00 shd ef gr gs col0 s gr 115 | % Polyline 116 | n 3000 4500 m 117 | 3300 4500 l gs col31 1.00 shd ef gr gs col0 s gr 118 | % Polyline 119 | n 3600 4500 m 120 | 3900 4500 l gs col31 1.00 shd ef gr gs col0 s gr 121 | % Polyline 122 | n 4200 4500 m 123 | 4500 4500 l gs col31 1.00 shd ef gr gs col0 s gr 124 | % Polyline 125 | n 3000 4800 m 126 | 3300 4800 l gs col31 1.00 shd ef gr gs col0 s gr 127 | % Polyline 128 | n 3600 4800 m 129 | 4500 4800 l gs col31 1.00 shd ef gr gs col0 s gr 130 | % Polyline 131 | n 3000 5100 m 132 | 4500 5100 l gs col31 1.00 shd ef gr gs col0 s gr 133 | % Polyline 134 | n 3000 5400 m 135 | 4500 5400 l gs col31 1.00 shd ef gr gs col0 s gr 136 | % Polyline 137 | n 3000 5700 m 138 | 4500 5700 l gs col31 1.00 shd ef gr gs col0 s gr 139 | % Polyline 140 | n 3000 6000 m 141 | 4500 6000 l gs col31 1.00 shd ef gr gs col0 s gr 142 | /Times-Roman ff 180.00 scf sf 143 | 2325 4725 m 144 | gs 1 -1 sc (H1) col0 sh gr 145 | /Times-Roman ff 180.00 scf sf 146 | 2325 5325 m 147 | gs 1 -1 sc (H2) col0 sh gr 148 | /Times-Roman ff 180.00 scf sf 149 | 2325 5925 m 150 | gs 1 -1 sc (H3) col0 sh gr 151 | /Times-Roman ff 180.00 scf sf 152 | 3075 4125 m 153 | gs 1 -1 sc (V1) col0 sh gr 154 | /Times-Roman ff 180.00 scf sf 155 | 3675 4125 m 156 | gs 1 -1 sc (V2) col0 sh gr 157 | /Times-Roman ff 180.00 scf sf 158 | 4275 4125 m 159 | gs 1 -1 sc (V3) col0 sh gr 160 | % here ends figure; 161 | $F2psEnd 162 | rs 163 | showpage 164 | -------------------------------------------------------------------------------- /text/dolls.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: dolls.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:15:57 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 183 200 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 200 moveto 0 0 lineto 183 0 lineto 183 200 lineto closepath clip newpath 49 | -88.7 289.3 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0 slj 0 slc 89 | 0.06000 0.06000 sc 90 | % 91 | % Fig objects follow 92 | % 93 | % 94 | % here starts figure with depth 0 95 | % Arc 96 | 15.000 slw 97 | n 2400.0 2118.8 468.8 163.7 16.3 arc 98 | gs col0 s gr 99 | 100 | % Polyline 101 | n 1500 2700 m 102 | 1725 4800 l gs col0 s gr 103 | % Polyline 104 | n 3300 2700 m 105 | 3075 4800 l gs col0 s gr 106 | % Polyline 107 | n 1500 2700 m 108 | 1950 2250 l gs col0 s gr 109 | % Polyline 110 | n 2850 2250 m 111 | 3300 2700 l gs col0 s gr 112 | % Polyline 113 | n 1725 4800 m 114 | 3075 4800 l gs col0 s gr 115 | % Arc 116 | n 2402.5 2349.8 383.8 163.8 16.2 arc 117 | gs col0 s gr 118 | 119 | % Polyline 120 | n 1666 2825 m 121 | 1850 4544 l gs col0 s gr 122 | % Polyline 123 | n 3139 2825 m 124 | 2955 4544 l gs col0 s gr 125 | % Polyline 126 | n 1666 2825 m 127 | 2034 2457 l gs col0 s gr 128 | % Polyline 129 | n 2771 2457 m 130 | 3139 2825 l gs col0 s gr 131 | % Polyline 132 | n 1850 4544 m 133 | 2955 4544 l gs col0 s gr 134 | % Arc 135 | n 2400.0 2829.0 231.0 163.9 16.1 arc 136 | gs col0 s gr 137 | 138 | % Polyline 139 | n 1957 3115 m 140 | 2068 4148 l gs col0 s gr 141 | % Polyline 142 | n 2843 3115 m 143 | 2732 4148 l gs col0 s gr 144 | % Polyline 145 | n 1957 3115 m 146 | 2178 2893 l gs col0 s gr 147 | % Polyline 148 | n 2622 2893 m 149 | 2843 3115 l gs col0 s gr 150 | % Polyline 151 | n 2068 4148 m 152 | 2732 4148 l gs col0 s gr 153 | % Arc 154 | n 2397.0 2563.2 308.2 163.8 16.2 arc 155 | gs col0 s gr 156 | 157 | % Polyline 158 | n 1805 2947 m 159 | 1952 4330 l gs col0 s gr 160 | % Polyline 161 | n 2989 2947 m 162 | 2842 4330 l gs col0 s gr 163 | % Polyline 164 | n 1805 2947 m 165 | 2101 2649 l gs col0 s gr 166 | % Polyline 167 | n 2693 2649 m 168 | 2989 2947 l gs col0 s gr 169 | % Polyline 170 | n 1952 4330 m 171 | 2842 4330 l gs col0 s gr 172 | % Polyline 173 | gs clippath 174 | 2476 1728 m 2498 1846 l 2780 1793 l 2534 1779 l 2758 1675 l cp 175 | eoclip 176 | n 2502 1785 m 177 | 3375 1620 l gs col0 s gr gr 178 | 179 | % arrowhead 180 | n 2758 1675 m 2534 1779 l 2780 1793 l 2758 1675 l cp gs 0.00 setgray ef gr col0 s 181 | % Polyline 182 | gs clippath 183 | 2476 2056 m 2496 2174 l 2779 2127 l 2533 2108 l 2759 2008 l cp 184 | eoclip 185 | n 2501 2113 m 186 | 3375 1965 l gs col0 s gr gr 187 | 188 | % arrowhead 189 | n 2759 2008 m 2533 2108 l 2779 2127 l 2759 2008 l cp gs 0.00 setgray ef gr col0 s 190 | % Polyline 191 | gs clippath 192 | 2431 2371 m 2446 2490 l 2731 2453 l 2486 2425 l 2716 2334 l cp 193 | eoclip 194 | n 2454 2429 m 195 | 3360 2310 l gs col0 s gr gr 196 | 197 | % arrowhead 198 | n 2716 2334 m 2486 2425 l 2731 2453 l 2716 2334 l cp gs 0.00 setgray ef gr col0 s 199 | % Polyline 200 | gs clippath 201 | 2425 2692 m 2442 2811 l 2726 2772 l 2481 2746 l 2710 2653 l cp 202 | eoclip 203 | n 2449 2750 m 204 | 3360 2625 l gs col0 s gr gr 205 | 206 | % arrowhead 207 | n 2710 2653 m 2481 2746 l 2726 2772 l 2710 2653 l cp gs 0.00 setgray ef gr col0 s 208 | /Times-Bold ff 270.00 scf sf 209 | 3480 1695 m 210 | gs 1 -1 sc (katarina) col0 sh gr 211 | /Times-Bold ff 270.00 scf sf 212 | 3495 2055 m 213 | gs 1 -1 sc (olga) col0 sh gr 214 | /Times-Bold ff 270.00 scf sf 215 | 3465 2370 m 216 | gs 1 -1 sc (natasha) col0 sh gr 217 | /Times-Bold ff 270.00 scf sf 218 | 3480 2715 m 219 | gs 1 -1 sc (irina) col0 sh gr 220 | % here ends figure; 221 | $F2psEnd 222 | rs 223 | showpage 224 | -------------------------------------------------------------------------------- /text/frontmatter.tex: -------------------------------------------------------------------------------- 1 | 2 | \thispagestyle{empty} 3 | \def\sqz{\hskip0pt minus1cm} 4 | \vspace*{2cm} 5 | 6 | \begin{center} 7 | {\jlctitleA T\sqz e\sqz x\sqz t\sqz s i\sqz n}\\[3ex] 8 | {\jlctitleA C\sqz o\sqz m\sqz p\sqz u\sqz t\sqz i\sqz n\sqz g}\\[3ex] 9 | {\jlctitleB Volume 7}\\[18ex] 10 | 11 | {\jlctitleC L\sqz e\sqz a\sqz r\sqz n P\sqz r\sqz o\sqz l\sqz o\sqz g N\sqz o\sqz w\sqz !} 12 | 13 | \end{center} 14 | \newpage\thispagestyle{empty} 15 | \newpage\thispagestyle{empty} 16 | 17 | \mbox{} 18 | \vfill 19 | 20 | \noindent {\sf Volume 1}\\ 21 | {\sf Programming Languages and Semantics}\\ 22 | {\sf Maribel Fernandez}\\[1ex] 23 | {\sf Volume 2}\\ 24 | {\sf An Introduction to Lambda Calculus for Computer Scientists}\\ 25 | {\sf Chris Hankin}\\[1ex] 26 | {\sf Volume 3}\\ 27 | {\sf Logical Reasoning: A First Course}\\ 28 | {\sf Rob Nederpelt and Fairouz Kamareddine}\\[1ex] 29 | {\sf Volume 4}\\ 30 | {\sf The Haskell Road to Logic, Maths and Programming}\\ 31 | {\sf Kees Doets and Jan van Eijck}\\[1ex] 32 | {\sf Volume 5}\\ 33 | {\sf Bridges from Classical to Nonmonotonic Reasoning}\\ 34 | {\sf David Makinson}\\[1ex] 35 | {\sf Volume 6}\\ 36 | {\sf Automata and Dictionaries}\\ 37 | {\sf Denis Maurel and Franz Guenthner}\\[1ex] 38 | {\sf Volume 7}\\ 39 | {\sf Learn Prolog Now!}\\ 40 | {\sf Patrick Blackburn, Johan Bos and Kristina Striegniz}\\[1ex] 41 | 42 | \noindent {\sf Texts in Computing Series Editor}\\ 43 | {\sf Ian Mackie \hfill ian.mackie@kcl.ac.uk}\\ 44 | 45 | \newpage 46 | \thispagestyle{empty} 47 | 48 | 49 | \begin{center} 50 | \vspace*{4cm} 51 | {\jlctitleC L\sqz e\sqz a\sqz r\sqz n P\sqz r\sqz o\sqz l\sqz o\sqz g N\sqz o\sqz w\sqz !}\\[16ex] 52 | {\jlctitleB Patrick Blackburn}\\[3ex] 53 | {\jlctitleB Johan Bos}\\[3ex] {\jlctitleB Kristina Striegnitz} 54 | \end{center} 55 | 56 | 57 | \newpage\thispagestyle{empty} 58 | \mbox{} 59 | \vspace*{3in} 60 | 61 | \vfill 62 | \noindent \copyright ~{\sf Individual author and King's College 2006. 63 | All rights reserved.}\\[3ex] 64 | {\sf ISBN 1-904987-17-6}\\ 65 | \noindent {\bf \sf College Publications}\\ 66 | {\sf Scientific Director: Dov Gabbay}\\ 67 | {\sf Managing Director: Jane Spurr}\\ 68 | {\sf Department of Computer Science}\\ 69 | {\sf Strand, London WC2R 2LS, UK}\\ 70 | %{\sf kcp@dcs.kcl.ac.uk}\\ 71 | [2ex] 72 | \noindent 73 | {\sf Cover design by Richard Fraser, www.avalonarts.co.uk}\\ 74 | {\sf Printed by Lightning Source, Milton Keynes, UK}\\[.5ex] 75 | %{\sf Distributed by King's College Publications, UK}\\ %[1ex] 76 | 77 | 78 | \noindent \hrulefill\\ 79 | \noindent \footnotesize{\sf All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior permission, in writing, from the publisher.} 80 | 81 | 82 | -------------------------------------------------------------------------------- /text/introduction.tex: -------------------------------------------------------------------------------- 1 | 2 | \chapter*{Introduction}\label{INTRODUCTION} 3 | 4 | First off, what is Prolog? It's a programming language, but a rather 5 | unusual one. ``Prolog'' is short for ``Programming with Logic'', and 6 | though the link between logic and Prolog is not completely 7 | straightforward, it is this link that gives Prolog its special 8 | character. At the heart of Prolog lies a beautiful idea: don't tell 9 | the computer what to do, simply describe situations of interest. Where 10 | does the computation come in? When we ask questions. Prolog enables 11 | the computer to logically deduce new facts about the situations we 12 | describe, and gives its deductions back to us as answers. 13 | 14 | This has a number of consequences. First, a practical one: if you are 15 | an experienced programmer, Prolog is likely to take you by 16 | surprise. It requires a different mindset. You have to learn to see 17 | computational problems from a different perspective. To use the 18 | standard terminology, you have to learn to think 19 | \textit{declaratively}, rather than \textit{procedurally}. This can 20 | be challenging, but it's also a lot of fun. 21 | 22 | A second consequence of Prolog's ``say what the problem \textit{is}, 23 | rather than how to solve it'' stance is that Prolog is a very 24 | high-level language. As will become apparent, Prolog enables you to 25 | describe some highly abstract things (for example, the syntactic 26 | structure of English) extremely succinctly. Moreover, these 27 | descriptions really are programs: they will do real work for us if we 28 | ask the right questions. For example, having described the syntactic 29 | structure of English, we can ask Prolog whether particular sentences 30 | are grammatical or not. Prolog will tell us, and if we ask the right 31 | question, will even give us a grammatical analysis. 32 | 33 | Prolog's ability to describe complex situations succinctly means that 34 | it is good for rapid prototyping. That is, if you have a good idea, 35 | and want to get a working program that embodies it, Prolog is often an 36 | excellent choice. Ideas become computational reality fast with Prolog, 37 | at least for some applications. Which applications? Those which 38 | depend on getting to grips with rich structure. Prolog application 39 | areas include computational linguistics (or natural languages 40 | processing as it is often called), Artificial Intelligence (AI), 41 | expert systems, molecular biology, and the semantic web. Where there 42 | is structure to be described, or knowledge to be represented, Prolog 43 | is likely to come into its own. 44 | 45 | Prolog is not a perfect language, and it's not suitable for 46 | everything. If you need to do serious text manipulation, go for Perl. 47 | If you need tight control over memory, go for C. If you want a 48 | mathematically elegant language that you can reason about easily, go 49 | for Caml, Haskell, or a clean Lisp dialect (such as Scheme). But no 50 | language is good for everything, and those that try (remember Ada?) 51 | often fall by the wayside. As we have just said, Prolog is a natural 52 | choice for knowledge-rich tasks, and there are a number of good 53 | reasons for learning it. If you are an experienced programmer, we 54 | think you will enjoy learning Prolog simply because it is so 55 | different; thinking declaratively, or almost declaratively, can send 56 | your brain in interesting new directions. And if you have little or 57 | no programing experience, and maybe aren't even sure if you like 58 | computers or not, then there are excellent reasons for choosing Prolog 59 | as your first language. Because it is so high-level, you 60 | get to do interesting things fast, without getting bogged down in 61 | tedious preparatory work. Moreover, you will swiftly learn about a 62 | number of fundamental programming concepts, notably recursion and 63 | recursive data structures, concepts that will be useful if you later 64 | study other languages. Finally, the link with logic adds an intriguing 65 | intellectual dimension to the learning process. 66 | 67 | Where does Prolog come from? It originated in Marseilles, in the south 68 | of France. Alain Colmerauer and Philippe Roussel devised and 69 | implemented the first Prolog interpreter in 1972. One of the earliest 70 | versions was partially implemented in Fortran, and partially in Prolog 71 | itself. An interesting mixture: it would be hard to find two languages 72 | that differ more widely than the numerically oriented, non-recursive, 73 | imperative scientific programming language Fortran, and the 74 | symbolically oriented, recursive, declarative Prolog. A few 75 | years later, Robert Kowalski, who had worked with the Marseilles team 76 | in 1971 and 1972, published his book \textit{Logic for Problem 77 | Solving}% 78 | \footnote{\textit{Logic for Problem Solving}, R. Kowalski, 79 | Elsevier/North-Holland, 1979.} which put the idea of logic 80 | programming firmly on the intellectual agenda. Another big step was 81 | taken in Edinburgh in 1977 with David Warren's implementation of 82 | the DEC 10 compiler.% 83 | \footnote{David H. D. Warren, \textit{Applied Logic --- Its Use and 84 | Implementation as a Programming Tool}, PhD thesis, University of 85 | Edinburgh. Scotland, 1977.} This implementation, which could compete 86 | with (and sometimes surpass) state of the art Lisp implementations in 87 | terms of efficiency, turned Prolog from an academic curiosity into a 88 | serious programming language. Interesting work soon followed. For 89 | example, in a classic paper, Pereira and Warren showed that Prolog's 90 | built-in mechanism for handling Definite Clause Grammars (DCGs) was a 91 | natural way of treating certain tasks in natural language processing.% 92 | \footnote{ 93 | ``Definite clause grammars for language 94 | analysis --- a survey of the formalism and a comparison with augmented transition 95 | networks'', F. Pereira and D. H. D. Warren, 96 | \textit{Journal of Artificial Intelligence}, 13(3):231--278, 1980.} 97 | 98 | Since then, Prolog has grown in popularity, particularly in Europe and 99 | Japan (in the United States, work on AI has tended to be Lisp-based). 100 | Prolog is, was, and always will be, a niche language. But the niche it 101 | occupies is fascinating. 102 | 103 | \subsection*{How to get the most out of this book} 104 | 105 | What we have said about Prolog so far has been high-level and 106 | abstract. We are now going to change gears. The approach taken to 107 | teaching Prolog in this book is \textit{not} abstract, and is 108 | certainly \textit{not} driven by high-level ideas (such as the link 109 | with logic). In fact, it's resolutely down to earth. We try to teach 110 | Prolog as concretely as possible. We've just told you why Prolog is 111 | not just another programming language, but we're going to teach it as 112 | if it was. 113 | 114 | Why? Quite simply, because we think that's the best approach for a 115 | first course. Programming in Prolog is a practical skill. There are 116 | concrete things that simply have to be learned, and we strongly 117 | believe that you just have to get in there and learn them as fast as 118 | possible. This does not mean that we find the abstract side of Prolog 119 | (and more generally, logic programming) unimportant or 120 | uninteresting. However (unless you already have a good theoretical 121 | background) these deeper ideas take time to emerge clearly and be 122 | absorbed. In the meantime, you should be getting on with mastering the 123 | nuts and bolts. 124 | 125 | To put it another way, we think that learning a programming language 126 | (any programming language, not just Prolog) is a lot like learning a 127 | foreign language. And what is the most important part of learning a 128 | foreign language? Actually \textit{using} it, actually putting it to 129 | work, actually trying it out. Sure, reflecting on the beauty of the 130 | language is pleasant, but at the end of the day, what really counts is 131 | the time you spend on mastering the mechanics. 132 | 133 | This attitude has strongly influenced the way \textit{Learn Prolog 134 | Now!} is written. In particular, as you will see, each chapter is 135 | divided into three parts. First comes the text. Next come a number 136 | of exercises. Finally there is what we call the practical session. 137 | Now, we cannot emphasise the following point too strongly: 138 | \textit{the practical sessions are the most important part of the 139 | book}. It is utterly imperative that you sit down, fire up a Prolog 140 | interpreter, and work through these sessions. Actually, just doing 141 | that is nowhere near enough. If you really want to master Prolog, 142 | you need to try out a lot more than is asked of you in these 143 | sessions. But we believe these sessions contain enough to put you on 144 | the right track. 145 | 146 | Gaining practical experience with a programming language is always 147 | important, but, in our opinion, it is even more important than usual 148 | with Prolog. Why? Because Prolog is deceptively easy to 149 | understand. It's a small language (there are not a lot of constructs 150 | to learn) and the basic ideas are beautiful in their simplicity. It is 151 | dangerously easy to smile, relax, and say ```Hey! I get it!''. Easy, 152 | but wrong. The basic ideas interact in subtle ways, and without 153 | \textit{lots} of practical experience you will be lost. We have had 154 | many (very bright) students who thought they understood it, didn't put 155 | in the effort on the practical side --- and who later found themselves 156 | scrambling to keep up. Prolog is subtle. You need to put in the hours 157 | if you want to master it. 158 | 159 | \medskip 160 | 161 | Summing up, \textit{Learn Prolog Now} is a practically oriented 162 | introduction to the central features of Prolog. It won't teach you 163 | everything, but if you make it to the end you'll have a good grasp of 164 | the basics, and will have caught a glimpse of what logic programming is 165 | about. Enjoy! 166 | 167 | -------------------------------------------------------------------------------- /text/kcp-template.tex: -------------------------------------------------------------------------------- 1 | \documentclass{book} 2 | 3 | \usepackage{makeidx,named,amssymb,kcp,kcp-texts} 4 | %\usepackage{jsinputs} 5 | %\usepackage{url,itemlist,named} 6 | 7 | %\usepackage{a4wide} 8 | 9 | \input{pst-tree} 10 | \input{pst-node} 11 | 12 | \def\rmdefault{ptm} 13 | \def\bfdefault{b} 14 | 15 | \newcommand{\sfive}{{\bf S5}} 16 | \renewcommand{\proves}{\mid\!\sim } 17 | \makeindex 18 | 19 | \newcommand\volume{5} 20 | \newcommand\isbn{1-904987-00-1} 21 | \newcommand\kcpAuthor{David Makinson} 22 | \newcommand\kcpInst{King's College London} 23 | 24 | \newcommand\TitleLineOne{B\sqz r\sqz i\sqz d\sqz g\sqz e\sqz s f\sqz 25 | r\sqz o\sqz m C\sqz l\sqz a\sqz s\sqz s\sqz i\sqz c\sqz a\sqz l} 26 | 27 | \newcommand\TitleLineTwo{t\sqz o} 28 | 29 | \newcommand\TitleLineThree{N\sqz o\sqz n\sqz m\sqz o\sqz n\sqz 30 | o\sqz t\sqz o\sqz n\sqz i\sqz c L\sqz o\sqz g\sqz i\sqz c} 31 | 32 | 33 | \begin{document} 34 | \thispagestyle{empty} 35 | 36 | \kcpfrontmatter 37 | 38 | \pagenumbering{roman} 39 | \setcounter{page}{5} 40 | \tableofcontents 41 | 42 | \chapter*{Preface} 43 | \addcontentsline{toc}{chapter}{Preface} 44 | \markboth{PREFACE}{PREFACE} 45 | 46 | 47 | \section*{Who are we writing for?} 48 | 49 | This book is directed to all those who have heard of nonmonotonic 50 | reasoning and would like to get a better idea of what it is all 51 | about. What are its driving ideas? In what ways does it differ from 52 | classical logic? How does it relate to probability? More generally, 53 | how does it behave and how can it be used? We will try to answer these 54 | questions as clearly as possible, without undue technicality on the 55 | one hand, nor vagueness or hand waving on the other. 56 | 57 | \section*{What does the reader need to know already?} 58 | 59 | Tackling a subject such as this does require a minimal background, and 60 | in honesty we must make it clear from the beginning what is needed. To 61 | those without any grounding in classical logic at all, who may out of 62 | curiosity have picked up the volume, we say: put it down, and go to 63 | square one. Get the rudiments of classical propositional logic (alias 64 | truth-functional logic) under your belt, and then come back. Otherwise 65 | you will be like someone trying to learn about algebra before knowing 66 | any arithmetic, counterpoint without sol-fa, or style without the 67 | elements of grammar. 68 | 69 | 70 | 71 | \section*{Main themes} 72 | 73 | From the outside, nonmonotonic logic is often seen as a rather 74 | mysterious affair. Even from the inside, it can appear to lack unity, 75 | with multiple systems proposed by as many authors going in different 76 | directions. The few available textbooks tend to perpetuate this 77 | impression. 78 | 79 | 80 | 81 | 82 | 83 | \section*{Topics Not Dealt With} 84 | 85 | 86 | We owe it to the reader --- and especially to the instructor who may 87 | be thinking of using the book --- to say clearly what topics, 88 | associated with nonmonotonic reasoning, are \textit{not} covered. 89 | 90 | 91 | 92 | 93 | 94 | \section*{Strategy of Presentation} 95 | 96 | When the author first began planning this text, he followed engrained 97 | habits and sought for maximal generality. `We have available a 98 | multitude of different formal approaches to nonmonotonic reasoning', 99 | he thought. `So in order to put some order into the affair, we need to 100 | find the most general schema possible, under which they all fall. We 101 | can then present the different accounts as so many special cases of 102 | the general schema'. 103 | 104 | 105 | 106 | 107 | \section*{Review and explore sections} 108 | 109 | Each chapter ends with a `Review and explore' section. It contains 110 | three packages to help the reader review the material covered and to 111 | go further into the literature. First, a \textit{recapitulation} of 112 | the essential message of the chapter. Second, a \textit{checklist} of 113 | the key concepts, both formal and informal, that were introduced 114 | there. The concepts are not explained all over again, but are simply 115 | listed for checking off at review time. The reader can relocate the 116 | formal definitions and informal explanations by looking for the 117 | corresponding italicised terms in the main text. Third, a short 118 | selection of texts for \textit{further reading}. Some of these cover 119 | essentially the same ground as the section itself, albeit from a 120 | different angle, in more detail or with particular attention to 121 | aspects that we have not dwelt on. Some go further. In general, these 122 | will be `bite size' --- short papers or chapters. Occasionally, a more 123 | extended text is mentioned. 124 | 125 | 126 | \section*{What is the best way to read this book?} 127 | 128 | Do it pencil in hand; scribble in the margins. Take nothing on faith; 129 | check out the assertions; find errors (and communicate them to the 130 | author); pose questions. 131 | 132 | 133 | 134 | 135 | \section*{For the instructor} 136 | 137 | The author's experience is that in a graduate class, teaching can take 138 | place at average of one section per hour, without counting section 1.1 139 | and the brief `review and explore' sections. This adds up to about 20 140 | hours of instruction time for the entire book, or about 15 hours for a 141 | minimal version like the one mentioned above. 142 | 143 | 144 | 145 | 146 | \section*{Conventions} 147 | 148 | Theorems are numbered by their section, followed by a dash and a 149 | digit. For example, the first explicitly displayed theorem in the book 150 | occurs in section 1.3 and is numbered Theorem \ref{T1.3-1}. However, 151 | only major results are displayed and numbered in this way. Many lesser 152 | facts are simply stated in the flow of the text, and the attentive 153 | reader should mark them as they are found. The same applies to 154 | definitions. Only a few key ones are given special display; the others 155 | are within the text, with their central terms italicized. 156 | 157 | 158 | 159 | 160 | \section*{Acknowledgements} 161 | \label{sec:acknowledgements} 162 | \addcontentsline{toc}{section}{Acknowledgements} 163 | 164 | \markboth{ACKNOWLEDGEMENTS}{ACKLNOWLEDGEMENTS} 165 | 166 | As the basic ideas underlying this book were developed, they were 167 | articulated in workshop and conference presentations, journal 168 | publications, and the classroom. 169 | 170 | 171 | 172 | 173 | 174 | \section*{Purpose} 175 | \addcontentsline{toc}{section}{Purpose} 176 | \markboth{PURPOSE}{PURPOSE} 177 | 178 | This overview is directed to those who have heard of nonmonotonic 179 | reasoning and would like to get a better idea of what it is all 180 | about. What are its driving ideas? In what ways does it differ from 181 | classical logic? How does it relate to probability? More generally, 182 | how does it behave and how can it be used? We will try to answer these 183 | questions as clearly as possible, without undue technicality on the 184 | one hand, nor vagueness or hand waving on the other. 185 | \cleardoublepage 186 | 187 | \pagenumbering{arabic} 188 | \setcounter{page}{0} 189 | 190 | \chapter{Introduction} 191 | 192 | \section{We Are All Nonmonotonic } 193 | 194 | 195 | This overview is directed to those who have heard of nonmonotonic 196 | reasoning and would like to get a better idea of what it is all 197 | about. What are its driving ideas? In what ways does it differ from 198 | classical logic? How does it relate to probability? More generally, 199 | how does it behave and how can it be used? We will try to answer these 200 | questions as clearly as possible, without undue technicality on the 201 | one hand, nor vagueness or hand waving on the other. 202 | 203 | 204 | 205 | This overview is directed to those who have heard of nonmonotonic 206 | reasoning and would like to get a better idea of what it is all 207 | about. What are its driving ideas? In what ways does it differ from 208 | classical logic? How does it relate to probability? More generally, 209 | how does it behave and how can it be used? We will try to answer these 210 | questions as clearly as possible, without undue technicality on the 211 | one hand, nor vagueness or hand waving on the other. 212 | 213 | 214 | 215 | This overview is directed to those who have heard of nonmonotonic 216 | reasoning and would like to get a better idea of what it is all 217 | about. What are its driving ideas? In what ways does it differ from 218 | classical logic? How does it relate to probability? More generally, 219 | how does it behave and how can it be used? We will try to answer these 220 | questions as clearly as possible, without undue technicality on the 221 | one hand, nor vagueness or hand waving on the other. 222 | 223 | 224 | 225 | This overview is directed to those who have heard of nonmonotonic 226 | reasoning and would like to get a better idea of what it is all 227 | about. What are its driving ideas? In what ways does it differ from 228 | classical logic? How does it relate to probability? More generally, 229 | how does it behave and how can it be used? We will try to answer these 230 | questions as clearly as possible, without undue technicality on the 231 | one hand, nor vagueness or hand waving on the other. 232 | 233 | 234 | 235 | This overview is directed to those who have heard of nonmonotonic 236 | reasoning and would like to get a better idea of what it is all 237 | about. What are its driving ideas? In what ways does it differ from 238 | classical logic? How does it relate to probability? More generally, 239 | how does it behave and how can it be used? We will try to answer these 240 | questions as clearly as possible, without undue technicality on the 241 | one hand, nor vagueness or hand waving on the other. 242 | 243 | 244 | 245 | This overview is directed to those who have heard of nonmonotonic 246 | reasoning and would like to get a better idea of what it is all 247 | about. What are its driving ideas? In what ways does it differ from 248 | classical logic? How does it relate to probability? More generally, 249 | how does it behave and how can it be used? We will try to answer these 250 | questions as clearly as possible, without undue technicality on the 251 | one hand, nor vagueness or hand waving on the other. 252 | 253 | 254 | 255 | This overview is directed to those who have heard of nonmonotonic 256 | reasoning and would like to get a better idea of what it is all 257 | about. What are its driving ideas? In what ways does it differ from 258 | classical logic? How does it relate to probability? More generally, 259 | how does it behave and how can it be used? We will try to answer these 260 | questions as clearly as possible, without undue technicality on the 261 | one hand, nor vagueness or hand waving on the other. 262 | 263 | 264 | 265 | This overview is directed to those who have heard of nonmonotonic 266 | reasoning and would like to get a better idea of what it is all 267 | about. What are its driving ideas? In what ways does it differ from 268 | classical logic? How does it relate to probability? More generally, 269 | how does it behave and how can it be used? We will try to answer these 270 | questions as clearly as possible, without undue technicality on the 271 | one hand, nor vagueness or hand waving on the other. 272 | 273 | 274 | 275 | This overview is directed to those who have heard of nonmonotonic 276 | reasoning and would like to get a better idea of what it is all 277 | about. What are its driving ideas? In what ways does it differ from 278 | classical logic? How does it relate to probability? More generally, 279 | how does it behave and how can it be used? We will try to answer these 280 | questions as clearly as possible, without undue technicality on the 281 | one hand, nor vagueness or hand waving on the other. 282 | 283 | 284 | 285 | This overview is directed to those who have heard of nonmonotonic 286 | reasoning and would like to get a better idea of what it is all 287 | about. What are its driving ideas? In what ways does it differ from 288 | classical logic? How does it relate to probability? More generally, 289 | how does it behave and how can it be used? We will try to answer these 290 | questions as clearly as possible, without undue technicality on the 291 | one hand, nor vagueness or hand waving on the other. 292 | 293 | 294 | 295 | This overview is directed to those who have heard of nonmonotonic 296 | reasoning and would like to get a better idea of what it is all 297 | about. What are its driving ideas? In what ways does it differ from 298 | classical logic? How does it relate to probability? More generally, 299 | how does it behave and how can it be used? We will try to answer these 300 | questions as clearly as possible, without undue technicality on the 301 | one hand, nor vagueness or hand waving on the other. 302 | 303 | 304 | 305 | This overview is directed to those who have heard of nonmonotonic 306 | reasoning and would like to get a better idea of what it is all 307 | about. What are its driving ideas? In what ways does it differ from 308 | classical logic? How does it relate to probability? More generally, 309 | how does it behave and how can it be used? We will try to answer these 310 | questions as clearly as possible, without undue technicality on the 311 | one hand, nor vagueness or hand waving on the other. 312 | 313 | 314 | 315 | This overview is directed to those who have heard of nonmonotonic 316 | reasoning and would like to get a better idea of what it is all 317 | about. What are its driving ideas? In what ways does it differ from 318 | classical logic? How does it relate to probability? More generally, 319 | how does it behave and how can it be used? We will try to answer these 320 | questions as clearly as possible, without undue technicality on the 321 | one hand, nor vagueness or hand waving on the other. 322 | 323 | 324 | 325 | This overview is directed to those who have heard of nonmonotonic 326 | reasoning and would like to get a better idea of what it is all 327 | about. What are its driving ideas? In what ways does it differ from 328 | classical logic? How does it relate to probability? More generally, 329 | how does it behave and how can it be used? We will try to answer these 330 | questions as clearly as possible, without undue technicality on the 331 | one hand, nor vagueness or hand waving on the other. 332 | 333 | 334 | 335 | This overview is directed to those who have heard of nonmonotonic 336 | reasoning and would like to get a better idea of what it is all 337 | about. What are its driving ideas? In what ways does it differ from 338 | classical logic? How does it relate to probability? More generally, 339 | how does it behave and how can it be used? We will try to answer these 340 | questions as clearly as possible, without undue technicality on the 341 | one hand, nor vagueness or hand waving on the other. 342 | 343 | 344 | 345 | This overview is directed to those who have heard of nonmonotonic 346 | reasoning and would like to get a better idea of what it is all 347 | about. What are its driving ideas? In what ways does it differ from 348 | classical logic? How does it relate to probability? More generally, 349 | how does it behave and how can it be used? We will try to answer these 350 | questions as clearly as possible, without undue technicality on the 351 | one hand, nor vagueness or hand waving on the other. 352 | 353 | 354 | 355 | This overview is directed to those who have heard of nonmonotonic 356 | reasoning and would like to get a better idea of what it is all 357 | about. What are its driving ideas? In what ways does it differ from 358 | classical logic? How does it relate to probability? More generally, 359 | how does it behave and how can it be used? We will try to answer these 360 | questions as clearly as possible, without undue technicality on the 361 | one hand, nor vagueness or hand waving on the other. 362 | 363 | 364 | 365 | This overview is directed to those who have heard of nonmonotonic 366 | reasoning and would like to get a better idea of what it is all 367 | about. What are its driving ideas? In what ways does it differ from 368 | classical logic? How does it relate to probability? More generally, 369 | how does it behave and how can it be used? We will try to answer these 370 | questions as clearly as possible, without undue technicality on the 371 | one hand, nor vagueness or hand waving on the other. 372 | 373 | 374 | 375 | This overview is directed to those who have heard of nonmonotonic 376 | reasoning and would like to get a better idea of what it is all 377 | about. What are its driving ideas? In what ways does it differ from 378 | classical logic? How does it relate to probability? More generally, 379 | how does it behave and how can it be used? We will try to answer these 380 | questions as clearly as possible, without undue technicality on the 381 | one hand, nor vagueness or hand waving on the other. 382 | 383 | 384 | 385 | This overview is directed to those who have heard of nonmonotonic 386 | reasoning and would like to get a better idea of what it is all 387 | about. What are its driving ideas? In what ways does it differ from 388 | classical logic? How does it relate to probability? More generally, 389 | how does it behave and how can it be used? We will try to answer these 390 | questions as clearly as possible, without undue technicality on the 391 | one hand, nor vagueness or hand waving on the other. 392 | 393 | 394 | 395 | This overview is directed to those who have heard of nonmonotonic 396 | reasoning and would like to get a better idea of what it is all 397 | about. What are its driving ideas? In what ways does it differ from 398 | classical logic? How does it relate to probability? More generally, 399 | how does it behave and how can it be used? We will try to answer these 400 | questions as clearly as possible, without undue technicality on the 401 | one hand, nor vagueness or hand waving on the other. 402 | 403 | 404 | \end{document} 405 | -------------------------------------------------------------------------------- /text/kcp-template.toc: -------------------------------------------------------------------------------- 1 | \contentsline {chapter}{\MakeTextUppercase {Preface}}{vii} 2 | \contentsline {chapter}{Preface}{vii} 3 | \contentsline {section}{Acknowledgements}{ix} 4 | \contentsline {section}{Purpose}{ix} 5 | \contentsline {chapter}{\MakeTextUppercase {CHAPTER}\nobreakspace {}1\hskip 1em\relax \MakeTextUppercase {Introduction}}{1} 6 | \contentsline {section}{\numberline {1}We Are All Nonmonotonic }{1} 7 | -------------------------------------------------------------------------------- /text/kcp-texts.sty: -------------------------------------------------------------------------------- 1 | % Tighten text - comments next 11 lines if you don't want this. 2 | \spaceskip=.5em plus .6em minus .2em 3 | \binoppenalty=2000 4 | \relpenalty=1500 5 | \interlinepenalty=50 6 | \predisplaypenalty=10000 7 | \postdisplaypenalty=400 8 | \clubpenalty=400 9 | \widowpenalty=400 10 | \displaywidowpenalty=1000 11 | \brokenpenalty=100 12 | \floatingpenalty=100 13 | 14 | %Times fonts - comment out if you don't want it. 15 | \def\rmdefault{ptm} 16 | \def\bfdefault{b} 17 | 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | 20 | \newcommand\TextsInComputing{\jlctitleC T\sqz e\sqz x\sqz t\sqz s i\sqz n C\sqz o\sqz m\sqz p\sqz u\sqz t\sqz i\sqz n\sqz g} 21 | 22 | 23 | %%%%% Page settings for Lightning Source %%%%% 24 | 25 | \setlength{\textheight}{175mm} 26 | %\setlength{\textwidth}{115mm} 27 | \setlength{\textwidth}{110mm} 28 | \setlength{\parindent}{4mm} 29 | \addtolength{\headheight}{2pt} 30 | %\setlength{\oddsidemargin}{2.21cm} 31 | %\setlength{\evensidemargin}{2.21cm} 32 | % Kris: to make these margins come out the same on Jane's printer they both needed 33 | % an extra 3mm in addition to what I calculated they should be based on the other 34 | % values (textwidth and width of A4 paper). However, in the printed version the centering 35 | % was off by exactly those 3 mm. In addition, the centering was off when I viewed the 36 | % postscripton my screen by 3mm. So, I am taking those 3 mm away again. 37 | %\setlength{\oddsidemargin}{1.81cm} % incl. extra 3mm 38 | %\setlength{\evensidemargin}{3.71cm} % incl. extra 3mm 39 | \setlength{\oddsidemargin}{1.51cm} % no extra 3mm 40 | \setlength{\evensidemargin}{3.41cm} % no extra 3mm 41 | %\setlength{\topmargin}{29mm} 42 | % Kris: same things as for the side margins. I am also taking the 3 mm away again. 43 | %\setlength{\topmargin}{32mm} 44 | \setlength{\topmargin}{29mm} 45 | 46 | %Font sizes 47 | \font\jlctitleA = cmss17 at 42pt 48 | \font\jlctitleB = cmss11 at 25pt 49 | \font\jlctitleC = cmss14 at 33pt 50 | \font\jlctitleD = cmss9 at 12pt 51 | \font\jlctitleE = cmss17% at 16pt 52 | \font\jlctitleF = cmss14 at 15pt 53 | 54 | 55 | \newcommand\FirstPage{\thispagestyle{empty} 56 | \def\sqz{\hskip0pt minus1cm} 57 | \vspace*{2cm} 58 | 59 | \begin{center} 60 | {\TextsInComputing}\\[4ex] {\jlctitleB Volume \volume}\\[22ex] 61 | {\jlctitleC\TitleLineOne} 62 | %{\jlctitleC\TitleLineOne}\\[4ex] 63 | %{\jlctitleC\TitleLineTwo}\\[4ex] 64 | %{\jlctitleC\TitleLineThree} 65 | \end{center} 66 | } 67 | 68 | 69 | \newcommand\SecondPage{ 70 | \newpage\thispagestyle{empty} 71 | \mbox{} 72 | \vfill 73 | \noindent 74 | {\sf Volume 1}\\ 75 | {\sf Programming Languages and Operational Semantics}\\ 76 | {\sf Maribel Fern\'andez}\\[1ex] 77 | {\sf Volume 2}\\ 78 | {\sf An Introduction to Lambda Calculi for Computer Scientists}\\ 79 | {\sf Chris Hankin}\\[1ex] 80 | {\sf Volume 3}\\ 81 | {\sf Logical Reasoning: A First Course}\\ 82 | {\sf Rob Nederpelt and Fairouz Kamareddine}\\[1ex] 83 | {\sf Volume 4}\\ 84 | {\sf The Haskell Road to Logic, Maths and Programming}\\ 85 | {\sf Kees Doets and Jan van Eijck}\\[1ex] 86 | {\sf Volume 5}\\ 87 | {\sf Bridges from Classical to Nonmonotonic Logic}\\ 88 | {\sf David Makinson}\\[1ex] 89 | {\sf Volume 6}\\ 90 | {\sf Automata and Dictionaries}\\ 91 | {\sf Franz Guenthner and Denis Maurel}\\[1ex] 92 | {\sf Volume 7}\\ 93 | {\sf Learn Prolog Now!}\\ 94 | {\sf Patrick Blackburn, Johan Bos and Kristina Striegnitz}\\[10ex] 95 | {\sf Texts in Computing Series Editor}\\ 96 | {\sf Ian Mackie, King's College London} 97 | } 98 | 99 | 100 | \newcommand\ThirdPage{ 101 | \newpage 102 | \thispagestyle{empty} 103 | \begin{center} 104 | \vspace*{4cm} 105 | \noindent 106 | {\jlctitleC\TitleLineOne}\\[22ex] 107 | %{\jlctitleC\TitleLineOne}\\[4ex] 108 | %{\jlctitleC\TitleLineTwo}\\[4ex] 109 | %{\jlctitleC\TitleLineThree}\\[22ex] 110 | {\jlctitleB \kcpAuthor}\\[3ex] 111 | %{\sf \jlctitleF \kcpInst} 112 | \end{center} 113 | } 114 | 115 | 116 | \newcommand\ForthPage{ 117 | \newpage\thispagestyle{empty} 118 | \mbox{} 119 | \vspace*{2in} 120 | \vfill 121 | \noindent \copyright ~{\sf Individual author and King's College 2006. 122 | All rights reserved.}\\[3ex] 123 | {\sf ISBN \isbn}\\ 124 | \noindent {\bf \sf College Publications}\\ 125 | {\sf Scientific Director: Dov Gabbay}\\ 126 | {\sf Managing Director: Jane Spurr}\\ 127 | {\sf Department of Computer Science}\\ 128 | {\sf Strand, London WC2R 2LS, UK}\\ 129 | %{\sf kcp@dcs.kcl.ac.uk}\\ 130 | [2ex] 131 | 132 | \noindent 133 | {\sf Cover design by Richard Fraser, www.avalonarts.co.uk}\\ 134 | {\sf Printed by Lightning Source, Milton Keynes, UK}\\[.5ex] 135 | 136 | \noindent \hrulefill\\ 137 | \noindent \footnotesize{\sf All rights reserved. No part of this 138 | publication may be reproduced, stored in a retrieval system or 139 | transmitted, in any form, or by any means, electronic, mechanical, 140 | photocopying, recording or otherwise, without prior permission, in 141 | writing, from the publisher.} 142 | 143 | } 144 | 145 | \newcommand\kcpfrontmatter{ 146 | \FirstPage 147 | \SecondPage 148 | \ThirdPage 149 | \ForthPage 150 | \newpage 151 | \normalsize 152 | \pagenumbering{roman} 153 | } 154 | 155 | \newcommand\blankpage{ 156 | \newpage 157 | \markboth{}{} 158 | \thispagestyle{empty} 159 | \pagestyle{empty} 160 | 161 | \mbox{} 162 | 163 | \cleardoublepage 164 | } 165 | -------------------------------------------------------------------------------- /text/listtree.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: listtree.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:21:35 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 332 123 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 123 moveto 0 0 lineto 332 0 lineto 332 123 lineto closepath clip newpath 49 | -112.5 207.0 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0 slj 0 slc 89 | 0.06000 0.06000 sc 90 | % 91 | % Fig objects follow 92 | % 93 | % 94 | % here starts figure with depth 100 95 | % Arc 96 | 7.500 slw 97 | gs clippath 98 | 6229 2508 m 6248 2451 l 6105 2403 l 6210 2470 l 6086 2460 l cp 99 | eoclip 100 | [60] 0 sd 101 | n 5812.5 3487.5 1093.3 -112.2 -67.8 arc 102 | gs col0 s gr 103 | gr 104 | [] 0 sd 105 | % arrowhead 106 | %n 6086 2460 m 6210 2470 l 6105 2403 l 6086 2460 l cp gs col7 1.00 shd ef gr col0 s 107 | % Arc 108 | [60] 0 sd 109 | n 4650.0 2362.5 940.5 -113.5 -66.5 arc 110 | gs col0 s gr 111 | [] 0 sd 112 | % Arc 113 | gs clippath 114 | 5477 2058 m 5500 2003 l 5360 1945 l 5460 2019 l 5337 2000 l cp 115 | eoclip 116 | [60] 0 sd 117 | n 5137.5 2662.5 721.3 -117.9 -62.1 arc 118 | gs col0 s gr 119 | gr 120 | [] 0 sd 121 | % arrowhead 122 | %n 5337 2000 m 5460 2019 l 5360 1945 l 5337 2000 l cp gs col7 1.00 shd ef gr col0 s 123 | % Arc 124 | gs clippath 125 | 3981 2432 m 3997 2375 l 3851 2335 l 3959 2396 l 3835 2392 l cp 126 | eoclip 127 | [60] 0 sd 128 | n 3450.0 4050.0 1731.5 -107.7 -72.3 arc 129 | gs col0 s gr 130 | gr 131 | [] 0 sd 132 | % arrowhead 133 | %n 3835 2392 m 3959 2396 l 3851 2335 l 3835 2392 l cp gs col7 1.00 shd ef gr col0 s 134 | % Arc 135 | gs clippath 136 | 4298 3024 m 4280 2966 l 4136 3011 l 4260 3005 l 4153 3068 l cp 137 | eoclip 138 | [60] 0 sd 139 | n 2835.9 -1481.2 4706.6 90.7 72.2 arcn 140 | gs col0 s gr 141 | gr 142 | [] 0 sd 143 | % arrowhead 144 | %n 4153 3068 m 4260 3005 l 4136 3011 l 4153 3068 l cp gs col7 1.00 shd ef gr col0 s 145 | % Polyline 146 | n 4200 1725 m 147 | 3600 1950 l gs col0 s gr 148 | % Polyline 149 | n 4200 1725 m 150 | 4725 1950 l gs col0 s gr 151 | % Polyline 152 | n 4725 2175 m 153 | 4125 2400 l gs col0 s gr 154 | % Polyline 155 | n 4725 2175 m 156 | 5325 2400 l gs col0 s gr 157 | % Polyline 158 | n 4050 2625 m 159 | 3825 2775 l gs col0 s gr 160 | % Polyline 161 | n 4050 2625 m 162 | 4350 2775 l gs col0 s gr 163 | % Polyline 164 | n 5400 2625 m 165 | 5100 2775 l gs col0 s gr 166 | % Polyline 167 | n 5400 2625 m 168 | 5700 2700 l gs col0 s gr 169 | % Polyline 170 | n 4425 3000 m 171 | 4125 3300 l gs col0 s gr 172 | % Polyline 173 | n 4425 3000 m 174 | 4650 3225 l gs col0 s gr 175 | /Times-Bold ff 300.00 scf sf 176 | 4050 2550 m 177 | gs 1 -1 sc (.) col0 sh gr 178 | /Times-Bold ff 210.00 scf sf 179 | 3750 3000 m 180 | gs 1 -1 sc (b) col0 sh gr 181 | /Times-Bold ff 300.00 scf sf 182 | 4350 2925 m 183 | gs 1 -1 sc (.) col0 sh gr 184 | /Times-Bold ff 210.00 scf sf 185 | 4050 3450 m 186 | gs 1 -1 sc (c) col0 sh gr 187 | /Times-Bold ff 210.00 scf sf 188 | 4575 3450 m 189 | gs 1 -1 sc ([ ]) col0 sh gr 190 | /Times-Bold ff 300.00 scf sf 191 | 5325 2550 m 192 | gs 1 -1 sc (.) col0 sh gr 193 | /Times-Bold ff 210.00 scf sf 194 | 5625 2925 m 195 | gs 1 -1 sc ([ ]) col0 sh gr 196 | /Times-Bold ff 210.00 scf sf 197 | 5025 3000 m 198 | gs 1 -1 sc (d) col0 sh gr 199 | /Times-Bold ff 300.00 scf sf 200 | 4725 2100 m 201 | gs 1 -1 sc (.) col0 sh gr 202 | /Times-Bold ff 210.00 scf sf 203 | 3525 2175 m 204 | gs 1 -1 sc (a) col0 sh gr 205 | /Times-Bold ff 300.00 scf sf 206 | 4200 1650 m 207 | gs 1 -1 sc (.) col0 sh gr 208 | /Times-Bold ff 210.00 scf sf 209 | 5475 2100 m 210 | gs 1 -1 sc (.\(.\(b, .\(c,[ ]\)\), .\(d,[]\)\)) col0 sh gr 211 | /Times-Bold ff 210.00 scf sf 212 | 6300 2550 m 213 | gs 1 -1 sc (.\(d, []\)) col0 sh gr 214 | /Times-Bold ff 210.00 scf sf 215 | 5100 1575 m 216 | gs 1 -1 sc (.\(a, .\(.\(b,.\(c,[ ]\)\), .\(d,[ ]\)\)\)) col0 sh gr 217 | /Times-Bold ff 210.00 scf sf 218 | 1875 2550 m 219 | gs 1 -1 sc (.\(b, .\(c,[ ]\)\)) col0 sh gr 220 | /Times-Bold ff 210.00 scf sf 221 | 2175 3225 m 222 | gs 1 -1 sc (.\(c, []\)) col0 sh gr 223 | % here ends figure; 224 | $F2psEnd 225 | rs 226 | showpage 227 | -------------------------------------------------------------------------------- /text/lpn-html.cfg: -------------------------------------------------------------------------------- 1 | \Preamble{options} 2 | 3 | \renewcommand{\LPNdef}[1]{} 4 | \renewcommand{\LPNex}[0]{} 5 | 6 | \renewcommand{\includegraphics}[2][none]{\Picture[*Pic not found*]{#2.png}} 7 | 8 | \begin{document} 9 | 10 | 11 | 12 | \EndPreamble -------------------------------------------------------------------------------- /text/lpn-html.tex: -------------------------------------------------------------------------------- 1 | \documentclass{book} 2 | 3 | 4 | \usepackage{pstricks} 5 | \usepackage{pst-node} 6 | \usepackage{pst-tree} 7 | \usepackage{fancyvrb} %% stuff for verbatim mode 8 | \usepackage{graphicx} 9 | \usepackage{color} 10 | \usepackage{url} 11 | 12 | \usepackage{makeidx} % Necessary if this book has an Index. 13 | \makeindex % Comment out this line when Index is final.\ 14 | 15 | 16 | %%% to be used only with tex4ht 17 | %\renewcommand{\includegraphics}[2][none]{\Picture{#2.gif}} 18 | 19 | 20 | \input{LPNmacros.tex} 21 | 22 | \title{Learn Prolog Now!} 23 | \author{Blackburn, Bos \& Striegnitz} 24 | 25 | \newcommand\volume{7} 26 | \newcommand\isbn{1-904987-17-6} 27 | 28 | \newcommand\TitleLineOne{L\sqz e\sqz a\sqz r\sqz n P\sqz r\sqz o\sqz l\sqz o\sqz g N\sqz o\sqz w\sqz !} 29 | 30 | 31 | \includeonly{preface, 32 | preface2, 33 | introduction, 34 | chapter1, 35 | chapter2, 36 | chapter3, 37 | chapter4, 38 | chapter5, 39 | chapter6, 40 | chapter7, 41 | chapter8, 42 | chapter9, 43 | chapter10, 44 | chapter11, 45 | chapter12, 46 | LPNindex} 47 | 48 | \begin{document} 49 | %\thispagestyle{empty} 50 | 51 | % used this to find out margins, Kris 52 | % voffset: \the\voffset\\ 53 | % headh: \the\headheight\\ 54 | % headsep: \the\headsep\\ 55 | % topmargin: \the\topmargin\\ 56 | % footskip: \the\footskip\\ 57 | % texth: \the\textheight\\ 58 | % topskip: \the\topskip\\ 59 | 60 | % hoffset: \the\hoffset\\ 61 | % textwidth: \the\textwidth\\ 62 | % odd: \the\oddsidemargin\\ 63 | % even: \the\evensidemargin 64 | 65 | 66 | % 67 | %\input frontmatter 68 | \pagenumbering{roman} 69 | \setcounter{page}{5} 70 | % 71 | \pagestyle{bbcontents} 72 | \tableofcontents 73 | 74 | 75 | \pagestyle{bbpreface} 76 | \include{preface2} 77 | 78 | % 79 | \pagestyle{bbpreface} 80 | \include{preface} 81 | 82 | % 83 | \pagestyle{bbintroduction} 84 | \include{introduction} 85 | 86 | \pagenumbering{arabic} 87 | \setcounter{page}{1} 88 | 89 | 90 | \include{chapter1} 91 | 92 | \include{chapter2} 93 | 94 | \include{chapter3} 95 | 96 | \include{chapter4} 97 | 98 | \include{chapter5} 99 | 100 | \include{chapter6} 101 | 102 | \include{chapter7} 103 | 104 | \include{chapter8} 105 | 106 | \include{chapter9} 107 | 108 | \include{chapter10} 109 | 110 | \include{chapter11} 111 | 112 | \include{chapter12} 113 | 114 | 115 | 116 | 117 | 118 | 119 | \include{LPNindex} 120 | 121 | \newpage\thispagestyle{empty}\strut 122 | \newpage\thispagestyle{empty}\strut 123 | \newpage\thispagestyle{empty}\strut 124 | \newpage\thispagestyle{empty}\strut 125 | \newpage\thispagestyle{empty}\strut 126 | 127 | \end{document} 128 | -------------------------------------------------------------------------------- /text/lpn.idx: -------------------------------------------------------------------------------- 1 | \indexentry{PROLOG ,/2@\texttt{,/2}}{6} 2 | \indexentry{PROLOG ;/2@\texttt{;/2}}{7} 3 | \indexentry{PROLOG listing/0@\texttt{listing/0}}{17} 4 | \indexentry{PROLOG =/2@\texttt{=/2}}{24} 5 | \indexentry{PROLOG unify\_with\_occurs\_check/2@\texttt{unify\_with\_occurs\_check/2}}{31} 6 | \indexentry{PROLOG \=/2@\verb-\=/2-}{42} 7 | \indexentry{PROLOG trace/0@\texttt{trace/0}}{43} 8 | \indexentry{PROLOG notrace/0@\texttt{notrace/0}}{45} 9 | \indexentry{PROLOG member/2@\texttt{member/2}}{76} 10 | \indexentry{PROLOG is/2@\texttt{is/2}}{90} 11 | \indexentry{PROLOG =/2@\texttt{>=/2}}{97} 16 | \indexentry{PROLOG >/2@\texttt{>/2}}{97} 17 | \indexentry{PROLOG append/3@\texttt{append/3}}{106} 18 | \indexentry{PROLOG c/3@\texttt{'C'/3}}{130} 19 | \indexentry{PROLOG c/3@\texttt{'C'/3}}{136} 20 | \indexentry{PROLOG ==/2@\texttt{==/2}}{160} 21 | \indexentry{PROLOG \==/2@\verb-\==/2-}{161} 22 | \indexentry{PROLOG ./2@\texttt{./2}}{164} 23 | \indexentry{PROLOG atom/1@\texttt{atom/1}}{167} 24 | \indexentry{PROLOG integer/1@\texttt{integer/1}}{167} 25 | \indexentry{PROLOG float/1@\texttt{float/1}}{167} 26 | \indexentry{PROLOG number/1@\texttt{number/1}}{167} 27 | \indexentry{PROLOG atomic/1@\texttt{atomic/1}}{167} 28 | \indexentry{PROLOG var/1@\texttt{var/1}}{167} 29 | \indexentry{PROLOG nonvar/1@\texttt{nonvar/1}}{167} 30 | \indexentry{PROLOG functor/3@\texttt{functor/3}}{170} 31 | \indexentry{PROLOG arg/3@\texttt{arg/3}}{172} 32 | \indexentry{PROLOG =..@\texttt{=../2}}{172} 33 | \indexentry{PROLOG atom\_codes/2@\texttt{atom\_codes/2}}{173} 34 | \indexentry{PROLOG number\_codes/2@\texttt{number\_codes/2}}{174} 35 | \indexentry{PROLOG op/3@\texttt{op/3}}{176} 36 | \indexentry{PROLOG display/1@\texttt{display/1}}{179} 37 | \indexentry{PROLOG write/1@\texttt{write/1}}{180} 38 | \indexentry{PROLOG tab/1@\texttt{tab/1}}{182} 39 | \indexentry{PROLOG nl/0@\texttt{nl/0}}{182} 40 | \indexentry{PROLOG !/0@\texttt{!/0}}{186} 41 | \indexentry{PROLOG max/3@\texttt{max/3}}{192} 42 | \indexentry{PROLOG assert/1@\texttt{assert/1}}{204} 43 | \indexentry{PROLOG retract/1@\texttt{retract/1}}{204} 44 | \indexentry{PROLOG assertz/1@\texttt{assertz/1}}{207} 45 | \indexentry{PROLOG asserta/1@\texttt{asserta/1}}{207} 46 | \indexentry{PROLOG retractall/3@\texttt{retractall/3}}{208} 47 | \indexentry{PROLOG findall/3@\texttt{findall/3}}{209} 48 | \indexentry{PROLOG bagof/3@\texttt{bagof/3}}{211} 49 | \indexentry{PROLOG setof/3@\texttt{setof/3}}{213} 50 | \indexentry{PROLOG ensure_loaded/1@\texttt{ensure\_loaded/1}}{219} 51 | \indexentry{PROLOG tab/1@\texttt{tab/1}}{220} 52 | \indexentry{PROLOG nl/0@\texttt{nl/0}}{220} 53 | \indexentry{PROLOG module/2@\texttt{module/2}}{221} 54 | \indexentry{PROLOG use_module/1@\texttt{use\_module/1}}{222} 55 | \indexentry{PROLOG use_module/2@\texttt{use\_module/2}}{222} 56 | \indexentry{PROLOG open/3@\texttt{open/3}}{223} 57 | \indexentry{PROLOG write/2@\texttt{write/2}}{223} 58 | \indexentry{PROLOG close/1@\texttt{close/1}}{223} 59 | \indexentry{PROLOG nl/1@\texttt{nl/1}}{223} 60 | \indexentry{PROLOG read/2@\texttt{read/2}}{224} 61 | \indexentry{PROLOG open/3@\texttt{open/3}}{224} 62 | \indexentry{PROLOG at_end_of_stream/1@\texttt{at\_end\_of\_stream/1}}{225} 63 | \indexentry{PROLOG get\_code/2@\texttt{get\_code/2}}{225} 64 | \indexentry{PROLOG atom\_codes/2@\texttt{atom\_codes/2}}{225} 65 | -------------------------------------------------------------------------------- /text/lpn.ilg: -------------------------------------------------------------------------------- 1 | This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support). 2 | Scanning style file ./LPN.isty....done (4 attributes redefined, 0 ignored). 3 | Scanning input file lpn.idx...done (0 entries accepted, 0 rejected). 4 | Nothing written in lpn.ind. 5 | Transcript written in lpn.ilg. 6 | -------------------------------------------------------------------------------- /text/lpn.ind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/lpn.ind -------------------------------------------------------------------------------- /text/lpn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/text/lpn.pdf -------------------------------------------------------------------------------- /text/lpn.tex: -------------------------------------------------------------------------------- 1 | \documentclass{book} 2 | 3 | 4 | \usepackage{kcp,kcp-texts} %% Kings College Press 5 | \usepackage{pstricks} 6 | \usepackage{pst-node} 7 | \usepackage{pst-tree} 8 | \usepackage{fancyvrb} %% stuff for verbatim mode 9 | \usepackage{graphicx} 10 | \usepackage{color} 11 | \usepackage{url} 12 | 13 | \usepackage{makeidx} % Necessary if this book has an Index. 14 | \makeindex % Comment out this line when Index is final.\ 15 | 16 | 17 | %%% to be used only with tex4ht 18 | %\renewcommand{\includegraphics}[2][none]{\Picture{#2.gif}} 19 | 20 | 21 | \input{LPNmacros.tex} 22 | 23 | \title{Learn Prolog Now!} 24 | \author{Blackburn, Bos \& Striegnitz} 25 | 26 | \newcommand\volume{7} 27 | \newcommand\isbn{1-904987-17-6} 28 | \newcommand\kcpAuthor{Patrick Blackburn\\[1ex]Johan Bos\\[1ex]Kristina Striegnitz} 29 | \newcommand\kcpInst{King's College London} 30 | 31 | \newcommand\TitleLineOne{L\sqz e\sqz a\sqz r\sqz n P\sqz r\sqz o\sqz l\sqz o\sqz g N\sqz o\sqz w\sqz !} 32 | 33 | \pagestyle{bbheadings} 34 | 35 | \includeonly{preface, 36 | preface2, 37 | introduction, 38 | chapter1, 39 | chapter2, 40 | chapter3, 41 | chapter4, 42 | chapter5, 43 | chapter6, 44 | chapter7, 45 | chapter8, 46 | chapter9, 47 | chapter10, 48 | chapter11, 49 | chapter12, 50 | appendix0, 51 | appendix1, 52 | appendix2, 53 | LPNindex} 54 | 55 | \begin{document} 56 | %\thispagestyle{empty} 57 | 58 | % used this to find out margins, Kris 59 | % voffset: \the\voffset\\ 60 | % headh: \the\headheight\\ 61 | % headsep: \the\headsep\\ 62 | % topmargin: \the\topmargin\\ 63 | % footskip: \the\footskip\\ 64 | % texth: \the\textheight\\ 65 | % topskip: \the\topskip\\ 66 | 67 | % hoffset: \the\hoffset\\ 68 | % textwidth: \the\textwidth\\ 69 | % odd: \the\oddsidemargin\\ 70 | % even: \the\evensidemargin 71 | 72 | 73 | % 74 | %\kcpfrontmatter 75 | %\input frontmatter 76 | \pagenumbering{roman} 77 | \setcounter{page}{5} 78 | % 79 | \pagestyle{bbcontents} 80 | \tableofcontents 81 | 82 | 83 | \pagestyle{bbpreface} 84 | \include{preface2} 85 | 86 | % 87 | \pagestyle{bbpreface} 88 | \include{preface} 89 | 90 | % 91 | \pagestyle{bbintroduction} 92 | \include{introduction} 93 | 94 | \pagestyle{bbheadings} 95 | \pagenumbering{arabic} 96 | \setcounter{page}{1} 97 | 98 | 99 | \include{chapter1} 100 | 101 | \include{chapter2} 102 | 103 | \include{chapter3} 104 | 105 | \include{chapter4} 106 | 107 | \include{chapter5} 108 | 109 | \include{chapter6} 110 | 111 | \include{chapter7} 112 | 113 | \include{chapter8} 114 | 115 | \include{chapter9} 116 | 117 | \include{chapter10} 118 | 119 | \include{chapter11} 120 | 121 | \include{chapter12} 122 | 123 | 124 | \appendix 125 | 126 | \pagestyle{bbanswers} 127 | \include{appendix0} 128 | 129 | \include{appendix1} 130 | 131 | \include{appendix2} 132 | 133 | \include{LPNindex} 134 | 135 | \newpage\thispagestyle{empty}\strut 136 | \newpage\thispagestyle{empty}\strut 137 | \newpage\thispagestyle{empty}\strut 138 | \newpage\thispagestyle{empty}\strut 139 | \newpage\thispagestyle{empty}\strut 140 | 141 | \end{document} 142 | -------------------------------------------------------------------------------- /text/lpn.toc: -------------------------------------------------------------------------------- 1 | \contentsline {chapter}{Preface to the First Reprinting}{ix} 2 | \contentsline {chapter}{Preface}{xi} 3 | \contentsline {chapter}{Introduction}{xiii} 4 | \contentsline {chapter}{Chapter\nobreakspace {}1\hskip 1em\relax \textbf {Facts, Rules, and Queries}}{1} 5 | \contentsline {section}{\numberline {1}Some Simple Examples}{2} 6 | \contentsline {section}{\numberline {2}Prolog Syntax}{11} 7 | \contentsline {section}{\numberline {3}Exercises}{14} 8 | \contentsline {section}{\numberline {4}Practical Session}{16} 9 | \contentsline {chapter}{Chapter\nobreakspace {}2\hskip 1em\relax \textbf {Unification and Proof Search}}{21} 10 | \contentsline {section}{\numberline {1}Unification}{22} 11 | \contentsline {section}{\numberline {2}Proof Search}{34} 12 | \contentsline {section}{\numberline {3}Exercises}{39} 13 | \contentsline {section}{\numberline {4}Practical Session}{42} 14 | \contentsline {chapter}{Chapter\nobreakspace {}3\hskip 1em\relax \textbf {Recursion}}{47} 15 | \contentsline {section}{\numberline {1}Recursive Definitions}{48} 16 | \contentsline {section}{\numberline {2}Rule Ordering, Goal Ordering, and Termination}{59} 17 | \contentsline {section}{\numberline {3}Exercises}{64} 18 | \contentsline {section}{\numberline {4}Practical Session}{65} 19 | \contentsline {chapter}{Chapter\nobreakspace {}4\hskip 1em\relax \textbf {Lists}}{71} 20 | \contentsline {section}{\numberline {1}Lists}{72} 21 | \contentsline {section}{\numberline {2}Member}{76} 22 | \contentsline {section}{\numberline {3}Recursing down Lists}{80} 23 | \contentsline {section}{\numberline {4}Exercises}{83} 24 | \contentsline {section}{\numberline {5}Practical Session}{86} 25 | \contentsline {chapter}{Chapter\nobreakspace {}5\hskip 1em\relax \textbf {Arithmetic}}{89} 26 | \contentsline {section}{\numberline {1}Arithmetic in Prolog}{90} 27 | \contentsline {section}{\numberline {2}A Closer Look}{91} 28 | \contentsline {section}{\numberline {3}Arithmetic and Lists}{94} 29 | \contentsline {section}{\numberline {4}Comparing Integers}{97} 30 | \contentsline {section}{\numberline {5}Exercises}{101} 31 | \contentsline {section}{\numberline {6}Practical Session}{102} 32 | \contentsline {chapter}{Chapter\nobreakspace {}6\hskip 1em\relax \textbf {More Lists}}{105} 33 | \contentsline {section}{\numberline {1}Append}{106} 34 | \contentsline {section}{\numberline {2}Reversing a List}{112} 35 | \contentsline {section}{\numberline {3}Exercises}{115} 36 | \contentsline {section}{\numberline {4}Practical Session}{117} 37 | \contentsline {chapter}{Chapter\nobreakspace {}7\hskip 1em\relax \textbf {Definite Clause Grammars}}{119} 38 | \contentsline {section}{\numberline {1}Context Free Grammars}{120} 39 | \contentsline {section}{\numberline {2}Definite Clause Grammars}{128} 40 | \contentsline {section}{\numberline {3}Exercises}{134} 41 | \contentsline {section}{\numberline {4}Practical Session}{135} 42 | \contentsline {chapter}{Chapter\nobreakspace {}8\hskip 1em\relax \textbf {More Definite Clause Grammars}}{139} 43 | \contentsline {section}{\numberline {1}Extra Arguments}{140} 44 | \contentsline {section}{\numberline {2}Extra Goals}{150} 45 | \contentsline {section}{\numberline {3}Concluding Remarks}{154} 46 | \contentsline {section}{\numberline {4}Exercises}{155} 47 | \contentsline {section}{\numberline {5}Practical Session}{156} 48 | \contentsline {chapter}{Chapter\nobreakspace {}9\hskip 1em\relax \textbf {A Closer Look at Terms}}{159} 49 | \contentsline {section}{\numberline {1}Comparing Terms}{160} 50 | \contentsline {section}{\numberline {2}Terms with a Special Notation}{162} 51 | \contentsline {section}{\numberline {3}Examining Terms}{166} 52 | \contentsline {section}{\numberline {4}Operators}{174} 53 | \contentsline {section}{\numberline {5}Exercises}{177} 54 | \contentsline {section}{\numberline {6}Practical Session}{179} 55 | \contentsline {chapter}{Chapter\nobreakspace {}10\hskip 1em\relax \textbf {Cuts and Negation}}{185} 56 | \contentsline {section}{\numberline {1}The Cut}{186} 57 | \contentsline {section}{\numberline {2}Using Cut}{192} 58 | \contentsline {section}{\numberline {3}Negation as Failure}{195} 59 | \contentsline {section}{\numberline {4}Exercises}{199} 60 | \contentsline {section}{\numberline {5}Practical Session}{200} 61 | \contentsline {chapter}{Chapter\nobreakspace {}11\hskip 1em\relax \textbf {Database Manipulation and Collecting Solutions}}{203} 62 | \contentsline {section}{\numberline {1}Database Manipulation}{204} 63 | \contentsline {section}{\numberline {2}Collecting Solutions}{209} 64 | \contentsline {section}{\numberline {3}Exercises}{214} 65 | \contentsline {section}{\numberline {4}Practical Session}{216} 66 | \contentsline {chapter}{Chapter\nobreakspace {}12\hskip 1em\relax \textbf {Working With Files}}{217} 67 | \contentsline {section}{\numberline {1}Splitting Programs over Files}{218} 68 | \contentsline {section}{\numberline {2}Writing to Files}{223} 69 | \contentsline {section}{\numberline {3}Reading from Files}{224} 70 | \contentsline {section}{\numberline {4}Exercises}{226} 71 | \contentsline {section}{\numberline {5}Practical Session}{227} 72 | \contentsline {chapter}{Answers to the Exercises}{231} 73 | \contentsline {chapter}{Further Reading}{257} 74 | \contentsline {chapter}{Prolog Environments}{259} 75 | \contentsline {chapter}{Predicate Index}{261} 76 | -------------------------------------------------------------------------------- /text/main.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt]{book} 2 | 3 | %\usepackage[LPNconf,3]{tex4ht} 4 | 5 | \usepackage{pstricks} 6 | \usepackage{pst-node} 7 | \usepackage{pst-tree} 8 | \usepackage{fancyvrb} 9 | 10 | \usepackage{graphicx} 11 | %%% to be used only with tex4ht 12 | %\renewcommand{\includegraphics}[2][none]{\Picture{#2.gif}} 13 | 14 | 15 | \input{LPNmacros.tex} 16 | 17 | \newcommand{\ignore}[1]{} 18 | \newcommand{\todo}[1]{{\bf **#1**}} 19 | 20 | 21 | \newcommand{\stnode}[1]{\TR{\psframebox{{\tt #1}}}} 22 | 23 | 24 | 25 | 26 | 27 | \begin{document} 28 | 29 | \title{Learn Prolog Now!} 30 | \author{Patrick Blackburn, 31 | Johan Bos, 32 | Kristina Striegnitz} 33 | \maketitle 34 | 35 | \tableofcontents 36 | 37 | \include{chapter1} 38 | 39 | \include{chapter2} 40 | 41 | \include{chapter3} 42 | 43 | \include{chapter4} 44 | 45 | \include{chapter5} 46 | 47 | \include{chapter6} 48 | 49 | \include{chapter7} 50 | 51 | \include{chapter8} 52 | 53 | \include{chapter9} 54 | 55 | \include{chapter10} 56 | 57 | \include{chapter11} 58 | 59 | \include{chapter12} 60 | 61 | \end{document} 62 | -------------------------------------------------------------------------------- /text/main.toc: -------------------------------------------------------------------------------- 1 | \contentsline {chapter}{\numberline {1}Facts, Rules, and Queries}{7} 2 | \contentsline {section}{\numberline {1.1}Some simple examples}{7} 3 | \contentsline {subsection}{\numberline {1.1.1}Knowledge Base 1}{8} 4 | \contentsline {subsection}{\numberline {1.1.2}Knowledge Base 2}{9} 5 | \contentsline {subsection}{\numberline {1.1.3}Knowledge Base 3}{11} 6 | \contentsline {subsection}{\numberline {1.1.4}Knowledge Base 4}{13} 7 | \contentsline {subsection}{\numberline {1.1.5}Knowledge Base 5}{16} 8 | \contentsline {section}{\numberline {1.2}Prolog Syntax}{17} 9 | \contentsline {subsection}{\numberline {1.2.1}Atoms}{17} 10 | \contentsline {subsection}{\numberline {1.2.2}Numbers}{18} 11 | \contentsline {subsection}{\numberline {1.2.3}Variables}{18} 12 | \contentsline {subsection}{\numberline {1.2.4}Complex terms}{18} 13 | \contentsline {section}{\numberline {1.3}Exercises}{20} 14 | \contentsline {section}{\numberline {1.4}Practical Session 1}{22} 15 | \contentsline {chapter}{\numberline {2}Matching and Proof Search}{27} 16 | \contentsline {section}{\numberline {2.1}Matching}{27} 17 | \contentsline {subsection}{\numberline {2.1.1}Examples}{29} 18 | \contentsline {subsection}{\numberline {2.1.2}The occurs check}{33} 19 | \contentsline {subsection}{\numberline {2.1.3}Programming with matching}{35} 20 | \contentsline {section}{\numberline {2.2}Proof Search}{38} 21 | \contentsline {section}{\numberline {2.3}Exercises}{44} 22 | \contentsline {section}{\numberline {2.4}Practical Session 2}{47} 23 | \contentsline {chapter}{\numberline {3}Recursion}{51} 24 | \contentsline {section}{\numberline {3.1}Recursive definitions}{51} 25 | \contentsline {subsection}{\numberline {3.1.1}Example 1: Eating}{51} 26 | \contentsline {subsection}{\numberline {3.1.2}Example 2: Descendant}{54} 27 | \contentsline {subsection}{\numberline {3.1.3}Example 3: Successor}{59} 28 | \contentsline {subsection}{\numberline {3.1.4}Example 3: Addition}{61} 29 | \contentsline {section}{\numberline {3.2}Clause ordering, goal ordering, and termination}{64} 30 | \contentsline {section}{\numberline {3.3}Exercises}{67} 31 | \contentsline {section}{\numberline {3.4}Practical Session 3}{69} 32 | \contentsline {chapter}{\numberline {4}Lists}{75} 33 | \contentsline {section}{\numberline {4.1}Lists}{75} 34 | \contentsline {section}{\numberline {4.2}Member}{80} 35 | \contentsline {section}{\numberline {4.3}Recursing down lists}{84} 36 | \contentsline {section}{\numberline {4.4}Exercises}{88} 37 | \contentsline {section}{\numberline {4.5}Practical Session 4}{91} 38 | \contentsline {chapter}{\numberline {5}Arithmetic}{93} 39 | \contentsline {section}{\numberline {5.1}Arithmetic in Prolog}{93} 40 | \contentsline {section}{\numberline {5.2}A closer look}{95} 41 | \contentsline {section}{\numberline {5.3}Arithmetic and lists}{98} 42 | \contentsline {section}{\numberline {5.4}Comparing integers}{101} 43 | \contentsline {section}{\numberline {5.5}Exercises}{105} 44 | \contentsline {section}{\numberline {5.6}Practical Session 5}{106} 45 | \contentsline {chapter}{\numberline {6}More Lists}{109} 46 | \contentsline {section}{\numberline {6.1}Append}{109} 47 | \contentsline {subsection}{\numberline {6.1.1}Defining append}{110} 48 | \contentsline {subsection}{\numberline {6.1.2}Using append}{113} 49 | \contentsline {section}{\numberline {6.2}Reversing a list}{116} 50 | \contentsline {subsection}{\numberline {6.2.1}Naive reverse using append}{117} 51 | \contentsline {subsection}{\numberline {6.2.2}Reverse using an accumulator}{118} 52 | \contentsline {section}{\numberline {6.3}Exercises}{119} 53 | \contentsline {section}{\numberline {6.4}Practical Session 6}{121} 54 | \contentsline {chapter}{\numberline {7}Definite Clause Grammars}{125} 55 | \contentsline {section}{\numberline {7.1}Context free grammars}{125} 56 | \contentsline {subsection}{\numberline {7.1.1}CFG recognition using append}{129} 57 | \contentsline {subsection}{\numberline {7.1.2}CFG recognition using difference lists}{132} 58 | \contentsline {section}{\numberline {7.2}Definite clause grammars}{134} 59 | \contentsline {subsection}{\numberline {7.2.1}A first example}{134} 60 | \contentsline {subsection}{\numberline {7.2.2}Adding recursive rules}{137} 61 | \contentsline {subsection}{\numberline {7.2.3}A DCG for a simple formal language}{139} 62 | \contentsline {section}{\numberline {7.3}Exercises}{141} 63 | \contentsline {section}{\numberline {7.4}Practical Session 7}{141} 64 | \contentsline {chapter}{\numberline {8}More Definite Clause Grammars}{145} 65 | \contentsline {section}{\numberline {8.1}Extra arguments}{145} 66 | \contentsline {subsection}{\numberline {8.1.1}Context free grammars with features}{145} 67 | \contentsline {subsection}{\numberline {8.1.2}Building parse trees}{152} 68 | \contentsline {subsection}{\numberline {8.1.3}Beyond context free languages}{155} 69 | \contentsline {section}{\numberline {8.2}Extra goals}{156} 70 | \contentsline {subsection}{\numberline {8.2.1}Separating rules and lexicon}{158} 71 | \contentsline {section}{\numberline {8.3}Concluding remarks}{160} 72 | \contentsline {section}{\numberline {8.4}Exercises}{162} 73 | \contentsline {section}{\numberline {8.5}Practical Session 8}{162} 74 | \contentsline {chapter}{\numberline {9}A Closer Look at Terms}{165} 75 | \contentsline {section}{\numberline {9.1}Comparing terms}{165} 76 | \contentsline {section}{\numberline {9.2}Terms with a special notation}{167} 77 | \contentsline {subsection}{\numberline {9.2.1}Arithmetic terms}{168} 78 | \contentsline {subsection}{\numberline {9.2.2}Lists as terms}{170} 79 | \contentsline {section}{\numberline {9.3}Examining Terms}{172} 80 | \contentsline {subsection}{\numberline {9.3.1}Types of Terms}{173} 81 | \contentsline {subsection}{\numberline {9.3.2}The Structure of Terms}{175} 82 | \contentsline {section}{\numberline {9.4}Operators}{179} 83 | \contentsline {subsection}{\numberline {9.4.1}Properties of operators}{179} 84 | \contentsline {subsection}{\numberline {9.4.2}Defining operators}{181} 85 | \contentsline {section}{\numberline {9.5}Exercises}{183} 86 | \contentsline {section}{\numberline {9.6}Practical Session}{185} 87 | \contentsline {chapter}{\numberline {10}Cuts and Negation}{191} 88 | \contentsline {section}{\numberline {10.1}The cut}{191} 89 | \contentsline {section}{\numberline {10.2}If-then-else}{200} 90 | \contentsline {section}{\numberline {10.3}Negation as failure}{201} 91 | \contentsline {section}{\numberline {10.4}Exercises}{205} 92 | \contentsline {section}{\numberline {10.5}Practical Session 10}{206} 93 | \contentsline {chapter}{\numberline {11}Database Manipulation and Collecting Solutions}{209} 94 | \contentsline {section}{\numberline {11.1}Database manipulation}{209} 95 | \contentsline {section}{\numberline {11.2}Collecting solutions}{214} 96 | \contentsline {subsection}{\numberline {11.2.1}{\tt findall/3}}{215} 97 | \contentsline {subsection}{\numberline {11.2.2}{\tt bagof/3}}{216} 98 | \contentsline {subsection}{\numberline {11.2.3}{\tt setof/3}}{219} 99 | \contentsline {section}{\numberline {11.3}Exercises}{220} 100 | \contentsline {section}{\numberline {11.4}Practical Session 11}{222} 101 | \contentsline {chapter}{\numberline {12}Working With Files}{225} 102 | \contentsline {section}{\numberline {12.1}Splitting Programs Over Files}{225} 103 | \contentsline {subsection}{\numberline {12.1.1}Reading in Programs}{225} 104 | \contentsline {subsection}{\numberline {12.1.2}Modules}{226} 105 | \contentsline {subsection}{\numberline {12.1.3}Libraries}{228} 106 | \contentsline {section}{\numberline {12.2}Writing To and Reading From Files}{229} 107 | \contentsline {section}{\numberline {12.3}Practical Session}{231} 108 | \contentsline {subsection}{\numberline {12.3.1}Step 1}{232} 109 | \contentsline {subsection}{\numberline {12.3.2}Step 2}{232} 110 | \contentsline {subsection}{\numberline {12.3.3}Step 3}{232} 111 | \contentsline {subsection}{\numberline {12.3.4}Step 4}{232} 112 | \contentsline {subsection}{\numberline {12.3.5}Step 5}{232} 113 | \contentsline {subsection}{\numberline {12.3.6}Step 6}{233} 114 | -------------------------------------------------------------------------------- /text/old_search_trees.txt: -------------------------------------------------------------------------------- 1 | ?- magic(Hermione). 2 | / | \ 3 | ?- house_elf(Hermione). | \ 4 | / | \ 5 | Hermione = dobby | \ 6 | | \ 7 | ?- wizard(Hermione). \ 8 | | \ 9 | fail | 10 | | 11 | ?- witch(Hermione). 12 | / | \ 13 | Hermione=hermione | \ 14 | | | 15 | Hermione='McGonagall' | 16 | | 17 | Hermione=rita_skeeter 18 | 19 | 20 | ?- member(a,[c,b,a,y]). 21 | / \ 22 | fail ?- member(a,[b,a,y)). 23 | / \ 24 | fail ?- member(a,[a,y]). 25 | / 26 | success 27 | 28 | 29 | ?- member(x,[a,b,c]]). 30 | / \ 31 | fail ?- member(x,[b,c]). 32 | / \ 33 | fail ?- member(x,[c]). 34 | / 35 | fail 36 | 37 | 38 | 39 | ?- member(X,a,b,c]]). 40 | / \ 41 | X=a ?- member(X,[b,c]). 42 | / \ 43 | X=b ?- member(X,[c]). 44 | / 45 | X=c 46 | 47 | -------------------------------------------------------------------------------- /text/parse.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: parse.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:20:02 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 167 137 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 137 moveto 0 0 lineto 167 0 lineto 167 137 lineto closepath clip newpath 49 | -153.0 292.5 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0 slj 0 slc 89 | 0.06000 0.06000 sc 90 | % 91 | % Fig objects follow 92 | % 93 | % 94 | % here starts figure with depth 100 95 | % Polyline 96 | 15.000 slw 97 | n 3600 2775 m 98 | 3150 3075 l gs col0 s gr 99 | % Polyline 100 | n 3600 2775 m 101 | 4125 3075 l gs col0 s gr 102 | % Polyline 103 | n 3150 3300 m 104 | 2700 3525 l gs col0 s gr 105 | % Polyline 106 | n 3150 3300 m 107 | 3375 3600 l gs col0 s gr 108 | % Polyline 109 | n 4200 3300 m 110 | 3975 3600 l gs col0 s gr 111 | % Polyline 112 | n 4200 3300 m 113 | 4800 3600 l gs col0 s gr 114 | % Polyline 115 | n 4800 3825 m 116 | 4575 4200 l gs col0 s gr 117 | % Polyline 118 | n 4800 3825 m 119 | 5100 4200 l gs col0 s gr 120 | % Polyline 121 | n 2700 3825 m 122 | 2700 4200 l gs col0 s gr 123 | % Polyline 124 | n 3375 3825 m 125 | 3375 4200 l gs col0 s gr 126 | % Polyline 127 | n 3975 3825 m 128 | 3975 4200 l gs col0 s gr 129 | % Polyline 130 | n 4575 4425 m 131 | 4575 4725 l gs col0 s gr 132 | % Polyline 133 | n 5175 4425 m 134 | 5175 4725 l gs col0 s gr 135 | /Times-Bold ff 210.00 scf sf 136 | 3600 2700 m 137 | gs 1 -1 sc (s) col0 sh gr 138 | /Times-Bold ff 210.00 scf sf 139 | 3075 3225 m 140 | gs 1 -1 sc (np) col0 sh gr 141 | /Times-Bold ff 210.00 scf sf 142 | 4050 3225 m 143 | gs 1 -1 sc (vp) col0 sh gr 144 | /Times-Bold ff 210.00 scf sf 145 | 2550 3750 m 146 | gs 1 -1 sc (det) col0 sh gr 147 | /Times-Bold ff 210.00 scf sf 148 | 3300 3750 m 149 | gs 1 -1 sc (n) col0 sh gr 150 | /Times-Italic ff 210.00 scf sf 151 | 2625 4350 m 152 | gs 1 -1 sc (a) col0 sh gr 153 | /Times-Italic ff 210.00 scf sf 154 | 3000 4350 m 155 | gs 1 -1 sc (woman) col0 sh gr 156 | /Times-Italic ff 210.00 scf sf 157 | 3675 4350 m 158 | gs 1 -1 sc (shoots) col0 sh gr 159 | /Times-Bold ff 210.00 scf sf 160 | 3900 3750 m 161 | gs 1 -1 sc (v) col0 sh gr 162 | /Times-Bold ff 210.00 scf sf 163 | 4725 3750 m 164 | gs 1 -1 sc (np) col0 sh gr 165 | /Times-Bold ff 210.00 scf sf 166 | 4425 4350 m 167 | gs 1 -1 sc (det) col0 sh gr 168 | /Times-Italic ff 210.00 scf sf 169 | 4500 4875 m 170 | gs 1 -1 sc (a) col0 sh gr 171 | /Times-Bold ff 210.00 scf sf 172 | 5100 4350 m 173 | gs 1 -1 sc (n) col0 sh gr 174 | /Times-Italic ff 210.00 scf sf 175 | 4950 4875 m 176 | gs 1 -1 sc (man) col0 sh gr 177 | % here ends figure; 178 | $F2psEnd 179 | rs 180 | showpage 181 | -------------------------------------------------------------------------------- /text/parse2.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: parse2.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:20:29 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 117 106 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 106 moveto 0 0 lineto 117 0 lineto 117 106 lineto closepath clip newpath 49 | -153.0 261.0 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0 slj 0 slc 89 | 0.06000 0.06000 sc 90 | % 91 | % Fig objects follow 92 | % 93 | % 94 | % here starts figure with depth 100 95 | % Polyline 96 | 15.000 slw 97 | n 3600 2775 m 98 | 3150 3075 l gs col0 s gr 99 | % Polyline 100 | n 3600 2775 m 101 | 4125 3075 l gs col0 s gr 102 | % Polyline 103 | n 3150 3300 m 104 | 2700 3525 l gs col0 s gr 105 | % Polyline 106 | n 3150 3300 m 107 | 3375 3600 l gs col0 s gr 108 | % Polyline 109 | n 4200 3300 m 110 | 4200 3600 l gs col0 s gr 111 | % Polyline 112 | n 2700 3825 m 113 | 2700 4200 l gs col0 s gr 114 | % Polyline 115 | n 3375 3825 m 116 | 3375 4200 l gs col0 s gr 117 | % Polyline 118 | n 4200 3825 m 119 | 4200 4200 l gs col0 s gr 120 | /Times-Bold ff 210.00 scf sf 121 | 3600 2700 m 122 | gs 1 -1 sc (s) col0 sh gr 123 | /Times-Bold ff 210.00 scf sf 124 | 3075 3225 m 125 | gs 1 -1 sc (np) col0 sh gr 126 | /Times-Bold ff 210.00 scf sf 127 | 4050 3225 m 128 | gs 1 -1 sc (vp) col0 sh gr 129 | /Times-Bold ff 210.00 scf sf 130 | 2550 3750 m 131 | gs 1 -1 sc (det) col0 sh gr 132 | /Times-Bold ff 210.00 scf sf 133 | 3300 3750 m 134 | gs 1 -1 sc (n) col0 sh gr 135 | /Times-Italic ff 210.00 scf sf 136 | 2625 4350 m 137 | gs 1 -1 sc (a) col0 sh gr 138 | /Times-Italic ff 210.00 scf sf 139 | 3000 4350 m 140 | gs 1 -1 sc (woman) col0 sh gr 141 | /Times-Bold ff 210.00 scf sf 142 | 4125 3750 m 143 | gs 1 -1 sc (v) col0 sh gr 144 | /Times-Italic ff 210.00 scf sf 145 | 3900 4350 m 146 | gs 1 -1 sc (shoots) col0 sh gr 147 | % here ends figure; 148 | $F2psEnd 149 | rs 150 | showpage 151 | -------------------------------------------------------------------------------- /text/preface.tex: -------------------------------------------------------------------------------- 1 | 2 | \chapter*{Preface}\label{PREFACE} 3 | 4 | \textit{Learn Prolog Now!} has a long and twisted history. In 1995, 5 | all three authors were based at the Department of Computational 6 | Linguistics, at the University of the Saarland, in Saarbr\"{u}cken, 7 | Germany. Johan, who was teaching the introduction to Prolog that year, 8 | was working with Patrick on a Prolog-based introduction to natural 9 | language semantics.% 10 | \footnote{\textit{Representation and Inference for Natural Language: A 11 | First Course in Computational Semantics}, Patrick Blackburn and Johan 12 | Bos, CSLI Publications, 2005.} 13 | He decided to prepare a short set 14 | of lecture notes on Prolog which could also be used as an Appendix to 15 | the computational semantics book. 16 | 17 | Nice idea, but that's not the way things worked out. First, between 18 | 1996 and 2000, Patrick and Johan rethought the structure of the Prolog 19 | courses, and along the way the notes became book-sized. Then, from 20 | 2001 till 2004, Kristina took over the teaching, added new material 21 | and (most importantly of all) turned \textit{Learn Prolog Now!} into 22 | a web-book. 23 | 24 | It quickly became apparent that we had a hit on our hands: the website 25 | got up to 4,000 visitors a month, and we received many 26 | emails. Actually, this put us in a bit of a quandary. We wanted to 27 | publish \textit{Learn Prolog Now!} as a (low-budget) book --- but at 28 | the same time we did \textit{not} want a publisher telling us that we 29 | had to get rid of the free online version. 30 | 31 | Luckily, Vincent Hendricks came to the rescue (thanks Vincent!). He 32 | told us about College Publications, Dov Gabbay's new publication 33 | house, which was specifically designed to enable authors to retain 34 | copyright. It was a marriage made in heaven. Thanks to College 35 | Publications we could make \textit{Learn Prolog Now!} available in 36 | book form at a reasonable price, and keep the web-book in place. 37 | 38 | And that's the book you're now reading. It has been thoroughly tested, 39 | first on nearly a decade's worth of students at Saarbr\"{u}cken, and 40 | at the \textit{16th European Summer School in Logic, Language and 41 | Information} which took place in Nancy, France, in August 2004, where 42 | Kristina taught a hands-on introduction to Prolog. Though, as we hope 43 | you will swiftly discover, you \textit{don't} need to be doing a 44 | course to follow this book. We've tried to make \textit{Learn Prolog 45 | Now!} self-contained and easy to follow, so that it can be used 46 | without a teacher. And as the feedback we have received confirms, this 47 | is one of the most popular ways of using it. 48 | 49 | So --- over to you. We had a lot of fun writing this. We hope you have 50 | a lot of fun reading it, and that it really will help you to learn 51 | Prolog now! 52 | 53 | \subsection*{Acknowledgments} 54 | 55 | Over the years that \textit{Learn Prolog Now!} existed as course notes 56 | and web-book, we received many emails, ranging from helpful comments to 57 | requests for answers to problems (a handful of which verged on demands 58 | that we do their homework assignments!). We can't thank everyone by name, 59 | but we did receive a lot of useful feedback this way and are very 60 | grateful. And if we did any homework assignments, we ain't 61 | telling\ldots 62 | 63 | We are extremely grateful to Gertjan van Noord and Robbert Prins, who 64 | used early versions of \textit{Learn Prolog Now!} in their teaching at 65 | the University of Groningen. They gave us detailed feedback on its 66 | weak points, and we've tried to take their advice into account; we 67 | hope we've succeeded. We'd also like to say \textit{Grazie!} to 68 | Malvina Nissim, who supplied us with an upgrade of 69 | Exercise~\ref{L2.EX4}, helped format the final hardcopy version, and 70 | generally gave us her enthusiastic support over many years. 71 | 72 | Some special thanks are in order. First, we'd like to thank Dov Gabbay 73 | for founding College Publications; may it do for academic publishing 74 | what the GNU Public License did for software! Second, heartfelt 75 | thanks to Jane Spurr; we've \textit{never} had a more helpful, 76 | competent, or enthusiastic editor, and \textit{nobody} reacts faster 77 | than Jane. Thirdly, we like to thank Jan Wielemaker (the Linus 78 | Torvalds of the Prolog world) for making SWI Prolog freely available 79 | over the internet. SWI Prolog is a an ISO-compliant Free Software 80 | Prolog environment, licensed under the Lesser GNU Public License. We 81 | don't know what we'd have done without it. We're also very grateful to 82 | him for the speedy and informative feedback he gave us on a number of 83 | technical issues, and for encouraging us to go for ISO-standard 84 | Prolog. Finally, a big thank you to Ian Mackie and an anonymous 85 | referee for all the time and energy they put into the penultimate version 86 | of the book. 87 | 88 | \begin{flushright} 89 | Patrick Blackburn\\ 90 | Johan Bos\\ 91 | Kristina Striegnitz\\ 92 | \textit{May 2006} 93 | \end{flushright} 94 | 95 | -------------------------------------------------------------------------------- /text/preface2.tex: -------------------------------------------------------------------------------- 1 | 2 | \chapter*{Preface to the First Reprinting}\label{PREFACE2} 3 | 4 | 5 | Well, what a year it's been! Interest in \textit{Learn Prolog Now!} 6 | continues to grow. College Publications brought out the first 7 | paperback edition in June 2006, and since then the number of hits on 8 | the website (\url{www.learnprolognow.org}) has increased steadily. The 9 | most dramatic month was May 2007 when we had 6,322 unique visitors; a reader 10 | submitted the LPN! link to Reddit (\url{http://programming.reddit.com}) 11 | and for a heady moment we felt a bit like Smosh! 12 | 13 | We've also been pleased by the emails we continue to get from students 14 | and instructors using the material. Some point out typos, others tell 15 | us of their experiences in teaching or learning with the book, and 16 | a pleasing number simply want to say ``Thank you!''. All in all, it 17 | was fast becoming clear that it was about time for a first (corrected) 18 | reprinting. 19 | 20 | But what really made us get down to work was the sudden appearance of 21 | a French translation. H\'{e}l\`{e}ne Manu\'{e}lian, who began 22 | translating LPN! shortly after its appearance in paperback, finished 23 | earlier than anticipated --- so suddenly we had \textit{Prolog Tout de 24 | Suite !} on our hands too! This inspired us all to get down to the 25 | task of correcting and improving the English version. 26 | 27 | So, here it is again, all squeaky clean. Once again, if you like the 28 | website, we hope you like the (new!) paperback even more. And, as 29 | usual, we wish you every success in your endeavours to Learn Prolog 30 | Now! 31 | 32 | \subsection*{Acknowledgments} 33 | 34 | Once again we're in debt to many people: everyone who gave us feedback 35 | on the first printing and the website, and (as ever) to the 36 | indefatigable Jane Spurr. However this time we owe a particularly deep 37 | debt to S\'{e}bastien Hinderer, Eric Kow, Matthieu Quignard, 38 | and (of course) H\'{e}l\`{e}ne Manu\'{e}lian. Their work on 39 | \textit{Prolog Tout de Suite !}, not only created a beautiful 40 | translation, it also helped us with the present volume. Warmest thanks 41 | to all. 42 | 43 | % Thanks to Peter Urbak (correction) 44 | % and Richard Kenyon (correction) 45 | % and Matt Braithwaite (correction) 46 | % and Anas Elghafari (correction) 47 | % and Shannon ``JJ'' Behrens (corrections) 48 | % and Alejandro Marín Buriticá 49 | % and Gabriele Medeot 50 | % and Ali Almiman 51 | \clearpage 52 | 53 | \begin{flushright} 54 | Patrick Blackburn\\ 55 | TALARIS team\\ 56 | INRIA Nancy Grand-Est, France\\\bigskip 57 | 58 | Johan Bos\\ 59 | Department of Computer Science\\ 60 | University of Rome ``La Sapienza'', Italy\\\bigskip 61 | 62 | Kristina Striegnitz\\ 63 | Computer Science Department\\ 64 | Union College, Schenectady, NY, United States\\\bigskip 65 | 66 | October 2007. 67 | \end{flushright} 68 | -------------------------------------------------------------------------------- /text/prolog.idx: -------------------------------------------------------------------------------- 1 | \indexentry{,/2@\texttt{,/2}}{6} 2 | \indexentry{;/2@\texttt{;/2}}{7} 3 | \indexentry{listing/0@\texttt{listing/0}}{17} 4 | \indexentry{=/2@\texttt{=/2}}{24} 5 | \indexentry{unify\_with\_occurs\_check/2@\texttt{unify\_with\_occurs\_check/2}}{31} 6 | \indexentry{\=/2@\verb-\=/2-}{42} 7 | \indexentry{trace/0@\texttt{trace/0}}{43} 8 | \indexentry{notrace/0@\texttt{notrace/0}}{45} 9 | \indexentry{member/2@\texttt{member/2}}{76} 10 | \indexentry{is/2@\texttt{is/2}}{90} 11 | \indexentry{=/2@\texttt{>=/2}}{97} 16 | \indexentry{>/2@\texttt{>/2}}{97} 17 | \indexentry{append/3@\texttt{append/3}}{106} 18 | \indexentry{c/3@\texttt{'C'/3}}{130} 19 | \indexentry{c/3@\texttt{'C'/3}}{136} 20 | \indexentry{==/2@\texttt{==/2}}{160} 21 | \indexentry{\==/2@\verb-\==/2-}{161} 22 | \indexentry{./2@\texttt{./2}}{164} 23 | \indexentry{atom/1@\texttt{atom/1}}{167} 24 | \indexentry{integer/1@\texttt{integer/1}}{167} 25 | \indexentry{float/1@\texttt{float/1}}{167} 26 | \indexentry{number/1@\texttt{number/1}}{167} 27 | \indexentry{atomic/1@\texttt{atomic/1}}{167} 28 | \indexentry{var/1@\texttt{var/1}}{167} 29 | \indexentry{nonvar/1@\texttt{nonvar/1}}{167} 30 | \indexentry{functor/3@\texttt{functor/3}}{170} 31 | \indexentry{arg/3@\texttt{arg/3}}{172} 32 | \indexentry{=..@\texttt{=../2}}{172} 33 | \indexentry{atom\_codes/2@\texttt{atom\_codes/2}}{173} 34 | \indexentry{number\_codes/2@\texttt{number\_codes/2}}{174} 35 | \indexentry{op/3@\texttt{op/3}}{176} 36 | \indexentry{display/1@\texttt{display/1}}{179} 37 | \indexentry{write/1@\texttt{write/1}}{180} 38 | \indexentry{tab/1@\texttt{tab/1}}{182} 39 | \indexentry{nl/0@\texttt{nl/0}}{182} 40 | \indexentry{!/0@\texttt{!/0}}{186} 41 | \indexentry{max/3@\texttt{max/3}}{192} 42 | \indexentry{assert/1@\texttt{assert/1}}{204} 43 | \indexentry{retract/1@\texttt{retract/1}}{204} 44 | \indexentry{assertz/1@\texttt{assertz/1}}{207} 45 | \indexentry{asserta/1@\texttt{asserta/1}}{207} 46 | \indexentry{retractall/3@\texttt{retractall/3}}{208} 47 | \indexentry{findall/3@\texttt{findall/3}}{209} 48 | \indexentry{bagof/3@\texttt{bagof/3}}{211} 49 | \indexentry{setof/3@\texttt{setof/3}}{213} 50 | \indexentry{ensure_loaded/1@\texttt{ensure\_loaded/1}}{219} 51 | \indexentry{tab/1@\texttt{tab/1}}{220} 52 | \indexentry{nl/0@\texttt{nl/0}}{220} 53 | \indexentry{module/2@\texttt{module/2}}{221} 54 | \indexentry{use_module/1@\texttt{use\_module/1}}{222} 55 | \indexentry{use_module/2@\texttt{use\_module/2}}{222} 56 | \indexentry{open/3@\texttt{open/3}}{223} 57 | \indexentry{write/2@\texttt{write/2}}{223} 58 | \indexentry{close/1@\texttt{close/1}}{223} 59 | \indexentry{nl/1@\texttt{nl/1}}{223} 60 | \indexentry{read/2@\texttt{read/2}}{224} 61 | \indexentry{open/3@\texttt{open/3}}{224} 62 | \indexentry{at_end_of_stream/1@\texttt{at\_end\_of\_stream/1}}{225} 63 | \indexentry{get\_code/2@\texttt{get\_code/2}}{225} 64 | \indexentry{atom\_codes/2@\texttt{atom\_codes/2}}{225} 65 | -------------------------------------------------------------------------------- /text/prolog.ilg: -------------------------------------------------------------------------------- 1 | This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support). 2 | Scanning style file ./LPN.isty....done (4 attributes redefined, 0 ignored). 3 | Scanning input file prolog.idx.... 4 | !! Input index error (file = prolog.idx, line = 40): 5 | -- Illegal null field. 6 | done (63 entries accepted, 1 rejected). 7 | Sorting entries....done (436 comparisons). 8 | Generating output file prolog.ind....done (117 lines written, 0 warnings). 9 | Output written in prolog.ind. 10 | Transcript written in prolog.ilg. 11 | -------------------------------------------------------------------------------- /text/prolog.ind: -------------------------------------------------------------------------------- 1 | \begin{theindex} 2 | \thispagestyle{empty} 3 | \textbf{Symbols} \nopagebreak 4 | \item \texttt{,/2}, 6 5 | \item \texttt{./2}, 164 6 | \item \texttt{;/2}, 7 7 | \item \texttt{/2}, 97 15 | \item \texttt{>=/2}, 97 16 | \item \verb-\=/2-, 42 17 | \item \verb-\==/2-, 161 18 | 19 | \indexspace 20 | \textbf{A} \nopagebreak 21 | \item \texttt{append/3}, 106 22 | \item \texttt{arg/3}, 172 23 | \item \texttt{assert/1}, 204 24 | \item \texttt{asserta/1}, 207 25 | \item \texttt{assertz/1}, 207 26 | \item \texttt{at\_end\_of\_stream/1}, 225 27 | \item \texttt{atom/1}, 167 28 | \item \texttt{atom\_codes/2}, 173, 225 29 | \item \texttt{atomic/1}, 167 30 | 31 | \indexspace 32 | \textbf{B} \nopagebreak 33 | \item \texttt{bagof/3}, 211 34 | 35 | \indexspace 36 | \textbf{C} \nopagebreak 37 | \item \texttt{'C'/3}, 130, 136 38 | \item \texttt{close/1}, 223 39 | 40 | \indexspace 41 | \textbf{D} \nopagebreak 42 | \item \texttt{display/1}, 179 43 | 44 | \indexspace 45 | \textbf{E} \nopagebreak 46 | \item \texttt{ensure\_loaded/1}, 219 47 | 48 | \indexspace 49 | \textbf{F} \nopagebreak 50 | \item \texttt{findall/3}, 209 51 | \item \texttt{float/1}, 167 52 | \item \texttt{functor/3}, 170 53 | 54 | \indexspace 55 | \textbf{G} \nopagebreak 56 | \item \texttt{get\_code/2}, 225 57 | 58 | \indexspace 59 | \textbf{I} \nopagebreak 60 | \item \texttt{integer/1}, 167 61 | \item \texttt{is/2}, 90 62 | 63 | \indexspace 64 | \textbf{L} \nopagebreak 65 | \item \texttt{listing/0}, 17 66 | 67 | \indexspace 68 | \textbf{M} \nopagebreak 69 | \item \texttt{max/3}, 192 70 | \item \texttt{member/2}, 76 71 | \item \texttt{module/2}, 221 72 | 73 | \indexspace 74 | \textbf{N} \nopagebreak 75 | \item \texttt{nl/0}, 182, 220 76 | \item \texttt{nl/1}, 223 77 | \item \texttt{nonvar/1}, 167 78 | \item \texttt{notrace/0}, 45 79 | \item \texttt{number/1}, 167 80 | \item \texttt{number\_codes/2}, 174 81 | 82 | \indexspace 83 | \textbf{O} \nopagebreak 84 | \item \texttt{op/3}, 176 85 | \item \texttt{open/3}, 223, 224 86 | 87 | \indexspace 88 | \textbf{R} \nopagebreak 89 | \item \texttt{read/2}, 224 90 | \item \texttt{retract/1}, 204 91 | \item \texttt{retractall/3}, 208 92 | 93 | \indexspace 94 | \textbf{S} \nopagebreak 95 | \item \texttt{setof/3}, 213 96 | 97 | \indexspace 98 | \textbf{T} \nopagebreak 99 | \item \texttt{tab/1}, 182, 220 100 | \item \texttt{trace/0}, 43 101 | 102 | \indexspace 103 | \textbf{U} \nopagebreak 104 | \item \texttt{unify\_with\_occurs\_check/2}, 31 105 | \item \texttt{use\_module/1}, 222 106 | \item \texttt{use\_module/2}, 222 107 | 108 | \indexspace 109 | \textbf{V} \nopagebreak 110 | \item \texttt{var/1}, 167 111 | 112 | \indexspace 113 | \textbf{W} \nopagebreak 114 | \item \texttt{write/1}, 180 115 | \item \texttt{write/2}, 223 116 | 117 | \end{theindex} 118 | -------------------------------------------------------------------------------- /text/splitindex.perl_orig.txt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | open(MAININDEX, ">/tmp/lpn.idx"); 4 | open(NAMEINDEX, ">names.idx"); 5 | open(PROLOGINDEX, ">prolog.idx"); 6 | open(FILE, ") { 10 | if ($_ =~ /indexentry\{NAME\s*(\w.*)\}\{(.*)\}/) { 11 | $AUTHOR = $1; 12 | $PAGE = $2; 13 | $AUTHOR =~ s/ +/ /g; 14 | $AUTHOR =~ s/^ //g; 15 | print NAMEINDEX "\\indexentry{$AUTHOR}{$PAGE}\n"; 16 | } elsif ($_ =~ /indexentry\{PROLOG (.*)\}\{(.*)\}/) { 17 | $PROLOG = $1; 18 | $PAGE = $2; 19 | $PROLOG =~ s/ +/ /g; 20 | $PROLOG =~ s/^ //g; 21 | print PROLOGINDEX "\\indexentry{$PROLOG}{$PAGE}\n"; 22 | } elsif ($_ =~ /indexentry\{CITATION (.*)\}\{(.*)\}/) { 23 | my $CITE = $1; 24 | my $PAGE = $2; 25 | my $FoundAuthor = 0; 26 | my $FoundEditor = 0; 27 | my $AUTHOR = ""; 28 | my $EDITOR = ""; 29 | 30 | open(BIB, ") { 34 | if ($_ =~ /@/ && $LookForAuthor eq 1) { 35 | $LookForAuthor = 0; 36 | $LookForEditor = 0; 37 | } 38 | if ($_ =~ /$CITE,/) { 39 | $LookForAuthor = 1; 40 | $LookForEditor = 1; 41 | } 42 | if ($_ =~ /author\s*=(.*\w.*)/ && $LookForAuthor eq 1) { 43 | $AUTHOR = $1; 44 | $AUTHOR =~ s/\\\"/QUOTE/g; 45 | $AUTHOR =~ s/\{\\o\}/OOOOO/g; 46 | $AUTHOR =~ s/\{\\aa\}/AAAAA/g; 47 | $AUTHOR =~ s/\"//g; 48 | $AUTHOR =~ s/,\s*$//g; 49 | $AUTHOR =~ s/\{//g; 50 | $AUTHOR =~ s/\}//g; 51 | $AUTHOR =~ s/^\s*//g; 52 | $AUTHOR =~ s/QUOTE/\\\"/g; 53 | $AUTHOR =~ s/OOOOO/\{\\o\}/g; 54 | $AUTHOR =~ s/AAAAA/\{\\aa\}/g; 55 | $LookForAuthor = 0; 56 | $FoundAuthor = 1; 57 | } 58 | if ($_ =~ /editor\s*=(.*\w.*)/ && $LookForAuthor eq 1 && $LookForEditor eq 1) { 59 | $EDITOR = $1; 60 | $EDITOR =~ s/\\\"/QUOTE/g; 61 | $EDITOR =~ s/\{\\o\}/OOOOO/g; 62 | $EDITOR =~ s/\{\\aa\}/AAAAA/g; 63 | $EDITOR =~ s/\"//g; 64 | $EDITOR =~ s/,\s*$//g; 65 | $EDITOR =~ s/\{//g; 66 | $EDITOR =~ s/\}//g; 67 | $EDITOR =~ s/^\s*//g; 68 | $EDITOR =~ s/QUOTE/\\\"/g; 69 | $EDITOR =~ s/OOOOO/\{\\o\}/g; 70 | $EDITOR =~ s/AAAAA/\{\\aa\}/g; 71 | $LookForEditor = 0; 72 | $FoundEditor = 1; 73 | } 74 | } 75 | close(BIB); 76 | if ($FoundAuthor eq 1) { 77 | printauthor($AUTHOR,$PAGE); 78 | } 79 | if ($FoundAuthor eq 0 && $FoundEditor eq 1) { 80 | printauthor($EDITOR,$PAGE); 81 | } 82 | if ($FoundAuthor eq 0 && $FoundEditor eq 0) { 83 | print NAMEINDEX "\\indexentry{NOT FOUND: $CITE}{$PAGE}\n"; 84 | } 85 | 86 | } else { 87 | s/ +/ /g; 88 | print MAININDEX $_; 89 | 90 | } 91 | } 92 | 93 | close(FILE); 94 | close(NAMEINDEX); 95 | close(PROLOGINDEX); 96 | close(MAININDEX); 97 | 98 | system("mv /tmp/lpn.idx ./lpn.idx"); 99 | 100 | 101 | sub printauthor { 102 | 103 | local($name,$page)=@_; 104 | if ($name =~ /(.*)\sand\s(.*)/) { 105 | my $author1 = $1; 106 | my $author2 = $2; 107 | printauthor($author1,$page); 108 | printauthor($author2,$page); 109 | } else { 110 | $name =~ s/Van Eijck, D\.J\.N\./Van Eijck, J\./; 111 | $name =~ s/Sag, I\.A\./Sag, I\./; 112 | if ($name =~ /\\\"/) { 113 | my $altname = $name; 114 | $altname =~ s/\\\"o/oe/g; 115 | $altname =~ s/\\\"u/ue/g; 116 | $altname =~ s/\\\"a/ae/g; 117 | print NAMEINDEX "\\indexentry{$altname\@$name}{$page}\n"; 118 | } else { 119 | print NAMEINDEX "\\indexentry{$name}{$page}\n"; 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /text/sublist.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: sublist.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:18:45 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 321 92 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 92 moveto 0 0 lineto 321 0 lineto 321 92 lineto closepath clip newpath 49 | -94.5 288.7 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0 slj 0 slc 89 | 0.06000 0.06000 sc 90 | % 91 | % Fig objects follow 92 | % 93 | % 94 | % here starts figure with depth 100 95 | % Polyline 96 | 7.500 slw 97 | n 4200 3300 m 6900 3300 l 6900 3600 l 4200 3600 l 98 | cp gs col8 1.00 shd ef gr gs col0 s gr 99 | % Polyline 100 | n 4800 3900 m 6900 3900 l 6900 4200 l 4800 4200 l 101 | cp gs col8 1.00 shd ef gr gs col0 s gr 102 | % Polyline 103 | n 4800 4500 m 6000 4500 l 6000 4800 l 4800 4800 l 104 | cp gs col8 1.00 shd ef gr gs col0 s gr 105 | % Polyline 106 | [60] 0 sd 107 | n 4200 3900 m 4800 3900 l 4800 4200 l 4200 4200 l 108 | cp gs col11 1.00 shd ef gr gs col0 s gr [] 0 sd 109 | % Polyline 110 | [60] 0 sd 111 | n 4200 4500 m 4800 4500 l 4800 4800 l 4200 4800 l 112 | cp gs col11 1.00 shd ef gr gs col0 s gr [] 0 sd 113 | % Polyline 114 | [60] 0 sd 115 | n 6000 4500 m 6900 4500 l 6900 4800 l 6000 4800 l 116 | cp gs col11 1.00 shd ef gr gs col0 s gr [] 0 sd 117 | /Times-Bold ff 210.00 scf sf 118 | 1575 4725 m 119 | gs 1 -1 sc (Take prefix to get sublist:) col0 sh gr 120 | /Times-Bold ff 210.00 scf sf 121 | 2850 4125 m 122 | gs 1 -1 sc (Take suffix:) col0 sh gr 123 | /Times-Bold ff 210.00 scf sf 124 | 3525 3525 m 125 | gs 1 -1 sc (List:) col0 sh gr 126 | % here ends figure; 127 | $F2psEnd 128 | rs 129 | showpage 130 | -------------------------------------------------------------------------------- /text/termtypes.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: termtypes.fig 3 | %%Creator: fig2dev Version 3.2 Patchlevel 4 4 | %%CreationDate: Mon Aug 30 20:21:47 2004 5 | %%For: kris@tora (Kristina Striegnitz) 6 | %%BoundingBox: 0 0 189 116 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 116 moveto 0 0 lineto 189 0 lineto 189 116 lineto closepath clip newpath 49 | -94.5 292.5 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 84 | /$F2psEnd {$F2psEnteredState restore end} def 85 | 86 | $F2psBegin 87 | 10 setmiterlimit 88 | 0 slj 0 slc 89 | 0.06000 0.06000 sc 90 | % 91 | % Fig objects follow 92 | % 93 | % 94 | % here starts figure with depth 100 95 | % Polyline 96 | 15.000 slw 97 | n 3225 3150 m 98 | 2550 3450 l gs col0 s gr 99 | % Polyline 100 | n 3225 3150 m 101 | 3825 3450 l gs col0 s gr 102 | % Polyline 103 | n 2475 3750 m 104 | 1950 4050 l gs col0 s gr 105 | % Polyline 106 | n 2475 3750 m 107 | 2850 4050 l gs col0 s gr 108 | % Polyline 109 | n 3000 4350 m 110 | 2550 4650 l gs col0 s gr 111 | % Polyline 112 | n 3000 4350 m 113 | 3375 4650 l gs col0 s gr 114 | /Times-Bold ff 180.00 scf sf 115 | 2025 3675 m 116 | gs 1 -1 sc (simple terms) col0 sh gr 117 | /Times-Bold ff 180.00 scf sf 118 | 3525 3675 m 119 | gs 1 -1 sc (complex terms) col0 sh gr 120 | /Times-Bold ff 180.00 scf sf 121 | 3000 3075 m 122 | gs 1 -1 sc (terms) col0 sh gr 123 | /Times-Bold ff 180.00 scf sf 124 | 1575 4275 m 125 | gs 1 -1 sc (variables) col0 sh gr 126 | /Times-Bold ff 180.00 scf sf 127 | 2625 4275 m 128 | gs 1 -1 sc (constants) col0 sh gr 129 | /Times-Bold ff 180.00 scf sf 130 | 2325 4875 m 131 | gs 1 -1 sc (atoms) col0 sh gr 132 | /Times-Bold ff 180.00 scf sf 133 | 3075 4875 m 134 | gs 1 -1 sc (numbers) col0 sh gr 135 | % here ends figure; 136 | $F2psEnd 137 | rs 138 | showpage 139 | -------------------------------------------------------------------------------- /text/test_frontmatter.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[twoside,leqno,10pt]{book} 3 | 4 | \nofiles 5 | 6 | \frenchspacing 7 | 8 | \usepackage{amssymb,amsmath,theorem,latexsym} 9 | %\usepackage{cslipubs,aiml3,pubsbib} 10 | \usepackage{makeidx} 11 | \makeindex 12 | 13 | \newcommand{\sfive}{{\bf S5}} 14 | \font\jlctitleA = cmss17 at 42pt 15 | \font\jlctitleB = cmss11 at 25pt 16 | \font\jlctitleC = cmss14 at 33pt 17 | \font\jlctitleD = cmss9 at 12pt 18 | 19 | \begin{document} 20 | 21 | \thispagestyle{empty} 22 | \def\sqz{\hskip0pt minus1cm} 23 | \vspace*{2cm} 24 | 25 | \begin{center} 26 | {\jlctitleA T\sqz e\sqz x\sqz t\sqz s i\sqz n}\\[3ex] 27 | {\jlctitleA C\sqz o\sqz m\sqz p\sqz u\sqz t\sqz i\sqz n\sqz g}\\[3ex] 28 | {\jlctitleB Volume 7}\\[18ex] 29 | 30 | {\jlctitleC L\sqz e\sqz a\sqz r\sqz n P\sqz r\sqz o\sqz l\sqz o\sqz g N\sqz o\sqz w\sqz !} 31 | 32 | \end{center} 33 | \newpage\thispagestyle{empty} 34 | \newpage\thispagestyle{empty} 35 | 36 | \mbox{} 37 | \vfill 38 | 39 | \noindent {\sf Volume 1}\\ 40 | {\sf Programming Languages and Semantics}\\ 41 | {\sf Maribel Fernandez}\\[1ex] 42 | {\sf Volume 2}\\ 43 | {\sf An Introduction to Lambda Calculus for Computer Scientists}\\ 44 | {\sf Chris Hankin}\\[1ex] 45 | {\sf Volume 3}\\ 46 | {\sf Logical Reasoning: A First Course}\\ 47 | {\sf Rob Nederpelt and Fairouz Kamareddine}\\[1ex] 48 | {\sf Volume 4}\\ 49 | {\sf The Haskell Road to Logic, Maths and Programming}\\ 50 | {\sf Kees Doets and Jan van Eijck}\\[1ex] 51 | {\sf Volume 5}\\ 52 | {\sf Bridges from Classical to Nonmonotonic Reasoning}\\ 53 | {\sf David Makinson}\\[1ex] 54 | {\sf Volume 6}\\ 55 | {\sf Automata and Dictionaries}\\ 56 | {\sf Denis Maurel and Franz Guenthner}\\[1ex] 57 | {\sf Volume 7}\\ 58 | {\sf Learn Prolog Now!}\\ 59 | {\sf Patrick Blackburn, Johan Bos and Kristina Striegniz}\\[1ex] 60 | 61 | \noindent {\sf Texts in Computing Series Editor}\\ 62 | {\sf Ian Mackie \hfill ian.mackie@kcl.ac.uk}\\ 63 | 64 | \newpage 65 | \thispagestyle{empty} 66 | 67 | 68 | \begin{center} 69 | \vspace*{4cm} 70 | {\jlctitleC L\sqz e\sqz a\sqz r\sqz n P\sqz r\sqz o\sqz l\sqz o\sqz g N\sqz o\sqz w\sqz !}\\[16ex] 71 | {\jlctitleB Patrick Blackburn}\\[3ex] 72 | {\jlctitleB Johan Bos}\\[3ex] {\jlctitleB Kristina Striegnitz} 73 | \end{center} 74 | 75 | 76 | \newpage\thispagestyle{empty} 77 | \mbox{} 78 | \vspace*{3in} 79 | 80 | \vfill 81 | \noindent \copyright ~{\sf Individual author and King's College 2006. 82 | All rights reserved.}\\[3ex] 83 | {\sf ISBN 1-904987-17-6}\\ 84 | \noindent {\bf \sf College Publications}\\ 85 | {\sf Scientific Director: Dov Gabbay}\\ 86 | {\sf Managing Director: Jane Spurr}\\ 87 | {\sf Department of Computer Science}\\ 88 | {\sf Strand, London WC2R 2LS, UK}\\ 89 | %{\sf kcp@dcs.kcl.ac.uk}\\ 90 | [2ex] 91 | \noindent 92 | {\sf Cover design by Richard Fraser, www.avalonarts.co.uk}\\ 93 | {\sf Printed by Lightning Source, Milton Keynes, UK}\\[.5ex] 94 | %{\sf Distributed by King's College Publications, UK}\\ %[1ex] 95 | 96 | 97 | \noindent \hrulefill\\ 98 | \noindent \footnotesize{\sf All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior permission, in writing, from the publisher.} 99 | 100 | 101 | \end{document} 102 | 103 | -------------------------------------------------------------------------------- /www/LPN_french_cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/www/LPN_french_cover.jpg -------------------------------------------------------------------------------- /www/bibtex.php: -------------------------------------------------------------------------------- 1 | 2 |
 3 | @book{learnprolognow,
 4 |  author =    {Blackburn, Patrick and 
 5 |               Bos, Johan and 
 6 |               Striegnitz, Kristina},
 7 |  publisher = {College Publications},
 8 |  series =    {Texts in Computing},
 9 |  volume =    {7},
10 |  title =     {Learn Prolog Now!},
11 |  year =      {2006},
12 |  isbn =      {1-904987-17-6},
13 | }
14 | 
15 | 16 | -------------------------------------------------------------------------------- /www/bibtex_french.php: -------------------------------------------------------------------------------- 1 | 2 |
 3 | @book{learnprolognow,
 4 |  author =    {Blackburn, Patrick and 
 5 |               Bos, Johan and 
 6 |               Striegnitz, Kristina},
 7 |  publisher = {College Publications},
 8 |  series =    {Cahiers de Logique et d'Épistémologie},
 9 |  volume =    {1},
10 |  title =     {Prolog, Tout de Suite !},
11 |  year =      {2007},
12 |  note =      {Traduit par Hélène Manuélian},
13 |  isbn =      {978-1904987529}
14 | }
15 | 
16 | 
17 | 
18 | 19 | -------------------------------------------------------------------------------- /www/contact.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Questions, comments, suggestions?

4 | 5 |

6 | We are at facebook, but you can also send us 7 | an email at this address: 8 |

9 | 10 |

 

11 | 12 |

13 | Looking for solutions to the exercises? 14 | The paperback version of "Learn Prolog Now!" includes solutions to all the exercises from the exercise section of each chapter. 15 |

-------------------------------------------------------------------------------- /www/cover_front.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/www/cover_front.gif -------------------------------------------------------------------------------- /www/cover_front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/www/cover_front.jpg -------------------------------------------------------------------------------- /www/cover_front_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/www/cover_front_small.jpg -------------------------------------------------------------------------------- /www/errata.php: -------------------------------------------------------------------------------- 1 |

Errata of the first printing

2 | 3 |

4 | This is a list of errata for the first printing of the handheld 5 | version of 'Learn Prolog Now!'. If you find any mistakes that are not 6 | listed here, yet, please let us know. 7 |

8 |

9 | The mistakes in this list have been corrected in the second printing. 10 |

11 | 12 |
13 | 14 |
p.95
15 |
accLen3/ should be accLen/3.
16 | 17 |
p. 169
18 |
novar should be nonvar.
19 | 20 |
p. 115, p.116
21 |
reverse/2 should be rev/2. 22 | Actually, in SWI Prolog reverse/2 is a built-in 23 | predicate which does what rev/2 does, namely reverse 24 | a list. So, if you are using SWI Prolog, you can write 25 | reverse/2 instead of rev/2.
26 | 27 |
pp. 119-137, Chapter 7
28 |
In this chapter, we sometimes refer to "extra goals" and sometimes to 29 | "extra test". That's the same thing.
30 | 31 |
p. 136
32 |
In the middle of the page, under number 2, it should be: and the b and c 33 | blocks are also exactly the same length and furthermore consist of an even number 34 | of bs and cs. 35 |
36 | 37 |
p. 156
38 |
The last rule of the DCG should be v --> [eats].
39 | 40 | 41 |
p. 236, Answer 1.3
42 |
The goals in this knowledge base are: man(X), woman(X), father(X,Y), 43 | man(Y), son(Z,Y), daughter(Z,Y). knows(Y,X) is not a goal. (It's 44 | not even mentioned in the knowledge base.)
45 | 46 |
p. 240
47 |
There is one occurrence of criminal in single 48 | quotes. It should be without quotes.
49 | 50 |
p. 246, Answer 6.2
51 |
This answer uses the predicate reverse/2 52 | which is built-in in SWI Prolog. If you are using some other version of 53 | Prolog, you should use rev/2 as defined in 54 | Chapter 6 instead. 55 |
56 | 57 |
p. 248, Answer 7.1
58 |
In the last line of the internal representation of the DCG, there 59 | is a goal wriggle(C,B). It should be 60 | wiggle(C,B).
61 | 62 |
p. 248, Answer 8.1
63 |
The NP-rule should be 64 | np(Num) --> det(Num), n(Num). And the determiner 65 | rules should be det(_) --> [the] and 66 | det(sg) --> [a].
67 | 68 |
69 |
70 | 71 |
72 | 73 |

74 | These errors were reported by: Hélène Manuélian 75 |

-------------------------------------------------------------------------------- /www/french.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

6 | Prolog est un langage de programmation tout à fait original. «Prolog» 7 | est l'abréviation de «Programmation logique», et le lien qu'il 8 | entretient avec la logique est ce qui lui donne sa spécificité. Au 9 | coeur de Prolog, réside une idée surprenante : ne pas dire à 10 | l'ordinateur ce qu'il doit faire, mais lui décrire des situations, et 11 | lui faire faire des calculs en lui posant des questions. Prolog 12 | déduira alors logiquement de nouveaux faits concernant les situations, 13 | et donnera en réponse ses déductions. Pourquoi apprendre Prolog ? Tout 14 | d'abord, l'aspect «dis-moi quel est ton problème au lieu de me dire 15 | comment le résoudre» de son approche en fait un langage de très haut 16 | niveau, adapté aux applications riches en connaissances comme 17 | l'intelligence artificielle, la linguistique informatique, ou le web 18 | sémantique. En étudiant Prolog, on arrive à une meilleure 19 | compréhension de la façon dont des tâches sophistiquées peuvent être 20 | effectuées informatiquement. 21 |

22 |

23 | De plus, Prolog demande un état d'esprit différent : il nous apprend à 24 | penser déclarativement au lieu de procéduralement. Acquérir cette 25 | façon de réfléchir et apprendre à apprécier les liens entre la logique 26 | et la programmation font de l'apprentissage de Prolog à la fois un 27 | challenge et une récompense. Prolog tout de suite ! est une traduction 28 | de Learn Prolog Now!). Gratuitement accessible en ligne depuis 2001 29 | (www.learnprolognow.org), le texte anglais est devenu l'une des 30 | introductions à la programmation en Prolog les plus populaires, grâce 31 | à sa clarté et son approche résolument concrète. Il est très largement 32 | utilisé comme manuel dans les universités du monde entier, et encore 33 | plus largement comme support d'auto-formation. College publications 34 | est fier de proposer la traduction française de ce classique du web. 35 |

36 |

37 | Préparée avec soin, et grâce aux remarques des lecteurs de la version 38 | anglaise, cette traduction ne présente que les implantations de Prolog 39 | compatibles avec la norme ISO. Elle présente aussi le système de 40 | modules de Prolog, et fournit toutes les réponses aux exercices. Que 41 | vous appreniez Prolog pour élargir votre compréhension de la logique 42 | et de l'informatique, ou pour vous ouvrir les portes de la riche 43 | littérature sur Prolog et le Traitement Automatique des Langues, vous 44 | trouverez certainement ici tout ce que vous souhaitiez pour apprendre 45 | Prolog... tout de suite! 46 |

47 | 48 | 49 |

50 |

Order the book at:
51 | amazon.com, 52 | amazon.co.uk, 53 | amazon.de, 54 | amazon.fr, 55 | amazon.ca, 56 | amazon.co.jp 57 |

58 | 59 |

60 | Click here for a BibTeX entry. 61 |

62 | 63 | 66 | -------------------------------------------------------------------------------- /www/handheld.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

6 | We are pleased to announce that Learn Prolog Now! is now available 7 | in book form: on 15 June 2006 it was published by 8 | College 9 | Publications as Volume 7 of their Texts in Computer Science series. 10 |

11 | 12 |

13 | Learn Prolog Now has been available as a web-book since 2001. Over 14 | this period we have received numerous requests for a real 15 | hold-in-your-hands version of LPN! (that is, what is technically 16 | known as a ‘book’!). Well, we've finally produced such a thing, but 17 | we've done more than that. While preparing it, we took the 18 | opportunity to make extensive changes and improvements. The most 19 | important are the following: 20 |

21 | 22 |
    23 |
  • 24 | We have rewritten a number of crucial sections. In particular, we 25 | have lengthened and improved our discussion of unification, proof 26 | search, recursion, termination, and DCGs. 27 |
  • 28 |
  • 29 | We have made numerous small corrections and changes throughout 30 | the text (thanks to the many readers who pointed out errors and 31 | infelicities). 32 |
  • 33 |
  • 34 | We took the opportunity to get rid of non-ISO constructs 35 | used in the web-book. 36 |
  • 37 |
  • 38 | We added a Preface (telling a little about the history of LPN!) 39 | and an introduction (which discusses Prolog from a more general 40 | perspective). We also added an appendix briefly discussing some 41 | other books on Prolog that we liked. 42 |
  • 43 |
  • 44 | We added new exercises, worked them all, and put all the answers 45 | into an appendix. 46 |
  • 47 |
48 | 49 |

50 | So, there you have it: LPN!, the handheld version. 51 |

52 | 53 | 54 |

55 |

Order the book at:
56 | amazon.com, 57 | amazon.co.uk, 58 | amazon.de, 59 | amazon.fr, 60 | amazon.ca, 61 | amazon.co.jp, 62 | Barnes and Noble, or 63 | bol.com. 64 |

65 | 66 |

Click here for a BibTeX entry. And click here for a list of errata. 67 |

68 | -------------------------------------------------------------------------------- /www/implementations.php: -------------------------------------------------------------------------------- 1 | 2 |

3 | Several Prolog environments are available, and probably the best idea 4 | is simply to google what's available. But we list here some of the 5 | more widely used systems. Or go to the comp.lang.prolog FAQ for a more complete list. 6 |

7 | 8 | 9 | 10 | 11 | 17 | 18 | 23 | 24 | 28 | 29 | 34 | 35 | 41 | 42 |
SWI-Prolog 12 | A Free Software Prolog environment, licensed under the Lesser GNU public 13 | license. This popular interpreter was developed by Jan 14 | Wielemaker. This is the interpreter we used while developing this book.
15 | http://www.swi-prolog.org/ 16 |
SICStus Prolog 19 | Industrial strength Prolog environment from the Swedish Institute of 20 | Computer Science.
21 | http://www.sics.se/sicstus/ 22 |
GNU Prolog 25 | Another more widely used free Prolog compiler developed by Daniel Diaz. 26 | http://www.gprolog.org 27 |
YAP Prolog 30 | A Prolog compiler developed at the Universidade do Porto and Universidade 31 | Federa do Rio de Janeiro. Free for use in academic environments.
32 | http://www.ncc.up.pt/~vsc/Yap/ 33 |
Strawberry Prolog 36 | Strawberry Prolog is specially designed for education. 37 | It works with Windows Vista/XP as well as Unix/Linux. 38 | It is developed at the Bulgarian Academy of Sciences and can be downloaded from 39 | http://www.dobrev.com/ 40 |
43 | -------------------------------------------------------------------------------- /www/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /www/info_email.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn/a0c6aa631e856d8558e96c88a0c2a5684196a55a/www/info_email.jpg -------------------------------------------------------------------------------- /www/links.php: -------------------------------------------------------------------------------- 1 | 2 |

Logic Programming Links

3 | 4 |

5 | What is Prolog? (Wikipedia) 6 |

7 | 8 |

9 | What is logic programming? (Wikipedia) 10 |

11 | 12 |

13 | The news:comp.lang.prolog usenet group and its FAQs 14 |

15 | 16 |

17 | The Prolog Programming Contests 18 |

19 | -------------------------------------------------------------------------------- /www/lpn_reds2.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | background-color:#ffffff; 4 | min-width: 500pt; 5 | } 6 | 7 | 8 | div.coloredbar { 9 | background-color:#ffcc33; 10 | margin:0pt; 11 | padding:10pt; 12 | height:50pt; 13 | } 14 | 15 | div.lpnheader { 16 | background-color:#ffcc33; 17 | margin:0pt; 18 | padding:10pt; 19 | text-align:left; 20 | font-family:Helvetica,sans-serif; 21 | font-size:300%; 22 | } 23 | 24 | .lpnheader a { 25 | color:black; 26 | font-family:Helvetica,sans-serif; 27 | text-decoration:none; 28 | } 29 | 30 | div.authorbar { 31 | background-color:#ff9900; 32 | margin:0pt; 33 | padding:7pt; 34 | text-align:right; 35 | font-family:Helvetica,sans-serif; 36 | font-size:100%; 37 | } 38 | 39 | .authorbar a { 40 | color:black; 41 | font-family:Helvetica,sans-serif; 42 | text-decoration:none; 43 | } 44 | 45 | div.navbar { 46 | float:left; 47 | background-color:#990000; 48 | color:#ffffff; 49 | width:150pt; 50 | %overflow:hidden; 51 | margin:0pt; 52 | height:400pt; 53 | padding-top:20pt; 54 | font-family:Helvetica,sans-serif; 55 | } 56 | 57 | .navbar ul { 58 | margin-left:0pt; 59 | padding-left:0pt; 60 | } 61 | 62 | .navbar li { 63 | list-style:none; 64 | margin:10pt 0pt 10pt 8pt; 65 | } 66 | 67 | .navbar li li { 68 | margin:3pt 0pt 3pt 15pt; 69 | font-size:90%; 70 | } 71 | 72 | div.content { 73 | padding:20pt; 74 | padding-left:10pt; 75 | margin-left:170pt; 76 | font-family:Helvetica,sans-serif; 77 | font-size:80%; 78 | overflow:visible; 79 | } 80 | 81 | .content td { 82 | font-size:80%; 83 | } 84 | 85 | div.foot { 86 | clear:both; 87 | padding-top:10pt; 88 | font-family:Helvetica,sans-serif; 89 | font-size:80%; 90 | } 91 | 92 | div.tracker { 93 | float:right; 94 | width:50pt; 95 | } 96 | 97 | .content a { 98 | color:#990000; %black; 99 | } 100 | 101 | .content h1 { 102 | color:#ff9900; 103 | } 104 | 105 | .navbar a { 106 | color:#ffffff; 107 | font-family:Helvetica,sans-serif; 108 | text-decoration:none; 109 | } 110 | 111 | div.newsbox { 112 | float:right; 113 | width:180pt; 114 | border:3px solid #ff9900; %#990000; 115 | padding:10px; 116 | margin-right:-10pt; 117 | margin-left:20pt; 118 | margin-bottom:20pt; 119 | } 120 | 121 | div.newsbar { 122 | width:180pt; 123 | background-color:#ff9900; %#990000; 124 | padding:10px; 125 | margin: -10px; 126 | margin-bottom: 10px; 127 | color:#ffffff; 128 | font-size:150%; 129 | } 130 | 131 | .emph { 132 | color:#990000; 133 | } 134 | 135 | pre { 136 | font-size:130%; 137 | overflow:visible; 138 | } 139 | 140 | span.code{ 141 | font-family:'courier'; 142 | } -------------------------------------------------------------------------------- /www/lpnpage.php: -------------------------------------------------------------------------------- 1 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Learn Prolog Now! 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 |
49 |
50 | Learn Prolog Now! 51 |
52 | 53 | 54 |
55 | by Patrick Blackburn, 56 | Johan Bos, and 57 | Kristina Striegnitz 58 |
59 | 60 | 61 | 69 | 70 | 71 | 72 |
73 | 74 | 80 | 81 |
82 | 83 | 84 | 85 |
86 |
87 |
88 | eXTReMe Tracker 90 |
104 |
105 | © 2006-2012 Patrick Blackburn, Johan Bos, Kristina Striegnitz 106 |
107 | 108 |
109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /www/lpnpage.php.mine: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Learn Prolog Now! 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 |
20 |
21 | Learn Prolog Now! 22 |
23 | 24 | 25 |
26 | by Patrick Blackburn, 27 | Johan Bos, and 28 | Kristina Striegnitz 29 |
30 | 31 | 32 | 40 | 41 | 42 | 43 |
44 | 45 | 51 | 52 |
53 | 54 | 55 | 56 |
57 |
58 |
59 | eXTReMe Tracker 61 |
75 |
76 | © 2006-2012 Patrick Blackburn, Johan Bos, Kristina Striegnitz 77 |
78 | 79 |
80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /www/lpnpage.php.r36: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Learn Prolog Now! 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | 33 |
34 |
35 | Learn Prolog Now! 36 |
37 | 38 | 39 |
40 | by Patrick Blackburn, 41 | Johan Bos, and 42 | Kristina Striegnitz 43 |
44 | 45 | 46 | 54 | 55 | 56 | 57 |
58 | 59 | 65 | 66 |
67 | 68 | 69 | 70 |
71 |
72 |
73 | eXTReMe Tracker 75 |
89 |
90 | © 2006-2012 Patrick Blackburn, Johan Bos, Kristina Striegnitz 91 |
92 | 93 |
94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /www/lpnpage.php.r37: -------------------------------------------------------------------------------- 1 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Learn Prolog Now! 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 |
46 |
47 | Learn Prolog Now! 48 |
49 | 50 | 51 |
52 | by Patrick Blackburn, 53 | Johan Bos, and 54 | Kristina Striegnitz 55 |
56 | 57 | 58 | 66 | 67 | 68 | 69 |
70 | 71 | 77 | 78 |
79 | 80 | 81 | 82 |
83 |
84 |
85 | eXTReMe Tracker 87 |
101 |
102 | © 2006-2012 Patrick Blackburn, Johan Bos, Kristina Striegnitz 103 |
104 | 105 |
106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /www/manuals.php: -------------------------------------------------------------------------------- 1 | 2 |

Manuals

3 | 4 |

5 | SWI Prolog 6 |

7 | 8 |

9 | SICStus Prolog 10 |

11 | 12 |

13 | YAP Prolog 14 |

15 | -------------------------------------------------------------------------------- /www/navbar.php: -------------------------------------------------------------------------------- 1 | 2 && count($item[2]) > 0) 11 | // { 12 | // foreach ($item[2] as $subitem) 13 | // { 14 | // if (is_decendant($pageid,$subitem)) 15 | // return True; 16 | // } 17 | // } 18 | // 19 | // return False; 20 | 21 | return True; 22 | } 23 | 24 | function make_menuitem($item,$pageid) 25 | { 26 | echo "
  • "; 27 | if ($item[0] == $pageid) 28 | { 29 | echo "> ".$item[1]; 30 | } 31 | else 32 | { 33 | echo "".$item[1].""; 34 | } 35 | 36 | if (is_decendant($pageid,$item) && count($item) > 2 && count($item[2]) > 0) 37 | { 38 | echo "
      "; 39 | foreach ($item[2] as $subitem_index => $subitem) 40 | { 41 | make_menuitem($subitem,$pageid); 42 | //echo "
    • ".$subitem[1]."
    • "; 43 | } 44 | echo "
    "; 45 | } 46 | 47 | echo "
  • "; 48 | } 49 | 50 | 51 | function make_navmenu($pageid) 52 | { 53 | 54 | 55 | // Here is where the structure of the site is defined. 56 | // Menu antries are: pageid (which is also the name of the file 57 | // containing the content), button text, submenu 58 | $menu = array(); 59 | $menu[] = array("top","LPN! Home",array()); 60 | $menu[] = array("online","Free Online Version",array()); 61 | $menu[] = array("handheld","Paperback English",array()); 62 | $menu[] = array("french","Paperback Français",array()); 63 | // array(array("handheld","English"), 64 | // array("french","Français"))); 65 | $menu[] = array("teaching","Teaching Prolog",array()); 66 | $menu[] = array("implementations","Prolog Implementations",array()); 67 | $menu[] = array("manuals","Prolog Manuals",array()); 68 | $menu[] = array("links","Prolog Links",array()); 69 | $menu[] = array("thanks","Thanks!",array()); 70 | $menu[] = array("contact","Contact us",array()); 71 | 72 | echo "
      "; 73 | 74 | foreach ($menu as $item) 75 | { 76 | make_menuitem($item,$pageid); 77 | } 78 | 79 | echo "
    "; 80 | 81 | } 82 | 83 | ?> -------------------------------------------------------------------------------- /www/online.php: -------------------------------------------------------------------------------- 1 | Chapter 1 Facts, Rules, and Queries
    2 | Chapter 2 Unification and Proof Search
    3 | Chapter 3 Recursion
    4 | Chapter 4 Lists
    5 | Chapter 5 Arithmetic
    6 | Chapter 6 More Lists
    7 | Chapter 7 Definite Clause Grammars
    8 | Chapter 8 More Definite Clause Grammars
    9 | Chapter 9 A Closer Look at Terms
    10 | Chapter 10 Cuts and Negation
    11 | Chapter 11 Database Manipulation and Collecting Solutions
    12 | Chapter 12 Working With Files
    13 | -------------------------------------------------------------------------------- /www/teaching.php: -------------------------------------------------------------------------------- 1 |

    Slides

    2 | 3 |

    4 | We have made a set 5 | of slides available which follows the chapter-by-chapter 6 | breakdown of the book. Enjoy! But this doesn't mean 7 | we don't want your slides too. On the contrary, 8 | we're very interested in making available slides 9 | in other languages, or slides which make us of the chapters 10 | in a different way. So if you have something interesting, please 11 | make it available ... 12 |

    13 | 14 |

    15 | The LPN set of slides (13 November 2013):
    16 | chapter 1 (PDF), 17 | chapter 2 (PDF), 18 | chapter 3 (PDF), 19 | chapter 4 (PDF), 20 | chapter 5 (PDF), 21 | chapter 6 (PDF), 22 | chapter 7 (PDF), 23 | chapter 8 (PDF), 24 | chapter 9 (PDF), 25 | chapter 10 (PDF), 26 | chapter 11 (PDF), 27 | chapter 12 (PDF), 28 |

    29 | 30 |

    31 | We are collecting slides! If you have taught a Prolog course based on 32 | our book and would like to make your slides available to 33 | others, then please send them to us and we will put them 34 | up on this page. All languages are welcome! 35 |

    36 | 37 |

    38 | Slides by Kristina Striegnitz in German:
    39 | week 1 (PDF), 40 | week 2 (PDF), 41 | week 3 (PDF), 42 | week 4 (PDF), 43 | week 5 (PDF), 44 | week 6 (PDF), 45 | week 7 (PDF), 46 | week 8 (PDF), 47 | week 9 (PDF), 48 | week 10 (PDF), 49 | week 11 (PDF) 50 |

    51 | 52 |

    53 | Slides on Horn Clauses by Johan Bos: 54 | Horn clauses (PDF). 55 |

    56 | 57 |

    58 | ESSLLI slides by Kristina Striegnitz in English and online practice material can be found here: 59 | cs.union.edu/~striegnk/courses/esslli04prolog. 60 |

    -------------------------------------------------------------------------------- /www/test.html: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 31 |
    32 | 33 | -------------------------------------------------------------------------------- /www/thanks.php: -------------------------------------------------------------------------------- 1 |

    Thank you!

    2 | 3 |

    4 | Over the years, a lot of people have contributed to Learn Prolog Now! 5 | in one way or another: 6 |

    7 | 8 |
      9 |
    • 10 | Gertjan van Noord and Robbert Prins used early versions of LPN! in 11 | their teaching at the University of Groningen. They gave us detailed 12 | feedback which really helped us improve the accuracy of the text. 13 |
    • 14 |
    • 15 | Malvina Nissim supplied us with an upgrade of 16 | Exercise 2.4 and gave us a lot of help and advice regarding the final 17 | hardcopy version. 18 |
    • 19 |
    • 20 | Dov Gabbay founded College Publications and thereby made it possible 21 | for us to publish LPN! on paper as well as online. And thanks to 22 | Vincent Hendricks for telling us about it. 23 |
    • 24 |
    • 25 | Jane Spurr, the managing director of College publications gave us lots of time 26 | and attention in the final run-up to publication. She was always there 27 | for us and reacted promptly to the invariable last minute 28 | problems. Thank you Jane. 29 |
    • 30 |
    • 31 | Jan Wielemaker made SWI Prolog freely available 32 | over the internet and gave us speedy and informative feedback on a number of 33 | technical issues. 34 |
    • 35 |
    • 36 | Ian Mackie and an anonymous 37 | referee put a lot of time and energy into the penultimate version 38 | of the (printed) book. 39 |
    • 40 |
    • Bart Demoen wrote a very thorough review of our book for the 41 | journal "Theory and Practice of Logic Programming", which brought up 42 | many good points that will help us improve LPN! for the next edition. 43 |
    • 44 |
    • 45 | Peter Urbak, Richard Kenyon, Matt Braithwaite, Anas Elghafari, Shannon "JJ" Behrens, Alejandro Marín Buriticá, Gabriele Medeot, Danny Rademacher, Ali Almiman 46 | sent us useful corrections that are incorporated in the free online version! 47 |
    • 48 |
    • 49 | And a big thank you to Hélène Manuélian who took on the task of 50 | translating LPN into french and did it so beautifully! 51 |
    • 52 |
    53 | 54 | -------------------------------------------------------------------------------- /www/toc.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 |

    Learn Prolog Now!

    11 | 12 |

    Patrick Blackburn, Johan Bos and Kristina Striegnitz

    13 | 14 |
    15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
    43 | 44 | 45 | -------------------------------------------------------------------------------- /www/top.php: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 |
    5 | 6 |

    7 | Learn Prolog Now! is an introductory course to programming in Prolog. The online version has been available 10 | since 2001, and now there is also a throughly revised version 11 | available in book form. 12 |

    13 | 14 |

    15 | We wanted to do two things with this course. First, we wanted to 16 | provide a text that was relatively self contained, a text that would 17 | permit someone with little or no knowledge of computing to pick up the 18 | basics of Prolog with the minimum of fuss. We also wanted the text to 19 | be clear enough to make it useful for self study. We believe that if 20 | you read the text, and do the associated exercises, you will gain a 21 | useful partial entry to the world of Prolog. 22 |

    23 | 24 |

    25 | But only a partial entry, and this brings us to our second point. We 26 | want to emphasize the practical aspects of Prolog. Prolog is something 27 | you do. You can't learn a programming language simply by reading about 28 | it, and if you really want to get the most out of this course, we 29 | strongly advise you to get hold of a Prolog interpreter (you'll find 30 | pointers to some nice ones on this website) and work through all the 31 | Practical Sessions that we provide. And of course, don't stop with 32 | what we provide. The more you program, the better you'll get.... 33 |

    34 | 35 |

    We hope you enjoy the course. And whether you're using this book 36 | to teach yourself Prolog, or you're using it as the basis for teaching 37 | others, we would like to hear from you. Please send us any comments/corrections 39 | you have so that we can take them into account in later versions. 40 |

    41 | --------------------------------------------------------------------------------