├── .gitignore ├── pamphlet.pdf ├── pamphlet-mini.pdf ├── datasets ├── cnf │ ├── simple_v3_c2.cnf │ ├── README.md │ ├── quinn.cnf │ ├── aim-50-1_6-yes1-4.cnf │ ├── aim-100-1_6-no-1.cnf │ ├── hole6.cnf │ ├── dubois20.cnf │ ├── dubois21.cnf │ ├── dubois22.cnf │ ├── par8-1-c.cnf │ └── zebra_v155_c1135.cnf ├── computer-purchase.csv ├── iris.csv └── diabetes.csv ├── book ├── doclicense-CC-by-sa.pdf ├── chapters │ ├── 6.tex │ ├── bib.tex │ ├── 4.tex │ ├── 0.tex │ ├── 3.tex │ └── 2.tex ├── pamphlet.tex ├── pamphlet-mini.tex ├── plots │ └── kmeans.tex └── doclicense.sty ├── README.md └── libraries ├── ice-9 └── nice-9.scm └── pamphlet.scm /.gitignore: -------------------------------------------------------------------------------- 1 | *.out 2 | *.aux 3 | *.log 4 | *.toc 5 | *~ 6 | -------------------------------------------------------------------------------- /pamphlet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panicz/pamphlet/HEAD/pamphlet.pdf -------------------------------------------------------------------------------- /pamphlet-mini.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panicz/pamphlet/HEAD/pamphlet-mini.pdf -------------------------------------------------------------------------------- /datasets/cnf/simple_v3_c2.cnf: -------------------------------------------------------------------------------- 1 | c simple_v3_c2.cnf 2 | c 3 | p cnf 3 2 4 | 1 -3 0 5 | 2 3 -1 0 6 | -------------------------------------------------------------------------------- /book/doclicense-CC-by-sa.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panicz/pamphlet/HEAD/book/doclicense-CC-by-sa.pdf -------------------------------------------------------------------------------- /datasets/cnf/README.md: -------------------------------------------------------------------------------- 1 | All the files in this directory were copied from: 2 | http://people.sc.fsu.edu/~jburkardt/data/cnf/cnf.html 3 | and can be distributed under the terms 4 | of the [GNU LGPL](https://www.gnu.org/licenses/lgpl-3.0.html) license 5 | -------------------------------------------------------------------------------- /datasets/computer-purchase.csv: -------------------------------------------------------------------------------- 1 | age,income,student,credit.rating,buys 2 | 31..40,high,no,fair,yes 3 | >40,medium,no,fair,yes 4 | >40,high,yes,excellent,yes 5 | >40,low,yes,excellent,no 6 | 31..40,low,no,excellent,yes 7 | <=30,medium,no,fair,no 8 | <=30,low,yes,fair,no -------------------------------------------------------------------------------- /datasets/cnf/quinn.cnf: -------------------------------------------------------------------------------- 1 | c quinn.cnf 2 | c 3 | p cnf 16 18 4 | 1 2 0 5 | -2 -4 0 6 | 3 4 0 7 | -4 -5 0 8 | 5 -6 0 9 | 6 -7 0 10 | 6 7 0 11 | 7 -16 0 12 | 8 -9 0 13 | -8 -14 0 14 | 9 10 0 15 | 9 -10 0 16 | -10 -11 0 17 | 10 12 0 18 | 11 12 0 19 | 13 14 0 20 | 14 -15 0 21 | 15 16 0 22 | -------------------------------------------------------------------------------- /book/chapters/6.tex: -------------------------------------------------------------------------------- 1 | \chapter*{What to do next?} 2 | 3 | \begin{chapquote}{Donald Knuth} 4 | ``Let us change our traditional attitude to the construction 5 | of programs: Instead of imagining that our main task is to 6 | instruct a computer what to do, let us concentrate rather 7 | on explaining to human beings what we want [...]'' 8 | \end{chapquote} 9 | 10 | Barry Rowlingson, one of the contributors to the R project, 11 | wrote: ``This is all documented in TFM. Those who WTFM 12 | don't want to have to WTFM again on the mailing list. RTFM''. 13 | 14 | My hope is that after reading this pamphlet at least some 15 | readers will see that there is another way -- that instead 16 | of being divided into groups of ``software package creators'' 17 | and ``software package users'', we can all participate 18 | in the joint movement of software literacy: that we will 19 | R\&WTFSC and FTM. 20 | 21 | There's plenty of ingenious ideas that have found their 22 | expression in the Scheme programming language, although 23 | they made it so without the ``rock-star status'', going 24 | against the flow. 25 | 26 | I encourage the interested readers to take a look at the papers 27 | available at \url{http://readscheme.org}. 28 | 29 | \begin{Snippet} 30 | 31 | 32 | $ chmod -R 666 / 33 | \end{Snippet} 34 | -------------------------------------------------------------------------------- /book/chapters/bib.tex: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{9} 2 | \bibitem{SICP} 3 | Harold Abelson, Gerald Jay Sussman, Julie Sussman 4 | \emph{Structure and Interpretation of Computer Programs} 5 | MIT Press, 1996 \\ 6 | \url{https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html} 7 | 8 | \bibitem{Harrison1996} 9 | John Harrison 10 | \emph{Introduction to Functional Programming} \\ 11 | \url{http://www.cl.cam.ac.uk/teaching/Lectures/funprog-jrh-1996/all.pdf} 12 | 13 | \bibitem{Ihaka2010} 14 | Ross Ihaka 15 | \emph{R: Lessons Learned, Directions for the Future} \\ 16 | \url{https://www.stat.auckland.ac.nz/~ihaka/downloads/JSM-2010.pdf} 17 | 18 | \bibitem{McCarthy1960} 19 | John McCarthy 20 | \emph{Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I} \\ 21 | \url{http://www-formal.stanford.edu/jmc/recursive.ps} 22 | 23 | \bibitem{Shlens2003} 24 | Jon Shlens 25 | \emph{Tutorial on Principal Component Analysis} 26 | \url{https://www.cs.princeton.edu/picasso/mats/PCA-Tutorial-Intuition_jp.pdf} 27 | 28 | \bibitem{Zadeh2008} 29 | Lotfi Zadeh 30 | \emph{Is there a need for fuzzy logic?} 31 | Information Sciences, Vol. 178, No. 13, 2751-2779, 2008 \\ 32 | \url{http://www.cs.berkeley.edu/~zadeh/papers/Is there a need for fuzzy logic.pdf} 33 | 34 | \end{thebibliography} 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A Pamphlet against R 2 | This repository contains [source codes](https://github.com/panicz/pamphlet/tree/master/libraries) 3 | and [data sets](https://github.com/panicz/pamphlet/tree/master/datasets) that are used in "A Pamphlet against R". 4 | 5 | There are also [LaTeX sources](https://github.com/panicz/pamphlet/tree/master/book) 6 | for the book, as well as the pdf versions of the booklet supplied for your convenience 7 | ([A4](https://github.com/panicz/pamphlet/raw/master/pamphlet.pdf) 8 | and [e-book-reader friendly](https://github.com/panicz/pamphlet/raw/master/pamphlet-mini.pdf)). 9 | 10 | If you're experiening technical problems with the code, 11 | report them via [Github issue tracker](https://github.com/panicz/pamphlet/issues). 12 | 13 | If you have any questions about Scheme and programming, 14 | you can ask me on [Quora](https://www.quora.com/profile/Panicz-Godek). 15 | You can also leave your review [there](https://www.quora.com/unanswered/Whats-your-review-of-A-Pamphlet-against-R). 16 | 17 | The book is available on the [CC-BY-SA](https://creativecommons.org/licenses/by-sa/4.0/), 18 | and the software -- on [GNU General Public License v.3](https://www.gnu.org/licenses/gpl.html). 19 | 20 | **If you're interested in compilers and other program transformations, 21 | you may want to check out my master thesis, 22 | [Data Structure Optimization for Functional Programs](https://github.com/panicz/master-thesis)** 23 | -------------------------------------------------------------------------------- /datasets/cnf/aim-50-1_6-yes1-4.cnf: -------------------------------------------------------------------------------- 1 | c FILE: aim-50-1_6-yes1-4.cnf 2 | c 3 | c SOURCE: Kazuo Iwama, Eiji Miyano (miyano@cscu.kyushu-u.ac.jp), 4 | c and Yuichi Asahiro 5 | c 6 | c DESCRIPTION: Artifical instances from generator by source. Generators 7 | c and more information in sat/contributed/iwama. 8 | c 9 | c NOTE: Satisfiable 10 | c 11 | p cnf 50 80 12 | 16 17 30 0 13 | -17 22 30 0 14 | -17 -22 30 0 15 | 16 -30 47 0 16 | 16 -30 -47 0 17 | -16 -21 31 0 18 | -16 -21 -31 0 19 | -16 21 -28 0 20 | -13 21 28 0 21 | 13 -16 18 0 22 | 13 -18 -38 0 23 | 13 -18 -31 0 24 | 31 38 44 0 25 | -8 31 -44 0 26 | 8 -12 -44 0 27 | 8 12 -27 0 28 | 12 27 40 0 29 | -4 27 -40 0 30 | 12 23 -40 0 31 | -3 4 -23 0 32 | 3 -23 -49 0 33 | 3 -13 -49 0 34 | -23 -26 49 0 35 | 12 -34 49 0 36 | -12 26 -34 0 37 | 19 34 36 0 38 | -19 26 36 0 39 | -30 34 -36 0 40 | 24 34 -36 0 41 | -24 -36 43 0 42 | 6 42 -43 0 43 | -24 42 -43 0 44 | -5 -24 -42 0 45 | 5 20 -42 0 46 | 5 -7 -20 0 47 | 4 7 10 0 48 | -4 10 -20 0 49 | 7 -10 -41 0 50 | -10 41 46 0 51 | -33 41 -46 0 52 | 33 -37 -46 0 53 | 32 33 37 0 54 | 6 -32 37 0 55 | -6 25 -32 0 56 | -6 -25 -48 0 57 | -9 28 48 0 58 | -9 -25 -28 0 59 | 19 -25 48 0 60 | 2 9 -19 0 61 | -2 -19 35 0 62 | -2 22 -35 0 63 | -22 -35 50 0 64 | -17 -35 -50 0 65 | -29 -35 -50 0 66 | -1 29 -50 0 67 | 1 11 29 0 68 | -11 17 -45 0 69 | -11 39 45 0 70 | -26 39 45 0 71 | -3 -26 45 0 72 | -11 15 -39 0 73 | 14 -15 -39 0 74 | 14 -15 -45 0 75 | 14 -15 -27 0 76 | -14 -15 47 0 77 | 17 17 40 0 78 | 1 -29 -31 0 79 | -7 32 38 0 80 | -14 -33 -47 0 81 | -1 2 -8 0 82 | 35 43 44 0 83 | 21 21 24 0 84 | 20 29 -48 0 85 | 23 35 -37 0 86 | 2 18 -33 0 87 | 15 25 -45 0 88 | 9 14 -38 0 89 | -5 11 50 0 90 | -3 -13 46 0 91 | -13 -41 43 0 -------------------------------------------------------------------------------- /book/pamphlet.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper,11pt]{book} 2 | \usepackage[T1]{fontenc} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage{lmodern} 5 | \usepackage{hyperref} 6 | \usepackage{graphicx} 7 | \usepackage[english]{babel} 8 | \usepackage{fancyvrb} 9 | \usepackage{mathtools} 10 | \usepackage{qtree} 11 | \usepackage{pgfplots} 12 | \usepackage[ 13 | type={CC}, 14 | modifier={by-sa}, 15 | version={4.0} 16 | ]{doclicense} 17 | 18 | 19 | \newenvironment{Snippet}{\Verbatim[samepage=true]}{\endVerbatim} 20 | 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | % 'dedication' environment: To add a dedication paragraph 23 | % at the start% of book 24 | % Source: http://www.tug.org/pipermail/texhax/2010-June/015184.html 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | \newenvironment{dedication} 27 | { 28 | \cleardoublepage 29 | \thispagestyle{empty} 30 | \vspace*{\stretch{1}} 31 | \hfill\begin{minipage}[t]{0.66\textwidth} 32 | \raggedright 33 | } 34 | { 35 | \end{minipage} 36 | \vspace*{\stretch{3}} 37 | \clearpage 38 | } 39 | 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 41 | % Chapter quote at the start of chapter % 42 | % Source: http://tex.stackexchange.com/a/53380 % 43 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 44 | \makeatletter 45 | \renewcommand{\@chapapp}{}% Not necessary... 46 | \newenvironment{chapquote}[2][2em] 47 | {\setlength{\@tempdima}{#1}% 48 | \def\chapquote@author{#2}% 49 | \parshape 1 \@tempdima \dimexpr\textwidth-2\@tempdima\relax% 50 | \itshape} 51 | {\par\normalfont\hfill--\ \chapquote@author\hspace*{\@tempdima}\par\bigskip} 52 | \makeatother 53 | 54 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 55 | % First page of book which contains 'stuff' like: % 56 | % - Book title, subtitle % 57 | % - Book author name % 58 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 59 | 60 | % Book's title and subtitle 61 | \title{\Huge \textbf{A Pamphlet against R} \\ \huge{Computational Intelligence \\ in Guile Scheme}} 62 | % Author 63 | \author{\textsc{Panicz Maciej Godek} 64 | \\ 65 | \\ 66 | \small{edited by: \textsc{Lawrence Bottorff} and \textsc{Rick Hanson}} } 67 | 68 | \begin{document} 69 | 70 | \frontmatter 71 | \maketitle 72 | \doclicenseThis 73 | 74 | \clearpage 75 | \thispagestyle{plain} 76 | \par\vspace*{.35\textheight}{\centering I dedicate this booklet to my brother, who excels at Excel programming.\par} 77 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 78 | % Auto-generated table of contents, list of figures and list of tables 79 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 80 | \tableofcontents 81 | 82 | \mainmatter 83 | 84 | \input{chapters/0.tex} 85 | 86 | \input{chapters/1.tex} 87 | 88 | \input{chapters/2.tex} 89 | 90 | \input{chapters/3.tex} 91 | 92 | \input{chapters/4.tex} 93 | 94 | \input{chapters/5.tex} 95 | 96 | \input{chapters/6.tex} 97 | 98 | \input{chapters/bib.tex} 99 | 100 | \end{document} 101 | -------------------------------------------------------------------------------- /datasets/cnf/aim-100-1_6-no-1.cnf: -------------------------------------------------------------------------------- 1 | c FILE: aim-100-1_6-no-1.cnf 2 | c 3 | c SOURCE: Kazuo Iwama, Eiji Miyano (miyano@cscu.kyushu-u.ac.jp), 4 | c and Yuichi Asahiro 5 | c 6 | c DESCRIPTION: Artifical instances from generator by source. Generators 7 | c and more information in sat/contributed/iwama. 8 | c 9 | c NOTE: Not Satisfiable 10 | c 11 | p cnf 100 160 12 | 16 30 95 0 13 | -16 30 95 0 14 | -30 35 78 0 15 | -30 -78 85 0 16 | -78 -85 95 0 17 | 8 55 100 0 18 | 8 55 -95 0 19 | 9 52 100 0 20 | 9 73 -100 0 21 | -8 -9 52 0 22 | 38 66 83 0 23 | -38 83 87 0 24 | -52 83 -87 0 25 | 66 74 -83 0 26 | -52 -66 89 0 27 | -52 73 -89 0 28 | -52 73 -74 0 29 | -8 -73 -95 0 30 | 40 -55 90 0 31 | -40 -55 90 0 32 | 25 35 82 0 33 | -25 82 -90 0 34 | -55 -82 -90 0 35 | 11 75 84 0 36 | 11 -75 96 0 37 | 23 -75 -96 0 38 | -11 23 -35 0 39 | -23 29 65 0 40 | 29 -35 -65 0 41 | -23 -29 84 0 42 | -35 54 70 0 43 | -54 70 77 0 44 | 19 -77 -84 0 45 | -19 -54 70 0 46 | 22 68 81 0 47 | -22 48 81 0 48 | -22 -48 93 0 49 | 3 -48 -93 0 50 | 7 18 -81 0 51 | -7 56 -81 0 52 | 3 18 -56 0 53 | -18 47 68 0 54 | -18 -47 -81 0 55 | -3 68 77 0 56 | -3 -77 -84 0 57 | 19 -68 -70 0 58 | -19 -68 74 0 59 | -68 -70 -74 0 60 | 54 61 -62 0 61 | 50 53 -62 0 62 | -50 61 -62 0 63 | -27 56 93 0 64 | 4 14 76 0 65 | 4 -76 96 0 66 | -4 14 80 0 67 | -14 -68 80 0 68 | -10 -39 -89 0 69 | 1 49 -81 0 70 | 1 26 -49 0 71 | 17 -26 -49 0 72 | -1 17 -40 0 73 | 16 51 -89 0 74 | -9 57 60 0 75 | 12 45 -51 0 76 | 2 12 69 0 77 | 2 -12 40 0 78 | -12 -51 69 0 79 | -33 60 -98 0 80 | 5 -32 -66 0 81 | 2 -47 -100 0 82 | -42 64 83 0 83 | 20 -42 -64 0 84 | 20 -48 98 0 85 | -20 50 98 0 86 | -32 -50 98 0 87 | -24 37 -73 0 88 | -24 -37 -100 0 89 | -57 71 81 0 90 | -37 40 -91 0 91 | 31 42 81 0 92 | -31 42 72 0 93 | -31 42 -72 0 94 | 7 -19 25 0 95 | -1 -25 -94 0 96 | -15 -44 79 0 97 | -6 31 46 0 98 | -39 41 88 0 99 | 28 -39 43 0 100 | 28 -43 -88 0 101 | -4 -28 -88 0 102 | -30 -39 -41 0 103 | -29 33 88 0 104 | -16 21 94 0 105 | -10 26 62 0 106 | -11 -64 86 0 107 | -6 -41 76 0 108 | 38 -46 93 0 109 | 26 -37 94 0 110 | -26 53 -79 0 111 | 78 87 -94 0 112 | 65 76 -87 0 113 | 23 51 -62 0 114 | -11 -36 57 0 115 | 41 59 -65 0 116 | -56 72 -91 0 117 | 13 -20 -46 0 118 | -13 15 79 0 119 | -17 47 -60 0 120 | -13 -44 99 0 121 | -7 -38 67 0 122 | 37 -49 62 0 123 | -14 -17 -79 0 124 | -13 -15 -22 0 125 | 32 -33 -34 0 126 | 24 45 48 0 127 | 21 24 -48 0 128 | -36 64 -85 0 129 | 10 -61 67 0 130 | -5 44 59 0 131 | -80 -85 -99 0 132 | 6 37 -97 0 133 | -21 -34 64 0 134 | -5 44 46 0 135 | 58 -76 97 0 136 | -21 -36 75 0 137 | -15 58 -59 0 138 | -58 -76 -99 0 139 | -2 15 33 0 140 | -26 34 -57 0 141 | -18 -82 -92 0 142 | 27 -80 -97 0 143 | 6 32 63 0 144 | -34 -86 92 0 145 | 13 -61 97 0 146 | -28 43 -98 0 147 | 5 39 -86 0 148 | 39 -45 92 0 149 | 27 -43 97 0 150 | 13 -58 -86 0 151 | -28 -67 -93 0 152 | -69 85 99 0 153 | 42 71 -72 0 154 | 10 -27 -63 0 155 | -59 63 -83 0 156 | 36 86 -96 0 157 | -2 36 75 0 158 | -59 -71 89 0 159 | 36 -67 91 0 160 | 36 -60 63 0 161 | -63 91 -93 0 162 | 25 87 92 0 163 | -21 49 -71 0 164 | -2 10 22 0 165 | 6 -18 41 0 166 | 6 71 -92 0 167 | -53 -69 -71 0 168 | -2 -53 -58 0 169 | 43 -45 -96 0 170 | 34 -45 -69 0 171 | 63 -86 -98 0 -------------------------------------------------------------------------------- /datasets/cnf/hole6.cnf: -------------------------------------------------------------------------------- 1 | c File: hole6.cnf 2 | c 3 | c SOURCE: John Hooker (jh38+@andrew.cmu.edu) 4 | c 5 | c DESCRIPTION: Pigeon hole problem of placing n (for file holen) pigeons 6 | c in n+1 holes without placing 2 pigeons in the same hole 7 | c 8 | c NOTE: Part of the collection at the Forschungsinstitut fuer 9 | c anwendungsorientierte Wissensverarbeitung in Ulm Germany. 10 | c 11 | c NOTE: Not satisfiable 12 | c 13 | p cnf 42 133 14 | -1 -7 0 15 | -1 -13 0 16 | -1 -19 0 17 | -1 -25 0 18 | -1 -31 0 19 | -1 -37 0 20 | -7 -13 0 21 | -7 -19 0 22 | -7 -25 0 23 | -7 -31 0 24 | -7 -37 0 25 | -13 -19 0 26 | -13 -25 0 27 | -13 -31 0 28 | -13 -37 0 29 | -19 -25 0 30 | -19 -31 0 31 | -19 -37 0 32 | -25 -31 0 33 | -25 -37 0 34 | -31 -37 0 35 | -2 -8 0 36 | -2 -14 0 37 | -2 -20 0 38 | -2 -26 0 39 | -2 -32 0 40 | -2 -38 0 41 | -8 -14 0 42 | -8 -20 0 43 | -8 -26 0 44 | -8 -32 0 45 | -8 -38 0 46 | -14 -20 0 47 | -14 -26 0 48 | -14 -32 0 49 | -14 -38 0 50 | -20 -26 0 51 | -20 -32 0 52 | -20 -38 0 53 | -26 -32 0 54 | -26 -38 0 55 | -32 -38 0 56 | -3 -9 0 57 | -3 -15 0 58 | -3 -21 0 59 | -3 -27 0 60 | -3 -33 0 61 | -3 -39 0 62 | -9 -15 0 63 | -9 -21 0 64 | -9 -27 0 65 | -9 -33 0 66 | -9 -39 0 67 | -15 -21 0 68 | -15 -27 0 69 | -15 -33 0 70 | -15 -39 0 71 | -21 -27 0 72 | -21 -33 0 73 | -21 -39 0 74 | -27 -33 0 75 | -27 -39 0 76 | -33 -39 0 77 | -4 -10 0 78 | -4 -16 0 79 | -4 -22 0 80 | -4 -28 0 81 | -4 -34 0 82 | -4 -40 0 83 | -10 -16 0 84 | -10 -22 0 85 | -10 -28 0 86 | -10 -34 0 87 | -10 -40 0 88 | -16 -22 0 89 | -16 -28 0 90 | -16 -34 0 91 | -16 -40 0 92 | -22 -28 0 93 | -22 -34 0 94 | -22 -40 0 95 | -28 -34 0 96 | -28 -40 0 97 | -34 -40 0 98 | -5 -11 0 99 | -5 -17 0 100 | -5 -23 0 101 | -5 -29 0 102 | -5 -35 0 103 | -5 -41 0 104 | -11 -17 0 105 | -11 -23 0 106 | -11 -29 0 107 | -11 -35 0 108 | -11 -41 0 109 | -17 -23 0 110 | -17 -29 0 111 | -17 -35 0 112 | -17 -41 0 113 | -23 -29 0 114 | -23 -35 0 115 | -23 -41 0 116 | -29 -35 0 117 | -29 -41 0 118 | -35 -41 0 119 | -6 -12 0 120 | -6 -18 0 121 | -6 -24 0 122 | -6 -30 0 123 | -6 -36 0 124 | -6 -42 0 125 | -12 -18 0 126 | -12 -24 0 127 | -12 -30 0 128 | -12 -36 0 129 | -12 -42 0 130 | -18 -24 0 131 | -18 -30 0 132 | -18 -36 0 133 | -18 -42 0 134 | -24 -30 0 135 | -24 -36 0 136 | -24 -42 0 137 | -30 -36 0 138 | -30 -42 0 139 | -36 -42 0 140 | 6 5 4 3 2 1 0 141 | 12 11 10 9 8 7 0 142 | 18 17 16 15 14 13 0 143 | 24 23 22 21 20 19 0 144 | 30 29 28 27 26 25 0 145 | 36 35 34 33 32 31 0 146 | 42 41 40 39 38 37 0 147 | -------------------------------------------------------------------------------- /book/pamphlet-mini.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt, oneside ]{book} 2 | \usepackage[a6paper,margin=0pt]{geometry} 3 | \renewcommand{\familydefault}{\sfdefault} 4 | \usepackage[T1]{fontenc} 5 | \usepackage[utf8]{inputenc} 6 | \usepackage{lmodern} 7 | \usepackage{hyperref} 8 | \usepackage{graphicx} 9 | \usepackage[english]{babel} 10 | \usepackage{fancyvrb} 11 | \usepackage{mathtools} 12 | \usepackage{qtree} 13 | \usepackage{pgfplots} 14 | \usepackage[ 15 | type={CC}, 16 | modifier={by-sa}, 17 | version={4.0} 18 | ]{doclicense} 19 | 20 | \newenvironment{Snippet}{\Verbatim[samepage=true,fontsize=\scriptsize]}{\endVerbatim} 21 | 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 23 | % 'dedication' environment: To add a dedication paragraph 24 | % at the start% of book 25 | % Source: http://www.tug.org/pipermail/texhax/2010-June/015184.html 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | \newenvironment{dedication} 28 | { 29 | \cleardoublepage 30 | \thispagestyle{empty} 31 | \vspace*{\stretch{1}} 32 | \hfill\begin{minipage}[t]{0.66\textwidth} 33 | \raggedright 34 | } 35 | { 36 | \end{minipage} 37 | \vspace*{\stretch{3}} 38 | \clearpage 39 | } 40 | 41 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 42 | % Chapter quote at the start of chapter % 43 | % Source: http://tex.stackexchange.com/a/53380 % 44 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45 | \makeatletter 46 | \renewcommand{\@chapapp}{}% Not necessary... 47 | \newenvironment{chapquote}[2][2em] 48 | {\setlength{\@tempdima}{#1}% 49 | \def\chapquote@author{#2}% 50 | \parshape 1 \@tempdima \dimexpr\textwidth-2\@tempdima\relax% 51 | \itshape} 52 | {\par\normalfont\hfill--\ \chapquote@author\hspace*{\@tempdima}\par\bigskip} 53 | \makeatother 54 | 55 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 56 | % First page of book which contains 'stuff' like: % 57 | % - Book title, subtitle % 58 | % - Book author name % 59 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 60 | 61 | % Book's title and subtitle 62 | \title{\Huge \textbf{A Pamphlet against R} \\ \huge{Computational Intelligence \\ in Guile Scheme}} 63 | % Author 64 | \author{\textsc{Panicz Maciej Godek} 65 | \\ 66 | \\ 67 | \small{edited by: \textsc{Lawrence Bottorff} and \textsc{Rick Hanson}} } 68 | 69 | \begin{document} 70 | 71 | \frontmatter 72 | \maketitle 73 | \doclicenseThis 74 | 75 | \clearpage 76 | \thispagestyle{plain} 77 | \par\vspace*{.35\textheight}{\centering I dedicate this booklet to my brother, who excels at Excel programming.\par} 78 | \par\vspace*{.35\textheight}{ 79 | \centering This e-book-reader-friendly version was prepared especially for Janek, co ma majtki z firanek.\par 80 | } 81 | 82 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83 | % Auto-generated table of contents, list of figures and list of tables 84 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 85 | \tableofcontents 86 | 87 | \mainmatter 88 | 89 | \input{chapters/0.tex} 90 | 91 | \input{chapters/1.tex} 92 | 93 | \input{chapters/2.tex} 94 | 95 | \input{chapters/3.tex} 96 | 97 | \input{chapters/4.tex} 98 | 99 | \input{chapters/5.tex} 100 | 101 | \input{chapters/6.tex} 102 | 103 | \input{chapters/bib.tex} 104 | 105 | \end{document} 106 | -------------------------------------------------------------------------------- /datasets/cnf/dubois20.cnf: -------------------------------------------------------------------------------- 1 | c FILE: dubois20.cnf 2 | c 3 | c SOURCE: Olivier Dubois (dubois@laforia.ibp.fr) 4 | c 5 | c DESCRIPTION: Instance from generator gensathard.c 6 | c 7 | c NOTE: Not satisfiable 8 | c 9 | c d = 20 10 | c n = 60 11 | c p = 160 12 | c r = 3 13 | p cnf 60 160 14 | 39 40 1 0 15 | -39 -40 1 0 16 | 39 -40 -1 0 17 | -39 40 -1 0 18 | 1 41 2 0 19 | -1 -41 2 0 20 | 1 -41 -2 0 21 | -1 41 -2 0 22 | 2 42 3 0 23 | -2 -42 3 0 24 | 2 -42 -3 0 25 | -2 42 -3 0 26 | 3 43 4 0 27 | -3 -43 4 0 28 | 3 -43 -4 0 29 | -3 43 -4 0 30 | 4 44 5 0 31 | -4 -44 5 0 32 | 4 -44 -5 0 33 | -4 44 -5 0 34 | 5 45 6 0 35 | -5 -45 6 0 36 | 5 -45 -6 0 37 | -5 45 -6 0 38 | 6 46 7 0 39 | -6 -46 7 0 40 | 6 -46 -7 0 41 | -6 46 -7 0 42 | 7 47 8 0 43 | -7 -47 8 0 44 | 7 -47 -8 0 45 | -7 47 -8 0 46 | 8 48 9 0 47 | -8 -48 9 0 48 | 8 -48 -9 0 49 | -8 48 -9 0 50 | 9 49 10 0 51 | -9 -49 10 0 52 | 9 -49 -10 0 53 | -9 49 -10 0 54 | 10 50 11 0 55 | -10 -50 11 0 56 | 10 -50 -11 0 57 | -10 50 -11 0 58 | 11 51 12 0 59 | -11 -51 12 0 60 | 11 -51 -12 0 61 | -11 51 -12 0 62 | 12 52 13 0 63 | -12 -52 13 0 64 | 12 -52 -13 0 65 | -12 52 -13 0 66 | 13 53 14 0 67 | -13 -53 14 0 68 | 13 -53 -14 0 69 | -13 53 -14 0 70 | 14 54 15 0 71 | -14 -54 15 0 72 | 14 -54 -15 0 73 | -14 54 -15 0 74 | 15 55 16 0 75 | -15 -55 16 0 76 | 15 -55 -16 0 77 | -15 55 -16 0 78 | 16 56 17 0 79 | -16 -56 17 0 80 | 16 -56 -17 0 81 | -16 56 -17 0 82 | 17 57 18 0 83 | -17 -57 18 0 84 | 17 -57 -18 0 85 | -17 57 -18 0 86 | 18 58 19 0 87 | -18 -58 19 0 88 | 18 -58 -19 0 89 | -18 58 -19 0 90 | 19 59 60 0 91 | -19 -59 60 0 92 | 19 -59 -60 0 93 | -19 59 -60 0 94 | 20 59 60 0 95 | -20 -59 60 0 96 | 20 -59 -60 0 97 | -20 59 -60 0 98 | 21 58 20 0 99 | -21 -58 20 0 100 | 21 -58 -20 0 101 | -21 58 -20 0 102 | 22 57 21 0 103 | -22 -57 21 0 104 | 22 -57 -21 0 105 | -22 57 -21 0 106 | 23 56 22 0 107 | -23 -56 22 0 108 | 23 -56 -22 0 109 | -23 56 -22 0 110 | 24 55 23 0 111 | -24 -55 23 0 112 | 24 -55 -23 0 113 | -24 55 -23 0 114 | 25 54 24 0 115 | -25 -54 24 0 116 | 25 -54 -24 0 117 | -25 54 -24 0 118 | 26 53 25 0 119 | -26 -53 25 0 120 | 26 -53 -25 0 121 | -26 53 -25 0 122 | 27 52 26 0 123 | -27 -52 26 0 124 | 27 -52 -26 0 125 | -27 52 -26 0 126 | 28 51 27 0 127 | -28 -51 27 0 128 | 28 -51 -27 0 129 | -28 51 -27 0 130 | 29 50 28 0 131 | -29 -50 28 0 132 | 29 -50 -28 0 133 | -29 50 -28 0 134 | 30 49 29 0 135 | -30 -49 29 0 136 | 30 -49 -29 0 137 | -30 49 -29 0 138 | 31 48 30 0 139 | -31 -48 30 0 140 | 31 -48 -30 0 141 | -31 48 -30 0 142 | 32 47 31 0 143 | -32 -47 31 0 144 | 32 -47 -31 0 145 | -32 47 -31 0 146 | 33 46 32 0 147 | -33 -46 32 0 148 | 33 -46 -32 0 149 | -33 46 -32 0 150 | 34 45 33 0 151 | -34 -45 33 0 152 | 34 -45 -33 0 153 | -34 45 -33 0 154 | 35 44 34 0 155 | -35 -44 34 0 156 | 35 -44 -34 0 157 | -35 44 -34 0 158 | 36 43 35 0 159 | -36 -43 35 0 160 | 36 -43 -35 0 161 | -36 43 -35 0 162 | 37 42 36 0 163 | -37 -42 36 0 164 | 37 -42 -36 0 165 | -37 42 -36 0 166 | 38 41 37 0 167 | -38 -41 37 0 168 | 38 -41 -37 0 169 | -38 41 -37 0 170 | 39 40 -38 0 171 | -39 -40 -38 0 172 | 39 -40 38 0 173 | -39 40 38 0 174 | -------------------------------------------------------------------------------- /datasets/cnf/dubois21.cnf: -------------------------------------------------------------------------------- 1 | c FILE: dubois21.cnf 2 | c 3 | c SOURCE: Olivier Dubois (dubois@laforia.ibp.fr) 4 | c 5 | c DESCRIPTION: Instance from generator gensathard.c 6 | c 7 | c NOTE: Not satisfiable 8 | c 9 | c d = 21 10 | c n = 63 11 | c p = 168 12 | c r = 3 13 | p cnf 63 168 14 | 41 42 1 0 15 | -41 -42 1 0 16 | 41 -42 -1 0 17 | -41 42 -1 0 18 | 1 43 2 0 19 | -1 -43 2 0 20 | 1 -43 -2 0 21 | -1 43 -2 0 22 | 2 44 3 0 23 | -2 -44 3 0 24 | 2 -44 -3 0 25 | -2 44 -3 0 26 | 3 45 4 0 27 | -3 -45 4 0 28 | 3 -45 -4 0 29 | -3 45 -4 0 30 | 4 46 5 0 31 | -4 -46 5 0 32 | 4 -46 -5 0 33 | -4 46 -5 0 34 | 5 47 6 0 35 | -5 -47 6 0 36 | 5 -47 -6 0 37 | -5 47 -6 0 38 | 6 48 7 0 39 | -6 -48 7 0 40 | 6 -48 -7 0 41 | -6 48 -7 0 42 | 7 49 8 0 43 | -7 -49 8 0 44 | 7 -49 -8 0 45 | -7 49 -8 0 46 | 8 50 9 0 47 | -8 -50 9 0 48 | 8 -50 -9 0 49 | -8 50 -9 0 50 | 9 51 10 0 51 | -9 -51 10 0 52 | 9 -51 -10 0 53 | -9 51 -10 0 54 | 10 52 11 0 55 | -10 -52 11 0 56 | 10 -52 -11 0 57 | -10 52 -11 0 58 | 11 53 12 0 59 | -11 -53 12 0 60 | 11 -53 -12 0 61 | -11 53 -12 0 62 | 12 54 13 0 63 | -12 -54 13 0 64 | 12 -54 -13 0 65 | -12 54 -13 0 66 | 13 55 14 0 67 | -13 -55 14 0 68 | 13 -55 -14 0 69 | -13 55 -14 0 70 | 14 56 15 0 71 | -14 -56 15 0 72 | 14 -56 -15 0 73 | -14 56 -15 0 74 | 15 57 16 0 75 | -15 -57 16 0 76 | 15 -57 -16 0 77 | -15 57 -16 0 78 | 16 58 17 0 79 | -16 -58 17 0 80 | 16 -58 -17 0 81 | -16 58 -17 0 82 | 17 59 18 0 83 | -17 -59 18 0 84 | 17 -59 -18 0 85 | -17 59 -18 0 86 | 18 60 19 0 87 | -18 -60 19 0 88 | 18 -60 -19 0 89 | -18 60 -19 0 90 | 19 61 20 0 91 | -19 -61 20 0 92 | 19 -61 -20 0 93 | -19 61 -20 0 94 | 20 62 63 0 95 | -20 -62 63 0 96 | 20 -62 -63 0 97 | -20 62 -63 0 98 | 21 62 63 0 99 | -21 -62 63 0 100 | 21 -62 -63 0 101 | -21 62 -63 0 102 | 22 61 21 0 103 | -22 -61 21 0 104 | 22 -61 -21 0 105 | -22 61 -21 0 106 | 23 60 22 0 107 | -23 -60 22 0 108 | 23 -60 -22 0 109 | -23 60 -22 0 110 | 24 59 23 0 111 | -24 -59 23 0 112 | 24 -59 -23 0 113 | -24 59 -23 0 114 | 25 58 24 0 115 | -25 -58 24 0 116 | 25 -58 -24 0 117 | -25 58 -24 0 118 | 26 57 25 0 119 | -26 -57 25 0 120 | 26 -57 -25 0 121 | -26 57 -25 0 122 | 27 56 26 0 123 | -27 -56 26 0 124 | 27 -56 -26 0 125 | -27 56 -26 0 126 | 28 55 27 0 127 | -28 -55 27 0 128 | 28 -55 -27 0 129 | -28 55 -27 0 130 | 29 54 28 0 131 | -29 -54 28 0 132 | 29 -54 -28 0 133 | -29 54 -28 0 134 | 30 53 29 0 135 | -30 -53 29 0 136 | 30 -53 -29 0 137 | -30 53 -29 0 138 | 31 52 30 0 139 | -31 -52 30 0 140 | 31 -52 -30 0 141 | -31 52 -30 0 142 | 32 51 31 0 143 | -32 -51 31 0 144 | 32 -51 -31 0 145 | -32 51 -31 0 146 | 33 50 32 0 147 | -33 -50 32 0 148 | 33 -50 -32 0 149 | -33 50 -32 0 150 | 34 49 33 0 151 | -34 -49 33 0 152 | 34 -49 -33 0 153 | -34 49 -33 0 154 | 35 48 34 0 155 | -35 -48 34 0 156 | 35 -48 -34 0 157 | -35 48 -34 0 158 | 36 47 35 0 159 | -36 -47 35 0 160 | 36 -47 -35 0 161 | -36 47 -35 0 162 | 37 46 36 0 163 | -37 -46 36 0 164 | 37 -46 -36 0 165 | -37 46 -36 0 166 | 38 45 37 0 167 | -38 -45 37 0 168 | 38 -45 -37 0 169 | -38 45 -37 0 170 | 39 44 38 0 171 | -39 -44 38 0 172 | 39 -44 -38 0 173 | -39 44 -38 0 174 | 40 43 39 0 175 | -40 -43 39 0 176 | 40 -43 -39 0 177 | -40 43 -39 0 178 | 41 42 -40 0 179 | -41 -42 -40 0 180 | 41 -42 40 0 181 | -41 42 40 0 182 | -------------------------------------------------------------------------------- /datasets/cnf/dubois22.cnf: -------------------------------------------------------------------------------- 1 | c FILE: dubois22.cnf 2 | c 3 | c SOURCE: Olivier Dubois (dubois@laforia.ibp.fr) 4 | c 5 | c DESCRIPTION: Instance from generator gensathard.c 6 | c 7 | c NOTE: Not satisfiable 8 | c 9 | c d = 22 10 | c n = 66 11 | c p = 176 12 | c r = 3 13 | p cnf 66 176 14 | 43 44 1 0 15 | -43 -44 1 0 16 | 43 -44 -1 0 17 | -43 44 -1 0 18 | 1 45 2 0 19 | -1 -45 2 0 20 | 1 -45 -2 0 21 | -1 45 -2 0 22 | 2 46 3 0 23 | -2 -46 3 0 24 | 2 -46 -3 0 25 | -2 46 -3 0 26 | 3 47 4 0 27 | -3 -47 4 0 28 | 3 -47 -4 0 29 | -3 47 -4 0 30 | 4 48 5 0 31 | -4 -48 5 0 32 | 4 -48 -5 0 33 | -4 48 -5 0 34 | 5 49 6 0 35 | -5 -49 6 0 36 | 5 -49 -6 0 37 | -5 49 -6 0 38 | 6 50 7 0 39 | -6 -50 7 0 40 | 6 -50 -7 0 41 | -6 50 -7 0 42 | 7 51 8 0 43 | -7 -51 8 0 44 | 7 -51 -8 0 45 | -7 51 -8 0 46 | 8 52 9 0 47 | -8 -52 9 0 48 | 8 -52 -9 0 49 | -8 52 -9 0 50 | 9 53 10 0 51 | -9 -53 10 0 52 | 9 -53 -10 0 53 | -9 53 -10 0 54 | 10 54 11 0 55 | -10 -54 11 0 56 | 10 -54 -11 0 57 | -10 54 -11 0 58 | 11 55 12 0 59 | -11 -55 12 0 60 | 11 -55 -12 0 61 | -11 55 -12 0 62 | 12 56 13 0 63 | -12 -56 13 0 64 | 12 -56 -13 0 65 | -12 56 -13 0 66 | 13 57 14 0 67 | -13 -57 14 0 68 | 13 -57 -14 0 69 | -13 57 -14 0 70 | 14 58 15 0 71 | -14 -58 15 0 72 | 14 -58 -15 0 73 | -14 58 -15 0 74 | 15 59 16 0 75 | -15 -59 16 0 76 | 15 -59 -16 0 77 | -15 59 -16 0 78 | 16 60 17 0 79 | -16 -60 17 0 80 | 16 -60 -17 0 81 | -16 60 -17 0 82 | 17 61 18 0 83 | -17 -61 18 0 84 | 17 -61 -18 0 85 | -17 61 -18 0 86 | 18 62 19 0 87 | -18 -62 19 0 88 | 18 -62 -19 0 89 | -18 62 -19 0 90 | 19 63 20 0 91 | -19 -63 20 0 92 | 19 -63 -20 0 93 | -19 63 -20 0 94 | 20 64 21 0 95 | -20 -64 21 0 96 | 20 -64 -21 0 97 | -20 64 -21 0 98 | 21 65 66 0 99 | -21 -65 66 0 100 | 21 -65 -66 0 101 | -21 65 -66 0 102 | 22 65 66 0 103 | -22 -65 66 0 104 | 22 -65 -66 0 105 | -22 65 -66 0 106 | 23 64 22 0 107 | -23 -64 22 0 108 | 23 -64 -22 0 109 | -23 64 -22 0 110 | 24 63 23 0 111 | -24 -63 23 0 112 | 24 -63 -23 0 113 | -24 63 -23 0 114 | 25 62 24 0 115 | -25 -62 24 0 116 | 25 -62 -24 0 117 | -25 62 -24 0 118 | 26 61 25 0 119 | -26 -61 25 0 120 | 26 -61 -25 0 121 | -26 61 -25 0 122 | 27 60 26 0 123 | -27 -60 26 0 124 | 27 -60 -26 0 125 | -27 60 -26 0 126 | 28 59 27 0 127 | -28 -59 27 0 128 | 28 -59 -27 0 129 | -28 59 -27 0 130 | 29 58 28 0 131 | -29 -58 28 0 132 | 29 -58 -28 0 133 | -29 58 -28 0 134 | 30 57 29 0 135 | -30 -57 29 0 136 | 30 -57 -29 0 137 | -30 57 -29 0 138 | 31 56 30 0 139 | -31 -56 30 0 140 | 31 -56 -30 0 141 | -31 56 -30 0 142 | 32 55 31 0 143 | -32 -55 31 0 144 | 32 -55 -31 0 145 | -32 55 -31 0 146 | 33 54 32 0 147 | -33 -54 32 0 148 | 33 -54 -32 0 149 | -33 54 -32 0 150 | 34 53 33 0 151 | -34 -53 33 0 152 | 34 -53 -33 0 153 | -34 53 -33 0 154 | 35 52 34 0 155 | -35 -52 34 0 156 | 35 -52 -34 0 157 | -35 52 -34 0 158 | 36 51 35 0 159 | -36 -51 35 0 160 | 36 -51 -35 0 161 | -36 51 -35 0 162 | 37 50 36 0 163 | -37 -50 36 0 164 | 37 -50 -36 0 165 | -37 50 -36 0 166 | 38 49 37 0 167 | -38 -49 37 0 168 | 38 -49 -37 0 169 | -38 49 -37 0 170 | 39 48 38 0 171 | -39 -48 38 0 172 | 39 -48 -38 0 173 | -39 48 -38 0 174 | 40 47 39 0 175 | -40 -47 39 0 176 | 40 -47 -39 0 177 | -40 47 -39 0 178 | 41 46 40 0 179 | -41 -46 40 0 180 | 41 -46 -40 0 181 | -41 46 -40 0 182 | 42 45 41 0 183 | -42 -45 41 0 184 | 42 -45 -41 0 185 | -42 45 -41 0 186 | 43 44 -42 0 187 | -43 -44 -42 0 188 | 43 -44 42 0 189 | -43 44 42 0 190 | -------------------------------------------------------------------------------- /datasets/iris.csv: -------------------------------------------------------------------------------- 1 | sepallength,sepalwidth,petallength,petalwidth,class 2 | 5.1,3.5,1.4,0.2,Iris-setosa 3 | 4.9,3.0,1.4,0.2,Iris-setosa 4 | 4.7,3.2,1.3,0.2,Iris-setosa 5 | 4.6,3.1,1.5,0.2,Iris-setosa 6 | 5.0,3.6,1.4,0.2,Iris-setosa 7 | 5.4,3.9,1.7,0.4,Iris-setosa 8 | 4.6,3.4,1.4,0.3,Iris-setosa 9 | 5.0,3.4,1.5,0.2,Iris-setosa 10 | 4.4,2.9,1.4,0.2,Iris-setosa 11 | 4.9,3.1,1.5,0.1,Iris-setosa 12 | 5.4,3.7,1.5,0.2,Iris-setosa 13 | 4.8,3.4,1.6,0.2,Iris-setosa 14 | 4.8,3.0,1.4,0.1,Iris-setosa 15 | 4.3,3.0,1.1,0.1,Iris-setosa 16 | 5.8,4.0,1.2,0.2,Iris-setosa 17 | 5.7,4.4,1.5,0.4,Iris-setosa 18 | 5.4,3.9,1.3,0.4,Iris-setosa 19 | 5.1,3.5,1.4,0.3,Iris-setosa 20 | 5.7,3.8,1.7,0.3,Iris-setosa 21 | 5.1,3.8,1.5,0.3,Iris-setosa 22 | 5.4,3.4,1.7,0.2,Iris-setosa 23 | 5.1,3.7,1.5,0.4,Iris-setosa 24 | 4.6,3.6,1.0,0.2,Iris-setosa 25 | 5.1,3.3,1.7,0.5,Iris-setosa 26 | 4.8,3.4,1.9,0.2,Iris-setosa 27 | 5.0,3.0,1.6,0.2,Iris-setosa 28 | 5.0,3.4,1.6,0.4,Iris-setosa 29 | 5.2,3.5,1.5,0.2,Iris-setosa 30 | 5.2,3.4,1.4,0.2,Iris-setosa 31 | 4.7,3.2,1.6,0.2,Iris-setosa 32 | 4.8,3.1,1.6,0.2,Iris-setosa 33 | 5.4,3.4,1.5,0.4,Iris-setosa 34 | 5.2,4.1,1.5,0.1,Iris-setosa 35 | 5.5,4.2,1.4,0.2,Iris-setosa 36 | 4.9,3.1,1.5,0.1,Iris-setosa 37 | 5.0,3.2,1.2,0.2,Iris-setosa 38 | 5.5,3.5,1.3,0.2,Iris-setosa 39 | 4.9,3.1,1.5,0.1,Iris-setosa 40 | 4.4,3.0,1.3,0.2,Iris-setosa 41 | 5.1,3.4,1.5,0.2,Iris-setosa 42 | 5.0,3.5,1.3,0.3,Iris-setosa 43 | 4.5,2.3,1.3,0.3,Iris-setosa 44 | 4.4,3.2,1.3,0.2,Iris-setosa 45 | 5.0,3.5,1.6,0.6,Iris-setosa 46 | 5.1,3.8,1.9,0.4,Iris-setosa 47 | 4.8,3.0,1.4,0.3,Iris-setosa 48 | 5.1,3.8,1.6,0.2,Iris-setosa 49 | 4.6,3.2,1.4,0.2,Iris-setosa 50 | 5.3,3.7,1.5,0.2,Iris-setosa 51 | 5.0,3.3,1.4,0.2,Iris-setosa 52 | 7.0,3.2,4.7,1.4,Iris-versicolor 53 | 6.4,3.2,4.5,1.5,Iris-versicolor 54 | 6.9,3.1,4.9,1.5,Iris-versicolor 55 | 5.5,2.3,4.0,1.3,Iris-versicolor 56 | 6.5,2.8,4.6,1.5,Iris-versicolor 57 | 5.7,2.8,4.5,1.3,Iris-versicolor 58 | 6.3,3.3,4.7,1.6,Iris-versicolor 59 | 4.9,2.4,3.3,1.0,Iris-versicolor 60 | 6.6,2.9,4.6,1.3,Iris-versicolor 61 | 5.2,2.7,3.9,1.4,Iris-versicolor 62 | 5.0,2.0,3.5,1.0,Iris-versicolor 63 | 5.9,3.0,4.2,1.5,Iris-versicolor 64 | 6.0,2.2,4.0,1.0,Iris-versicolor 65 | 6.1,2.9,4.7,1.4,Iris-versicolor 66 | 5.6,2.9,3.6,1.3,Iris-versicolor 67 | 6.7,3.1,4.4,1.4,Iris-versicolor 68 | 5.6,3.0,4.5,1.5,Iris-versicolor 69 | 5.8,2.7,4.1,1.0,Iris-versicolor 70 | 6.2,2.2,4.5,1.5,Iris-versicolor 71 | 5.6,2.5,3.9,1.1,Iris-versicolor 72 | 5.9,3.2,4.8,1.8,Iris-versicolor 73 | 6.1,2.8,4.0,1.3,Iris-versicolor 74 | 6.3,2.5,4.9,1.5,Iris-versicolor 75 | 6.1,2.8,4.7,1.2,Iris-versicolor 76 | 6.4,2.9,4.3,1.3,Iris-versicolor 77 | 6.6,3.0,4.4,1.4,Iris-versicolor 78 | 6.8,2.8,4.8,1.4,Iris-versicolor 79 | 6.7,3.0,5.0,1.7,Iris-versicolor 80 | 6.0,2.9,4.5,1.5,Iris-versicolor 81 | 5.7,2.6,3.5,1.0,Iris-versicolor 82 | 5.5,2.4,3.8,1.1,Iris-versicolor 83 | 5.5,2.4,3.7,1.0,Iris-versicolor 84 | 5.8,2.7,3.9,1.2,Iris-versicolor 85 | 6.0,2.7,5.1,1.6,Iris-versicolor 86 | 5.4,3.0,4.5,1.5,Iris-versicolor 87 | 6.0,3.4,4.5,1.6,Iris-versicolor 88 | 6.7,3.1,4.7,1.5,Iris-versicolor 89 | 6.3,2.3,4.4,1.3,Iris-versicolor 90 | 5.6,3.0,4.1,1.3,Iris-versicolor 91 | 5.5,2.5,4.0,1.3,Iris-versicolor 92 | 5.5,2.6,4.4,1.2,Iris-versicolor 93 | 6.1,3.0,4.6,1.4,Iris-versicolor 94 | 5.8,2.6,4.0,1.2,Iris-versicolor 95 | 5.0,2.3,3.3,1.0,Iris-versicolor 96 | 5.6,2.7,4.2,1.3,Iris-versicolor 97 | 5.7,3.0,4.2,1.2,Iris-versicolor 98 | 5.7,2.9,4.2,1.3,Iris-versicolor 99 | 6.2,2.9,4.3,1.3,Iris-versicolor 100 | 5.1,2.5,3.0,1.1,Iris-versicolor 101 | 5.7,2.8,4.1,1.3,Iris-versicolor 102 | 6.3,3.3,6.0,2.5,Iris-virginica 103 | 5.8,2.7,5.1,1.9,Iris-virginica 104 | 7.1,3.0,5.9,2.1,Iris-virginica 105 | 6.3,2.9,5.6,1.8,Iris-virginica 106 | 6.5,3.0,5.8,2.2,Iris-virginica 107 | 7.6,3.0,6.6,2.1,Iris-virginica 108 | 4.9,2.5,4.5,1.7,Iris-virginica 109 | 7.3,2.9,6.3,1.8,Iris-virginica 110 | 6.7,2.5,5.8,1.8,Iris-virginica 111 | 7.2,3.6,6.1,2.5,Iris-virginica 112 | 6.5,3.2,5.1,2.0,Iris-virginica 113 | 6.4,2.7,5.3,1.9,Iris-virginica 114 | 6.8,3.0,5.5,2.1,Iris-virginica 115 | 5.7,2.5,5.0,2.0,Iris-virginica 116 | 5.8,2.8,5.1,2.4,Iris-virginica 117 | 6.4,3.2,5.3,2.3,Iris-virginica 118 | 6.5,3.0,5.5,1.8,Iris-virginica 119 | 7.7,3.8,6.7,2.2,Iris-virginica 120 | 7.7,2.6,6.9,2.3,Iris-virginica 121 | 6.0,2.2,5.0,1.5,Iris-virginica 122 | 6.9,3.2,5.7,2.3,Iris-virginica 123 | 5.6,2.8,4.9,2.0,Iris-virginica 124 | 7.7,2.8,6.7,2.0,Iris-virginica 125 | 6.3,2.7,4.9,1.8,Iris-virginica 126 | 6.7,3.3,5.7,2.1,Iris-virginica 127 | 7.2,3.2,6.0,1.8,Iris-virginica 128 | 6.2,2.8,4.8,1.8,Iris-virginica 129 | 6.1,3.0,4.9,1.8,Iris-virginica 130 | 6.4,2.8,5.6,2.1,Iris-virginica 131 | 7.2,3.0,5.8,1.6,Iris-virginica 132 | 7.4,2.8,6.1,1.9,Iris-virginica 133 | 7.9,3.8,6.4,2.0,Iris-virginica 134 | 6.4,2.8,5.6,2.2,Iris-virginica 135 | 6.3,2.8,5.1,1.5,Iris-virginica 136 | 6.1,2.6,5.6,1.4,Iris-virginica 137 | 7.7,3.0,6.1,2.3,Iris-virginica 138 | 6.3,3.4,5.6,2.4,Iris-virginica 139 | 6.4,3.1,5.5,1.8,Iris-virginica 140 | 6.0,3.0,4.8,1.8,Iris-virginica 141 | 6.9,3.1,5.4,2.1,Iris-virginica 142 | 6.7,3.1,5.6,2.4,Iris-virginica 143 | 6.9,3.1,5.1,2.3,Iris-virginica 144 | 5.8,2.7,5.1,1.9,Iris-virginica 145 | 6.8,3.2,5.9,2.3,Iris-virginica 146 | 6.7,3.3,5.7,2.5,Iris-virginica 147 | 6.7,3.0,5.2,2.3,Iris-virginica 148 | 6.3,2.5,5.0,1.9,Iris-virginica 149 | 6.5,3.0,5.2,2.0,Iris-virginica 150 | 6.2,3.4,5.4,2.3,Iris-virginica 151 | 5.9,3.0,5.1,1.8,Iris-virginica -------------------------------------------------------------------------------- /datasets/cnf/par8-1-c.cnf: -------------------------------------------------------------------------------- 1 | c FILE: par8-1-c.cnf 2 | c 3 | c SOURCE: James Crawford (jc@research.att.com) 4 | c 5 | c DESCRIPTION: Instance arises from the problem of learning the parity 6 | c function. 7 | c 8 | c parxx-y denotes a parity problem on xx bits. y is simply the 9 | c intance number. 10 | c 11 | c parxx-y-c denotes an instance identical to parxx-y except that 12 | c the instances have been simplified (to create an equivalent 13 | c problem). 14 | c 15 | c NOTE: Satisfiable (checked for 8 and 16 size instances. All 16 | c instances are satisfiable by construction) 17 | c 18 | c NOTE: Number of clauses corrected August 3, 1993 19 | c 20 | c Converted from tableau format Tue Aug 3 09:55:20 EDT 1993 21 | p cnf 64 254 22 | -2 1 23 | 0 24 | -3 -2 25 | 0 26 | -3 -2 -1 27 | 0 28 | 3 2 -1 29 | 0 30 | -3 2 1 31 | 0 32 | 3 -2 1 33 | 0 34 | -4 2 35 | 0 36 | -5 -4 37 | 0 38 | -5 -4 -2 39 | 0 40 | 5 4 -2 41 | 0 42 | -5 4 2 43 | 0 44 | 5 -4 2 45 | 0 46 | -6 4 47 | 0 48 | -7 -6 49 | 0 50 | -7 -6 -4 51 | 0 52 | 7 6 -4 53 | 0 54 | -7 6 4 55 | 0 56 | 7 -6 4 57 | 0 58 | -8 6 59 | 0 60 | -9 -8 61 | 0 62 | -9 -8 -6 63 | 0 64 | 9 8 -6 65 | 0 66 | -9 8 6 67 | 0 68 | 9 -8 6 69 | 0 70 | -10 8 71 | 0 72 | -11 -10 73 | 0 74 | -11 -10 -8 75 | 0 76 | 11 10 -8 77 | 0 78 | -11 10 8 79 | 0 80 | 11 -10 8 81 | 0 82 | -12 10 83 | 0 84 | -13 -12 85 | 0 86 | -13 -12 -10 87 | 0 88 | 13 12 -10 89 | 0 90 | -13 12 10 91 | 0 92 | 13 -12 10 93 | 0 94 | -14 12 95 | 0 96 | -15 -14 97 | 0 98 | -15 -14 -12 99 | 0 100 | 15 14 -12 101 | 0 102 | -15 14 12 103 | 0 104 | 15 -14 12 105 | 0 106 | -16 14 107 | 0 108 | -17 -16 109 | 0 110 | -17 -16 -14 111 | 0 112 | 17 16 -14 113 | 0 114 | -17 16 14 115 | 0 116 | 17 -16 14 117 | 0 118 | -18 16 119 | 0 120 | -19 -18 121 | 0 122 | -19 -18 -16 123 | 0 124 | 19 18 -16 125 | 0 126 | -19 18 16 127 | 0 128 | 19 -18 16 129 | 0 130 | -20 18 131 | 0 132 | -21 -20 133 | 0 134 | -21 -20 -18 135 | 0 136 | 21 20 -18 137 | 0 138 | -21 20 18 139 | 0 140 | 21 -20 18 141 | 0 142 | -22 20 143 | 0 144 | -23 -22 145 | 0 146 | -23 -22 -20 147 | 0 148 | 23 22 -20 149 | 0 150 | -23 22 20 151 | 0 152 | 23 -22 20 153 | 0 154 | -24 22 155 | 0 156 | -25 -24 157 | 0 158 | -25 -24 -22 159 | 0 160 | 25 24 -22 161 | 0 162 | -25 24 22 163 | 0 164 | 25 -24 22 165 | 0 166 | -26 24 167 | 0 168 | -27 -26 169 | 0 170 | -27 -26 -24 171 | 0 172 | 27 26 -24 173 | 0 174 | -27 26 24 175 | 0 176 | 27 -26 24 177 | 0 178 | -28 26 179 | 0 180 | -29 -28 181 | 0 182 | -29 -28 -26 183 | 0 184 | 29 28 -26 185 | 0 186 | -29 28 26 187 | 0 188 | 29 -28 26 189 | 0 190 | 28 -30 191 | 0 192 | -31 -30 193 | 0 194 | -31 -28 -30 195 | 0 196 | 31 -28 30 197 | 0 198 | -31 28 30 199 | 0 200 | 31 28 -30 201 | 0 202 | -33 -32 -3 203 | 0 204 | 33 32 -3 205 | 0 206 | -33 32 3 207 | 0 208 | 33 -32 3 209 | 0 210 | -35 -34 -32 211 | 0 212 | 35 34 -32 213 | 0 214 | -35 34 32 215 | 0 216 | 35 -34 32 217 | 0 218 | -37 -34 36 219 | 0 220 | 37 -34 -36 221 | 0 222 | -37 34 -36 223 | 0 224 | 37 34 36 225 | 0 226 | -39 -38 -5 227 | 0 228 | 39 38 -5 229 | 0 230 | -39 38 5 231 | 0 232 | 39 -38 5 233 | 0 234 | -35 -40 -38 235 | 0 236 | 35 40 -38 237 | 0 238 | -35 40 38 239 | 0 240 | 35 -40 38 241 | 0 242 | -42 -41 -40 243 | 0 244 | 42 41 -40 245 | 0 246 | -42 41 40 247 | 0 248 | 42 -41 40 249 | 0 250 | -36 -41 43 251 | 0 252 | 36 -41 -43 253 | 0 254 | -36 41 -43 255 | 0 256 | 36 41 43 257 | 0 258 | -44 -7 29 259 | 0 260 | 44 -7 -29 261 | 0 262 | 44 7 29 263 | 0 264 | -44 7 -29 265 | 0 266 | -33 -45 -44 267 | 0 268 | 33 45 -44 269 | 0 270 | -33 45 44 271 | 0 272 | 33 -45 44 273 | 0 274 | -37 -36 -45 275 | 0 276 | 37 36 -45 277 | 0 278 | -37 36 45 279 | 0 280 | 37 -36 45 281 | 0 282 | -37 -46 -9 283 | 0 284 | 37 46 -9 285 | 0 286 | -37 46 9 287 | 0 288 | 37 -46 9 289 | 0 290 | -36 -43 -46 291 | 0 292 | 36 43 -46 293 | 0 294 | -36 43 46 295 | 0 296 | 36 -43 46 297 | 0 298 | -39 -47 -11 299 | 0 300 | 39 47 -11 301 | 0 302 | -39 47 11 303 | 0 304 | 39 -47 11 305 | 0 306 | -33 -48 -47 307 | 0 308 | 33 48 -47 309 | 0 310 | -33 48 47 311 | 0 312 | 33 -48 47 313 | 0 314 | -37 -36 -48 315 | 0 316 | 37 36 -48 317 | 0 318 | -37 36 48 319 | 0 320 | 37 -36 48 321 | 0 322 | -39 -49 -13 323 | 0 324 | 39 49 -13 325 | 0 326 | -39 49 13 327 | 0 328 | 39 -49 13 329 | 0 330 | -33 -36 -49 331 | 0 332 | 33 36 -49 333 | 0 334 | -33 36 49 335 | 0 336 | 33 -36 49 337 | 0 338 | -50 -15 29 339 | 0 340 | 50 -15 -29 341 | 0 342 | 50 15 29 343 | 0 344 | -50 15 -29 345 | 0 346 | -35 -37 -50 347 | 0 348 | 35 37 -50 349 | 0 350 | -35 37 50 351 | 0 352 | 35 -37 50 353 | 0 354 | -39 -35 -17 355 | 0 356 | 39 35 -17 357 | 0 358 | -39 35 17 359 | 0 360 | 39 -35 17 361 | 0 362 | -39 -51 -19 363 | 0 364 | 39 51 -19 365 | 0 366 | -39 51 19 367 | 0 368 | 39 -51 19 369 | 0 370 | -35 -52 -51 371 | 0 372 | 35 52 -51 373 | 0 374 | -35 52 51 375 | 0 376 | 35 -52 51 377 | 0 378 | -37 -52 42 379 | 0 380 | 37 -52 -42 381 | 0 382 | -37 52 -42 383 | 0 384 | 37 52 42 385 | 0 386 | -53 -21 29 387 | 0 388 | 53 -21 -29 389 | 0 390 | 53 21 29 391 | 0 392 | -53 21 -29 393 | 0 394 | -33 -54 -53 395 | 0 396 | 33 54 -53 397 | 0 398 | -33 54 53 399 | 0 400 | 33 -54 53 401 | 0 402 | -35 -54 42 403 | 0 404 | 35 -54 -42 405 | 0 406 | -35 54 -42 407 | 0 408 | 35 54 42 409 | 0 410 | -33 -23 42 411 | 0 412 | 33 -23 -42 413 | 0 414 | -33 23 -42 415 | 0 416 | 33 23 42 417 | 0 418 | -55 -25 29 419 | 0 420 | 55 -25 -29 421 | 0 422 | 55 25 29 423 | 0 424 | -55 25 -29 425 | 0 426 | -33 -56 -55 427 | 0 428 | 33 56 -55 429 | 0 430 | -33 56 55 431 | 0 432 | 33 -56 55 433 | 0 434 | -35 -56 36 435 | 0 436 | 35 -56 -36 437 | 0 438 | -35 56 -36 439 | 0 440 | 35 56 36 441 | 0 442 | -39 -57 -27 443 | 0 444 | 39 57 -27 445 | 0 446 | -39 57 27 447 | 0 448 | 39 -57 27 449 | 0 450 | -58 -57 29 451 | 0 452 | 58 -57 -29 453 | 0 454 | 58 57 29 455 | 0 456 | -58 57 -29 457 | 0 458 | -35 -59 -58 459 | 0 460 | 35 59 -58 461 | 0 462 | -35 59 58 463 | 0 464 | 35 -59 58 465 | 0 466 | -37 -59 -36 467 | 0 468 | 37 -59 36 469 | 0 470 | -37 59 36 471 | 0 472 | 37 59 -36 473 | 0 474 | -37 -60 -31 475 | 0 476 | 37 60 -31 477 | 0 478 | -37 60 31 479 | 0 480 | 37 -60 31 481 | 0 482 | -42 -61 -60 483 | 0 484 | 42 61 -60 485 | 0 486 | -42 61 60 487 | 0 488 | 42 -61 60 489 | 0 490 | -36 -61 43 491 | 0 492 | 36 -61 -43 493 | 0 494 | -36 61 -43 495 | 0 496 | 36 61 43 497 | 0 498 | -39 -62 -30 499 | 0 500 | 39 62 -30 501 | 0 502 | -39 62 30 503 | 0 504 | 39 -62 30 505 | 0 506 | -33 -63 -62 507 | 0 508 | 33 63 -62 509 | 0 510 | -33 63 62 511 | 0 512 | 33 -63 62 513 | 0 514 | -42 -64 -63 515 | 0 516 | 42 64 -63 517 | 0 518 | -42 64 63 519 | 0 520 | 42 -64 63 521 | 0 522 | -36 -64 -43 523 | 0 524 | 36 -64 43 525 | 0 526 | -36 64 43 527 | 0 528 | 36 64 -43 529 | 0 530 | 531 | -------------------------------------------------------------------------------- /book/chapters/4.tex: -------------------------------------------------------------------------------- 1 | 2 | \chapter{Matrix Operations} 3 | 4 | \begin{chapquote}{David Jacobs} 5 | ``Code is like poetry; most of it shouldn't have been written.'' 6 | \end{chapquote} 7 | 8 | In the previous chapters we've been dealing with certain methods 9 | of \textit{soft computing}. The numerical packages (or ``programming 10 | languages'', as some people call them) like R, SPSS or Matlab 11 | have often been praised for their ``native'' support for matrix 12 | operations and statistical notions. 13 | 14 | In this chapter, we will show how easily these concepts can be 15 | implemented in Scheme using the means that we already know. We will 16 | also learn to define and use \textit{variadic} functions. 17 | 18 | It is common in mathematics and science to organize the computations 19 | in the form of \textit{matrices}, because this allows to process 20 | large amounts of data in a systematic and uniform manner. 21 | 22 | A \textit{matrix} is a rectangular array of numbers, for example 23 | 24 | \begin{equation*} 25 | \begin{pmatrix} 26 | 1 & 2 & 3 & 4 \\ 27 | 0 & 4 & 5 & 8 \\ 28 | 0 & 0 & 7 & 6 29 | \end{pmatrix} 30 | \end{equation*} 31 | 32 | We can use lists of lists of equal length to represent matrices, 33 | for example 34 | 35 | \begin{Snippet} 36 | '((1 2 3 4) 37 | (0 4 5 8) 38 | (0 0 7 6)) 39 | \end{Snippet} 40 | 41 | \subsection{Matrix addition} 42 | 43 | Given a matrix, we can determine its \textit{dimensions}. 44 | For example, the above matrix is three-by-four. 45 | 46 | \begin{Snippet} 47 | (define (dim x) 48 | (match x 49 | ((first . rest) 50 | `(,(length x) . ,(dim first))) 51 | (_ 52 | '()))) 53 | \end{Snippet} 54 | 55 | Probably the simplest algebraic operation that one can 56 | conduct on a matrix is \textit{matrix addition}: given 57 | matrices of the same dimensions, we add each element 58 | of one matrix to the corresponding element of the 59 | second matrix: 60 | 61 | \begin{Snippet} 62 | (define (M+2 A B) 63 | (assert (equal? (dim A) (dim B))) 64 | (map (lambda (a b) 65 | (map + a b)) 66 | A B)) 67 | \end{Snippet} 68 | \begin{Snippet} 69 | (e.g. 70 | (M+2 '((1 2 3) 71 | (4 5 6)) '((1 2 3) 72 | (4 5 6))) ===> ((2 4 6) 73 | (8 10 12))) 74 | \end{Snippet} 75 | 76 | \subsection{Variadic functions} 77 | 78 | I called the function \texttt{M+2} to emphasize that it 79 | takes two arguments. However, because matrix addition is 80 | associative (like conjunction and disjunction in propositional 81 | logic), so it might be more convenient to write 82 | \texttt{(M+ A B C)} instead of \texttt{(M+ (M+ A B) C)} 83 | or \texttt{(M+ A (M+ B C))}. Actually you can check that 84 | this is already the case for scalar addition: the 85 | expression \texttt{(+ 1 2 3)} evaluates to $6$. This 86 | is also true for multiplication. 87 | 88 | We can use the \texttt{M+2} function to perform the 89 | generalization to the arbitrary number of arguments, 90 | but no less than one. 91 | 92 | \begin{Snippet} 93 | (define (M+ . MM) 94 | (match MM 95 | ((M) 96 | M) 97 | ((A B . X) 98 | (apply M+ `(,(M+2 A B) . X))))) 99 | \end{Snippet} 100 | 101 | We have used an \textit{improper list} of arguments, 102 | or a \textit{dotted tail notation}. An improper list 103 | is a list whose last \texttt{cdr} is not the empty 104 | list. If the list of arguments is improper, then the 105 | symbol in the dotted tail will be bound the list of 106 | remaining arguments, so for example if we had no 107 | \texttt{list} function defined, we could use that 108 | feature: 109 | 110 | \begin{Snippet} 111 | (define (list . items) 112 | items) 113 | \end{Snippet} 114 | \begin{Snippet} 115 | ;; or equivalently: 116 | \end{Snippet} 117 | \begin{Snippet} 118 | (define list (lambda items items)) 119 | \end{Snippet} 120 | 121 | Note the use of the \texttt{apply} function. It takes 122 | a function and a list of arguments, and \textit{applies} 123 | the function to arguments. For example, if \texttt{l} 124 | is a list containing three elements, then 125 | \texttt{(apply f l)} is equivalent to 126 | \texttt{(f (first l) (second l) (third l))}. However, 127 | if the number of arguments is unknown, then the use 128 | of \texttt{apply} is inevitable if we want to preserve 129 | generality. 130 | 131 | Note also, that since the \texttt{max} and \texttt{min} 132 | functions can take an arbitrary number of arguments 133 | (and return the greatest and the smallest of them, 134 | respectively), instead of defining the \texttt{maximum} 135 | and \texttt{minimum} functions, we could have written 136 | \texttt{(apply max ...)} and \texttt{(apply min ...)}. 137 | 138 | The \texttt{apply} function can also take a variable 139 | number of arguments -- all arguments between the first 140 | and the last are simply \texttt{cons}ed to the last, 141 | so we could have written \texttt{(apply M+ (M+2 A B) X)} 142 | in the previous definition, yielding the same effect. 143 | 144 | \subsection{Transpose} 145 | If we swap columns and rows of a matrix, we obtain 146 | its \textit{transpose}. For example, the transpose 147 | of the matrix 148 | \begin{equation*} 149 | \begin{pmatrix} 150 | 1 & 2 & 3 \\ 151 | 4 & 5 & 6 152 | \end{pmatrix} 153 | \end{equation*} 154 | is the matrix 155 | \begin{equation*} 156 | \begin{pmatrix} 157 | 1 & 4 \\ 158 | 2 & 5 \\ 159 | 3 & 6 160 | \end{pmatrix} 161 | \end{equation*} 162 | 163 | The code for constructing the transpose of a matrix is 164 | a bit tricky: 165 | 166 | \begin{Snippet} 167 | (define (transpose M) 168 | (apply map list M)) 169 | \end{Snippet} 170 | 171 | To see why it works, let's try to evaluate 172 | \begin{Snippet} 173 | (transpose '((1 2 3) 174 | (4 5 6))) 175 | \end{Snippet} 176 | 177 | According to our definition, it can be rewritten as 178 | 179 | \begin{Snippet} 180 | (apply map list '((1 2 3) (4 5 6))) 181 | \end{Snippet} 182 | 183 | which -- according to what we said earlier -- can 184 | be rewritten as 185 | 186 | \begin{Snippet} 187 | (map list '(1 2 3) '(4 5 6)) 188 | \end{Snippet} 189 | 190 | which yields the desired result. 191 | 192 | \subsection{Matrix multiplication} 193 | 194 | Multiplying two matrices is much trickier than adding 195 | them and is best explained by a math tutor pointing 196 | fingers on the blackboard. 197 | 198 | If $A$ and $B$ are matrices, the product $AB$ is 199 | defined only if the number of columns of matrix $A$ 200 | equals the number of rows of the matrix $B$. Then, 201 | the number of rows of $AB$ is the same as the number 202 | of rows of $A$, and the number of columns of $AB$ 203 | is the same as the number of columns of $B$. 204 | 205 | \begin{Snippet} 206 | (define (M*2 A B) 207 | (assert (let* (((A-rows A-cols) (dim A)) 208 | ((B-rows B-cols) (dim B))) 209 | (= A-cols B-rows))) 210 | (let* ((B^T (transpose B))) 211 | (map (lambda (rA) 212 | (map (lambda (cB) 213 | (sum (map * rA cB))) 214 | B^T)) 215 | A))) 216 | \end{Snippet} 217 | 218 | We can extend the \texttt{M*2} to support arbitrary 219 | number of arguments analogically as we did for \texttt{M+2}. 220 | 221 | There are some other important operations that can be defined 222 | for matrices, like the determinant or rank. Their exposition 223 | is beyond the scope of this pamphlet, but some of them can 224 | be found in this pamphlet's repository. 225 | 226 | -------------------------------------------------------------------------------- /book/plots/kmeans.tex: -------------------------------------------------------------------------------- 1 | \begin{tikzpicture} 2 | \begin{axis}[ 3 | xlabel={PCA1}, 4 | ylabel={PCA2}, 5 | ] 6 | \addplot+[ 7 | nodes near coords, 8 | only marks, 9 | point meta=explicit symbolic, 10 | ] 11 | table[ 12 | meta=label, 13 | ] { 14 | x y label 15 | -0.06161711715313449 0.12996942830060373 $$ 16 | -0.05807229769243277 0.11137145174192183 $$ 17 | -0.05676338516730648 0.1182947693033406 $$ 18 | -0.056654313968970874 0.105607729117619 $$ 19 | -0.06123006441704709 0.1314311417740595 $$ 20 | -0.06750333894965883 0.13121548909498384 $$ 21 | -0.05748191998868599 0.11688581315371398 $$ 22 | -0.060973238901847825 0.12128227872938517 $$ 23 | -0.05376213630754356 0.10023310181869789 $$ 24 | -0.058827956809018665 0.11239131256616681 $$ 25 | -0.06529216383472475 0.13695682834115136 $$ 26 | -0.059942307914473435 0.11405684263162513 $$ 27 | -0.057114464451829404 0.11170394422395846 $$ 28 | -0.05159569819216177 0.11563975235933245 $$ 29 | -0.06800666760874802 0.1646310497964307 $$ 30 | -0.07076141332462106 0.15942601962430097 $$ 31 | -0.06536411073785399 0.14721505155300138 $$ 32 | -0.06179208137357522 0.1280241630769381 $$ 33 | -0.06928116550563142 0.1349245863284467 $$ 34 | -0.0635143372787522 0.13324773110768848 $$ 35 | -0.06517432908840144 0.11973358846688771 $$ 36 | -0.06329348521511752 0.12822797966893926 $$ 37 | -0.055959360124591025 0.14097961326556566 $$ 38 | -0.06295479840515956 0.10598498835592639 $$ 39 | -0.061546729073327096 0.10205717078811198 $$ 40 | -0.05992478081849803 0.10498444325454095 $$ 41 | -0.0618579743956802 0.11339185766755219 $$ 42 | -0.06293479322624863 0.1275823104277258 $$ 43 | -0.06200416988922219 0.12850771482714526 $$ 44 | -0.058367806326160156 0.10629509745982745 $$ 45 | -0.05875485906224769 0.10483338398637032 $$ 46 | -0.06445464342338017 0.12384283924856791 $$ 47 | -0.06513472671025955 0.1479744929418998 $$ 48 | -0.06751930722231257 0.15794192277270835 $$ 49 | -0.058827956809018665 0.11239131256616681 $$ 50 | -0.05857718517484365 0.12713297814272842 $$ 51 | -0.0642137861808346 0.14042040988161797 $$ 52 | -0.058827956809018665 0.11239131256616681 $$ 53 | -0.0536231455386676 0.1073074786482872 $$ 54 | -0.0617561079220106 0.12289505147101303 $$ 55 | -0.06047440530046122 0.1304112809498146 $$ 56 | -0.05181026479074422 0.08545358266065609 $$ 57 | -0.05441477810681811 0.11345645107845713 $$ 58 | -0.06260371912063663 0.1125758134353086 $$ 59 | -0.06582852971099769 0.11530290342600667 $$ 60 | -0.05746439289271059 0.10781341377662985 $$ 61 | -0.06387418011126283 0.13119310571684845 $$ 62 | -0.056515323200094905 0.11268210594720839 $$ 63 | -0.06450929481456197 0.1353440555995235 $$ 64 | -0.06004261556482133 0.12220768312880462 $$ 65 | }; 66 | \addplot+[ 67 | nodes near coords, 68 | only marks, 69 | point meta=explicit symbolic, 70 | ] 71 | table[ 72 | meta=label, 73 | ] { 74 | x y label 75 | -0.09505238307667932 -0.003950921216340174 $$ 76 | -0.08946051907024073 -0.007573041660762608 $$ 77 | -0.09511827609878432 -0.018583226625726007 $$ 78 | -0.07582838762646103 -0.0258683887513271 $$ 79 | -0.08919493000705372 -0.022258104393979006 $$ 80 | -0.08204724235191896 -0.027269865265168614 $$ 81 | -0.0903180446604962 -0.016056374639978613 $$ 82 | -0.06725844775757917 0.0013644909865145269 $$ 83 | -0.09002368687041061 -0.013680314989937624 $$ 84 | -0.074703202869763 -0.01635413672503065 $$ 85 | -0.0675276657473434 -0.017320462361206265 $$ 86 | -0.08315012024242258 -0.009786205955558484 $$ 87 | -0.078822023781878 -0.015043215587280065 $$ 88 | -0.08681911304298845 -0.02768933453624546 $$ 89 | -0.07684692613927042 0.010190863738827991 $$ 90 | -0.09070353857326205 1.3594618720455024e-4 $$ 91 | -0.08240593434078786 -0.026624196023955125 $$ 92 | -0.07977017421487986 -0.006896220609615304 $$ 93 | -0.07651815372094192 -0.010216222517696393 $$ 94 | -0.08767548778960216 -0.03347237288340778 $$ 95 | -0.08250468316781408 -8.193212261354083e-4 $$ 96 | -0.086073368318032 -0.02687329030400184 $$ 97 | -0.08685352767123136 -0.004906188629680096 $$ 98 | -0.089524853269024 -0.004551312769508217 $$ 99 | -0.09243818695300396 -0.02347430217443999 $$ 100 | -0.0940414572682159 -0.0327736793858996 $$ 101 | -0.08514159413736379 -0.0232475912725288 $$ 102 | -0.07538264659293452 0.012415864120698245 $$ 103 | -0.07480466136375263 -0.01090359085990477 $$ 104 | -0.07409489009036085 -0.004958435021736108 $$ 105 | -0.07905048854985862 -0.00278696982793511 $$ 106 | -0.08084019630046224 -0.029849741507210762 $$ 107 | -0.08729563977818063 -0.009820425420768301 $$ 108 | -0.0924829239525563 -0.013808990879972899 $$ 109 | -0.08423056799956825 -0.0289657692763221 $$ 110 | -0.07991677768810178 -0.00673410311860897 $$ 111 | -0.07662002019461153 -0.01971941632115717 $$ 112 | -0.07898010047005105 -0.030699227340425506 $$ 113 | -0.08668012227411244 -0.020614957706656098 $$ 114 | -0.07918947931873456 -0.009861346657524472 $$ 115 | -0.06764550049366673 -9.722248694261789e-5 $$ 116 | -0.07926413588882725 -0.019957452378368254 $$ 117 | -0.08105948954077519 -0.007175955767821258 $$ 118 | -0.08083863747714053 -0.012195707206570507 $$ 119 | -0.08528778963090575 -0.00813173411293578 $$ 120 | -0.06779054514356696 0.01771892930470396 $$ 121 | -0.07990801414011407 -0.011270302807151055 $$ 122 | -0.08766672424161445 -0.03800857257194987 $$ 123 | }; 124 | \addplot+[ 125 | nodes near coords, 126 | only marks, 127 | point meta=explicit symbolic, 128 | ] 129 | table[ 130 | meta=label, 131 | ] { 132 | x y label 133 | -0.08393661818916259 -0.04154344929486779 $$ 134 | -0.08804616427335603 -0.046706780366002704 $$ 135 | -0.08773376810736117 -0.055341172613389285 $$ 136 | -0.09884521433282735 -0.08556233964151426 $$ 137 | -0.08669292272835737 -0.06440251376763782 $$ 138 | -0.10268605370719039 -0.07010266484458498 $$ 139 | -0.09389797144163735 -0.06824386547818649 $$ 140 | -0.09762899675370301 -0.07772467590351184 $$ 141 | -0.1103440481786629 -0.09003803543797657 $$ 142 | -0.07529669822015317 -0.05717656673810322 $$ 143 | -0.10547031101392385 -0.08011537236343891 $$ 144 | -0.09651579649188997 -0.08209050060102373 $$ 145 | -0.10761329141946953 -0.06582381693611337 $$ 146 | -0.09432705151031379 -0.03968593872448259 $$ 147 | -0.09245975095523658 -0.06272565854687961 $$ 148 | -0.09819821843489714 -0.058941420611450884 $$ 149 | -0.08475857830753342 -0.07010963354859544 $$ 150 | -0.08796356011463553 -0.07105435367087433 $$ 151 | -0.09513868925737519 -0.05513428836611204 $$ 152 | -0.09532471871308698 -0.057943943165341474 $$ 153 | -0.11500321874481956 -0.06977452881383779 $$ 154 | -0.11149800166225958 -0.11661340984753028 $$ 155 | -0.08504491541359312 -0.06476844785064541 $$ 156 | -0.10119226256999406 -0.06306998711599048 $$ 157 | -0.08462835108664517 -0.05849905703046407 $$ 158 | -0.11069512746318584 -0.09662886051735875 $$ 159 | -0.08936268950282833 -0.046393603606825685 $$ 160 | -0.09967241237286253 -0.05933051593683266 $$ 161 | -0.10427046968713315 -0.06050501461629872 $$ 162 | -0.08844082971378954 -0.04093199951886414 $$ 163 | -0.08898440031472846 -0.040395690444826465 $$ 164 | -0.09480991683904666 -0.07554137462263645 $$ 165 | -0.10205929457219903 -0.05476367537013128 $$ 166 | -0.10496271386454956 -0.07552256983155158 $$ 167 | -0.11461460718541029 -0.05065878103974042 $$ 168 | -0.09498488105948726 -0.07748663984630072 $$ 169 | -0.09030322723148426 -0.04548310294975664 $$ 170 | -0.09044492766732365 -0.0729118087120398 $$ 171 | -0.10880281037495082 -0.07231634007115535 $$ 172 | -0.09692683818465714 -0.0645430257447474 $$ 173 | -0.09493766597699944 -0.05648222969188433 $$ 174 | -0.09884209668618396 -0.05025427104023373 $$ 175 | -0.09887086541308257 -0.06731539342349097 $$ 176 | -0.09758760396821148 -0.042145129644049095 $$ 177 | -0.08669292272835737 -0.06440251376763782 $$ 178 | -0.10147900765573367 -0.0726825410866271 $$ 179 | -0.10037226925462489 -0.0671115768314898 $$ 180 | -0.09616085669676186 -0.05244505195689411 $$ 181 | -0.08928082820806965 -0.058487731875164255 $$ 182 | -0.09407022599511451 -0.0498348017691569 $$ 183 | -0.09489939083815128 -0.05621075203370223 $$ 184 | -0.08848827638030532 -0.051621017157090845 $$ 185 | }; 186 | \addplot+[ 187 | nodes near coords, 188 | only marks, 189 | point meta=explicit symbolic, 190 | ] 191 | table[ 192 | meta=label, 193 | ] { 194 | x y label 195 | -0.06097591169212255 0.12251649653540746 C 196 | }; 197 | \addplot+[ 198 | nodes near coords, 199 | only marks, 200 | point meta=explicit symbolic, 201 | ] 202 | table[ 203 | meta=label, 204 | ] { 205 | x y label 206 | -0.08239273499786132 -0.013729627446612947 C 207 | }; 208 | \addplot+[ 209 | nodes near coords, 210 | only marks, 211 | point meta=explicit symbolic, 212 | ] 213 | table[ 214 | meta=label, 215 | ] { 216 | x y label 217 | -0.09617812168198688 -0.06337689296894312 C 218 | }; 219 | \end{axis} 220 | \end{tikzpicture} 221 | 222 | -------------------------------------------------------------------------------- /book/doclicense.sty: -------------------------------------------------------------------------------- 1 | %% See file 'doclicense.dtx' for copyright and license. 2 | \NeedsTeXFormat{LaTeX2e}[1998/12/01] 3 | \ProvidesPackage{doclicense} 4 | [2015/12/13 v1.4.0 Support for putting documents under a license] 5 | %% ^^A nag warned about the center environment and it really messes up spacing. 6 | 7 | %% Dependencies ((( 8 | \RequirePackage{kvoptions} 9 | \RequirePackage{xifthen} 10 | \RequirePackage{etoolbox} %% \ifcsdef 11 | \RequirePackage{xspace} 12 | \RequirePackage{verbatim} 13 | \AtEndPreamble{% 14 | \@ifpackageloaded{csquotes}{}{\RequirePackage{csquotes}} 15 | \@ifpackageloaded{ccicons}{}{\RequirePackage{ccicons}} 16 | %% For \doclicenseIcon 17 | \@ifpackageloaded{graphicx}{}{\RequirePackage{graphicx}} 18 | %% For \doclicenseImage 19 | \@ifpackageloaded{hyperref}{}{\RequirePackage{hyperref}} 20 | \@ifpackageloaded{hyperxmp}{% 21 | %% The following options are only defined when the hyperxmp package was loaded. 22 | \hypersetup{ 23 | pdfcopyright = {\doclicenseLongText}, 24 | pdflicenseurl = {\doclicenseURL}, 25 | } 26 | }{} 27 | } 28 | %% ))) 29 | 30 | %% Parameters ((( 31 | \DeclareStringOption[CC]{type} 32 | \DeclareStringOption[by-sa]{modifier} 33 | \DeclareStringOption{version} 34 | \DeclareStringOption{lang} 35 | \DeclareStringOption{imagemodifier} 36 | \DeclareStringOption[10em]{imagewidth} 37 | %% ))) 38 | 39 | \ProcessLocalKeyvalOptions* 40 | %% Declare variables ((( 41 | \newcommand{\doclicense@baseUrlCC}{https://creativecommons.org} 42 | \newcommand{\doclicense@versionFallback}{} 43 | \newcommand{\doclicense@versionUsed}{} 44 | \newboolean{doclicense@licenseKnown} 45 | \newlength{\doclicense@hsize} 46 | \newcommand{\doclicense@longName}{% 47 | \@nameuse{doclicense@lang@lic@\doclicense@type @\doclicense@modifier% 48 | @\doclicense@versionUsed}% 49 | } 50 | \newcommand{\doclicense@icon}{% 51 | \PackageError{doclicense}{Icon not defined} 52 | {Please check the documentation of doclicense to see what you can do about it.}% 53 | } 54 | \newcommand{\doclicense@modifier@uppercase}{\texorpdfstring{% 55 | \MakeUppercase{\doclicense@modifier}% 56 | }{% 57 | \doclicense@modifier}% 58 | } 59 | %% ))) 60 | 61 | %% User macros ((( 62 | \newcommand{\doclicenseType}{\doclicense@type\xspace} 63 | \newcommand{\doclicenseLongType}{} 64 | \newcommand{\doclicenseModifier}{\doclicense@modifier@uppercase\xspace} 65 | \newcommand{\doclicenseVersion}{\doclicense@versionUsed\xspace} 66 | \newcommand{\doclicenseName}{% 67 | \doclicense@type~\doclicense@modifier@uppercase~% 68 | \doclicense@versionUsed\xspace% 69 | } 70 | \newcommand{\doclicenseNameRef}{\href{\doclicenseURL}{\doclicenseName}\xspace} 71 | \newcommand{\doclicenseLongName}{\doclicenseLongType\space% 72 | \doclicense@longName\xspace} 73 | \newcommand{\doclicenseLongNameRef}{\href{\doclicenseURL}{\doclicenseLongName}} 74 | \newcommand{\doclicenseText}{% 75 | \doclicense@lang@thisDoc\space 76 | \href{\doclicenseURL}{\enquote{\doclicenseName{}}} 77 | \doclicense@lang@word@license.\xspace% 78 | } 79 | \newcommand{\doclicenseLongText}{% 80 | \doclicense@lang@thisDoc\space 81 | \href{\doclicenseURL}{\doclicenseLongType\space\enquote{\doclicense@longName}} 82 | \doclicense@lang@word@license.\xspace% 83 | } 84 | \newcommand{\doclicenseIcon}{\doclicense@icon\xspace} 85 | \newcommand{\doclicenseTypeIcon}{\doclicenseType} 86 | \newcommand{\doclicenseImageFileName}{% 87 | doclicense-\doclicense@type-\doclicense@modifier\doclicense@imagemodifier} 88 | \newcommand{\doclicenseImage}[1][]{% 89 | \setkeys{doclicense}{#1} 90 | \href{\doclicenseURL}{% 91 | \includegraphics[ 92 | width=\doclicense@imagewidth% 93 | ]{\doclicenseImageFileName}% 94 | } 95 | } 96 | \newcommand{\doclicensePlainFullTextFileName}{% 97 | doclicense-\doclicense@type-\doclicense@modifier% 98 | -\doclicense@versionUsed-plaintext 99 | } 100 | \newcommand{\doclicensePlainFullText}{% 101 | \verbatiminput{\doclicensePlainFullTextFileName} 102 | } 103 | \newcommand{\doclicenseFullTextFileName}{% 104 | doclicense-\doclicense@type-\doclicense@modifier-\doclicense@versionUsed-latex} 105 | \newcommand{\doclicenseFullText}{\input{\doclicenseFullTextFileName}} 106 | 107 | \newcommand{\doclicenseLicense}{\doclicenseThis} %% legacy support 108 | \newcommand{\doclicenseThis}{% 109 | \setlength{\doclicense@hsize}{\textwidth-\doclicense@imagewidth-2em}% 110 | \ifthenelse{\isnamedefined{iflandscape}}{% 111 | \iflandscape{% 112 | % \setlength{\doclicense@hsize}{\doclicense@hsize-10em}% 113 | }{}% 114 | }{}% 115 | % {% 116 | % \centering% 117 | \begin{center} 118 | \begin{minipage}{\doclicense@hsize} 119 | \doclicenseLongText% 120 | \end{minipage} 121 | \hfill 122 | \begin{minipage}{\doclicense@imagewidth} 123 | \doclicenseImage% 124 | \end{minipage} 125 | \end{center} 126 | % } 127 | } 128 | %% ))) 129 | 130 | %% Language support ((( 131 | \ifthenelse{\equal{\doclicense@lang}{}}{% 132 | \renewcommand{\doclicense@lang}{\languagename}}{} 133 | \IfFileExists{doclicense-\doclicense@lang.ldf}{% 134 | \input{doclicense-\doclicense@lang.ldf} 135 | }{% 136 | \PackageWarning{doclicense}{% 137 | No language definition for \doclicense@lang found. 138 | Please add one and submit a patch. Using English as fallback.} 139 | \renewcommand{\doclicense@lang}{english} 140 | \input{doclicense-\doclicense@lang.ldf} 141 | } 142 | \ifthenelse{\equal{\doclicense@imagemodifier}{-us}}{% 143 | \@namedef{doclicense@imagemodifier}{} 144 | }{} 145 | 146 | %% ))) 147 | 148 | %% Set license ((( 149 | \newcommand{\doclicense@setVersion}[1][]{% 150 | \ifthenelse{\equal{#1}{}}{}{% 151 | \renewcommand{\doclicense@versionFallback}{#1} 152 | } 153 | \ifthenelse{\equal{\doclicense@version}{}}{% 154 | \renewcommand{\doclicense@versionUsed}{\doclicense@versionFallback} 155 | }{% 156 | \renewcommand{\doclicense@versionUsed}{\doclicense@version} 157 | } 158 | } 159 | \newcommand{\doclicense@set}{% 160 | %% CC ((( 161 | \ifthenelse{\equal{\doclicense@type}{CC}}{% 162 | \renewcommand{\doclicenseLongType}{Creative Commons\xspace} 163 | \renewcommand{\doclicenseTypeIcon}{\ccLogo\xspace} 164 | 165 | \doclicense@setVersion[3.0] 166 | 167 | %% Allow to predefine the following macros in ldf files. 168 | \ifcsdef{doclicense@UrlLangPart}{}{% 169 | \ifthenelse{\equal{\doclicense@lang@lic@CC@code}{}}{% 170 | \edef\doclicense@UrlLangPart{} 171 | }{% 172 | \edef\doclicense@UrlLangPart{/deed.\doclicense@lang@lic@CC@code} 173 | } 174 | } 175 | \ifcsdef{doclicenseURL}{}{% 176 | \edef\doclicenseURL{% 177 | \doclicense@baseUrlCC/% 178 | licenses/% 179 | \doclicense@modifier/% 180 | \doclicense@versionUsed\doclicense@UrlLangPart% 181 | } 182 | } 183 | \ifthenelse{\equal{\doclicense@modifier}{by}}{% 184 | \renewcommand{\doclicense@icon}{\ccby} 185 | \renewcommand{\doclicense@imagemodifier}{} 186 | }{} 187 | \ifthenelse{\equal{\doclicense@modifier}{by-sa}}{% 188 | \renewcommand{\doclicense@icon}{\ccbysa} 189 | \renewcommand{\doclicense@imagemodifier}{} 190 | }{} 191 | \ifthenelse{\equal{\doclicense@modifier}{by-nd}}{% 192 | \renewcommand{\doclicense@icon}{\ccbynd} 193 | \renewcommand{\doclicense@imagemodifier}{} 194 | }{} 195 | \ifthenelse{\equal{\doclicense@modifier}{by-nc}}{% 196 | \renewcommand{\doclicense@icon}{\ccbync} 197 | \ifthenelse{\equal{\doclicense@imagemodifier}{-eu}}{% 198 | \renewcommand{\doclicense@icon}{\ccbynceu} 199 | }{} 200 | \ifthenelse{\equal{\doclicense@imagemodifier}{-jp}}{% 201 | \renewcommand{\doclicense@icon}{\ccbyncjp} 202 | }{} 203 | \renewcommand{\doclicense@imagemodifier}{} 204 | }{} 205 | \ifthenelse{\equal{\doclicense@modifier}{by-nc-sa}}{ 206 | \renewcommand{\doclicense@icon}{\ccbyncsa} 207 | \ifthenelse{\equal{\doclicense@imagemodifier}{-eu}}{% 208 | \renewcommand{\doclicense@icon}{\ccbyncsaeu} 209 | }{} 210 | \ifthenelse{\equal{\doclicense@imagemodifier}{-jp}}{% 211 | \renewcommand{\doclicense@icon}{\ccbyncsajp} 212 | }{} 213 | }{} 214 | \ifthenelse{\equal{\doclicense@modifier}{by-nc-nd}}{ 215 | \renewcommand{\doclicense@icon}{\ccbyncnd} 216 | \ifthenelse{\equal{\doclicense@imagemodifier}{-eu}}{% 217 | \renewcommand{\doclicense@icon}{\ccbyncndeu} 218 | }{} 219 | \ifthenelse{\equal{\doclicense@imagemodifier}{-jp}}{% 220 | \renewcommand{\doclicense@icon}{\ccbyncndjp} 221 | }{} 222 | }{} 223 | \ifthenelse{\equal{\doclicense@modifier}{zero}}{% 224 | \renewcommand{\doclicense@icon}{\cczero} 225 | \renewcommand{\doclicense@imagemodifier}{} 226 | \doclicense@setVersion[1.0] 227 | \edef\doclicenseURL{% 228 | \doclicense@baseUrlCC/% 229 | publicdomain/% 230 | \doclicense@modifier/% 231 | \doclicense@versionUsed\doclicense@UrlLangPart} 232 | }{} 233 | \ifthenelse{\equal{\doclicense@modifier}{pd}}{ 234 | \renewcommand{\doclicense@icon}{\ccpd} 235 | \renewcommand{\doclicense@imagemodifier}{} 236 | \doclicense@setVersion[1.0] 237 | \edef\doclicenseURL{% 238 | \doclicense@baseUrlCC/% 239 | licenses/publicdomain/% 240 | \doclicense@versionUsed\doclicense@UrlLangPart} 241 | }{} 242 | 243 | \ifcsdef{doclicense@lang@lic@\doclicense@type% 244 | @\doclicense@modifier @\doclicense@versionUsed}{}{% 245 | 246 | \PackageError{doclicense}{License long name not defined}% 247 | {% 248 | Please check the documentation of doclicense 249 | to see what you can do about it.% 250 | }% 251 | } 252 | 253 | \setboolean{doclicense@licenseKnown}{true} 254 | }{}%% ))) 255 | \ifthenelse{\not\boolean{doclicense@licenseKnown}}{% 256 | \PackageError{doclicense}{License unknown}% 257 | {% 258 | Please check the documentation of doclicense 259 | to see what you can do about it.% 260 | }% 261 | }{}% 262 | } 263 | %% ))) 264 | 265 | \doclicense@set% 266 | \endinput 267 | %% 268 | %% End of file `doclicense.sty'. 269 | -------------------------------------------------------------------------------- /libraries/ice-9/nice-9.scm: -------------------------------------------------------------------------------- 1 | (define-module (ice-9 nice-9) 2 | #:use-module (ice-9 match) 3 | #:use-module (srfi srfi-1) 4 | #:re-export (match) 5 | #:export ((and-let*/match . and-let*) 6 | primitive-lambda) 7 | #:replace ((cdefine . define) 8 | (mlambda . lambda) 9 | (named-match-let-values . let) 10 | (match-let*-values . let*) 11 | (letrec-syntax/rules . letrec-syntax) 12 | (let-syntax/rules . let-syntax) 13 | (define-syntax/rules . define-syntax))) 14 | 15 | ;; This module extends the syntax of a few core forms so that their 16 | ;; "abuses" behave meaningfully -- in particular, it allows to 17 | ;; destructure bindings in "lambda" and "let" forms and use curried definitions. 18 | ;; It also provides pattern-matching version of "and-let*". 19 | 20 | (define-syntax define-syntax/rules 21 | (syntax-rules () 22 | ((_ (name . pattern) template) 23 | (define-syntax name 24 | (syntax-rules () 25 | ((name . pattern) template)))) 26 | 27 | ((_ name transformer) 28 | (define-syntax name transformer)) 29 | 30 | ((_ name keywords (pattern template) ...) 31 | (define-syntax name 32 | (syntax-rules keywords 33 | (pattern 34 | template) 35 | ...))) 36 | )) 37 | 38 | (define-syntax let*-syntax/rules 39 | (syntax-rules () 40 | ((_ let*-syntax () processed-bindings body . *) 41 | (let*-syntax processed-bindings body . *)) 42 | 43 | ((_ let*-syntax (((name pattern ...) template) bindings ...) 44 | (processed ...) body . *) 45 | (let*-syntax/rules 46 | let*-syntax 47 | (bindings ...) 48 | (processed ... (name (syntax-rules () 49 | ((_ pattern ...) 50 | template)))) 51 | body . *)) 52 | 53 | ((_ let*-syntax ((name value) bindings ...) (processed ...) body . *) 54 | (let*-syntax/rules 55 | let*-syntax 56 | (bindings ...) 57 | (processed ... (name value)) 58 | body . *)) 59 | 60 | ((_ let*-syntax ((name keywords (pattern template) ...) bindings ...) 61 | (processed ...) 62 | body . *) 63 | (let*-syntax/rules 64 | let*-syntax 65 | (bindings ...) 66 | (processed ... (name (syntax-rules keywords 67 | (pattern 68 | template) 69 | ...))) 70 | body . *)) 71 | )) 72 | 73 | (define-syntax let-syntax/rules 74 | (syntax-rules () 75 | ((_ (bindings ...) body . *) 76 | (let*-syntax/rules let-syntax (bindings ...) () body . *)))) 77 | 78 | (define-syntax letrec-syntax/rules 79 | (syntax-rules () 80 | ((_ (bindings ...) body . *) 81 | (let*-syntax/rules letrec-syntax (bindings ...) () body . *)))) 82 | 83 | (define-syntax mlambda 84 | (lambda (stx) 85 | (syntax-case stx () 86 | 87 | ((_ (first-arg ... last-arg . rest-args) . body) 88 | (and (every identifier? #'(first-arg ... last-arg)) 89 | (or (identifier? #'rest-args) (null? #'rest-args))) 90 | #'(lambda (first-arg ... last-arg . rest-args) . body)) 91 | 92 | ((_ arg body ...) 93 | (or (identifier? #'arg) (null? #'arg)) 94 | #'(lambda arg body ...)) 95 | 96 | ((_ args body ...) 97 | #'(match-lambda* (args body ...) 98 | (_ (error 'mlambda (current-source-location) '(args body ...))))) 99 | ))) 100 | 101 | (define-syntax primitive-lambda 102 | (syntax-rules () 103 | ((_ . whatever) 104 | (lambda . whatever)))) 105 | 106 | (define-syntax cdefine 107 | (syntax-rules () 108 | ((_ ((head . tail) . args) body ...) 109 | (cdefine (head . tail) 110 | (mlambda args body ...))) 111 | ((_ (name . args) body ...) 112 | (define name (mlambda args body ...))) 113 | ((_ . rest) 114 | (define . rest)) 115 | )) 116 | 117 | 118 | (define-syntax list<-values 119 | (syntax-rules () 120 | ((_ call) 121 | (call-with-values (lambda () call) list)))) 122 | 123 | (define-syntax match-let/error 124 | (syntax-rules () 125 | ((_ ((structure expression) ...) 126 | body + ...) 127 | ((match-lambda* ((structure ...) body + ...) 128 | (_ (error 'match-let/error (current-source-location) 129 | '((structure expression) ...)))) 130 | expression ...)))) 131 | 132 | (define-syntax named-match-let-values 133 | (lambda (stx) 134 | (syntax-case stx () 135 | ((_ ((identifier expression) ...) ;; optimization: plain "let" form 136 | body + ...) 137 | (every identifier? #'(identifier ...)) 138 | #'(let ((identifier expression) ...) 139 | body + ...)) 140 | 141 | ((_ name ((identifier expression) ...) ;; optimization: regular named-let 142 | body + ...) 143 | (and (identifier? #'name) (every identifier? #'(identifier ...))) 144 | #'(let name ((identifier expression) ...) 145 | body + ...)) 146 | 147 | ((_ name ((structure expression) ...) 148 | body + ...) 149 | (identifier? #'name) 150 | #'(letrec ((name (mlambda (structure ...) body + ...))) 151 | (name expression ...))) 152 | 153 | ((_ ((structure expression) ...) 154 | body + ...) 155 | #'(match-let/error ((structure expression) ...) 156 | body + ...)) 157 | 158 | ((_ ((identifier identifiers ... expression)) body + ...) 159 | (every identifier? #'(identifier identifiers ...)) 160 | #'(call-with-values (lambda () expression) 161 | (lambda (identifier identifiers ... . _) 162 | body + ...))) 163 | 164 | ((_ ((structure structures ... expression)) body + ...) 165 | #'(call-with-values (lambda () expression) 166 | (match-lambda* 167 | ((structure structures ... . _) body + ...) 168 | (_ (error 'named-match-let-values 169 | (current-source-location) 170 | 'name))))) 171 | 172 | ((_ name ((identifier identifiers ... expression) body + ...)) 173 | (and (identifier? #'name) 174 | (every identifier? #'(identifier identifiers ...))) 175 | #'(let ((name (lambda (identifier identifiers ...) body + ...))) 176 | (call-with-values (lambda () expression) name))) 177 | 178 | ((_ name ((structure structures ... expression) body + ...)) 179 | (identifier? #'name) 180 | #'(let ((name (match-lambda* ((structure structures ...) body + ...) 181 | (_ (error 'named-match-let-values 182 | (current-source-location) 183 | 'name))))) 184 | (call-with-values (lambda () expression) name))) 185 | 186 | ;; it should generally be discouraged to use the plain let 187 | ;; with multiple values, because there's no natural way to implement 188 | ;; that when there's more than one (multiple-value) binding, 189 | ;; but it could be added for completeness 190 | #| 191 | ((_ ((structure structures ... expression) ...) 192 | body + ...) 193 | #'(match-let/error (((structure structures ... . _) 194 | (list<-values expression)) ...) 195 | body + ...)) 196 | 197 | ((_ name ((structure structures ... expression) ...) 198 | body + ...) 199 | (identifier? #'name) 200 | #'(letrec ((loop 201 | (match-lambda* 202 | (((structure structures ... . _) ...) 203 | (let-syntax ((name (syntax-rules () 204 | ((_ args (... ...)) 205 | (loop (list<-values args) 206 | (... ...)))))) 207 | body + ...)) 208 | (_ (error 'named-match-let-values 209 | (current-source-location) 210 | 'name))))) 211 | (loop (list<-values expression) ...))) 212 | |# 213 | ))) 214 | 215 | (define-syntax match-let*-values 216 | (lambda (stx) 217 | (syntax-case stx () 218 | 219 | ((_ ((identifier expression) ...) ;; optimization: regular let* 220 | body + ...) 221 | (every identifier? #'(identifier ...)) 222 | #'(let* ((identifier expression) ...) 223 | body + ...)) 224 | 225 | ((_ ((identifier expression) remaining-bindings ...) 226 | body + ...) 227 | (identifier? #'identifier) 228 | #'(let ((identifier expression)) 229 | (match-let*-values (remaining-bindings ...) body + ...))) 230 | 231 | ((_ ((structure expression) remaining-bindings ...) 232 | body + ...) 233 | #'(match-let/error ((structure expression)) 234 | (match-let*-values (remaining-bindings ...) 235 | body + ...))) 236 | 237 | ((_ ((identifier identifiers ... expression) remaining-bindings ...) 238 | body + ...) 239 | (every identifier? #'(identifier identifiers ...)) 240 | #'(call-with-values (lambda () expression) 241 | (lambda (identifier identifiers ... . _) 242 | (match-let*-values (remaining-bindings ...) 243 | body + ...)))) 244 | 245 | ((_ ((structure structures ... expression) remaining-bindings ...) 246 | body + ...) 247 | #'(call-with-values (lambda () expression) 248 | (match-lambda* ((structure structures ... . _) 249 | (match-let*-values (remaining-bindings ...) 250 | body + ...)) 251 | (_ (error 'match-let*-values (current-source-location)))))) 252 | ))) 253 | 254 | (define-syntax and-let*/match 255 | (lambda (stx) 256 | (syntax-case stx () 257 | 258 | ((_) 259 | #'#t) 260 | 261 | ((_ ()) 262 | #'#t) 263 | 264 | ((_ () body ...) 265 | #'(let () body ...)) 266 | 267 | ((_ ((value binding) rest ...) body ...) 268 | (identifier? #'value) 269 | #'(let ((value binding)) 270 | (and value 271 | (and-let*/match (rest ...) 272 | body ...)))) 273 | 274 | ((_ ((value binding) rest ...) body ...) 275 | #'(match binding 276 | (value 277 | (and-let*/match (rest ...) 278 | body ...)) 279 | (_ #f))) 280 | 281 | ((_ ((condition) rest ...) 282 | body ...) 283 | #'(and condition 284 | (and-let*/match (rest ...) 285 | body ...))) 286 | 287 | ((_ ((values ... expression) rest ...) body ...) 288 | (every identifier? #'(values ...)) 289 | #'(call-with-values (lambda () expression) 290 | (match-lambda* 291 | ((values ... . _) 292 | (and values ... 293 | (and-let*/match (rest ...) 294 | body ...))) 295 | (_ #f)))) 296 | 297 | ;; this behavior can be questionable, but to increase coherence, 298 | ;; every identifier bound with multiple values at the top level 299 | ;; must be non-false, so while 300 | ;; 301 | ;; (and-let* ((a b #f (values 1 2 #f))) #t) 302 | ;; 303 | ;; will succeed, 304 | ;; 305 | ;; (and-let* ((a b #f (values 1 #f #f))) #t) 306 | ;; 307 | ;; will fail. 308 | ;; On the other hand, arguments bound as a result to pattern-matching 309 | ;; can have any value, so 310 | ;; 311 | ;; (and-let* (((a) (b) (values '(#f) '(#f)))) #t) 312 | ;; 313 | ;; will succeed. 314 | ((_ ((values ... expression) rest ...) body ...) 315 | (with-syntax (((identifiers ...) (filter identifier? #'(values ...)))) 316 | #'(call-with-values (lambda () expression) 317 | (lambda args 318 | (match args 319 | ((values ... . _) 320 | (and identifiers ... 321 | (and-let*/match (rest ...) 322 | body ...))) 323 | (_ #f)))))) 324 | ))) 325 | -------------------------------------------------------------------------------- /book/chapters/0.tex: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%% 2 | % Preface % 3 | %%%%%%%%%%% 4 | \chapter*{Preface} 5 | 6 | \begin{chapquote}{Anyone who hates all the stupid quotes 7 | at the beginning of each chapter} 8 | ``I hate all those stupid quotes at the beginning of each chapter.'' 9 | \end{chapquote} 10 | 11 | 12 | Behind every text, however technical, there is a personal story of 13 | its author\footnote{Even if the text was generated by a machine, and 14 | the machine was designed by a computer program, and so on, this causal 15 | chain eventually has its author.} and the author's motivations. 16 | 17 | Having worked for a couple of months in an engineering company that 18 | manufactured electronic equipment, I decided that perhaps it was the 19 | best time to finish my education. So, I enrolled at the department of 20 | Computer Science at the University of Gdańsk. Among other topics, 21 | one lab was devoted to data processing heuristics jointly named 22 | ``computational intelligence''. 23 | 24 | Our first meeting was spent getting acquainted with the 25 | programming language R that we were supposed to use throughout 26 | the semester for the assignments. But I balked. 27 | 28 | On the one hand, I've used many programming languages throughout my career: 29 | JavaScript, Python, PHP, Perl, Bash, Matlab, SQL, C, C++, Assembly, Haskell, 30 | Erlang, Prolog, Pascal, BASIC, VisualBasic, MiniKanren, and a few others. 31 | Some of those languages were really mind-expanding in their own unique ways. 32 | 33 | On the other hand, being a rather seasoned Schemer, I knew that 34 | most of these languages were only inferior incarnations of Lisp, 35 | and I could find little value in learning a new syntactical disguise 36 | for those well-established concepts. 37 | 38 | I was very soon to find out that my skepticism was right, and that 39 | learning R would require internalizing a lot of unfortunate 40 | idiosyncrasies that the authors of the language had chosen for their 41 | own reasons, and that I would be constantly stumbling over 42 | those incomprehensible limitations and discrepancies between common 43 | practices and the language developers' decisions. And for that 44 | I didn't want to waste my time. 45 | 46 | Bjarne Stroustrup said that there are only two kinds of languages: 47 | the ones people complain about and the ones nobody uses\footnote{He 48 | probably said that, because he was himself a creator of a popular 49 | language that everybody complains about.}. The advocates of R sometimes 50 | admit that perhaps the language isn't perfect, but it contains 51 | a lot of convenient libraries to make the whole thing worthwhile. 52 | 53 | Being a nobody, I was in a rather comfortable position, free 54 | to decide if I want to complain on the language that I use or not. 55 | 56 | I asked my TA whether he would allow me to choose 57 | another language for doing the assignments, and he agreed. 58 | 59 | My language of choice was of course Scheme, or -- more precisely -- 60 | Guile Scheme. I chose Guile because it has a wonderful trait: 61 | rather than helplessly complain about features I don't like, I can 62 | replace them with whatever I find more suitable. If a feature is 63 | missing from the language, I can add it, rather than swear and curse 64 | its developers. 65 | 66 | The title of this pamphlet may suggest that it is written against 67 | the R programming language, but it is actually written against the 68 | majority of programming languages in use today\footnote{ 69 | However, the case of the R programming language is particularly 70 | interesting, because initially it was just a harmless implementation 71 | of Scheme; but then as a result of the irresponsible experiments 72 | of mad scientists it mutated into a monster\cite{Ihaka2010}.}. 73 | The ultimate goal of this text is to violently eliminate them all. 74 | 75 | Recognizing that the aforementioned goal is rather quixotic, I will 76 | be satisfied instead if anyone finds any value in 77 | this pamphlet, whether it be education, entertainment or personal 78 | hygiene\footnote{Concerns the printed copies}. 79 | 80 | \section*{Structure of this pamphlet} 81 | This pamphlet assumes no prior knowledge of programming. 82 | If you think you already possess programming knowledge, 83 | you'll probably see much that is new here. 84 | 85 | Throughout the subsequent chapters, a large subset of the Scheme 86 | programming language will be laid out, later chapters building 87 | upon the earlier. 88 | The first chapter introduces all the elementary notions needed 89 | for programming in Scheme. The next two chapters show how to use that 90 | knowledge in practice. The fourth chapter introduces a few 91 | more features of the language that are used in the fifth 92 | chapter. 93 | 94 | Each chapter will introduce new definitions to be used 95 | in later applications. For example, the third chapter presents 96 | the notion of \texttt{equi\-valence\--classes} used 97 | extensively throughout the fifth chapter. 98 | 99 | The vision of programming presented here departs significantly 100 | from the mainstream view, where a program is perceived 101 | as a sequence of steps that lead us to a desired goal. 102 | 103 | On the contrary, I intended to explain programs as 104 | intellectual constructs of increasing complexity; 105 | hence, reading the chapters in their proper sequence 106 | is strongly recommended. 107 | 108 | \section*{How to read this pamphlet} 109 | 110 | The most essential part of this pamphlet are the definitions. 111 | Everything else is just scaffolding whose purpose is to 112 | facilitate their comprehension. The ultimate goal is to 113 | make those definitions dance in the reader's head; hence 114 | each definition should be studied with care. If there are 115 | no examples given, it is up to the reader to come up 116 | with proper examples, because if a definition is the 117 | dance, then examples are the dancers. 118 | 119 | The whole point of a definition is to create or express 120 | a notion that can be further used to think about phenomena 121 | in the world. Internalizing a definition is not always 122 | a pleasant task, because it requires an intellectual 123 | effort of focusing and remembering. 124 | 125 | Reading programs isn't like reading novels. Because 126 | of their familiar narrative specificity, we typically absorb 127 | stories almost effortlessly. However, comprehending logical abstractions 128 | requires a very different approach. Well written programs 129 | are a bit like mathematical textbooks. The latter usually 130 | consist mainly of definitions, examples, theorems and proofs 131 | (and exercises). 132 | 133 | The role of theorems is usually diminished in the realm 134 | of computer programs: essential are the constructions, 135 | the definitions. Examples (sometimes called \textit{unit 136 | tests} by software folks) serve mainly as a means 137 | of ensuring a program behaves as expected, which gains 138 | importance as the program is subjected to changes. 139 | Theorems manifest themselves in the weak form of \textit{assertions} 140 | and \textit{type signatures}, while proofs are usually performed 141 | by specific tools such as type checkers or model checkers. 142 | Furthermore, false assertions can typically be refuted 143 | during the execution of a program. 144 | 145 | In the case of math textbooks, exercises and examples 146 | are a way of facilitating comprehension. It is usually 147 | much easier to understand an abstract definition if 148 | we consider examples that are concrete instances of the abstract 149 | definition. Similarly, exercises are like examples but where some or 150 | all of the reasoning is left out; as such, they can be thought of as 151 | ``partial examples'' where we are challenged to come up with the 152 | reasoning for ourselves. 153 | 154 | Reading a math textbook without doing the exercises is also 155 | possible, but it is up to the reader to come up 156 | with the deeper and broader understanding\footnote{ 157 | Programmers usually read computer programs in order 158 | to change them, which is an ultimate exercise 159 | in the comprehension of complex systems. On the 160 | other hand, programs are often written with the 161 | purpose of ``doing their job'', rather than 162 | being comprehended and modified. 163 | 164 | From my experience, this approach dominates, 165 | not only in industry (which is understandable), 166 | but also in education (which is harmful to industry). 167 | }. 168 | 169 | \section*{Who should read this pamphlet} 170 | 171 | The title of this pamphlet may be misleading since readers 172 | might think we are only concerned with computational methods. 173 | Although there are certainly computational methods 174 | involved, this work is really about thinking 175 | and communicating thoughts. 176 | 177 | While it is difficult to imagine anyone who would not benefit 178 | from the knowledge presented here, there are some groups who 179 | are particularly encouraged to do so. For instance, this text 180 | may be of interest to philosophers and linguists, as it presents 181 | a linguistic perspective on communicating thoughts 182 | in a precise manner. 183 | 184 | It may also be interesting to evolutionary biologists, 185 | because it contains a quote from Richard Dawkins 186 | and stuff like that. 187 | 188 | It should be of particular interest to computer 189 | scientists and programming language designers, to 190 | convince them to \textit{stop designing new languages immediately!}, 191 | because -- as the history teaches us -- they often enough 192 | succeed, thereby forcing generations of programmers to 193 | suffer due to the ignorance of their creators. 194 | 195 | However, as previously indicated, this book is about programming 196 | \textit{and} clear thinking in equal measure, and 197 | it is difficult to imagine someone who could not 198 | benefit from this combination. 199 | 200 | And so perhaps the shortest answer to the question posited 201 | in the title of this section is: \textit{you}. 202 | 203 | \section*{Acknowledgements} 204 | Most of all, I would like to thank Grzegorz Madejski, the teaching 205 | assistant who allowed me to go my own way, 206 | and encouraged me to devote time to this project. 207 | His classes were the source of all the examples presented in this text. 208 | 209 | I am also truly grateful to my family and my girlfriend, 210 | as they all encouraged me to go back to university. I certainly 211 | couldn't have done it without their support. 212 | 213 | I deeply appreciate the interest, support, feedback and 214 | encouragement of my friends who allowed me to bother them with 215 | the early versions of this text, and with whom I have had many 216 | valuable and inspiring conversations, including Ścisław Dercz, 217 | Hubert Melchert, Michał Janke, Marcin Jędruch, Jan Makulec 218 | and Aleksander Mohuczy-Dominiak. 219 | 220 | I owe thanks to Piotr Fusik, David Hashe, Robert Różański, Martin Clausen, 221 | Dave Creelman, Wojciech Gac, Noah Doersing and stephnem for pointing 222 | out some errors and suggesting improvements. 223 | 224 | Last but not least, I owe thanks to Lawrence Bottorff and Rick Hanson, 225 | who volunteered as the editors of this booklet. 226 | 227 | \section*{Reporting bugs} 228 | 229 | I realize that the quality of this text may be questionable. 230 | After all, this is a pamphlet. However, if you find any parts 231 | of the text obscure or difficult to understand, or if you 232 | find any mistakes in the explanations presented here, or 233 | simply want to talk about how miserable the world is, feel 234 | free to write an e-mail to 235 | \href{mailto:godek.maciek+pamphlet@gmail.com}{godek.maciek+pamphlet@gmail.com}. 236 | 237 | Also make sure that you are reading the latest version 238 | of this pamphlet, always available from 239 | 240 | \url{https://panicz.github.io/pamphlet} 241 | 242 | \noindent as many of the bugs may already have been fixed. 243 | 244 | Finally, if you would like to become a co-author and add your 245 | own chapters or examples, it will be my pleasure to merge your 246 | pull-requests. 247 | -------------------------------------------------------------------------------- /libraries/pamphlet.scm: -------------------------------------------------------------------------------- 1 | (define-module (pamphlet) 2 | #:use-module (ice-9 nice-9) 3 | #:use-module (srfi srfi-1) 4 | #:use-module (system base compile) 5 | #:export (assert 6 | e.g. 7 | publish 8 | argmin 9 | argmax 10 | min+max 11 | argmin+argmax 12 | skip 13 | alter 14 | generate-list 15 | list<-values 16 | measured 17 | now 18 | with-default 19 | without-default 20 | specify 21 | rest 22 | equivalence-classes 23 | subsets 24 | hash-map->alist 25 | number->symbol 26 | ->string 27 | sum 28 | product 29 | fold-left 30 | fold-right 31 | scan 32 | prefix-sum 33 | extend-left 34 | extend-right 35 | in? 36 | indexed 37 | multicombinations 38 | ) 39 | #:re-export (every 40 | any 41 | filter-map 42 | append-map 43 | concatenate 44 | reduce 45 | take 46 | drop 47 | partition 48 | split-at 49 | iota 50 | count 51 | first 52 | ) 53 | #:replace ((compose/values . compose))) 54 | 55 | (define* (expand-form e #:key (opts '())) 56 | (let ((exp env (decompile 57 | (compile e #:from 'scheme 58 | #:to 'tree-il 59 | #:env (current-module)) 60 | #:from 'tree-idl 61 | #:to 'scheme 62 | #:opts opts))) 63 | exp)) 64 | 65 | (define-syntax (expand expression) 66 | (expand-form 'expression)) 67 | 68 | (define-syntax (assert proposition) 69 | (begin)) 70 | 71 | (define-syntax (e.g. . _) 72 | (begin)) 73 | 74 | #| 75 | (define-syntax e.g. (===> ~~~>) 76 | ((_ example) 77 | (or example 78 | (error 'example))) 79 | ((_ example ===> value) 80 | (let ((result example)) 81 | (if (equal? result 'value) 82 | result 83 | (error '(example ===> value))))) 84 | 85 | ((_ example ===> values ...) 86 | (call-with-values (lambda () example) 87 | (lambda results (equal? results '(values ...))))) 88 | 89 | ((_ example ~~~> value) ;; the ~~~> reads as "may nondeterministically 90 | example)) ;; evaluate to" 91 | |# 92 | 93 | ;; The `publish' macro is used to provide means to separate public 94 | ;; definitions from private ones (such that are visible only from within 95 | ;; the public procedures and from within themselves). 96 | ;; For example, the form 97 | ;; 98 | ;; (publish 99 | ;; (define (f x) (+ a x)) 100 | ;; (define (g y) (* a y)) 101 | ;; where 102 | ;; (define a 5)) 103 | ;; 104 | ;; is equivalent to 105 | ;; 106 | ;; (begin 107 | ;; (define f (and (defined? 'f) f)) 108 | ;; (define g (and (defined? 'g) g)) 109 | ;; (let () 110 | ;; (define a 5) 111 | ;; (set! f (let () (define (f x) (+ a x)) f)) 112 | ;; (set! g (let () (define (g x) (* a y)) g)))) 113 | 114 | (define-syntax (publish definitions ...) 115 | (publisher (definitions ...) ())) 116 | 117 | (define-syntax publisher (where) 118 | ((_ (where private ...) (public ...)) 119 | (private+public (private ...) (public ...))) 120 | ((_ (new defs ...) (approved ...)) 121 | (publisher (defs ...) 122 | (approved ... new)))) 123 | 124 | (define-syntax private+public 125 | (lambda (stx) 126 | (define (sorted-private/interfaces+names+bodies private specs) 127 | ;; both sorting and name extraction takes place in the 128 | ;; same function called from with-syntax, because that 129 | ;; way we can tell the macro processor that the bindings in 130 | ;; the code belong to the same scope 131 | (define (interface-name interface) 132 | (match interface 133 | ((head . tail) 134 | (interface-name head)) 135 | ((? symbol? name) 136 | name))) 137 | `(,(datum->syntax ;; this reordering is done, so that the (e.g. ...) 138 | stx ;; forms can be freely mixed with definitions 139 | (let ((definitions non-definitions 140 | (partition (lambda (prototype) 141 | (match prototype 142 | (((? symbol? x) . _) 143 | (string-contains (symbol->string x) 144 | "def")) 145 | (_ #f))) 146 | (syntax->datum private)))) 147 | `(,@definitions ,@non-definitions))) 148 | ,(map (lambda (spec) 149 | (syntax-case spec () 150 | ((interface . body) 151 | (datum->syntax stx `(,(syntax->datum #'interface) 152 | ,(interface-name 153 | (syntax->datum #'interface)) 154 | ,(syntax->datum #'body)))))) 155 | specs))) 156 | (syntax-case stx () 157 | ((_ (private ...) ((define-variant . spec) ...)) 158 | (with-syntax ((((private ...) ((interface name body) ...)) 159 | (sorted-private/interfaces+names+bodies 160 | #'(private ...) #'(spec ...)))) 161 | #'(begin 162 | (define name (and (defined? 'name) name)) 163 | ... 164 | (let () 165 | private ... 166 | (set! name 167 | (let () 168 | (define-variant interface . body) 169 | name)) 170 | ...))))))) 171 | 172 | (define (hash-map->alist hash) 173 | (hash-map->list cons hash)) 174 | 175 | (define (number->symbol n) 176 | (let* ((n (if (exact? n) (exact->inexact n) n)) 177 | (s (number->string n))) 178 | (string->symbol 179 | (string-take s (min (string-length s) 4))))) 180 | 181 | (define rest cdr) 182 | 183 | (publish 184 | (define (argmin property element . elements) 185 | (apply argopt < property element elements)) 186 | (define (argmax property element . elements) 187 | (apply argopt > property element elements)) 188 | where 189 | (define (argopt < property element . elements) 190 | (let next-trial ((champion element) 191 | (mastery (property element)) 192 | (opponents elements)) 193 | (if (null? opponents) 194 | (values champion mastery) 195 | (let* ((rival (first opponents)) 196 | (challenge (property rival))) 197 | (if (< challenge mastery) 198 | (next-trial rival challenge (rest opponents)) 199 | (next-trial champion mastery (rest opponents)))))))) 200 | 201 | (e.g. 202 | (argmin length '(1 2) '(3) '(4 5 6)) 203 | ===> (3)) 204 | 205 | (define (min+max first . args) 206 | (assert (and (number? first) 207 | (every number? args))) 208 | (let loop ((min first) 209 | (max first) 210 | (remaining args)) 211 | (match remaining 212 | (() 213 | (values min max)) 214 | ((current . remaining) 215 | (cond ((< current min) 216 | (loop current max remaining)) 217 | ((> current max) 218 | (loop min current remaining)) 219 | (else 220 | (loop min max remaining))))))) 221 | 222 | (e.g. 223 | (min+max 5 4 6 3 7 2 8 1) 224 | ===> 1 8) 225 | 226 | (define (argmin+argmax property element . elements) 227 | (let ((quality (property element))) 228 | (let next-trial ((winner element) 229 | (looser element) 230 | (mastery quality) 231 | (failure quality) 232 | (opponents elements)) 233 | (if (null? opponents) 234 | (values looser winner) 235 | (let* ((rival (first opponents)) 236 | (quality (property rival))) 237 | (cond ((< quality failure) 238 | (next-trial winner rival mastery quality (rest opponents))) 239 | ((> quality mastery) 240 | (next-trial rival looser quality failure (rest opponents))) 241 | (else 242 | (next-trial winner looser mastery failure 243 | (rest opponents))))))))) 244 | 245 | (e.g. 246 | (argmin+argmax length '(1 2) '(3) '(4 5 6)) 247 | ===> (3) (4 5 6)) 248 | 249 | (define (skip #;element-number n #;in list) 250 | (let (((head . tail) list)) 251 | (if (= n 0) 252 | tail 253 | `(,head . ,(skip #;element-number (- n 1) #;in tail))))) 254 | 255 | (e.g. (skip #;element-number 1 #;in '(a b c)) ===> (a c)) 256 | 257 | (define (alter #;element-number n #;in list #;with replacement) 258 | (assert (and (integer? n) (>= n 0))) 259 | (let (((head . tail) list)) 260 | (if (= n 0) 261 | `(,replacement . ,tail) 262 | `(,head . ,(alter #;element-number (- n 1) 263 | #;in tail #;with replacement))))) 264 | 265 | (e.g. 266 | (alter #;element-number 1 #;in '(ząb dupa zębowa) #;with 'zupa) 267 | ===> (ząb zupa zębowa)) 268 | 269 | (define (generate-list n generator) 270 | (assert (and (integer? size) (>= size 0))) 271 | (if (= n 0) 272 | '() 273 | `(,(generator) . ,(generate-list (- n 1) generator)))) 274 | 275 | (define-syntax (list<-values values) 276 | (call-with-values (lambda () values) list)) 277 | 278 | (define now get-internal-real-time) 279 | 280 | (define-syntax (measured expression) 281 | (let ((starting-time (now))) 282 | (let ((result (list<-values expression))) 283 | (format #t "~s: ~s ns\n" 'expression (- (now) starting-time)) 284 | (apply values result)))) 285 | 286 | (define SPECIFIC-CONTEXT (make-hash-table)) 287 | 288 | (let-syntax (((specific-literal-syntax binding-structure name value) 289 | (lambda (stx) 290 | (assert (appears? #'name #;in #'binding-structure)) 291 | (syntax-case stx () 292 | ((_ (binding-structure (... ...)) actions . *) 293 | (with-syntax ((specific (datum->syntax stx 'specific))) 294 | #'(let-syntax 295 | ((specific 296 | (syntax-rules (name (... ...)) 297 | ((_ name) 298 | (let ((default (hash-ref 299 | SPECIFIC-CONTEXT 300 | 'name '()))) 301 | (if (null? default) 302 | value 303 | (first default)))) 304 | (... ...)))) 305 | actions . *))))))) 306 | (define-syntax with-default 307 | (specific-literal-syntax (name value) name value)) 308 | (define-syntax without-default 309 | (specific-literal-syntax 310 | name name (throw 'unspecified #:name 'name 311 | #:context (hash-map->alist SPECIFIC-CONTEXT))))) 312 | 313 | (define-syntax specify 314 | (lambda (stx) 315 | (syntax-case stx () 316 | ((_ ((name expression) ...) 317 | actions ...) 318 | (with-syntax (((value ...) (generate-temporaries #'(expression ...)))) 319 | #'(let ((value expression) ...) 320 | (dynamic-wind 321 | (lambda () 322 | (hash-set! SPECIFIC-CONTEXT 'name 323 | (cons value (hash-ref SPECIFIC-CONTEXT 'name '()))) 324 | ...) 325 | (lambda () 326 | actions ...) 327 | (lambda () 328 | (hash-set! SPECIFIC-CONTEXT 'name 329 | (rest (hash-ref SPECIFIC-CONTEXT 'name))) 330 | ...)))))))) 331 | 332 | (e.g. ; this is how the trio 'with-default', 333 | (let () ; 'specific' and 'specify' can be used 334 | (with-default ((x 10) 335 | (y 20)) 336 | (define (f) 337 | `(,(specific x) ,(specific y)))) 338 | (specify ((x 30)) 339 | (f))) 340 | ===> (30 20)) 341 | 342 | (define (equivalence-classes equivalent? set) 343 | (let next-item ((set set)(result '())) 344 | (match set 345 | (() 346 | (reverse (map reverse result))) 347 | ((item . set) 348 | (match result 349 | (() 350 | (next-item set `((,item) . ,result))) 351 | ((this . next) 352 | (let next-class ((past '()) (present this) (future next)) 353 | (match present 354 | ((paradigm . _) 355 | (if (equivalent? item paradigm) 356 | (next-item set `((,item . ,present) 357 | . (,@past ,@future))) 358 | (match future 359 | (() 360 | (next-item set `((,item) ,@result))) 361 | ((this . next) 362 | (next-class `(,present . ,past) this next))) 363 | ))) 364 | ))))))) 365 | 366 | (e.g. 367 | (equivalence-classes (lambda(x y)(= (modulo x 3) (modulo y 3))) (iota 9)) 368 | ===> ((0 3 6) (1 4 7) (2 5 8))) 369 | 370 | (define (subsets l n) 371 | (cond 372 | ((= n 0) '()) 373 | ((= n 1) (map list l)) 374 | ((> n 1) 375 | (match l 376 | (() '()) 377 | ((first . rest) 378 | (append (map (lambda (next) 379 | `(,first . ,next)) 380 | (subsets rest (1- n))) 381 | (subsets rest n))))))) 382 | 383 | (define (impose-arity n procedure) 384 | (let ((new-procedure (lambda args (apply procedure args)))) 385 | (set-procedure-property! new-procedure 'name 386 | (or (procedure-name procedure) 387 | 'fixed-arity)) 388 | (set-procedure-property! new-procedure 'imposed-arity 389 | (if (list? n) n `(,n 0 #f))) 390 | new-procedure)) 391 | 392 | (define (arity procedure) 393 | (assert (procedure? procedure)) 394 | (or (procedure-property procedure 'imposed-arity) 395 | (procedure-property procedure 'arity))) 396 | 397 | (define (clip args #;to arity) 398 | (match arity 399 | ((min _ #f) 400 | (take args min)) 401 | ((? number?) 402 | (take args arity)) 403 | (_ 404 | args))) 405 | 406 | (define (compose/values . fns) 407 | (define (make-chain fn chains) 408 | (impose-arity 409 | (arity fn) 410 | (lambda args 411 | (call-with-values 412 | (lambda () (apply fn args)) 413 | (lambda vals (apply chains (clip vals (arity chains)))))))) 414 | (let ((composer (reduce make-chain values fns))) 415 | composer)) 416 | 417 | (define (->string object) 418 | (cond ((symbol? object) 419 | (symbol->string object)) 420 | ((number? object) 421 | (number->string object)) 422 | ((list? object) 423 | (string-append 424 | "(" (string-join (map ->string object) " ") ")")) 425 | ((pair? object) 426 | (string-append 427 | "(" (->string (car object)) " . " (->string (cdr object)))) 428 | ((string? object) 429 | object) 430 | ((vector? object) 431 | (string-append "#" (->string (vector->list object)))) 432 | (else 433 | (with-output-to-string 434 | (lambda () 435 | (display object)))))) 436 | 437 | 438 | (define (fold-left op e . ls) 439 | (match ls 440 | (((heads . tails) ...) 441 | (apply fold-left op (apply op e heads) tails)) 442 | (_ 443 | e))) 444 | 445 | (define (fold-right op e . ls) 446 | (match ls 447 | (((heads . tails) ...) 448 | (apply op (apply fold-right op e tails) heads)) 449 | (_ 450 | e))) 451 | 452 | (define (sum elements) 453 | (fold-left + 0 elements)) 454 | 455 | (define (product elements) 456 | (fold-left * 1 elements)) 457 | 458 | (define (scan op e l) 459 | (match l 460 | (() 461 | '()) 462 | ((h . t) 463 | (let ((e* (op e h))) 464 | `(,e* . ,(scan op e* t)))))) 465 | 466 | (e.g. 467 | (scan * 1 '(1 2 3 4 5 6)) ===> (1 2 6 24 120 720)) 468 | 469 | (define (prefix-sum l) 470 | (scan + 0 l)) 471 | 472 | (define* (extend-right l #;to size #;with #:optional (fill #f)) 473 | (let ((extension-size (- size (length l)))) 474 | (if (< extension-size 0) 475 | (error "list length exceeds the desired length") 476 | `(,@l ,@(make-list extension-size fill))))) 477 | 478 | (e.g. (extend-right '(1 2 3) 5 0) ===> (1 2 3 0 0)) 479 | 480 | (define* (extend-left l #;to size #;with #:optional (fill #f)) 481 | (let ((extension-size (- size (length l)))) 482 | (if (< extension-size 0) 483 | (error "list length exceeds the desired length") 484 | `(,@(make-list extension-size fill) ,@l)))) 485 | 486 | (e.g. (extend-left '(1 2 3) 5 0) ===> (0 0 1 2 3)) 487 | 488 | (define ((in? set) element) 489 | (match set 490 | ((first . rest) 491 | (or (equal? element first) 492 | ((in? rest) element))) 493 | (_ 494 | #f))) 495 | 496 | (e.g. ((in? '(a b c)) 'a)) 497 | 498 | (e.g. (not ((in? '(a b c)) 'd))) 499 | 500 | (define (indexed list) 501 | (zip (iota (length list)) list)) 502 | 503 | (e.g. (indexed '(a b c)) ===> ((0 a) (1 b) (2 c))) 504 | 505 | (define (multicombinations #;from-set A #;of-length n) 506 | (assert (not (contains-duplicates? A))) 507 | (cond ((= n 0) 508 | '()) 509 | ((= n 1) 510 | (map list A)) 511 | (else 512 | (append-map (lambda (combination) 513 | (map (lambda (a) 514 | `(,a . ,combination)) A)) 515 | (multicombinations #;from-set A #;of-length (- n 1)))))) 516 | 517 | (e.g. 518 | (multicombinations #;from-set '(a b) #;of-length 3) 519 | ===> 520 | ((a a a) (b a a) (a b a) (b b a) (a a b) (b a b) (a b b) (b b b))) 521 | -------------------------------------------------------------------------------- /datasets/cnf/zebra_v155_c1135.cnf: -------------------------------------------------------------------------------- 1 | c The zebra problem. 2 | c 3 | c Reference: 4 | c 5 | c Rina Dechter, 6 | c Enhancement Schemes for Constraint Processing: 7 | c Backjumping, Learning, and Cutset Decomposition", 8 | c Artificial Intelligence, 9 | c Volume 41, pages 273-312. 10 | c 11 | c Encoded in CNF by Jon Freeman, November 1994. 12 | c I have found three solutions; there may be more. 13 | c 14 | p cnf 155 1135 15 | 1 2 3 16 | 4 5 0 17 | -1 -2 0 18 | -1 -3 0 19 | -1 -4 0 20 | -1 -5 0 21 | -2 -3 0 22 | -2 -4 0 23 | -2 -5 0 24 | -3 -4 0 25 | -3 -5 0 26 | -4 -5 0 27 | 6 7 8 28 | 9 10 0 29 | -6 -7 0 30 | -6 -8 0 31 | -6 -9 0 32 | -6 -10 0 33 | -7 -8 0 34 | -7 -9 0 35 | -7 -10 0 36 | -8 -9 0 37 | -8 -10 0 38 | -9 -10 0 39 | 11 12 13 40 | 14 15 0 41 | -11 -12 0 42 | -11 -13 0 43 | -11 -14 0 44 | -11 -15 0 45 | -12 -13 0 46 | -12 -14 0 47 | -12 -15 0 48 | -13 -14 0 49 | -13 -15 0 50 | -14 -15 0 51 | 16 17 18 52 | 19 20 0 53 | -16 -17 0 54 | -16 -18 0 55 | -16 -19 0 56 | -16 -20 0 57 | -17 -18 0 58 | -17 -19 0 59 | -17 -20 0 60 | -18 -19 0 61 | -18 -20 0 62 | -19 -20 0 63 | 21 22 23 64 | 24 25 0 65 | -21 -22 0 66 | -21 -23 0 67 | -21 -24 0 68 | -21 -25 0 69 | -22 -23 0 70 | -22 -24 0 71 | -22 -25 0 72 | -23 -24 0 73 | -23 -25 0 74 | -24 -25 0 75 | 51 52 53 76 | 54 55 0 77 | -51 -52 0 78 | -51 -53 0 79 | -51 -54 0 80 | -51 -55 0 81 | -52 -53 0 82 | -52 -54 0 83 | -52 -55 0 84 | -53 -54 0 85 | -53 -55 0 86 | -54 -55 0 87 | 56 57 58 88 | 59 60 0 89 | -56 -57 0 90 | -56 -58 0 91 | -56 -59 0 92 | -56 -60 0 93 | -57 -58 0 94 | -57 -59 0 95 | -57 -60 0 96 | -58 -59 0 97 | -58 -60 0 98 | -59 -60 0 99 | 61 62 63 100 | 64 65 0 101 | -61 -62 0 102 | -61 -63 0 103 | -61 -64 0 104 | -61 -65 0 105 | -62 -63 0 106 | -62 -64 0 107 | -62 -65 0 108 | -63 -64 0 109 | -63 -65 0 110 | -64 -65 0 111 | 66 67 68 112 | 69 70 0 113 | -66 -67 0 114 | -66 -68 0 115 | -66 -69 0 116 | -66 -70 0 117 | -67 -68 0 118 | -67 -69 0 119 | -67 -70 0 120 | -68 -69 0 121 | -68 -70 0 122 | -69 -70 0 123 | 71 72 73 124 | 74 75 0 125 | -71 -72 0 126 | -71 -73 0 127 | -71 -74 0 128 | -71 -75 0 129 | -72 -73 0 130 | -72 -74 0 131 | -72 -75 0 132 | -73 -74 0 133 | -73 -75 0 134 | -74 -75 0 135 | 26 27 28 136 | 29 30 0 137 | -26 -27 0 138 | -26 -28 0 139 | -26 -29 0 140 | -26 -30 0 141 | -27 -28 0 142 | -27 -29 0 143 | -27 -30 0 144 | -28 -29 0 145 | -28 -30 0 146 | -29 -30 0 147 | 31 32 33 148 | 34 35 0 149 | -31 -32 0 150 | -31 -33 0 151 | -31 -34 0 152 | -31 -35 0 153 | -32 -33 0 154 | -32 -34 0 155 | -32 -35 0 156 | -33 -34 0 157 | -33 -35 0 158 | -34 -35 0 159 | 36 37 38 160 | 39 40 0 161 | -36 -37 0 162 | -36 -38 0 163 | -36 -39 0 164 | -36 -40 0 165 | -37 -38 0 166 | -37 -39 0 167 | -37 -40 0 168 | -38 -39 0 169 | -38 -40 0 170 | -39 -40 0 171 | 41 42 43 172 | 44 45 0 173 | -41 -42 0 174 | -41 -43 0 175 | -41 -44 0 176 | -41 -45 0 177 | -42 -43 0 178 | -42 -44 0 179 | -42 -45 0 180 | -43 -44 0 181 | -43 -45 0 182 | -44 -45 0 183 | 46 47 48 184 | 49 50 0 185 | -46 -47 0 186 | -46 -48 0 187 | -46 -49 0 188 | -46 -50 0 189 | -47 -48 0 190 | -47 -49 0 191 | -47 -50 0 192 | -48 -49 0 193 | -48 -50 0 194 | -49 -50 0 195 | 101 102 103 196 | 104 105 0 197 | -101 -102 0 198 | -101 -103 0 199 | -101 -104 0 200 | -101 -105 0 201 | -102 -103 0 202 | -102 -104 0 203 | -102 -105 0 204 | -103 -104 0 205 | -103 -105 0 206 | -104 -105 0 207 | 106 107 108 208 | 109 110 0 209 | -106 -107 0 210 | -106 -108 0 211 | -106 -109 0 212 | -106 -110 0 213 | -107 -108 0 214 | -107 -109 0 215 | -107 -110 0 216 | -108 -109 0 217 | -108 -110 0 218 | -109 -110 0 219 | 111 112 113 220 | 114 115 0 221 | -111 -112 0 222 | -111 -113 0 223 | -111 -114 0 224 | -111 -115 0 225 | -112 -113 0 226 | -112 -114 0 227 | -112 -115 0 228 | -113 -114 0 229 | -113 -115 0 230 | -114 -115 0 231 | 116 117 118 232 | 119 120 0 233 | -116 -117 0 234 | -116 -118 0 235 | -116 -119 0 236 | -116 -120 0 237 | -117 -118 0 238 | -117 -119 0 239 | -117 -120 0 240 | -118 -119 0 241 | -118 -120 0 242 | -119 -120 0 243 | 121 122 123 244 | 124 125 0 245 | -121 -122 0 246 | -121 -123 0 247 | -121 -124 0 248 | -121 -125 0 249 | -122 -123 0 250 | -122 -124 0 251 | -122 -125 0 252 | -123 -124 0 253 | -123 -125 0 254 | -124 -125 0 255 | 76 77 78 256 | 79 80 0 257 | -76 -77 0 258 | -76 -78 0 259 | -76 -79 0 260 | -76 -80 0 261 | -77 -78 0 262 | -77 -79 0 263 | -77 -80 0 264 | -78 -79 0 265 | -78 -80 0 266 | -79 -80 0 267 | 81 82 83 268 | 84 85 0 269 | -81 -82 0 270 | -81 -83 0 271 | -81 -84 0 272 | -81 -85 0 273 | -82 -83 0 274 | -82 -84 0 275 | -82 -85 0 276 | -83 -84 0 277 | -83 -85 0 278 | -84 -85 0 279 | 86 87 88 280 | 89 90 0 281 | -86 -87 0 282 | -86 -88 0 283 | -86 -89 0 284 | -86 -90 0 285 | -87 -88 0 286 | -87 -89 0 287 | -87 -90 0 288 | -88 -89 0 289 | -88 -90 0 290 | -89 -90 0 291 | 91 92 93 292 | 94 95 0 293 | -91 -92 0 294 | -91 -93 0 295 | -91 -94 0 296 | -91 -95 0 297 | -92 -93 0 298 | -92 -94 0 299 | -92 -95 0 300 | -93 -94 0 301 | -93 -95 0 302 | -94 -95 0 303 | 96 97 98 304 | 99 100 0 305 | -96 -97 0 306 | -96 -98 0 307 | -96 -99 0 308 | -96 -100 0 309 | -97 -98 0 310 | -97 -99 0 311 | -97 -100 0 312 | -98 -99 0 313 | -98 -100 0 314 | -99 -100 0 315 | -1 -7 126 0 316 | -2 -8 126 0 317 | -3 -9 126 0 318 | -4 -10 126 0 319 | -1 -12 127 0 320 | -2 -13 127 0 321 | -3 -14 127 0 322 | -4 -15 127 0 323 | -1 -17 128 0 324 | -2 -18 128 0 325 | -3 -19 128 0 326 | -4 -20 128 0 327 | -1 -22 129 0 328 | -2 -23 129 0 329 | -3 -24 129 0 330 | -4 -25 129 0 331 | -6 -2 130 0 332 | -7 -3 130 0 333 | -8 -4 130 0 334 | -9 -5 130 0 335 | -6 -12 131 0 336 | -7 -13 131 0 337 | -8 -14 131 0 338 | -9 -15 131 0 339 | -6 -17 132 0 340 | -7 -18 132 0 341 | -8 -19 132 0 342 | -9 -20 132 0 343 | -6 -22 133 0 344 | -7 -23 133 0 345 | -8 -24 133 0 346 | -9 -25 133 0 347 | -11 -2 134 0 348 | -12 -3 134 0 349 | -13 -4 134 0 350 | -14 -5 134 0 351 | -11 -7 135 0 352 | -12 -8 135 0 353 | -13 -9 135 0 354 | -14 -10 135 0 355 | -11 -17 136 0 356 | -12 -18 136 0 357 | -13 -19 136 0 358 | -14 -20 136 0 359 | -11 -22 137 0 360 | -12 -23 137 0 361 | -13 -24 137 0 362 | -14 -25 137 0 363 | -16 -2 138 0 364 | -17 -3 138 0 365 | -18 -4 138 0 366 | -19 -5 138 0 367 | -16 -7 139 0 368 | -17 -8 139 0 369 | -18 -9 139 0 370 | -19 -10 139 0 371 | -16 -12 140 0 372 | -17 -13 140 0 373 | -18 -14 140 0 374 | -19 -15 140 0 375 | -16 -22 141 0 376 | -17 -23 141 0 377 | -18 -24 141 0 378 | -19 -25 141 0 379 | -21 -2 142 0 380 | -22 -3 142 0 381 | -23 -4 142 0 382 | -24 -5 142 0 383 | -21 -7 143 0 384 | -22 -8 143 0 385 | -23 -9 143 0 386 | -24 -10 143 0 387 | -21 -12 144 0 388 | -22 -13 144 0 389 | -23 -14 144 0 390 | -24 -15 144 0 391 | -21 -17 145 0 392 | -22 -18 145 0 393 | -23 -19 145 0 394 | -24 -20 145 0 395 | -1 -8 -126 0 396 | -1 -9 -126 0 397 | -1 -10 -126 0 398 | -2 -6 -126 0 399 | -2 -9 -126 0 400 | -2 -10 -126 0 401 | -3 -6 -126 0 402 | -3 -7 -126 0 403 | -3 -10 -126 0 404 | -4 -6 -126 0 405 | -4 -7 -126 0 406 | -4 -8 -126 0 407 | -5 -6 -126 0 408 | -5 -7 -126 0 409 | -5 -8 -126 0 410 | -5 -9 -126 0 411 | -1 -13 -127 0 412 | -1 -14 -127 0 413 | -1 -15 -127 0 414 | -2 -11 -127 0 415 | -2 -14 -127 0 416 | -2 -15 -127 0 417 | -3 -11 -127 0 418 | -3 -12 -127 0 419 | -3 -15 -127 0 420 | -4 -11 -127 0 421 | -4 -12 -127 0 422 | -4 -13 -127 0 423 | -5 -11 -127 0 424 | -5 -12 -127 0 425 | -5 -13 -127 0 426 | -5 -14 -127 0 427 | -1 -18 -128 0 428 | -1 -19 -128 0 429 | -1 -20 -128 0 430 | -2 -16 -128 0 431 | -2 -19 -128 0 432 | -2 -20 -128 0 433 | -3 -16 -128 0 434 | -3 -17 -128 0 435 | -3 -20 -128 0 436 | -4 -16 -128 0 437 | -4 -17 -128 0 438 | -4 -18 -128 0 439 | -5 -16 -128 0 440 | -5 -17 -128 0 441 | -5 -18 -128 0 442 | -5 -19 -128 0 443 | -1 -23 -129 0 444 | -1 -24 -129 0 445 | -1 -25 -129 0 446 | -2 -21 -129 0 447 | -2 -24 -129 0 448 | -2 -25 -129 0 449 | -3 -21 -129 0 450 | -3 -22 -129 0 451 | -3 -25 -129 0 452 | -4 -21 -129 0 453 | -4 -22 -129 0 454 | -4 -23 -129 0 455 | -5 -21 -129 0 456 | -5 -22 -129 0 457 | -5 -23 -129 0 458 | -5 -24 -129 0 459 | -6 -3 -130 0 460 | -6 -4 -130 0 461 | -6 -5 -130 0 462 | -7 -1 -130 0 463 | -7 -4 -130 0 464 | -7 -5 -130 0 465 | -8 -1 -130 0 466 | -8 -2 -130 0 467 | -8 -5 -130 0 468 | -9 -1 -130 0 469 | -9 -2 -130 0 470 | -9 -3 -130 0 471 | -10 -1 -130 0 472 | -10 -2 -130 0 473 | -10 -3 -130 0 474 | -10 -4 -130 0 475 | -6 -13 -131 0 476 | -6 -14 -131 0 477 | -6 -15 -131 0 478 | -7 -11 -131 0 479 | -7 -14 -131 0 480 | -7 -15 -131 0 481 | -8 -11 -131 0 482 | -8 -12 -131 0 483 | -8 -15 -131 0 484 | -9 -11 -131 0 485 | -9 -12 -131 0 486 | -9 -13 -131 0 487 | -10 -11 -131 0 488 | -10 -12 -131 0 489 | -10 -13 -131 0 490 | -10 -14 -131 0 491 | -6 -18 -132 0 492 | -6 -19 -132 0 493 | -6 -20 -132 0 494 | -7 -16 -132 0 495 | -7 -19 -132 0 496 | -7 -20 -132 0 497 | -8 -16 -132 0 498 | -8 -17 -132 0 499 | -8 -20 -132 0 500 | -9 -16 -132 0 501 | -9 -17 -132 0 502 | -9 -18 -132 0 503 | -10 -16 -132 0 504 | -10 -17 -132 0 505 | -10 -18 -132 0 506 | -10 -19 -132 0 507 | -6 -23 -133 0 508 | -6 -24 -133 0 509 | -6 -25 -133 0 510 | -7 -21 -133 0 511 | -7 -24 -133 0 512 | -7 -25 -133 0 513 | -8 -21 -133 0 514 | -8 -22 -133 0 515 | -8 -25 -133 0 516 | -9 -21 -133 0 517 | -9 -22 -133 0 518 | -9 -23 -133 0 519 | -10 -21 -133 0 520 | -10 -22 -133 0 521 | -10 -23 -133 0 522 | -10 -24 -133 0 523 | -11 -3 -134 0 524 | -11 -4 -134 0 525 | -11 -5 -134 0 526 | -12 -1 -134 0 527 | -12 -4 -134 0 528 | -12 -5 -134 0 529 | -13 -1 -134 0 530 | -13 -2 -134 0 531 | -13 -5 -134 0 532 | -14 -1 -134 0 533 | -14 -2 -134 0 534 | -14 -3 -134 0 535 | -15 -1 -134 0 536 | -15 -2 -134 0 537 | -15 -3 -134 0 538 | -15 -4 -134 0 539 | -11 -8 -135 0 540 | -11 -9 -135 0 541 | -11 -10 -135 0 542 | -12 -6 -135 0 543 | -12 -9 -135 0 544 | -12 -10 -135 0 545 | -13 -6 -135 0 546 | -13 -7 -135 0 547 | -13 -10 -135 0 548 | -14 -6 -135 0 549 | -14 -7 -135 0 550 | -14 -8 -135 0 551 | -15 -6 -135 0 552 | -15 -7 -135 0 553 | -15 -8 -135 0 554 | -15 -9 -135 0 555 | -11 -18 -136 0 556 | -11 -19 -136 0 557 | -11 -20 -136 0 558 | -12 -16 -136 0 559 | -12 -19 -136 0 560 | -12 -20 -136 0 561 | -13 -16 -136 0 562 | -13 -17 -136 0 563 | -13 -20 -136 0 564 | -14 -16 -136 0 565 | -14 -17 -136 0 566 | -14 -18 -136 0 567 | -15 -16 -136 0 568 | -15 -17 -136 0 569 | -15 -18 -136 0 570 | -15 -19 -136 0 571 | -11 -23 -137 0 572 | -11 -24 -137 0 573 | -11 -25 -137 0 574 | -12 -21 -137 0 575 | -12 -24 -137 0 576 | -12 -25 -137 0 577 | -13 -21 -137 0 578 | -13 -22 -137 0 579 | -13 -25 -137 0 580 | -14 -21 -137 0 581 | -14 -22 -137 0 582 | -14 -23 -137 0 583 | -15 -21 -137 0 584 | -15 -22 -137 0 585 | -15 -23 -137 0 586 | -15 -24 -137 0 587 | -16 -3 -138 0 588 | -16 -4 -138 0 589 | -16 -5 -138 0 590 | -17 -1 -138 0 591 | -17 -4 -138 0 592 | -17 -5 -138 0 593 | -18 -1 -138 0 594 | -18 -2 -138 0 595 | -18 -5 -138 0 596 | -19 -1 -138 0 597 | -19 -2 -138 0 598 | -19 -3 -138 0 599 | -20 -1 -138 0 600 | -20 -2 -138 0 601 | -20 -3 -138 0 602 | -20 -4 -138 0 603 | -16 -8 -139 0 604 | -16 -9 -139 0 605 | -16 -10 -139 0 606 | -17 -6 -139 0 607 | -17 -9 -139 0 608 | -17 -10 -139 0 609 | -18 -6 -139 0 610 | -18 -7 -139 0 611 | -18 -10 -139 0 612 | -19 -6 -139 0 613 | -19 -7 -139 0 614 | -19 -8 -139 0 615 | -20 -6 -139 0 616 | -20 -7 -139 0 617 | -20 -8 -139 0 618 | -20 -9 -139 0 619 | -16 -13 -140 0 620 | -16 -14 -140 0 621 | -16 -15 -140 0 622 | -17 -11 -140 0 623 | -17 -14 -140 0 624 | -17 -15 -140 0 625 | -18 -11 -140 0 626 | -18 -12 -140 0 627 | -18 -15 -140 0 628 | -19 -11 -140 0 629 | -19 -12 -140 0 630 | -19 -13 -140 0 631 | -20 -11 -140 0 632 | -20 -12 -140 0 633 | -20 -13 -140 0 634 | -20 -14 -140 0 635 | -16 -23 -141 0 636 | -16 -24 -141 0 637 | -16 -25 -141 0 638 | -17 -21 -141 0 639 | -17 -24 -141 0 640 | -17 -25 -141 0 641 | -18 -21 -141 0 642 | -18 -22 -141 0 643 | -18 -25 -141 0 644 | -19 -21 -141 0 645 | -19 -22 -141 0 646 | -19 -23 -141 0 647 | -20 -21 -141 0 648 | -20 -22 -141 0 649 | -20 -23 -141 0 650 | -20 -24 -141 0 651 | -21 -3 -142 0 652 | -21 -4 -142 0 653 | -21 -5 -142 0 654 | -22 -1 -142 0 655 | -22 -4 -142 0 656 | -22 -5 -142 0 657 | -23 -1 -142 0 658 | -23 -2 -142 0 659 | -23 -5 -142 0 660 | -24 -1 -142 0 661 | -24 -2 -142 0 662 | -24 -3 -142 0 663 | -25 -1 -142 0 664 | -25 -2 -142 0 665 | -25 -3 -142 0 666 | -25 -4 -142 0 667 | -21 -8 -143 0 668 | -21 -9 -143 0 669 | -21 -10 -143 0 670 | -22 -6 -143 0 671 | -22 -9 -143 0 672 | -22 -10 -143 0 673 | -23 -6 -143 0 674 | -23 -7 -143 0 675 | -23 -10 -143 0 676 | -24 -6 -143 0 677 | -24 -7 -143 0 678 | -24 -8 -143 0 679 | -25 -6 -143 0 680 | -25 -7 -143 0 681 | -25 -8 -143 0 682 | -25 -9 -143 0 683 | -21 -13 -144 0 684 | -21 -14 -144 0 685 | -21 -15 -144 0 686 | -22 -11 -144 0 687 | -22 -14 -144 0 688 | -22 -15 -144 0 689 | -23 -11 -144 0 690 | -23 -12 -144 0 691 | -23 -15 -144 0 692 | -24 -11 -144 0 693 | -24 -12 -144 0 694 | -24 -13 -144 0 695 | -25 -11 -144 0 696 | -25 -12 -144 0 697 | -25 -13 -144 0 698 | -25 -14 -144 0 699 | -21 -18 -145 0 700 | -21 -19 -145 0 701 | -21 -20 -145 0 702 | -22 -16 -145 0 703 | -22 -19 -145 0 704 | -22 -20 -145 0 705 | -23 -16 -145 0 706 | -23 -17 -145 0 707 | -23 -20 -145 0 708 | -24 -16 -145 0 709 | -24 -17 -145 0 710 | -24 -18 -145 0 711 | -25 -16 -145 0 712 | -25 -17 -145 0 713 | -25 -18 -145 0 714 | -25 -19 -145 0 715 | -126 146 0 716 | -127 147 0 717 | -128 148 0 718 | -129 149 0 719 | -131 150 0 720 | -132 151 0 721 | -133 152 0 722 | -136 153 0 723 | -137 154 0 724 | -141 155 0 725 | -130 146 0 726 | -134 147 0 727 | -138 148 0 728 | -142 149 0 729 | -135 150 0 730 | -139 151 0 731 | -143 152 0 732 | -140 153 0 733 | -144 154 0 734 | -145 155 0 735 | 126 130 -146 0 736 | 127 134 -147 0 737 | 128 138 -148 0 738 | 129 142 -149 0 739 | 131 135 -150 0 740 | 132 139 -151 0 741 | 133 143 -152 0 742 | 136 140 -153 0 743 | 137 144 -154 0 744 | 141 145 -155 0 745 | -1 -6 0 746 | -1 -11 0 747 | -1 -16 0 748 | -1 -21 0 749 | -6 -11 0 750 | -6 -16 0 751 | -6 -21 0 752 | -11 -16 0 753 | -11 -21 0 754 | -16 -21 0 755 | -2 -7 0 756 | -2 -12 0 757 | -2 -17 0 758 | -2 -22 0 759 | -7 -12 0 760 | -7 -17 0 761 | -7 -22 0 762 | -12 -17 0 763 | -12 -22 0 764 | -17 -22 0 765 | -3 -8 0 766 | -3 -13 0 767 | -3 -18 0 768 | -3 -23 0 769 | -8 -13 0 770 | -8 -18 0 771 | -8 -23 0 772 | -13 -18 0 773 | -13 -23 0 774 | -18 -23 0 775 | -4 -9 0 776 | -4 -14 0 777 | -4 -19 0 778 | -4 -24 0 779 | -9 -14 0 780 | -9 -19 0 781 | -9 -24 0 782 | -14 -19 0 783 | -14 -24 0 784 | -19 -24 0 785 | -5 -10 0 786 | -5 -15 0 787 | -5 -20 0 788 | -5 -25 0 789 | -10 -15 0 790 | -10 -20 0 791 | -10 -25 0 792 | -15 -20 0 793 | -15 -25 0 794 | -20 -25 0 795 | -51 -56 0 796 | -51 -61 0 797 | -51 -66 0 798 | -51 -71 0 799 | -56 -61 0 800 | -56 -66 0 801 | -56 -71 0 802 | -61 -66 0 803 | -61 -71 0 804 | -66 -71 0 805 | -52 -57 0 806 | -52 -62 0 807 | -52 -67 0 808 | -52 -72 0 809 | -57 -62 0 810 | -57 -67 0 811 | -57 -72 0 812 | -62 -67 0 813 | -62 -72 0 814 | -67 -72 0 815 | -53 -58 0 816 | -53 -63 0 817 | -53 -68 0 818 | -53 -73 0 819 | -58 -63 0 820 | -58 -68 0 821 | -58 -73 0 822 | -63 -68 0 823 | -63 -73 0 824 | -68 -73 0 825 | -54 -59 0 826 | -54 -64 0 827 | -54 -69 0 828 | -54 -74 0 829 | -59 -64 0 830 | -59 -69 0 831 | -59 -74 0 832 | -64 -69 0 833 | -64 -74 0 834 | -69 -74 0 835 | -55 -60 0 836 | -55 -65 0 837 | -55 -70 0 838 | -55 -75 0 839 | -60 -65 0 840 | -60 -70 0 841 | -60 -75 0 842 | -65 -70 0 843 | -65 -75 0 844 | -70 -75 0 845 | -26 -31 0 846 | -26 -36 0 847 | -26 -41 0 848 | -26 -46 0 849 | -31 -36 0 850 | -31 -41 0 851 | -31 -46 0 852 | -36 -41 0 853 | -36 -46 0 854 | -41 -46 0 855 | -27 -32 0 856 | -27 -37 0 857 | -27 -42 0 858 | -27 -47 0 859 | -32 -37 0 860 | -32 -42 0 861 | -32 -47 0 862 | -37 -42 0 863 | -37 -47 0 864 | -42 -47 0 865 | -28 -33 0 866 | -28 -38 0 867 | -28 -43 0 868 | -28 -48 0 869 | -33 -38 0 870 | -33 -43 0 871 | -33 -48 0 872 | -38 -43 0 873 | -38 -48 0 874 | -43 -48 0 875 | -29 -34 0 876 | -29 -39 0 877 | -29 -44 0 878 | -29 -49 0 879 | -34 -39 0 880 | -34 -44 0 881 | -34 -49 0 882 | -39 -44 0 883 | -39 -49 0 884 | -44 -49 0 885 | -30 -35 0 886 | -30 -40 0 887 | -30 -45 0 888 | -30 -50 0 889 | -35 -40 0 890 | -35 -45 0 891 | -35 -50 0 892 | -40 -45 0 893 | -40 -50 0 894 | -45 -50 0 895 | -101 -106 0 896 | -101 -111 0 897 | -101 -116 0 898 | -101 -121 0 899 | -106 -111 0 900 | -106 -116 0 901 | -106 -121 0 902 | -111 -116 0 903 | -111 -121 0 904 | -116 -121 0 905 | -102 -107 0 906 | -102 -112 0 907 | -102 -117 0 908 | -102 -122 0 909 | -107 -112 0 910 | -107 -117 0 911 | -107 -122 0 912 | -112 -117 0 913 | -112 -122 0 914 | -117 -122 0 915 | -103 -108 0 916 | -103 -113 0 917 | -103 -118 0 918 | -103 -123 0 919 | -108 -113 0 920 | -108 -118 0 921 | -108 -123 0 922 | -113 -118 0 923 | -113 -123 0 924 | -118 -123 0 925 | -104 -109 0 926 | -104 -114 0 927 | -104 -119 0 928 | -104 -124 0 929 | -109 -114 0 930 | -109 -119 0 931 | -109 -124 0 932 | -114 -119 0 933 | -114 -124 0 934 | -119 -124 0 935 | -105 -110 0 936 | -105 -115 0 937 | -105 -120 0 938 | -105 -125 0 939 | -110 -115 0 940 | -110 -120 0 941 | -110 -125 0 942 | -115 -120 0 943 | -115 -125 0 944 | -120 -125 0 945 | -76 -81 0 946 | -76 -86 0 947 | -76 -91 0 948 | -76 -96 0 949 | -81 -86 0 950 | -81 -91 0 951 | -81 -96 0 952 | -86 -91 0 953 | -86 -96 0 954 | -91 -96 0 955 | -77 -82 0 956 | -77 -87 0 957 | -77 -92 0 958 | -77 -97 0 959 | -82 -87 0 960 | -82 -92 0 961 | -82 -97 0 962 | -87 -92 0 963 | -87 -97 0 964 | -92 -97 0 965 | -78 -83 0 966 | -78 -88 0 967 | -78 -93 0 968 | -78 -98 0 969 | -83 -88 0 970 | -83 -93 0 971 | -83 -98 0 972 | -88 -93 0 973 | -88 -98 0 974 | -93 -98 0 975 | -79 -84 0 976 | -79 -89 0 977 | -79 -94 0 978 | -79 -99 0 979 | -84 -89 0 980 | -84 -94 0 981 | -84 -99 0 982 | -89 -94 0 983 | -89 -99 0 984 | -94 -99 0 985 | -80 -85 0 986 | -80 -90 0 987 | -80 -95 0 988 | -80 -100 0 989 | -85 -90 0 990 | -85 -95 0 991 | -85 -100 0 992 | -90 -95 0 993 | -90 -100 0 994 | -95 -100 0 995 | 51 0 996 | 42 0 997 | 122 0 998 | 11 0 999 | 82 0 1000 | -65 0 1001 | -55 147 0 1002 | -60 150 0 1003 | -70 153 0 1004 | -75 154 0 1005 | -101 -57 0 1006 | -101 -62 0 1007 | -101 -67 0 1008 | -101 -72 0 1009 | -106 -52 0 1010 | -106 -62 0 1011 | -106 -67 0 1012 | -106 -72 0 1013 | -111 -52 0 1014 | -111 -57 0 1015 | -111 -67 0 1016 | -111 -72 0 1017 | -116 -52 0 1018 | -116 -57 0 1019 | -116 -62 0 1020 | -116 -72 0 1021 | -121 -52 0 1022 | -121 -57 0 1023 | -121 -62 0 1024 | -121 -67 0 1025 | -30 -81 0 1026 | -30 -86 0 1027 | -30 -91 0 1028 | -30 -96 0 1029 | -35 -76 0 1030 | -35 -86 0 1031 | -35 -91 0 1032 | -35 -96 0 1033 | -40 -76 0 1034 | -40 -81 0 1035 | -40 -91 0 1036 | -40 -96 0 1037 | -45 -76 0 1038 | -45 -81 0 1039 | -45 -86 0 1040 | -45 -96 0 1041 | -50 -76 0 1042 | -50 -81 0 1043 | -50 -86 0 1044 | -50 -91 0 1045 | -54 -83 0 1046 | -54 -88 0 1047 | -54 -93 0 1048 | -54 -98 0 1049 | -59 -78 0 1050 | -59 -88 0 1051 | -59 -93 0 1052 | -59 -98 0 1053 | -64 -78 0 1054 | -64 -83 0 1055 | -64 -93 0 1056 | -64 -98 0 1057 | -69 -78 0 1058 | -69 -83 0 1059 | -69 -88 0 1060 | -69 -98 0 1061 | -74 -78 0 1062 | -74 -83 0 1063 | -74 -88 0 1064 | -74 -93 0 1065 | -79 -108 0 1066 | -79 -113 0 1067 | -79 -118 0 1068 | -79 -123 0 1069 | -84 -103 0 1070 | -84 -113 0 1071 | -84 -118 0 1072 | -84 -123 0 1073 | -89 -103 0 1074 | -89 -108 0 1075 | -89 -118 0 1076 | -89 -123 0 1077 | -94 -103 0 1078 | -94 -108 0 1079 | -94 -113 0 1080 | -94 -123 0 1081 | -99 -103 0 1082 | -99 -108 0 1083 | -99 -113 0 1084 | -99 -118 0 1085 | -105 -8 0 1086 | -105 -13 0 1087 | -105 -18 0 1088 | -105 -23 0 1089 | -110 -3 0 1090 | -110 -13 0 1091 | -110 -18 0 1092 | -110 -23 0 1093 | -115 -3 0 1094 | -115 -8 0 1095 | -115 -18 0 1096 | -115 -23 0 1097 | -120 -3 0 1098 | -120 -8 0 1099 | -120 -13 0 1100 | -120 -23 0 1101 | -125 -3 0 1102 | -125 -8 0 1103 | -125 -13 0 1104 | -125 -18 0 1105 | -53 -57 126 0 1106 | -53 -62 127 0 1107 | -53 -67 128 0 1108 | -53 -72 129 0 1109 | -58 -52 130 0 1110 | -58 -62 131 0 1111 | -58 -67 132 0 1112 | -58 -72 133 0 1113 | -63 -52 134 0 1114 | -63 -57 135 0 1115 | -63 -67 136 0 1116 | -63 -72 137 0 1117 | -68 -52 138 0 1118 | -68 -57 139 0 1119 | -68 -62 140 0 1120 | -68 -72 141 0 1121 | -73 -52 142 0 1122 | -73 -57 143 0 1123 | -73 -62 144 0 1124 | -73 -67 145 0 1125 | -80 -29 0 1126 | -85 -34 0 1127 | -90 -39 0 1128 | -95 -44 0 1129 | -100 -49 0 1130 | -80 -34 146 0 1131 | -80 -39 147 0 1132 | -80 -44 148 0 1133 | -80 -49 149 0 1134 | -85 -29 146 0 1135 | -85 -39 150 0 1136 | -85 -44 151 0 1137 | -85 -49 152 0 1138 | -90 -29 147 0 1139 | -90 -34 150 0 1140 | -90 -44 153 0 1141 | -90 -49 154 0 1142 | -95 -29 148 0 1143 | -95 -34 151 0 1144 | -95 -39 153 0 1145 | -95 -49 155 0 1146 | -100 -29 149 0 1147 | -100 -34 152 0 1148 | -100 -39 154 0 1149 | -100 -44 155 0 1150 | -78 -28 0 1151 | -83 -33 0 1152 | -88 -38 0 1153 | -93 -43 0 1154 | -98 -48 0 1155 | -78 -33 146 0 1156 | -78 -38 147 0 1157 | -78 -43 148 0 1158 | -78 -48 149 0 1159 | -83 -28 146 0 1160 | -83 -38 150 0 1161 | -83 -43 151 0 1162 | -83 -48 152 0 1163 | -88 -28 147 0 1164 | -88 -33 150 0 1165 | -88 -43 153 0 1166 | -88 -48 154 0 1167 | -93 -28 148 0 1168 | -93 -33 151 0 1169 | -93 -38 153 0 1170 | -93 -48 155 0 1171 | -98 -28 149 0 1172 | -98 -33 152 0 1173 | -98 -38 154 0 1174 | -98 -43 155 0 1175 | -------------------------------------------------------------------------------- /book/chapters/3.tex: -------------------------------------------------------------------------------- 1 | \chapter{Fuzzy Logic} 2 | 3 | \begin{chapquote}{Vladimir Ilyich Ulyanov} 4 | ``A lie told often enough becomes the truth.'' 5 | \end{chapquote} 6 | 7 | 8 | \section{Basic concepts} 9 | 10 | In the previous two chapters, we have been inquiring into 11 | the issue of satisfiability of propositional calculus. 12 | We expressed the notion of satisfiability by means of the 13 | notions of truth and falsehood, that were represented 14 | by the Scheme special values \texttt{\#t} and \texttt{\#f}. 15 | 16 | It is customary however to represent these notions using 17 | numerical values: truth is usually represented using $1$, 18 | and falsehood -- using $0$. If we view it that way, the 19 | conjunction can be perceived as a particular case of the 20 | \textit{minimum} function, and disjunction -- as an 21 | instance of the \textit{maximum} function. Furthermore, 22 | the negation can be interpreted as the function $1-x$, where 23 | $x$ is the logical value of the negated formula. 24 | 25 | This observation could prompt someone to allow propositional 26 | formulas to take any real value between $0$ and $1$, for 27 | example $0.785398$, because then the basic junctions would 28 | generalize naturally to support those values. 29 | 30 | However unrealistic it may sound, this actually happened: 31 | in the 1960s, Lotfi Zadeh proposed a theory of \textit{fuzzy 32 | sets}, where the aforementioned observation found its 33 | application. Unlike in the traditional set theory, where 34 | a given element either belongs to a given set, or it does 35 | not, Zadeh proposed a theory where an element can belong 36 | to a set with a certain \textit{degree}, and each set 37 | is characterized with a \textit{membership function} 38 | that describes how certain elements (usually being real 39 | numbers) belong -- or not -- to that set. 40 | 41 | \section{Criticism} 42 | 43 | Having formulated a theory, Zadeh tried to find an application 44 | for it. Therefore he announced that his theory models the way 45 | in which \textit{vague expressions} behave in the natural 46 | language, and how people perform \textit{approximate reasoning}. 47 | 48 | Worst of all, Zadeh really believed it. In the justification 49 | of his work, he claimed that ``a natural language is basically 50 | a system for describing perceptions''\cite{Zadeh2008}, not 51 | even caring how is the sentence ``a natural language is basically 52 | a system for describing perceptions'' a description of 53 | a perception. Reading Zadeh's work, one gets the sense that, 54 | trying to prove the value of his idea, he indeed started to 55 | reason in a vague and imprecise way. 56 | 57 | Among the examples that Zadeh gives is the notion of ``tallness''. 58 | For example, most people will admit that a person that is 59 | two-meters tall could be called a tall person. On the other 60 | hand, if a person has $1.5$ meter, he will unlikely be called 61 | a tall person. It is however impossible to set the limit between 62 | the height to be considered tall and non-tall: we are more 63 | likely to admit that the shift between tallness and non-tallness 64 | occurs gradually. 65 | 66 | Zadeh claims that the accurate description is to provide 67 | a membership function that would describe the interpolation 68 | between tallness and its negation. 69 | 70 | The problem is that there could be many competing 71 | membership functions that differ only in some tiny details, 72 | but there is no criterion to prefer any one of these functions 73 | over another. 74 | 75 | A deeper problem is that the whole ``thought experiment'' 76 | makes absolutely no sense: those seemingly ``vague'' 77 | descriptions usually serve the practical purpose 78 | of designating an object of interest. We have no problem 79 | understanding an expression ``the tall midget'' when 80 | presented a group of midgets of varying height. But we 81 | are rarely faced with the task of demarcating between 82 | being tall and being non--tall. 83 | 84 | Although the notion of fuzzy logic is very susceptible to 85 | criticism that it has been receiving ever since it was 86 | formulated, for some reason it also received a lot of attention 87 | among people who dealt with Artificial Intelligence, and 88 | some practical tools were built based on that theory 89 | (It may be impressive to some that this actually succeeded, 90 | but in practice the results were usually much less 91 | efficient than they could be if the classical control 92 | theory was applied). 93 | Because of that, it will also be presented here, albeit 94 | in a rather flaccid way. 95 | 96 | \section{Exposition} 97 | 98 | The remainder of this chapter will assume some basic 99 | intuitions concerning real-valued functions of real variables. 100 | The humanity won't suffer if you decide to skip it. (Make 101 | however sure to read the section regarding the notion of 102 | \texttt{equivalence-classes}.) 103 | 104 | Also, if you wish to get a detailed explanation of the presented 105 | method, it's best if you look elsewhere. 106 | 107 | We will use fuzzy logic to implement a virtual 108 | \textit{underwriter}, whose purpose is to give 109 | a rating of potential clients for an insurance agency 110 | based on a set of parameters, such as \textit{Body-Mass Index}, 111 | the level of \textit{glycated hemoglobin} in organism 112 | or the \textit{blood pressure}. 113 | 114 | The underwriter performs the inference based on a set 115 | of \textit{fuzzy rules}, like ``if BMI is \textit{underweight} 116 | or BMI is \textit{obese} or the glycated hemoglobin level is 117 | \textit{low}, then the rating is \textit{refuse}''. 118 | 119 | We could define the set of rules for the considered problem 120 | in the following way. 121 | 122 | \begin{Snippet} 123 | (define underwriter-rules 124 | '((if (or (is bmi underweight) (is bmi obese) 125 | (is glycated-hemoglobin low)) 126 | (is rating refuse)) 127 | (if (or (is bmi overweight) (is glycated-hemoglobin low) 128 | (is blood-pressure slight-overpressure)) 129 | (is rating standard)) 130 | (if (and (is bmi healthy) (is glycated-hemoglobin normal) 131 | (is blood-pressure normal)) 132 | (is rating preferred)))) 133 | \end{Snippet} 134 | 135 | An inquisitive reader could ask an uncomfortable question: 136 | why should we consider this set of rules as valid, rather 137 | than some other one? The slack-off answer is that this 138 | particular set was specified by an experienced professional 139 | who encoded his or her intuitions acquired throughout the 140 | years of practice. 141 | 142 | Now we need to define what it means for the glycated hemoglobin 143 | to be normal or low: 144 | 145 | \begin{Snippet} 146 | (define health-categories 147 | `((bmi (underweight ,(gaussian 9.25 3.0)) 148 | (healthy ,(gaussian 21.75 3.0)) 149 | (overweight ,(gaussian 27.5 3.0)) 150 | (obese ,(gaussian 35.0 3.0))) 151 | (glycated-hemoglobin (low ,(cone 4.0 5.0)) 152 | (normal ,(cone 5.25 5.0)) 153 | (high ,(cone 7.0 5.0))) 154 | (blood-pressure (normal ,(gaussian 0.0 2.5)) 155 | (slight-overpressure ,(gaussian 10.0 2.5)) 156 | (overpressure ,(gaussian 20.0 2.5)) 157 | (high-overpressure ,(gaussian 30.0 2.5))) 158 | (rating (refuse ,(cone 10.0 5.0)) 159 | (standard ,(cone 5.0 5.0)) 160 | (preferred ,(cone 1.0 5.0))))) 161 | \end{Snippet} 162 | 163 | An inquisitive reader could ask an uncomfortable question: 164 | what makes us choose these shapes of membership functions 165 | rather than some other ones? The slack-off answer would be 166 | that the data was prepared and evaluated by a team of 167 | highly educated medical experts who spent years studying 168 | the complicated machinery of human body and now are able 169 | to present their knowledge and linguistic intuitions 170 | in a highly digestive form of a few functions of a single 171 | variable. Even if you didn't trust that guy from the 172 | insurance, it would be insane not to trust the medicals, 173 | or wouldn't it? 174 | 175 | \begin{tikzpicture} 176 | \begin{axis}[ 177 | title=Body-Mass Index Categories (gaussian), 178 | xlabel=BMI, 179 | ylabel=membership, 180 | legend entries={underweight, healthy, overweight, obese}, 181 | width = 4.5in, 182 | height = 2in 183 | ] 184 | \addplot[ % underweight 185 | yellow, 186 | domain=0:80, 187 | samples=201, 188 | ] 189 | {exp(-(x-9.25)^2 / 18)}; 190 | 191 | \addplot[ % healthy 192 | green, 193 | domain=0:50, 194 | samples=201, 195 | ] 196 | {exp(-(x-21.75)^2 / 18)}; 197 | 198 | \addplot[ % overweight 199 | blue, 200 | domain=0:50, 201 | samples=201, 202 | ] 203 | {exp(-(x-27.5)^2 / 18)}; 204 | 205 | \addplot[ % obese 206 | red, 207 | domain=0:50, 208 | samples=201, 209 | ] 210 | {exp(-(x-35.0)^2 / 18)}; 211 | 212 | \end{axis} 213 | \end{tikzpicture} 214 | 215 | \begin{tikzpicture}[ 216 | declare function={ 217 | cone(\x) = and(\x>=-1,\x<0)*(\x+1) + and(\x>=0,\x<1)*(1-\x); 218 | } 219 | ] 220 | \begin{axis}[ 221 | title=Glycated Hemoglobin Categories (cone), 222 | xlabel=Glycated Hemoglobin, 223 | ylabel=membership, 224 | legend entries={low,normal,high}, 225 | width = 4.5in, 226 | height = 2in 227 | ] 228 | \addplot[ % low 229 | blue, 230 | domain=0:20, 231 | samples=201, 232 | ] 233 | {cone((x-4)/5)}; 234 | 235 | \addplot[ % normal 236 | green, 237 | domain=0:20, 238 | samples=201, 239 | ] 240 | {cone((x-5.25)/5)}; 241 | 242 | \addplot[ % high 243 | red, 244 | domain=0:20, 245 | samples=201, 246 | ] 247 | {cone((x-7)/5)}; 248 | 249 | \end{axis} 250 | \end{tikzpicture} 251 | 252 | 253 | It should be instructive to see the plots of at least some of 254 | the membership functions, to appeal to our visual intuitions. 255 | Also, for the practical purposes it is inevitable to define the 256 | formulas for the cone and the gaussian curve: 257 | 258 | \begin{Snippet} 259 | (define ((gaussian center deviation) x) 260 | (exp (- (/ (square (- x center)) 261 | (* 2 (square deviation)))))) 262 | \end{Snippet} 263 | \begin{Snippet} 264 | (define ((cone center radius) x) 265 | (cond ((<= x (- center radius)) 266 | 0) 267 | ((<= x center) 268 | (/ (+ x (- radius center)) radius)) 269 | ((< x (+ center radius)) 270 | (/ (+ (- x) center radius) radius)) 271 | (else 272 | 0))) 273 | \end{Snippet} 274 | 275 | In the definition of \texttt{gaussian} we refer to the 276 | built-in exponential function \texttt{(exp x)}, or $e^{x}$. 277 | 278 | The definition of the \texttt{cone} function contains 279 | a \texttt{cond} clause that we haven't seen before. It 280 | is actually a variant of the \texttt{if} instruction 281 | that we're already familiar with, and the definition 282 | could as well have been written using the following form: 283 | 284 | \begin{Snippet} 285 | (define ((cone center radius) x) 286 | (if (<= x (- center radius)) 287 | 0 288 | (if (<= x center) 289 | (/ (+ x (- radius center)) radius) 290 | (if (< x (+ center radius)) 291 | (/ (+ (- x) center radius) radius) 292 | 0)))) 293 | \end{Snippet} 294 | 295 | It is apparent that the form using \texttt{if} 296 | has a more complex structure because of the 297 | higher nesting level. 298 | 299 | As all the rules and words' meanings are already known, 300 | the only thing that's left is to actually conduct the 301 | inference: given a tuple of labeled parameters describing 302 | a \texttt{patient}, say, \texttt{((bmi 29) (glycated-hemoglobin 5) 303 | (blood-pressure 20))}, we wish to provide a desired rating for it. 304 | In other words, want to \texttt{(infer \#;from underwriter\--rules 305 | \#;about patient \#;within health-categories)}. 306 | 307 | First, we need to say to what \texttt{extent} does a 308 | \texttt{patient} belong to a given classes: for example, 309 | according to the membership functions defined above, 310 | the BMI parameter of $29$ may be considered \textit{overweight} 311 | with the degree $0.88$, \textit{obese} with the degree $0.13$, 312 | \textit{healthy} with the degree $0.05$ and \textit{underweight} 313 | with a degree very close to $0$. 314 | 315 | So it would be convenient to have a function that, for 316 | a given labeled tuple, returns the extent in which the 317 | tuple's values belong to certain classes defined within 318 | specified categories. It could also be handy if the classes 319 | were sorted, so that the classes to which a given values 320 | ``belongs more'' would appear earlier on the list. 321 | 322 | \begin{Snippet} 323 | (define (extent #;in-which entity #;belongs-to categories) 324 | (map (lambda ((property value)) 325 | (let* ((category (lookup property categories)) 326 | (classes (map (lambda ((name extent)) 327 | `(,name ,(extent value))) 328 | category))) 329 | `(,property . ,(sort classes 330 | (lambda ((_ degree-1) (_ degree-2)) 331 | (> degree-1 degree-2)))))) 332 | entity)) 333 | \end{Snippet} 334 | \begin{Snippet} 335 | (e.g. 336 | (extent '((bmi 29) (glycated-hemoglobin 5) (blood-pressure 20)) 337 | health-categories) 338 | ===> ((bmi (overweight 0.8824969025845955) 339 | (obese 0.1353352832366127) 340 | (healthy 0.053926197030622854) 341 | (underweight 3.879522352578383e-10)) 342 | (glycated-hemoglobin (normal 0.95) (low 0.8) (high 0.6)) 343 | (blood-pressure (overpressure 1.0) 344 | (slight-overpressure 3.3546262790251185e-4) 345 | (high-overpressure 3.3546262790251185e-4) 346 | (normal 1.2664165549094176e-14)))) 347 | \end{Snippet} 348 | 349 | Probably the most surprising is the use of the \texttt{e.g.} form. 350 | This is a syntactic extension that serves as a lightweight 351 | \textit{unit test} framework: it evaluates the function before 352 | the \texttt{===>} sign and raises an error condition if 353 | its value isn't \texttt{equal?} to the value on the right. 354 | It therefore enhances the reliability of the system, because 355 | we have a confirmation that our function works as expected. 356 | 357 | More importantly, it enriches the code with the information that 358 | is more concrete and easier to digest than the sole definition, 359 | because it shows exactly, which outputs can be expected for 360 | given inputs. 361 | 362 | The example could not be comprehended in the absence of 363 | the definition of \texttt{health-categories}, but it shows 364 | us what kind of output from the function we should expect, 365 | which in turn prompts us with the idea of how this output 366 | should be processed further. 367 | 368 | We ought to take another look at our \texttt{underwriter\--rules}. 369 | They all take the form 370 | 371 | \texttt{`(if ,condition (is ,property ,classification))} 372 | 373 | where \texttt{condition} either has a form 374 | 375 | \texttt{`(is ,property ,classification)} 376 | 377 | or is a junction (i.e. conjunction, disjunction or negation) 378 | of simpler formulas. In the first case, say, 379 | \texttt{(is bmi overweight)} we evaluate it to the extent 380 | in which the BMI belongs to the set ``overweight''. 381 | In the particular case of BMI being equal $29$, it will 382 | be the value of approx. $0.82$. 383 | 384 | In the case of the junction of formulas, we evaluate 385 | it according to the rules given above: conjunction 386 | is the minimum function, disjunction -- the maximum 387 | function, and negation -- the $1-x$ function. 388 | Note the resemblance between the below 389 | \texttt{satisfaction-degree} function and 390 | the definition \texttt{satisfied?} from the earlier chapters. 391 | 392 | \begin{Snippet} 393 | (define (satisfaction-degree formula interpretation) 394 | (match formula 395 | (('and . clauses) 396 | (minimum (map (lambda (clause) 397 | (satisfaction-degree clause interpretation)) 398 | clauses))) 399 | (('or . clauses) 400 | (maximum (map (lambda (clause) 401 | (satisfaction-degree clause interpretation)) 402 | clauses))) 403 | (('not clause) 404 | (- 1.0 (satisfaction-degree clause interpretation))) 405 | (('is property classification) 406 | (let* ((classifications (lookup property interpretation)) 407 | ((extent) (lookup classification classifications))) 408 | extent)))) 409 | \end{Snippet} 410 | \begin{Snippet} 411 | ;; where 412 | (define (maximum list) 413 | (match list 414 | ((last) 415 | last) 416 | ((first . rest) 417 | (max first (maximum rest))))) 418 | 419 | (define (minimum list) 420 | (match list 421 | ((last) 422 | last) 423 | ((first . rest) 424 | (min first (minimum rest))))) 425 | \end{Snippet} 426 | 427 | We defined two auxiliary functions that designate 428 | the \texttt{minimum} and \texttt{maximum} of the list, 429 | using the built-in \texttt{min} and \texttt{max} 430 | functions that return the largest of its arguments. 431 | As we will see in the following chapters, that definition 432 | wasn't strictly necessary. 433 | 434 | Now that we can determine the \texttt{satisfaction-degree} 435 | of a given predicative formula, we have a set of rules 436 | and the preconditions of those rules, the only thing 437 | that is left is to conduct the inference. 438 | 439 | This is actually the trickiest part, as it is concerned 440 | with a notion (or rather pseudo-notion) of \textit{defuzzification}. 441 | Let me remind that the \texttt{underwriter\--rules} consist 442 | of three rules, corresponding to three possible classifications 443 | of \texttt{rating}: \texttt{standard}, \texttt{perfect} and 444 | \texttt{refuse}. For example, the first rule said: 445 | 446 | \begin{Snippet} 447 | (if (or (is bmi underweight) (is bmi obese) 448 | (is glycated-hemoglobin low)) 449 | (is rating refuse)) 450 | \end{Snippet} 451 | 452 | 453 | We need to blend those three rules, based on the extents 454 | of their preconditions, in order to choose the ``right'' 455 | classification. 456 | 457 | One idea would be to choose the rule whose precondition 458 | is the highest \texttt{satisfaction-degree}. However, according 459 | to Wikipedia, ``this approach loses information''. Therefore 460 | another method is used: first we clip the membership functions 461 | for the various classes of the category \texttt{rating}, so that 462 | their values are limited to the satisfaction-degrees, then 463 | we create a new function that gives the maximum of each of the 464 | clipped functions, and finally we apply some numerical method 465 | like calculation of the \textit{center of gravity} of the function 466 | (Wikipedia lists 20 other defuzzification functions, each of them being 467 | equally arbitrary, none of them having any apparent advantages 468 | over the another). 469 | 470 | \begin{Snippet} 471 | (define (infer #;from rules #;about entity #;within categories) 472 | (let* ((judgment (extent entity categories)) 473 | (conclusions 474 | (map 475 | (lambda (('if condition ('is property classification))) 476 | (let* ((degree (satisfaction-degree condition judgment)) 477 | (categories (lookup property categories)) 478 | ((membership) (lookup classification categories)) 479 | (conclusion (clip membership 0 degree))) 480 | `(,property ,conclusion))) 481 | rules)) 482 | (common-subject (equivalence-classes 483 | (lambda ((property-1 _) (property-2 _)) 484 | (eq? property-1 property-2)) 485 | conclusions))) 486 | (map (lambda (((properties functions) ...)) 487 | (let* (((property . _) properties) 488 | (composition (lambda (x) 489 | (maximum (map (lambda (f) 490 | (f x)) 491 | functions))))) 492 | `(,property ,composition))) 493 | common-subject))) 494 | \end{Snippet} 495 | 496 | The code above is somewhat terse, and requires a bit of explanation. 497 | First we calculate the \texttt{judgment} using the \texttt{condition} 498 | function. The \texttt{judgment} therefore contains a list of the 499 | form \texttt{'((bmi (overweight 0.9) (normal 0.1) ...) 500 | (glycated-hemoglobin (normal 0.9) ...) ...)}. Then for each rule 501 | we decompose it into \texttt{condition} and the consequent of the form 502 | \texttt{('is property classification)}, so for example, the name 503 | \texttt{condition} can be bound to the sequence 504 | \texttt{'(or (is bmi underweight) (is bmi obese) 505 | (is glycated-hemoglobin low))}, \texttt{property} is bound to 506 | \texttt{'rating}, and \texttt{classification} is bound to 507 | \texttt{'refuse}. Then we take the \texttt{membership} function 508 | for the given \texttt{property} and \texttt{classification} pair. 509 | In the case of \texttt{rating}, \texttt{refuse} it is the 510 | \texttt{(cone 10.0 5.0)} function. Eventually we return a pair with 511 | the name of the classification and the clipped membership function. 512 | 513 | Note that although it isn't the case with our example, we could in 514 | general have more properties than just \texttt{rating} contained 515 | in the consequents of our rules. Therefor we would need to split 516 | the rules that refer to the same property. This is what the 517 | \texttt{equivalence-classes} concept is for. In general, it takes 518 | a set and the so-called \textit{equivalence relation}\footnote{ 519 | Intuitively, an equivalence relation expresses some sort of common 520 | property, like ``$X$ is of the same religion as $Y$''. This 521 | particular relation divides humans into equivalence classes such 522 | as Buddhists, Christians, Jews, Muslims, and so on, which 523 | leads to many pointless wars.} and returns a list of lists whose 524 | elements all belong to the same equivalence class. 525 | 526 | For example, if we had a list of natural numbers, say, 527 | \texttt{(1 2 3 4 5 6 7 8 9)}, then its equivalence classes 528 | for the equivalence relation ``$x$ and $y$ have the same 529 | remainder of the division by $3$'' would be a list of three 530 | lists: \texttt{((1 4 7) (2 5 8) (3 6 9))}. 531 | 532 | Although the notion of \texttt{equivalence-classes} isn't essential 533 | for this particular task, it will be used later, so I will present 534 | the code here without any comments, except the note that it preserves 535 | the original order among the elements of the classes, and the 536 | observation that it uses the so-called \textit{named-let} construct 537 | that won't be covered in this pamphlet. The explanation isn't 538 | difficult to find with Google. 539 | 540 | \begin{Snippet} 541 | (define (equivalence-classes equivalent? set) 542 | (let next-item ((set set)(result '())) 543 | (match set 544 | (() 545 | (reverse (map reverse result))) 546 | ((item . set) 547 | (match result 548 | (() 549 | (next-item set `((,item) . ,result))) 550 | ((this . next) 551 | (let next-class ((past '()) (present this) (future next)) 552 | (match present 553 | ((paradigm . _) 554 | (if (equivalent? item paradigm) 555 | (next-item set `((,item . ,present) 556 | . (,@past ,@future))) 557 | (match future 558 | (() 559 | (next-item set `((,item) ,@result))) 560 | ((this . next) 561 | (next-class `(,present . ,past) this next))) 562 | ))) 563 | ))))))) 564 | \end{Snippet} 565 | 566 | Having the conclusions split into \texttt{equivalence-classes} 567 | of conclusions that regard the same \texttt{property}, we create 568 | a \texttt{composition} of the clipped functions of \texttt{membership} 569 | to given \texttt{classification}s, which are constructed by 570 | selecting the \texttt{maximum} value of each of the component 571 | functions. 572 | 573 | The only thing that may be unknown at this point is what it means 574 | to \texttt{clip} a function. This is rather straightforward: 575 | 576 | \begin{Snippet} 577 | (define ((clip function bottom top) x) 578 | (assert (<= bottom top)) 579 | (max bottom (min top (function x)))) 580 | \end{Snippet} 581 | 582 | The \texttt{infer} function returns a list of form 583 | \texttt{((property function) ...)}. In order to get 584 | the classifications of the \texttt{property} values, 585 | we need to defuzzify each \texttt{function}. 586 | 587 | We are going to use the aforementioned method of 588 | computing the \texttt{center\--of\--gravity}. This 589 | method is based on \textit{numerical integration} 590 | that will not be covered here. 591 | 592 | \begin{Snippet} 593 | (with-default ((bottom 0) 594 | (top 100) 595 | (step 0.1)) 596 | (define (center-of-gravity function) 597 | (let* ((step (specific step)) 598 | (domain (range #;from (specific bottom) 599 | #;to (specific top) #;by step))) 600 | (/ (sum (map (lambda (x) (* x (function x) step)) domain)) 601 | (sum (map (lambda (x) (* (function x) step)) domain)))))) 602 | ;; where 603 | (define (range #;from bottom #;to top #;by step) 604 | (if (> bottom top) 605 | '() 606 | `(,bottom . ,(range #;from (+ bottom step) #;to top #;by step)))) 607 | \end{Snippet} 608 | 609 | The surprising thing is the use of the \texttt{with-default} derived 610 | form. It is used to give some default values to certain names, 611 | but without committing to those values. The form will be explained 612 | in one of the later chapters. 613 | 614 | Finally, we can evaluate the expression 615 | 616 | \begin{Snippet} 617 | (let* ((conclusions (infer #;from underwriter-rules 618 | #;about '((bmi 29) 619 | (glycated-hemoglobin 5) 620 | (blood-pressure 20)) 621 | #;within health-categories))) 622 | (map (lambda ((property function)) 623 | `(,property ,(center-of-gravity function))) 624 | conclusions)) 625 | \end{Snippet} 626 | 627 | to find out that the \texttt{rating} received by our candidate is $7.46$. 628 | In other words, we passed along some numbers to receive yet another number. 629 | -------------------------------------------------------------------------------- /book/chapters/2.tex: -------------------------------------------------------------------------------- 1 | \chapter{Genetic Algorithms} 2 | 3 | \begin{chapquote}{Richard Dawkins} 4 | ``It is absolutely safe to say that if you meet somebody who claims 5 | not to believe in [what Richard Dawkins claims to believe], that 6 | person is ignorant, stupid or insane.'' 7 | \end{chapquote} 8 | 9 | In the previous chapter, we defined what it means for a 10 | proposition to be satisfied under a given valuation. 11 | We also said informally, what it means for a propositional 12 | logic formula to be satisfiable -- namely, that there exists 13 | a valuation such that the formula is satisfied. 14 | 15 | This formulation is rather easy to comprehend, but in practice 16 | the amount of checks that we may need to perform to see if 17 | a formula is satisfiable may grow exponentially with the number 18 | of atomic propositions occurring in the formula: adding another 19 | atomic proposition doubles the number of possibilities, so the 20 | problem quickly becomes intractable. 21 | 22 | The problem isn't just theoretical. Although propositional 23 | calculus is extremely simple, it has some useful practical 24 | applications in software verification. 25 | 26 | Besides, despite the fact that the general solutions fail 27 | for more complex formulas, one can frequently find some 28 | \textit{heuristics} that perform very well for the most 29 | common cases. 30 | 31 | \section{Biological inspiration} 32 | 33 | One of such heuristics is called \textit{genetic algorithms}. 34 | It is inspired by the process of natural selection. Most 35 | generally, the idea is to encode the solution as a sequence 36 | of \textit{chromosomes} that behave as binary switches, where 37 | each switch splits the search space in half. 38 | 39 | The solutions are searched in larger groups called 40 | \textit{populations}. Each specimen of a population 41 | is evaluated using a so-called \textit{fitness function}, 42 | which measures the quality of a solution. Rather than 43 | deciding that a given specimen is either good or bad, 44 | the fitness function assigns it a grade. 45 | 46 | \subsection{Chromosomal crossover} 47 | 48 | During the evolution process, the best solutions are 49 | combined with each other, and the worst ones are rejected. 50 | The hope is that if we combine a few individuals into 51 | a new one, it has a chance to inherit the good traits 52 | of its originals. In practice, the chromosomes 53 | of couples of the best specimens from the population 54 | are recombined in a \textit{crossing-over} process: 55 | therefore the new individuals can be regarded as 56 | an offspring of the old ones. 57 | 58 | The crossing-over can be defined as a function that takes 59 | two chromosomes, splits them at a random point and returns 60 | a new one composed of the prefix of the first one and 61 | the suffix of the second: 62 | 63 | \begin{Snippet} 64 | (define (cross-over daddy mommy) 65 | (assert (= (length daddy) (length mommy))) 66 | (let* ((position (random (length daddy))) 67 | (sperm (take daddy position)) 68 | (ovum (drop mommy position))) 69 | `(,@sperm ,@ovum))) 70 | \end{Snippet} 71 | 72 | Of the things that deserve attention, the first one is the 73 | presence of an \textit{assertion}. An assertion essentially 74 | does nothing more than informing the reader about the 75 | assumptions that the author made about the intended usage 76 | of a function -- in this particular case, he assumed that 77 | the two arguments -- \texttt{mommy} and \texttt{daddy} 78 | -- are lists of equal length. 79 | 80 | Then we choose a random\footnote{Each occurrence of the 81 | \texttt{(random n)} expression can be replaced with 82 | a value randomly chosen from the range $0$ to $n-1$. 83 | This \textit{indeterminism} is the main reason why 84 | I prefer the term \textit{expression-based programming} 85 | to \textit{functional programming}. Disallowing such 86 | non-deterministic expressions would make many simple 87 | things complex.} position from the range between 88 | $0$ and \textit{the length of chromosome} minus $1$. 89 | We use the prefix of the \texttt{daddy} chromosome (for 90 | example, if \texttt{daddy} is \texttt{(a\,b\,c\,d\,e)}, then 91 | \texttt{(take daddy 3)} evaluates to \texttt{(a\,b\,c)}) 92 | and the suffix of the \texttt{mommy} chromosome (similarly, 93 | if \texttt{mommy} is \texttt{(u\,v\,w\,x\,y)}, then 94 | \texttt{(drop mommy 3)} evaluates to \texttt{(x\,y)}). 95 | 96 | Finally, we construct a new list from the prefix and the 97 | suffix. 98 | 99 | Now that we've seen the intimate details of copulation, 100 | we can have a look at the process from the social perspective. 101 | 102 | \subsection{The ceremony of procreation} 103 | 104 | Whether a given specimen becomes a daddy or a mommy is 105 | a matter of luck, and it may happen that the same specimen 106 | serves as a mommy during an intercourse with one partner, 107 | and as a daddy with another. It is important however, that the 108 | specimen with the high social status (i.e. better fitness 109 | function) procreate more often than the ragtag. 110 | 111 | Also, contrary to what many catholic priests say, it is 112 | perfectly fine when a specimen copulates with itself: 113 | when it happens, its child is an exact copy of its sole 114 | parent (however in practice this privilege is reserved 115 | to the elite). 116 | 117 | The ceremony proceeds as follows. First, a census is prepared, 118 | where each member of the population is assigned a value 119 | of a fitness function. Then, the census is sorted according 120 | to that value. Subsequently, the lottery drawing occurs, where each 121 | member of the population draws an opportunity to copulate. 122 | A single specimen can appear on the list more than once, and 123 | the probability of being enrolled to the list is higher for 124 | the specimens that are higher on the list. The length of 125 | the list equals the population. 126 | 127 | Finally, each one of those lucky beggars is assigned a partner 128 | from another list generated in the same way (so, as it was said 129 | before, it can happen that the he-and-she spends the night with 130 | a \textit{very} familiar company), and then the new generation 131 | comes to the fore. 132 | 133 | This cycle can repeat for a few hundreds of times or more, until 134 | the best man from the population is satisfactory to its 135 | transcendent creator. 136 | 137 | It can also happen, say, once in a generation on average, 138 | that a chromosome of a specimen is mutated. 139 | 140 | The social perspective on the ceremony of copulation can 141 | be expressed in Scheme in the following way: 142 | 143 | \begin{Snippet} 144 | (define (procreate population social-status) 145 | (let* ((census (map (lambda (specimen) 146 | `(,(social-status specimen) . ,specimen)) 147 | population)) 148 | (social-ladder (sort census (lambda ((a . _) (b . _)) 149 | (> a b)))) 150 | (population (map (lambda ((status . specimen)) specimen) 151 | social-ladder)) 152 | (size (length population)) 153 | (males (biased-random-indices size)) 154 | (females (shuffle (biased-random-indices size))) 155 | (offspring (map (lambda (man woman) 156 | (cross-over (list-ref population man) 157 | (list-ref population woman))) 158 | males females))) 159 | (map (on-average-once-in size (mutate #;using not)) offspring))) 160 | \end{Snippet} 161 | 162 | Note that the arguments to \texttt{lambda} provided to the \texttt{sort} 163 | function are destructured (pattern-matched) in place. This is a convenient 164 | syntactic extension to Scheme that replaces the built-in \texttt{lambda}. 165 | 166 | Also, we provided three arguments to \texttt{map}, rather than two 167 | -- one function of two arguments and two lists. The value of the expression 168 | will be a list whose elements are values of the function for the first element 169 | from the first list and the first element of the second list, the 170 | second element of the first list and the second element of the second 171 | list, and so on. It is assumed that the length of both lists is the 172 | same -- and that will also be the length of the result. 173 | 174 | We will learn how to define functions of variable number of arguments 175 | later. For now it is sufficient to know that it is possible to do so, 176 | which can often be convenient. 177 | 178 | It is apparent that the \texttt{cross-over} function is given two 179 | arguments that result from the invocation of the built-in \texttt{list-ref} 180 | function, which takes a list of length $n>0$ and an index $i$ (starting 181 | from $0$) and returns the $i$-th element of the list. 182 | 183 | The procedure \texttt{biased-random-indices} generates a list of 184 | indices with the desired distribution: 185 | 186 | \begin{Snippet} 187 | (define (biased-random-indices size) 188 | (if (= size 0) 189 | '() 190 | `(,(random size) . ,(biased-random-indices (- size 1))))) 191 | \end{Snippet} 192 | 193 | The length of the generated list will be \texttt{size}. 194 | Furthermore, the index $0$ is guaranteed to appear on the list 195 | as the last element, has a $50\%$ chance to appear as the 196 | penultimate element, one third to appear one before, and so 197 | on, so it will almost certainly appear on the list more than 198 | once. On the other hand, the last index can appear only 199 | as the first element of the list, but this opportunity 200 | is shared evenly by all the other indices, so it is rather 201 | unlikely that it will ever happen. This strategy is called 202 | ``equal opportunity policy'' by the social ideologies. 203 | 204 | Two separate lists are created for \texttt{males} 205 | and \texttt{females}. In order to increase the variation 206 | of the population, the list of \texttt{females} is shuffled, 207 | which gives them a chance to advance to the upper class. 208 | 209 | The shuffling proceeds as follows: if the list has more 210 | than one element, then a random pivot point is chosen, 211 | and the (recursively shuffled) sub-lists are swapped with 212 | a $50\%$ probability. Otherwise the shuffled list is 213 | identical with the original one. 214 | 215 | \begin{Snippet} 216 | (define (shuffle l) 217 | (match (length l) 218 | (0 '()) 219 | (1 l) 220 | (n (let ((left right (split-at l (random n)))) 221 | (if (= (random 2) 1) 222 | `(,@(shuffle right) ,@(shuffle left)) 223 | `(,@(shuffle left) ,@(shuffle right))))))) 224 | \end{Snippet} 225 | 226 | The last thing that requires an explanation is the mutation. 227 | We wish it to occur on average once per generation, therefore 228 | we define a function that applies a given function with 229 | a probability $\frac{1}{n}$ for a given $n$, where $n$ is 230 | a positive integer: 231 | 232 | \begin{Snippet} 233 | (define ((on-average-once-in n action) arg) 234 | (assert (and (integer? n) (> n 0))) 235 | (if (= (random n) 0) 236 | (action arg) 237 | arg)) 238 | \end{Snippet} 239 | 240 | The \texttt{action} of \texttt{mutation} that we wish to apply 241 | inverts the random chromosome: 242 | 243 | \begin{Snippet} 244 | (define ((mutate how) specimen) 245 | (let* ((n (random (length specimen))) 246 | (mutation (how (list-ref specimen n)))) 247 | (alter #;element-number n #;in specimen #;with mutation))) 248 | \end{Snippet} 249 | 250 | The meaning \texttt{(alter n l value)} is a list that contains 251 | all the same elements as \texttt{l}, except its \texttt{n}-th 252 | element, which has a new \texttt{value}. 253 | 254 | \subsection{Evolution} 255 | 256 | The struggles of a sole generation in the quest for the perfect 257 | society are unlikely to bring satisfactory results (especially 258 | if these struggles boil down to copulation). Only within 259 | the span of many lifetimes can the true value arise. It is 260 | entirely up to the creator to decide many cycles of lives 261 | and deaths will the world witness, how complex can its inhabitants 262 | be, and how many of them will be brought to existence. 263 | 264 | \begin{Snippet} 265 | (define (evolve population #;towards criterion #;for iterations) 266 | (assert (and (integer? iterations) (>= iterations 0))) 267 | (if (<= iterations 0) 268 | population 269 | (evolve (procreate population criterion) 270 | #;towards criterion 271 | #;for (- iterations 1)))) 272 | \end{Snippet} 273 | \begin{Snippet} 274 | (define (generate-specimen dimension) 275 | (generate-list dimension (lambda () (= (random 2) 0)))) 276 | \end{Snippet} 277 | \begin{Snippet} 278 | (define (generate-population size dimension) 279 | (generate-list size (lambda () (generate-specimen dimension)))) 280 | \end{Snippet} 281 | \begin{Snippet} 282 | (define (optimize dimension population-size iterations criterion) 283 | (let* ((population (generate-population population-size dimension)) 284 | (modern-society (evolve population #;towards criterion 285 | #;for iterations))) 286 | (argmax criterion modern-society))) 287 | \end{Snippet} 288 | 289 | The \texttt{generate-list} procedure takes a \texttt{lambda} expression 290 | of no arguments that evaluates nondeterministically to some value 291 | (in our case, it is either logical truth or logical falsehood) 292 | and generates a list containing a specified number of results of 293 | such evaluation: 294 | \begin{Snippet} 295 | (define (generate-list n generator) 296 | (assert (and (integer? size) (>= size 0))) 297 | (if (= n 0) 298 | '() 299 | `(,(generator) . ,(generate-list (- n 1) generator)))) 300 | \end{Snippet} 301 | 302 | Lastly, the \texttt{argmax} is a library function that takes 303 | a measure function and a list and evaluates to the element of the 304 | list that has the greatest measure. 305 | 306 | \section{Solving the SAT} 307 | 308 | In the previous section, we have presented a heuristic 309 | for optimizing certain problems with reasonable (linear) 310 | computational means. In this section, we will apply that 311 | heuristic to the problem of satisfiability in propositional 312 | logic. 313 | 314 | \subsection{Parsing DIMACS CNF files} 315 | 316 | We are not going to operate in vacuum -- there are many 317 | resources on the Web that provide the information and databases 318 | of examples. However, the format in which the examples are 319 | encoded may vary. One such format, proposed by the Center 320 | for Discrete Mathematics and Theoretical Computer Science, 321 | is called DIMACS CNF (for \textit{Conjunction Normal Form}), 322 | and is encoded in text files. 323 | 324 | A DIMACS CNF file is line-based. If a line begins with the \texttt{c} 325 | character, then it is a comment and shall be ignored. A first 326 | line of the DIMACS CNF file that is not a comment should take the 327 | form: 328 | 329 | \texttt{p cnf } 330 | 331 | where \texttt{} specifies the maximum number of atomic 332 | propositions that appear in the formula, and \texttt{} 333 | specifies the number of disjunctive clauses in the formula, or 334 | the number of meaningful lines that follow the given line. 335 | 336 | After the header, there appear \texttt{} lines that 337 | contain sequences of integers (possibly negative) separated with 338 | white space and terminated with zero. A number $n$ means that 339 | an atomic formula appears in a given disjunctive clause, 340 | or -- if it is negative -- that its negation appears in the 341 | disjunctive clause. 342 | 343 | This may sound complicated, so it can be instructive to see 344 | an example. The file 345 | 346 | \begin{Snippet} 347 | c simple_v3_c2.cnf 348 | c 349 | p cnf 3 2 350 | 1 -3 0 351 | 2 3 -1 0 352 | \end{Snippet} 353 | 354 | would correspond to the formula 355 | 356 | \texttt{(and (or x1 (not x3)) (or x2 x3 (not x1)))} 357 | 358 | As we can see, the whole expression is a conjunction (this is 359 | why it's called \textit{conjunctive} normal form), and its 360 | sub-expressions are disjunctions. There are two of them, 361 | as there are lines below the DIMACS CNF header. The first 362 | line contains numbers \texttt{1 -3 0}, which correspond 363 | to the expression \texttt{(or x1 (not x3))}, and the second 364 | line contains numbers \texttt{2 3 -1 0} that correspond to 365 | the expression \texttt{(or x2 x3 (not x1))}. 366 | 367 | It can be puzzling why someone decided to be able to represent 368 | only conjunctions of disjunctions of formulas and their negations, 369 | but it turns out that for every formula of classical logic 370 | one can find an equivalent conjunctive normal form. The details 371 | are beyond the scope of this pamphlet. 372 | 373 | We therefore need to find a way to transform the numbers 374 | given in the lines of the DIMACS CNF file into S-expressions. 375 | 376 | We will be using the \texttt{(ice-9 regex)} library bundled 377 | with Guile and its ability to process \textit{regular expressions}. 378 | The regular expressions will be exposed here rather than explained, 379 | as the more detailed explanation can be found rather easily 380 | among the vast resources of the Worldwide Web. 381 | 382 | Also, we are going to process the file line by line. The 383 | Scheme itself doesn't provide facilities for doing that, 384 | but Guile comes with the \texttt{(ice-9 rdelim)} library 385 | which provides a function that returns a next available line 386 | from a given \texttt{input-port}. We will fix the 387 | \texttt{input-port} to mean \texttt{(current-input-port)}, 388 | which is a notion similar to \textit{standard input} known 389 | from UNIX and its descendants. 390 | 391 | We shall gather the input lines from the list. The 392 | function terminates when it approaches an \textit{end-of-file 393 | object}: 394 | 395 | \begin{Snippet} 396 | (define (input-lines) 397 | (let* ((line (read-line (current-input-port)))) 398 | (if (eof-object? line) 399 | '() 400 | `(,line . ,(input-lines))))) 401 | \end{Snippet} 402 | 403 | We shall ignore all the lines that contain anything else 404 | than (possibly negative) numbers separated with white-spaces 405 | and terminated with 0. For that, we will use the \texttt{filter} 406 | function which takes a predicate and a list, and returns 407 | a new list that contains only those elements from the old 408 | list that satisfy the predicate (preserving the order). 409 | Thus, the expression 410 | 411 | \begin{Snippet} 412 | (filter (lambda (line) 413 | (string-match "^\\s*(-?[0-9]+\\s+)+0\\s*$" line)) 414 | (input-lines)) 415 | \end{Snippet} 416 | 417 | will evaluate to a list that contains only the meaningful 418 | lines. Note that we used the \texttt{string-match} procedure 419 | here, that takes a regular expression and a string (I 420 | didn't mention it before, but Scheme also provides strings as 421 | its elementary data type) and evaluates to truth-ish value 422 | if the string matches the regular expression\footnote{ 423 | We said that the logical truth is expressed using the 424 | \texttt{\#t} syntax, but in fact any value other than 425 | \texttt{\#f} is regarded as true in the context of the 426 | \texttt{if} form and its derivatives.}. The meaning 427 | of the regular expression is as follows. The \texttt{\string^} 428 | character anchors the regular expression at the beginning 429 | of the string. Then, \texttt{"\char`\\\char`\\s*"} allows a sequence 430 | of white spaces to appear at the beginning. The group 431 | \texttt{"(-?[0-9]+\char`\\\char`\\s+)+"} requires that there 432 | will appear (one or more times) a non-empty sequence of digits followed 433 | by a non-empty sequence of white-spaces, and that it can be 434 | prepended with the minus sign. Lastly, the expression 435 | \texttt{"0\char`\\\char`\\s*\$"} says that \texttt{0} has to appear 436 | at the end of the sequence, and that it can optionally be 437 | followed with a sequence of white characters. 438 | 439 | We now have a sequence of valid lines that need to be 440 | converted to propositional logic expressions. If a line has 441 | a form of a string \texttt{"2 3 -1 0"}, then if we split 442 | the line by spaces, we obtain a list of strings 443 | \texttt{("2" "3" "-1" "0")}. We can then further 444 | convert each of those strings (but the last one) to number 445 | using the built-in \texttt{string->number} function. We used 446 | the plural form, so it will probably require the use 447 | of \texttt{map}. 448 | 449 | Lastly, we need to convert the number to an expression, 450 | that is -- either a symbol or a negation of a symbol. 451 | We can therefore define: 452 | 453 | \begin{Snippet} 454 | (define (number->expression number) 455 | (if (negative? number) 456 | `(not ,(number->expression (- number))) 457 | ((numbered-symbol 'x) number))) 458 | \end{Snippet} 459 | 460 | where \texttt{numbered-symbol} could be defined in 461 | terms of the primitive Scheme functions: 462 | 463 | \begin{Snippet} 464 | (define ((numbered-symbol symbol) number) 465 | (symbol-append symbol (string->symbol (number->string number)))) 466 | \end{Snippet} 467 | 468 | Putting it all together, we can define our DIMACS-CNF 469 | processor: 470 | 471 | \begin{Snippet} 472 | (define (process-dimacs-cnf) 473 | (define (disjunction line) 474 | (let* (((strings ... "0") (filter (lambda (s) 475 | (not (equal? s ""))) 476 | (string-split line #\space))) 477 | (numbers (map string->number strings)) 478 | (expressions (map number->expression numbers))) 479 | `(or . ,expressions))) 480 | (let* ((data-lines (filter (lambda (line) 481 | (string-match 482 | "^\\s*(-?[0-9]+\\s+)+0$" 483 | line)) 484 | (input-lines)))) 485 | `(and . ,(map disjunction data-lines)))) 486 | \end{Snippet} 487 | 488 | The only thing that can be unobvious is binding the value 489 | of the expression \texttt{(string-split line \#\char`\\space)} 490 | to the pattern \texttt{(strings ... "0")}. What it actually 491 | does is that it skips the last element (that is assumed to 492 | be \texttt{"0"}) from the result of \texttt{string-split}. 493 | The \texttt{...} operator for the pattern matcher behaves 494 | in a complementary way to the \texttt{unquote-splicing} 495 | operator, so for example, in the expression 496 | \begin{Snippet} 497 | (match '(1 2 3 4 5 6) 498 | ((a b c ... z)) 499 | `(,a ,b ,@c ,z)) 500 | \end{Snippet} 501 | \texttt{a},\texttt{b} and \texttt{z} will be bound with 502 | \texttt{1}, \texttt{2} and \texttt{6}, respectively, and the 503 | \texttt{c} name will be bound with the list \texttt{(3 4 5)}, 504 | so the value of the above expression will simply be the list 505 | \texttt{(1 2 3 4 5 6)}. The \texttt{...} operator cannot 506 | appear more than once in a list, so for example patterns like 507 | \texttt{(a ... k ... z)} are illegal, as they would result 508 | in an ambiguous match. The \texttt{...} operator has 509 | another magical property -- in the pattern 510 | \begin{Snippet} 511 | (match '((a . 1) (b . 2) (c . 3)) 512 | (((keys . values) ...) 513 | `(,keys ,values))) 514 | \end{Snippet} 515 | the \texttt{keys} symbol will be bound with the list \texttt{(a b c)}, 516 | and the \texttt{values} symbol -- with \texttt{(1 2 3)}, so the 517 | list subjected to pattern matching will be \textit{unzipped}. 518 | We will be making a use of this feature later. 519 | 520 | Back to our parser, note that we used the value 521 | \texttt{\#\char`\\space} as the second argument to 522 | \texttt{string-split}. It is a Scheme name for the ``space'' character 523 | (characters are also a data type in Scheme). Note also 524 | that we had to apply another filter on the result of the 525 | \texttt{string-split}, in order to remove empty strings from it, 526 | that appeared if there were two or more 527 | consecutive spaces in a given line. 528 | 529 | \subsection{Applying the genetic strategy} 530 | 531 | Now that we know how to convert the DIMACS CNF files to Scheme, 532 | we can test whether the provided formulas are satisfiable -- or, 533 | to put it in another way -- seek for a valuation under which 534 | they are satisfied. 535 | 536 | It is rather obvious that our chromosomes will denote the 537 | values of subsequent atomic propositions for the valuations 538 | (therefore, they will be rather straightforward to decode). 539 | We need to know how many distinct atomic formulas are there 540 | in the main formula: 541 | 542 | \begin{Snippet} 543 | (define (atomic-formulas proposition) 544 | (match proposition 545 | (('not clause) 546 | (atomic-formulas clause)) 547 | ((operator . clauses) 548 | (delete-duplicates (append-map atomic-formulas clauses))) 549 | ((? symbol?) 550 | `(,proposition)))) 551 | \end{Snippet} 552 | 553 | The code uses two library functions, \texttt{delete-duplicates} 554 | (that does exactly what it says\footnote{ 555 | It is very important in programming to choose appropriate 556 | names for concepts, whether ultimate or intermediate, because 557 | knowing that we can trust the names, we don't need to resort 558 | to documentation. 559 | }) and \texttt{append-map}, which 560 | is like \texttt{map} except that its functional argument is 561 | expected to return a list, and that list is \textit{appended} 562 | to the resulting list, rather than \textit{inserted} as 563 | a single element. 564 | 565 | The structure of the formulas -- the conjunctive normal 566 | form -- also prompts us with the fitness function: that 567 | will be the number of the satisfied disjunctive sub-clauses. 568 | 569 | \begin{Snippet} 570 | (define (number-of-satisfied-subformulas #;of cnf #;for chromosome) 571 | (let* ((variables (generate-variables #;from 1 572 | #;to (length chromosome))) 573 | (valuation (map cons variables chromosome)) 574 | (('and . or-clauses) cnf)) 575 | (count (lambda (subformula) 576 | (satisfied? subformula #;under valuation)) 577 | or-clauses))) 578 | \end{Snippet} 579 | \begin{Snippet} 580 | ;; where 581 | (define (generate-variables #;from first #;to last) 582 | (if (> first last) 583 | '() 584 | `(,((numbered-symbol 'x) first) 585 | . ,(generate-variables #;from (+ first 1) #;to last)))) 586 | \end{Snippet} 587 | 588 | Here, we use the library function \texttt{count} that takes 589 | a predicate and a list and returns the number of elements 590 | of the list that satisfy the predicate. 591 | 592 | The only thing that's left is to put the pieces together 593 | and enjoy the show\footnote{The file ``dubois20.cnf'', 594 | among others, was obtained from the website 595 | \url{http://people.sc.fsu.edu/~jburkardt/data/cnf/cnf.html}.}: 596 | 597 | \begin{Snippet} 598 | (let* ((formula (with-input-from-file "dubois20.cnf" 599 | process-dimacs-cnf)) 600 | (dimension (length (atomic-formulas formula))) 601 | (measure (lambda (chromosome) 602 | (number-of-satisfied-subformulas #;of formula 603 | #;for chromosome)))) 604 | (optimize dimension 160 100 measure)) 605 | \end{Snippet} 606 | -------------------------------------------------------------------------------- /datasets/diabetes.csv: -------------------------------------------------------------------------------- 1 | pregnant-times,glucose-concentr,blood-pressure,skin-thickness,insulin,mass-index,pedigree-func,age,class 2 | 6,148,72,35,0,33.6,0.627,50,tested_positive 3 | 1,85,66,29,0,26.6,0.351,31,tested_negative 4 | 8,183,64,0,0,23.3,0.672,32,tested_positive 5 | 1,89,66,23,94,28.1,0.167,21,tested_negative 6 | 0,137,40,35,168,43.1,2.288,33,tested_positive 7 | 5,116,74,0,0,25.6,0.201,30,tested_negative 8 | 3,78,50,32,88,31,0.248,26,tested_positive 9 | 10,115,0,0,0,35.3,0.134,29,tested_negative 10 | 2,197,70,45,543,30.5,0.158,53,tested_positive 11 | 8,125,96,0,0,0,0.232,54,tested_positive 12 | 4,110,92,0,0,37.6,0.191,30,tested_negative 13 | 10,168,74,0,0,38,0.537,34,tested_positive 14 | 10,139,80,0,0,27.1,1.441,57,tested_negative 15 | 1,189,60,23,846,30.1,0.398,59,tested_positive 16 | 5,166,72,19,175,25.8,0.587,51,tested_positive 17 | 7,100,0,0,0,30,0.484,32,tested_positive 18 | 0,118,84,47,230,45.8,0.551,31,tested_positive 19 | 7,107,74,0,0,29.6,0.254,31,tested_positive 20 | 1,103,30,38,83,43.3,0.183,33,tested_negative 21 | 1,115,70,30,96,34.6,0.529,32,tested_positive 22 | 3,126,88,41,235,39.3,0.704,27,tested_negative 23 | 8,99,84,0,0,35.4,0.388,50,tested_negative 24 | 7,196,90,0,0,39.8,0.451,41,tested_positive 25 | 9,119,80,35,0,29,0.263,29,tested_positive 26 | 11,143,94,33,146,36.6,0.254,51,tested_positive 27 | 10,125,70,26,115,31.1,0.205,41,tested_positive 28 | 7,147,76,0,0,39.4,0.257,43,tested_positive 29 | 1,97,66,15,140,23.2,0.487,22,tested_negative 30 | 13,145,82,19,110,22.2,0.245,57,tested_negative 31 | 5,117,92,0,0,34.1,0.337,38,tested_negative 32 | 5,109,75,26,0,36,0.546,60,tested_negative 33 | 3,158,76,36,245,31.6,0.851,28,tested_positive 34 | 3,88,58,11,54,24.8,0.267,22,tested_negative 35 | 6,92,92,0,0,19.9,0.188,28,tested_negative 36 | 10,122,78,31,0,27.6,0.512,45,tested_negative 37 | 4,103,60,33,192,24,0.966,33,tested_negative 38 | 11,138,76,0,0,33.2,0.42,35,tested_negative 39 | 9,102,76,37,0,32.9,0.665,46,tested_positive 40 | 2,90,68,42,0,38.2,0.503,27,tested_positive 41 | 4,111,72,47,207,37.1,1.39,56,tested_positive 42 | 3,180,64,25,70,34,0.271,26,tested_negative 43 | 7,133,84,0,0,40.2,0.696,37,tested_negative 44 | 7,106,92,18,0,22.7,0.235,48,tested_negative 45 | 9,171,110,24,240,45.4,0.721,54,tested_positive 46 | 7,159,64,0,0,27.4,0.294,40,tested_negative 47 | 0,180,66,39,0,42,1.893,25,tested_positive 48 | 1,146,56,0,0,29.7,0.564,29,tested_negative 49 | 2,71,70,27,0,28,0.586,22,tested_negative 50 | 7,103,66,32,0,39.1,0.344,31,tested_positive 51 | 7,105,0,0,0,0,0.305,24,tested_negative 52 | 1,103,80,11,82,19.4,0.491,22,tested_negative 53 | 1,101,50,15,36,24.2,0.526,26,tested_negative 54 | 5,88,66,21,23,24.4,0.342,30,tested_negative 55 | 8,176,90,34,300,33.7,0.467,58,tested_positive 56 | 7,150,66,42,342,34.7,0.718,42,tested_negative 57 | 1,73,50,10,0,23,0.248,21,tested_negative 58 | 7,187,68,39,304,37.7,0.254,41,tested_positive 59 | 0,100,88,60,110,46.8,0.962,31,tested_negative 60 | 0,146,82,0,0,40.5,1.781,44,tested_negative 61 | 0,105,64,41,142,41.5,0.173,22,tested_negative 62 | 2,84,0,0,0,0,0.304,21,tested_negative 63 | 8,133,72,0,0,32.9,0.27,39,tested_positive 64 | 5,44,62,0,0,25,0.587,36,tested_negative 65 | 2,141,58,34,128,25.4,0.699,24,tested_negative 66 | 7,114,66,0,0,32.8,0.258,42,tested_positive 67 | 5,99,74,27,0,29,0.203,32,tested_negative 68 | 0,109,88,30,0,32.5,0.855,38,tested_positive 69 | 2,109,92,0,0,42.7,0.845,54,tested_negative 70 | 1,95,66,13,38,19.6,0.334,25,tested_negative 71 | 4,146,85,27,100,28.9,0.189,27,tested_negative 72 | 2,100,66,20,90,32.9,0.867,28,tested_positive 73 | 5,139,64,35,140,28.6,0.411,26,tested_negative 74 | 13,126,90,0,0,43.4,0.583,42,tested_positive 75 | 4,129,86,20,270,35.1,0.231,23,tested_negative 76 | 1,79,75,30,0,32,0.396,22,tested_negative 77 | 1,0,48,20,0,24.7,0.14,22,tested_negative 78 | 7,62,78,0,0,32.6,0.391,41,tested_negative 79 | 5,95,72,33,0,37.7,0.37,27,tested_negative 80 | 0,131,0,0,0,43.2,0.27,26,tested_positive 81 | 2,112,66,22,0,25,0.307,24,tested_negative 82 | 3,113,44,13,0,22.4,0.14,22,tested_negative 83 | 2,74,0,0,0,0,0.102,22,tested_negative 84 | 7,83,78,26,71,29.3,0.767,36,tested_negative 85 | 0,101,65,28,0,24.6,0.237,22,tested_negative 86 | 5,137,108,0,0,48.8,0.227,37,tested_positive 87 | 2,110,74,29,125,32.4,0.698,27,tested_negative 88 | 13,106,72,54,0,36.6,0.178,45,tested_negative 89 | 2,100,68,25,71,38.5,0.324,26,tested_negative 90 | 15,136,70,32,110,37.1,0.153,43,tested_positive 91 | 1,107,68,19,0,26.5,0.165,24,tested_negative 92 | 1,80,55,0,0,19.1,0.258,21,tested_negative 93 | 4,123,80,15,176,32,0.443,34,tested_negative 94 | 7,81,78,40,48,46.7,0.261,42,tested_negative 95 | 4,134,72,0,0,23.8,0.277,60,tested_positive 96 | 2,142,82,18,64,24.7,0.761,21,tested_negative 97 | 6,144,72,27,228,33.9,0.255,40,tested_negative 98 | 2,92,62,28,0,31.6,0.13,24,tested_negative 99 | 1,71,48,18,76,20.4,0.323,22,tested_negative 100 | 6,93,50,30,64,28.7,0.356,23,tested_negative 101 | 1,122,90,51,220,49.7,0.325,31,tested_positive 102 | 1,163,72,0,0,39,1.222,33,tested_positive 103 | 1,151,60,0,0,26.1,0.179,22,tested_negative 104 | 0,125,96,0,0,22.5,0.262,21,tested_negative 105 | 1,81,72,18,40,26.6,0.283,24,tested_negative 106 | 2,85,65,0,0,39.6,0.93,27,tested_negative 107 | 1,126,56,29,152,28.7,0.801,21,tested_negative 108 | 1,96,122,0,0,22.4,0.207,27,tested_negative 109 | 4,144,58,28,140,29.5,0.287,37,tested_negative 110 | 3,83,58,31,18,34.3,0.336,25,tested_negative 111 | 0,95,85,25,36,37.4,0.247,24,tested_positive 112 | 3,171,72,33,135,33.3,0.199,24,tested_positive 113 | 8,155,62,26,495,34,0.543,46,tested_positive 114 | 1,89,76,34,37,31.2,0.192,23,tested_negative 115 | 4,76,62,0,0,34,0.391,25,tested_negative 116 | 7,160,54,32,175,30.5,0.588,39,tested_positive 117 | 4,146,92,0,0,31.2,0.539,61,tested_positive 118 | 5,124,74,0,0,34,0.22,38,tested_positive 119 | 5,78,48,0,0,33.7,0.654,25,tested_negative 120 | 4,97,60,23,0,28.2,0.443,22,tested_negative 121 | 4,99,76,15,51,23.2,0.223,21,tested_negative 122 | 0,162,76,56,100,53.2,0.759,25,tested_positive 123 | 6,111,64,39,0,34.2,0.26,24,tested_negative 124 | 2,107,74,30,100,33.6,0.404,23,tested_negative 125 | 5,132,80,0,0,26.8,0.186,69,tested_negative 126 | 0,113,76,0,0,33.3,0.278,23,tested_positive 127 | 1,88,30,42,99,55,0.496,26,tested_positive 128 | 3,120,70,30,135,42.9,0.452,30,tested_negative 129 | 1,118,58,36,94,33.3,0.261,23,tested_negative 130 | 1,117,88,24,145,34.5,0.403,40,tested_positive 131 | 0,105,84,0,0,27.9,0.741,62,tested_positive 132 | 4,173,70,14,168,29.7,0.361,33,tested_positive 133 | 9,122,56,0,0,33.3,1.114,33,tested_positive 134 | 3,170,64,37,225,34.5,0.356,30,tested_positive 135 | 8,84,74,31,0,38.3,0.457,39,tested_negative 136 | 2,96,68,13,49,21.1,0.647,26,tested_negative 137 | 2,125,60,20,140,33.8,0.088,31,tested_negative 138 | 0,100,70,26,50,30.8,0.597,21,tested_negative 139 | 0,93,60,25,92,28.7,0.532,22,tested_negative 140 | 0,129,80,0,0,31.2,0.703,29,tested_negative 141 | 5,105,72,29,325,36.9,0.159,28,tested_negative 142 | 3,128,78,0,0,21.1,0.268,55,tested_negative 143 | 5,106,82,30,0,39.5,0.286,38,tested_negative 144 | 2,108,52,26,63,32.5,0.318,22,tested_negative 145 | 10,108,66,0,0,32.4,0.272,42,tested_positive 146 | 4,154,62,31,284,32.8,0.237,23,tested_negative 147 | 0,102,75,23,0,0,0.572,21,tested_negative 148 | 9,57,80,37,0,32.8,0.096,41,tested_negative 149 | 2,106,64,35,119,30.5,1.4,34,tested_negative 150 | 5,147,78,0,0,33.7,0.218,65,tested_negative 151 | 2,90,70,17,0,27.3,0.085,22,tested_negative 152 | 1,136,74,50,204,37.4,0.399,24,tested_negative 153 | 4,114,65,0,0,21.9,0.432,37,tested_negative 154 | 9,156,86,28,155,34.3,1.189,42,tested_positive 155 | 1,153,82,42,485,40.6,0.687,23,tested_negative 156 | 8,188,78,0,0,47.9,0.137,43,tested_positive 157 | 7,152,88,44,0,50,0.337,36,tested_positive 158 | 2,99,52,15,94,24.6,0.637,21,tested_negative 159 | 1,109,56,21,135,25.2,0.833,23,tested_negative 160 | 2,88,74,19,53,29,0.229,22,tested_negative 161 | 17,163,72,41,114,40.9,0.817,47,tested_positive 162 | 4,151,90,38,0,29.7,0.294,36,tested_negative 163 | 7,102,74,40,105,37.2,0.204,45,tested_negative 164 | 0,114,80,34,285,44.2,0.167,27,tested_negative 165 | 2,100,64,23,0,29.7,0.368,21,tested_negative 166 | 0,131,88,0,0,31.6,0.743,32,tested_positive 167 | 6,104,74,18,156,29.9,0.722,41,tested_positive 168 | 3,148,66,25,0,32.5,0.256,22,tested_negative 169 | 4,120,68,0,0,29.6,0.709,34,tested_negative 170 | 4,110,66,0,0,31.9,0.471,29,tested_negative 171 | 3,111,90,12,78,28.4,0.495,29,tested_negative 172 | 6,102,82,0,0,30.8,0.18,36,tested_positive 173 | 6,134,70,23,130,35.4,0.542,29,tested_positive 174 | 2,87,0,23,0,28.9,0.773,25,tested_negative 175 | 1,79,60,42,48,43.5,0.678,23,tested_negative 176 | 2,75,64,24,55,29.7,0.37,33,tested_negative 177 | 8,179,72,42,130,32.7,0.719,36,tested_positive 178 | 6,85,78,0,0,31.2,0.382,42,tested_negative 179 | 0,129,110,46,130,67.1,0.319,26,tested_positive 180 | 5,143,78,0,0,45,0.19,47,tested_negative 181 | 5,130,82,0,0,39.1,0.956,37,tested_positive 182 | 6,87,80,0,0,23.2,0.084,32,tested_negative 183 | 0,119,64,18,92,34.9,0.725,23,tested_negative 184 | 1,0,74,20,23,27.7,0.299,21,tested_negative 185 | 5,73,60,0,0,26.8,0.268,27,tested_negative 186 | 4,141,74,0,0,27.6,0.244,40,tested_negative 187 | 7,194,68,28,0,35.9,0.745,41,tested_positive 188 | 8,181,68,36,495,30.1,0.615,60,tested_positive 189 | 1,128,98,41,58,32,1.321,33,tested_positive 190 | 8,109,76,39,114,27.9,0.64,31,tested_positive 191 | 5,139,80,35,160,31.6,0.361,25,tested_positive 192 | 3,111,62,0,0,22.6,0.142,21,tested_negative 193 | 9,123,70,44,94,33.1,0.374,40,tested_negative 194 | 7,159,66,0,0,30.4,0.383,36,tested_positive 195 | 11,135,0,0,0,52.3,0.578,40,tested_positive 196 | 8,85,55,20,0,24.4,0.136,42,tested_negative 197 | 5,158,84,41,210,39.4,0.395,29,tested_positive 198 | 1,105,58,0,0,24.3,0.187,21,tested_negative 199 | 3,107,62,13,48,22.9,0.678,23,tested_positive 200 | 4,109,64,44,99,34.8,0.905,26,tested_positive 201 | 4,148,60,27,318,30.9,0.15,29,tested_positive 202 | 0,113,80,16,0,31,0.874,21,tested_negative 203 | 1,138,82,0,0,40.1,0.236,28,tested_negative 204 | 0,108,68,20,0,27.3,0.787,32,tested_negative 205 | 2,99,70,16,44,20.4,0.235,27,tested_negative 206 | 6,103,72,32,190,37.7,0.324,55,tested_negative 207 | 5,111,72,28,0,23.9,0.407,27,tested_negative 208 | 8,196,76,29,280,37.5,0.605,57,tested_positive 209 | 5,162,104,0,0,37.7,0.151,52,tested_positive 210 | 1,96,64,27,87,33.2,0.289,21,tested_negative 211 | 7,184,84,33,0,35.5,0.355,41,tested_positive 212 | 2,81,60,22,0,27.7,0.29,25,tested_negative 213 | 0,147,85,54,0,42.8,0.375,24,tested_negative 214 | 7,179,95,31,0,34.2,0.164,60,tested_negative 215 | 0,140,65,26,130,42.6,0.431,24,tested_positive 216 | 9,112,82,32,175,34.2,0.26,36,tested_positive 217 | 12,151,70,40,271,41.8,0.742,38,tested_positive 218 | 5,109,62,41,129,35.8,0.514,25,tested_positive 219 | 6,125,68,30,120,30,0.464,32,tested_negative 220 | 5,85,74,22,0,29,1.224,32,tested_positive 221 | 5,112,66,0,0,37.8,0.261,41,tested_positive 222 | 0,177,60,29,478,34.6,1.072,21,tested_positive 223 | 2,158,90,0,0,31.6,0.805,66,tested_positive 224 | 7,119,0,0,0,25.2,0.209,37,tested_negative 225 | 7,142,60,33,190,28.8,0.687,61,tested_negative 226 | 1,100,66,15,56,23.6,0.666,26,tested_negative 227 | 1,87,78,27,32,34.6,0.101,22,tested_negative 228 | 0,101,76,0,0,35.7,0.198,26,tested_negative 229 | 3,162,52,38,0,37.2,0.652,24,tested_positive 230 | 4,197,70,39,744,36.7,2.329,31,tested_negative 231 | 0,117,80,31,53,45.2,0.089,24,tested_negative 232 | 4,142,86,0,0,44,0.645,22,tested_positive 233 | 6,134,80,37,370,46.2,0.238,46,tested_positive 234 | 1,79,80,25,37,25.4,0.583,22,tested_negative 235 | 4,122,68,0,0,35,0.394,29,tested_negative 236 | 3,74,68,28,45,29.7,0.293,23,tested_negative 237 | 4,171,72,0,0,43.6,0.479,26,tested_positive 238 | 7,181,84,21,192,35.9,0.586,51,tested_positive 239 | 0,179,90,27,0,44.1,0.686,23,tested_positive 240 | 9,164,84,21,0,30.8,0.831,32,tested_positive 241 | 0,104,76,0,0,18.4,0.582,27,tested_negative 242 | 1,91,64,24,0,29.2,0.192,21,tested_negative 243 | 4,91,70,32,88,33.1,0.446,22,tested_negative 244 | 3,139,54,0,0,25.6,0.402,22,tested_positive 245 | 6,119,50,22,176,27.1,1.318,33,tested_positive 246 | 2,146,76,35,194,38.2,0.329,29,tested_negative 247 | 9,184,85,15,0,30,1.213,49,tested_positive 248 | 10,122,68,0,0,31.2,0.258,41,tested_negative 249 | 0,165,90,33,680,52.3,0.427,23,tested_negative 250 | 9,124,70,33,402,35.4,0.282,34,tested_negative 251 | 1,111,86,19,0,30.1,0.143,23,tested_negative 252 | 9,106,52,0,0,31.2,0.38,42,tested_negative 253 | 2,129,84,0,0,28,0.284,27,tested_negative 254 | 2,90,80,14,55,24.4,0.249,24,tested_negative 255 | 0,86,68,32,0,35.8,0.238,25,tested_negative 256 | 12,92,62,7,258,27.6,0.926,44,tested_positive 257 | 1,113,64,35,0,33.6,0.543,21,tested_positive 258 | 3,111,56,39,0,30.1,0.557,30,tested_negative 259 | 2,114,68,22,0,28.7,0.092,25,tested_negative 260 | 1,193,50,16,375,25.9,0.655,24,tested_negative 261 | 11,155,76,28,150,33.3,1.353,51,tested_positive 262 | 3,191,68,15,130,30.9,0.299,34,tested_negative 263 | 3,141,0,0,0,30,0.761,27,tested_positive 264 | 4,95,70,32,0,32.1,0.612,24,tested_negative 265 | 3,142,80,15,0,32.4,0.2,63,tested_negative 266 | 4,123,62,0,0,32,0.226,35,tested_positive 267 | 5,96,74,18,67,33.6,0.997,43,tested_negative 268 | 0,138,0,0,0,36.3,0.933,25,tested_positive 269 | 2,128,64,42,0,40,1.101,24,tested_negative 270 | 0,102,52,0,0,25.1,0.078,21,tested_negative 271 | 2,146,0,0,0,27.5,0.24,28,tested_positive 272 | 10,101,86,37,0,45.6,1.136,38,tested_positive 273 | 2,108,62,32,56,25.2,0.128,21,tested_negative 274 | 3,122,78,0,0,23,0.254,40,tested_negative 275 | 1,71,78,50,45,33.2,0.422,21,tested_negative 276 | 13,106,70,0,0,34.2,0.251,52,tested_negative 277 | 2,100,70,52,57,40.5,0.677,25,tested_negative 278 | 7,106,60,24,0,26.5,0.296,29,tested_positive 279 | 0,104,64,23,116,27.8,0.454,23,tested_negative 280 | 5,114,74,0,0,24.9,0.744,57,tested_negative 281 | 2,108,62,10,278,25.3,0.881,22,tested_negative 282 | 0,146,70,0,0,37.9,0.334,28,tested_positive 283 | 10,129,76,28,122,35.9,0.28,39,tested_negative 284 | 7,133,88,15,155,32.4,0.262,37,tested_negative 285 | 7,161,86,0,0,30.4,0.165,47,tested_positive 286 | 2,108,80,0,0,27,0.259,52,tested_positive 287 | 7,136,74,26,135,26,0.647,51,tested_negative 288 | 5,155,84,44,545,38.7,0.619,34,tested_negative 289 | 1,119,86,39,220,45.6,0.808,29,tested_positive 290 | 4,96,56,17,49,20.8,0.34,26,tested_negative 291 | 5,108,72,43,75,36.1,0.263,33,tested_negative 292 | 0,78,88,29,40,36.9,0.434,21,tested_negative 293 | 0,107,62,30,74,36.6,0.757,25,tested_positive 294 | 2,128,78,37,182,43.3,1.224,31,tested_positive 295 | 1,128,48,45,194,40.5,0.613,24,tested_positive 296 | 0,161,50,0,0,21.9,0.254,65,tested_negative 297 | 6,151,62,31,120,35.5,0.692,28,tested_negative 298 | 2,146,70,38,360,28,0.337,29,tested_positive 299 | 0,126,84,29,215,30.7,0.52,24,tested_negative 300 | 14,100,78,25,184,36.6,0.412,46,tested_positive 301 | 8,112,72,0,0,23.6,0.84,58,tested_negative 302 | 0,167,0,0,0,32.3,0.839,30,tested_positive 303 | 2,144,58,33,135,31.6,0.422,25,tested_positive 304 | 5,77,82,41,42,35.8,0.156,35,tested_negative 305 | 5,115,98,0,0,52.9,0.209,28,tested_positive 306 | 3,150,76,0,0,21,0.207,37,tested_negative 307 | 2,120,76,37,105,39.7,0.215,29,tested_negative 308 | 10,161,68,23,132,25.5,0.326,47,tested_positive 309 | 0,137,68,14,148,24.8,0.143,21,tested_negative 310 | 0,128,68,19,180,30.5,1.391,25,tested_positive 311 | 2,124,68,28,205,32.9,0.875,30,tested_positive 312 | 6,80,66,30,0,26.2,0.313,41,tested_negative 313 | 0,106,70,37,148,39.4,0.605,22,tested_negative 314 | 2,155,74,17,96,26.6,0.433,27,tested_positive 315 | 3,113,50,10,85,29.5,0.626,25,tested_negative 316 | 7,109,80,31,0,35.9,1.127,43,tested_positive 317 | 2,112,68,22,94,34.1,0.315,26,tested_negative 318 | 3,99,80,11,64,19.3,0.284,30,tested_negative 319 | 3,182,74,0,0,30.5,0.345,29,tested_positive 320 | 3,115,66,39,140,38.1,0.15,28,tested_negative 321 | 6,194,78,0,0,23.5,0.129,59,tested_positive 322 | 4,129,60,12,231,27.5,0.527,31,tested_negative 323 | 3,112,74,30,0,31.6,0.197,25,tested_positive 324 | 0,124,70,20,0,27.4,0.254,36,tested_positive 325 | 13,152,90,33,29,26.8,0.731,43,tested_positive 326 | 2,112,75,32,0,35.7,0.148,21,tested_negative 327 | 1,157,72,21,168,25.6,0.123,24,tested_negative 328 | 1,122,64,32,156,35.1,0.692,30,tested_positive 329 | 10,179,70,0,0,35.1,0.2,37,tested_negative 330 | 2,102,86,36,120,45.5,0.127,23,tested_positive 331 | 6,105,70,32,68,30.8,0.122,37,tested_negative 332 | 8,118,72,19,0,23.1,1.476,46,tested_negative 333 | 2,87,58,16,52,32.7,0.166,25,tested_negative 334 | 1,180,0,0,0,43.3,0.282,41,tested_positive 335 | 12,106,80,0,0,23.6,0.137,44,tested_negative 336 | 1,95,60,18,58,23.9,0.26,22,tested_negative 337 | 0,165,76,43,255,47.9,0.259,26,tested_negative 338 | 0,117,0,0,0,33.8,0.932,44,tested_negative 339 | 5,115,76,0,0,31.2,0.343,44,tested_positive 340 | 9,152,78,34,171,34.2,0.893,33,tested_positive 341 | 7,178,84,0,0,39.9,0.331,41,tested_positive 342 | 1,130,70,13,105,25.9,0.472,22,tested_negative 343 | 1,95,74,21,73,25.9,0.673,36,tested_negative 344 | 1,0,68,35,0,32,0.389,22,tested_negative 345 | 5,122,86,0,0,34.7,0.29,33,tested_negative 346 | 8,95,72,0,0,36.8,0.485,57,tested_negative 347 | 8,126,88,36,108,38.5,0.349,49,tested_negative 348 | 1,139,46,19,83,28.7,0.654,22,tested_negative 349 | 3,116,0,0,0,23.5,0.187,23,tested_negative 350 | 3,99,62,19,74,21.8,0.279,26,tested_negative 351 | 5,0,80,32,0,41,0.346,37,tested_positive 352 | 4,92,80,0,0,42.2,0.237,29,tested_negative 353 | 4,137,84,0,0,31.2,0.252,30,tested_negative 354 | 3,61,82,28,0,34.4,0.243,46,tested_negative 355 | 1,90,62,12,43,27.2,0.58,24,tested_negative 356 | 3,90,78,0,0,42.7,0.559,21,tested_negative 357 | 9,165,88,0,0,30.4,0.302,49,tested_positive 358 | 1,125,50,40,167,33.3,0.962,28,tested_positive 359 | 13,129,0,30,0,39.9,0.569,44,tested_positive 360 | 12,88,74,40,54,35.3,0.378,48,tested_negative 361 | 1,196,76,36,249,36.5,0.875,29,tested_positive 362 | 5,189,64,33,325,31.2,0.583,29,tested_positive 363 | 5,158,70,0,0,29.8,0.207,63,tested_negative 364 | 5,103,108,37,0,39.2,0.305,65,tested_negative 365 | 4,146,78,0,0,38.5,0.52,67,tested_positive 366 | 4,147,74,25,293,34.9,0.385,30,tested_negative 367 | 5,99,54,28,83,34,0.499,30,tested_negative 368 | 6,124,72,0,0,27.6,0.368,29,tested_positive 369 | 0,101,64,17,0,21,0.252,21,tested_negative 370 | 3,81,86,16,66,27.5,0.306,22,tested_negative 371 | 1,133,102,28,140,32.8,0.234,45,tested_positive 372 | 3,173,82,48,465,38.4,2.137,25,tested_positive 373 | 0,118,64,23,89,0,1.731,21,tested_negative 374 | 0,84,64,22,66,35.8,0.545,21,tested_negative 375 | 2,105,58,40,94,34.9,0.225,25,tested_negative 376 | 2,122,52,43,158,36.2,0.816,28,tested_negative 377 | 12,140,82,43,325,39.2,0.528,58,tested_positive 378 | 0,98,82,15,84,25.2,0.299,22,tested_negative 379 | 1,87,60,37,75,37.2,0.509,22,tested_negative 380 | 4,156,75,0,0,48.3,0.238,32,tested_positive 381 | 0,93,100,39,72,43.4,1.021,35,tested_negative 382 | 1,107,72,30,82,30.8,0.821,24,tested_negative 383 | 0,105,68,22,0,20,0.236,22,tested_negative 384 | 1,109,60,8,182,25.4,0.947,21,tested_negative 385 | 1,90,62,18,59,25.1,1.268,25,tested_negative 386 | 1,125,70,24,110,24.3,0.221,25,tested_negative 387 | 1,119,54,13,50,22.3,0.205,24,tested_negative 388 | 5,116,74,29,0,32.3,0.66,35,tested_positive 389 | 8,105,100,36,0,43.3,0.239,45,tested_positive 390 | 5,144,82,26,285,32,0.452,58,tested_positive 391 | 3,100,68,23,81,31.6,0.949,28,tested_negative 392 | 1,100,66,29,196,32,0.444,42,tested_negative 393 | 5,166,76,0,0,45.7,0.34,27,tested_positive 394 | 1,131,64,14,415,23.7,0.389,21,tested_negative 395 | 4,116,72,12,87,22.1,0.463,37,tested_negative 396 | 4,158,78,0,0,32.9,0.803,31,tested_positive 397 | 2,127,58,24,275,27.7,1.6,25,tested_negative 398 | 3,96,56,34,115,24.7,0.944,39,tested_negative 399 | 0,131,66,40,0,34.3,0.196,22,tested_positive 400 | 3,82,70,0,0,21.1,0.389,25,tested_negative 401 | 3,193,70,31,0,34.9,0.241,25,tested_positive 402 | 4,95,64,0,0,32,0.161,31,tested_positive 403 | 6,137,61,0,0,24.2,0.151,55,tested_negative 404 | 5,136,84,41,88,35,0.286,35,tested_positive 405 | 9,72,78,25,0,31.6,0.28,38,tested_negative 406 | 5,168,64,0,0,32.9,0.135,41,tested_positive 407 | 2,123,48,32,165,42.1,0.52,26,tested_negative 408 | 4,115,72,0,0,28.9,0.376,46,tested_positive 409 | 0,101,62,0,0,21.9,0.336,25,tested_negative 410 | 8,197,74,0,0,25.9,1.191,39,tested_positive 411 | 1,172,68,49,579,42.4,0.702,28,tested_positive 412 | 6,102,90,39,0,35.7,0.674,28,tested_negative 413 | 1,112,72,30,176,34.4,0.528,25,tested_negative 414 | 1,143,84,23,310,42.4,1.076,22,tested_negative 415 | 1,143,74,22,61,26.2,0.256,21,tested_negative 416 | 0,138,60,35,167,34.6,0.534,21,tested_positive 417 | 3,173,84,33,474,35.7,0.258,22,tested_positive 418 | 1,97,68,21,0,27.2,1.095,22,tested_negative 419 | 4,144,82,32,0,38.5,0.554,37,tested_positive 420 | 1,83,68,0,0,18.2,0.624,27,tested_negative 421 | 3,129,64,29,115,26.4,0.219,28,tested_positive 422 | 1,119,88,41,170,45.3,0.507,26,tested_negative 423 | 2,94,68,18,76,26,0.561,21,tested_negative 424 | 0,102,64,46,78,40.6,0.496,21,tested_negative 425 | 2,115,64,22,0,30.8,0.421,21,tested_negative 426 | 8,151,78,32,210,42.9,0.516,36,tested_positive 427 | 4,184,78,39,277,37,0.264,31,tested_positive 428 | 0,94,0,0,0,0,0.256,25,tested_negative 429 | 1,181,64,30,180,34.1,0.328,38,tested_positive 430 | 0,135,94,46,145,40.6,0.284,26,tested_negative 431 | 1,95,82,25,180,35,0.233,43,tested_positive 432 | 2,99,0,0,0,22.2,0.108,23,tested_negative 433 | 3,89,74,16,85,30.4,0.551,38,tested_negative 434 | 1,80,74,11,60,30,0.527,22,tested_negative 435 | 2,139,75,0,0,25.6,0.167,29,tested_negative 436 | 1,90,68,8,0,24.5,1.138,36,tested_negative 437 | 0,141,0,0,0,42.4,0.205,29,tested_positive 438 | 12,140,85,33,0,37.4,0.244,41,tested_negative 439 | 5,147,75,0,0,29.9,0.434,28,tested_negative 440 | 1,97,70,15,0,18.2,0.147,21,tested_negative 441 | 6,107,88,0,0,36.8,0.727,31,tested_negative 442 | 0,189,104,25,0,34.3,0.435,41,tested_positive 443 | 2,83,66,23,50,32.2,0.497,22,tested_negative 444 | 4,117,64,27,120,33.2,0.23,24,tested_negative 445 | 8,108,70,0,0,30.5,0.955,33,tested_positive 446 | 4,117,62,12,0,29.7,0.38,30,tested_positive 447 | 0,180,78,63,14,59.4,2.42,25,tested_positive 448 | 1,100,72,12,70,25.3,0.658,28,tested_negative 449 | 0,95,80,45,92,36.5,0.33,26,tested_negative 450 | 0,104,64,37,64,33.6,0.51,22,tested_positive 451 | 0,120,74,18,63,30.5,0.285,26,tested_negative 452 | 1,82,64,13,95,21.2,0.415,23,tested_negative 453 | 2,134,70,0,0,28.9,0.542,23,tested_positive 454 | 0,91,68,32,210,39.9,0.381,25,tested_negative 455 | 2,119,0,0,0,19.6,0.832,72,tested_negative 456 | 2,100,54,28,105,37.8,0.498,24,tested_negative 457 | 14,175,62,30,0,33.6,0.212,38,tested_positive 458 | 1,135,54,0,0,26.7,0.687,62,tested_negative 459 | 5,86,68,28,71,30.2,0.364,24,tested_negative 460 | 10,148,84,48,237,37.6,1.001,51,tested_positive 461 | 9,134,74,33,60,25.9,0.46,81,tested_negative 462 | 9,120,72,22,56,20.8,0.733,48,tested_negative 463 | 1,71,62,0,0,21.8,0.416,26,tested_negative 464 | 8,74,70,40,49,35.3,0.705,39,tested_negative 465 | 5,88,78,30,0,27.6,0.258,37,tested_negative 466 | 10,115,98,0,0,24,1.022,34,tested_negative 467 | 0,124,56,13,105,21.8,0.452,21,tested_negative 468 | 0,74,52,10,36,27.8,0.269,22,tested_negative 469 | 0,97,64,36,100,36.8,0.6,25,tested_negative 470 | 8,120,0,0,0,30,0.183,38,tested_positive 471 | 6,154,78,41,140,46.1,0.571,27,tested_negative 472 | 1,144,82,40,0,41.3,0.607,28,tested_negative 473 | 0,137,70,38,0,33.2,0.17,22,tested_negative 474 | 0,119,66,27,0,38.8,0.259,22,tested_negative 475 | 7,136,90,0,0,29.9,0.21,50,tested_negative 476 | 4,114,64,0,0,28.9,0.126,24,tested_negative 477 | 0,137,84,27,0,27.3,0.231,59,tested_negative 478 | 2,105,80,45,191,33.7,0.711,29,tested_positive 479 | 7,114,76,17,110,23.8,0.466,31,tested_negative 480 | 8,126,74,38,75,25.9,0.162,39,tested_negative 481 | 4,132,86,31,0,28,0.419,63,tested_negative 482 | 3,158,70,30,328,35.5,0.344,35,tested_positive 483 | 0,123,88,37,0,35.2,0.197,29,tested_negative 484 | 4,85,58,22,49,27.8,0.306,28,tested_negative 485 | 0,84,82,31,125,38.2,0.233,23,tested_negative 486 | 0,145,0,0,0,44.2,0.63,31,tested_positive 487 | 0,135,68,42,250,42.3,0.365,24,tested_positive 488 | 1,139,62,41,480,40.7,0.536,21,tested_negative 489 | 0,173,78,32,265,46.5,1.159,58,tested_negative 490 | 4,99,72,17,0,25.6,0.294,28,tested_negative 491 | 8,194,80,0,0,26.1,0.551,67,tested_negative 492 | 2,83,65,28,66,36.8,0.629,24,tested_negative 493 | 2,89,90,30,0,33.5,0.292,42,tested_negative 494 | 4,99,68,38,0,32.8,0.145,33,tested_negative 495 | 4,125,70,18,122,28.9,1.144,45,tested_positive 496 | 3,80,0,0,0,0,0.174,22,tested_negative 497 | 6,166,74,0,0,26.6,0.304,66,tested_negative 498 | 5,110,68,0,0,26,0.292,30,tested_negative 499 | 2,81,72,15,76,30.1,0.547,25,tested_negative 500 | 7,195,70,33,145,25.1,0.163,55,tested_positive 501 | 6,154,74,32,193,29.3,0.839,39,tested_negative 502 | 2,117,90,19,71,25.2,0.313,21,tested_negative 503 | 3,84,72,32,0,37.2,0.267,28,tested_negative 504 | 6,0,68,41,0,39,0.727,41,tested_positive 505 | 7,94,64,25,79,33.3,0.738,41,tested_negative 506 | 3,96,78,39,0,37.3,0.238,40,tested_negative 507 | 10,75,82,0,0,33.3,0.263,38,tested_negative 508 | 0,180,90,26,90,36.5,0.314,35,tested_positive 509 | 1,130,60,23,170,28.6,0.692,21,tested_negative 510 | 2,84,50,23,76,30.4,0.968,21,tested_negative 511 | 8,120,78,0,0,25,0.409,64,tested_negative 512 | 12,84,72,31,0,29.7,0.297,46,tested_positive 513 | 0,139,62,17,210,22.1,0.207,21,tested_negative 514 | 9,91,68,0,0,24.2,0.2,58,tested_negative 515 | 2,91,62,0,0,27.3,0.525,22,tested_negative 516 | 3,99,54,19,86,25.6,0.154,24,tested_negative 517 | 3,163,70,18,105,31.6,0.268,28,tested_positive 518 | 9,145,88,34,165,30.3,0.771,53,tested_positive 519 | 7,125,86,0,0,37.6,0.304,51,tested_negative 520 | 13,76,60,0,0,32.8,0.18,41,tested_negative 521 | 6,129,90,7,326,19.6,0.582,60,tested_negative 522 | 2,68,70,32,66,25,0.187,25,tested_negative 523 | 3,124,80,33,130,33.2,0.305,26,tested_negative 524 | 6,114,0,0,0,0,0.189,26,tested_negative 525 | 9,130,70,0,0,34.2,0.652,45,tested_positive 526 | 3,125,58,0,0,31.6,0.151,24,tested_negative 527 | 3,87,60,18,0,21.8,0.444,21,tested_negative 528 | 1,97,64,19,82,18.2,0.299,21,tested_negative 529 | 3,116,74,15,105,26.3,0.107,24,tested_negative 530 | 0,117,66,31,188,30.8,0.493,22,tested_negative 531 | 0,111,65,0,0,24.6,0.66,31,tested_negative 532 | 2,122,60,18,106,29.8,0.717,22,tested_negative 533 | 0,107,76,0,0,45.3,0.686,24,tested_negative 534 | 1,86,66,52,65,41.3,0.917,29,tested_negative 535 | 6,91,0,0,0,29.8,0.501,31,tested_negative 536 | 1,77,56,30,56,33.3,1.251,24,tested_negative 537 | 4,132,0,0,0,32.9,0.302,23,tested_positive 538 | 0,105,90,0,0,29.6,0.197,46,tested_negative 539 | 0,57,60,0,0,21.7,0.735,67,tested_negative 540 | 0,127,80,37,210,36.3,0.804,23,tested_negative 541 | 3,129,92,49,155,36.4,0.968,32,tested_positive 542 | 8,100,74,40,215,39.4,0.661,43,tested_positive 543 | 3,128,72,25,190,32.4,0.549,27,tested_positive 544 | 10,90,85,32,0,34.9,0.825,56,tested_positive 545 | 4,84,90,23,56,39.5,0.159,25,tested_negative 546 | 1,88,78,29,76,32,0.365,29,tested_negative 547 | 8,186,90,35,225,34.5,0.423,37,tested_positive 548 | 5,187,76,27,207,43.6,1.034,53,tested_positive 549 | 4,131,68,21,166,33.1,0.16,28,tested_negative 550 | 1,164,82,43,67,32.8,0.341,50,tested_negative 551 | 4,189,110,31,0,28.5,0.68,37,tested_negative 552 | 1,116,70,28,0,27.4,0.204,21,tested_negative 553 | 3,84,68,30,106,31.9,0.591,25,tested_negative 554 | 6,114,88,0,0,27.8,0.247,66,tested_negative 555 | 1,88,62,24,44,29.9,0.422,23,tested_negative 556 | 1,84,64,23,115,36.9,0.471,28,tested_negative 557 | 7,124,70,33,215,25.5,0.161,37,tested_negative 558 | 1,97,70,40,0,38.1,0.218,30,tested_negative 559 | 8,110,76,0,0,27.8,0.237,58,tested_negative 560 | 11,103,68,40,0,46.2,0.126,42,tested_negative 561 | 11,85,74,0,0,30.1,0.3,35,tested_negative 562 | 6,125,76,0,0,33.8,0.121,54,tested_positive 563 | 0,198,66,32,274,41.3,0.502,28,tested_positive 564 | 1,87,68,34,77,37.6,0.401,24,tested_negative 565 | 6,99,60,19,54,26.9,0.497,32,tested_negative 566 | 0,91,80,0,0,32.4,0.601,27,tested_negative 567 | 2,95,54,14,88,26.1,0.748,22,tested_negative 568 | 1,99,72,30,18,38.6,0.412,21,tested_negative 569 | 6,92,62,32,126,32,0.085,46,tested_negative 570 | 4,154,72,29,126,31.3,0.338,37,tested_negative 571 | 0,121,66,30,165,34.3,0.203,33,tested_positive 572 | 3,78,70,0,0,32.5,0.27,39,tested_negative 573 | 2,130,96,0,0,22.6,0.268,21,tested_negative 574 | 3,111,58,31,44,29.5,0.43,22,tested_negative 575 | 2,98,60,17,120,34.7,0.198,22,tested_negative 576 | 1,143,86,30,330,30.1,0.892,23,tested_negative 577 | 1,119,44,47,63,35.5,0.28,25,tested_negative 578 | 6,108,44,20,130,24,0.813,35,tested_negative 579 | 2,118,80,0,0,42.9,0.693,21,tested_positive 580 | 10,133,68,0,0,27,0.245,36,tested_negative 581 | 2,197,70,99,0,34.7,0.575,62,tested_positive 582 | 0,151,90,46,0,42.1,0.371,21,tested_positive 583 | 6,109,60,27,0,25,0.206,27,tested_negative 584 | 12,121,78,17,0,26.5,0.259,62,tested_negative 585 | 8,100,76,0,0,38.7,0.19,42,tested_negative 586 | 8,124,76,24,600,28.7,0.687,52,tested_positive 587 | 1,93,56,11,0,22.5,0.417,22,tested_negative 588 | 8,143,66,0,0,34.9,0.129,41,tested_positive 589 | 6,103,66,0,0,24.3,0.249,29,tested_negative 590 | 3,176,86,27,156,33.3,1.154,52,tested_positive 591 | 0,73,0,0,0,21.1,0.342,25,tested_negative 592 | 11,111,84,40,0,46.8,0.925,45,tested_positive 593 | 2,112,78,50,140,39.4,0.175,24,tested_negative 594 | 3,132,80,0,0,34.4,0.402,44,tested_positive 595 | 2,82,52,22,115,28.5,1.699,25,tested_negative 596 | 6,123,72,45,230,33.6,0.733,34,tested_negative 597 | 0,188,82,14,185,32,0.682,22,tested_positive 598 | 0,67,76,0,0,45.3,0.194,46,tested_negative 599 | 1,89,24,19,25,27.8,0.559,21,tested_negative 600 | 1,173,74,0,0,36.8,0.088,38,tested_positive 601 | 1,109,38,18,120,23.1,0.407,26,tested_negative 602 | 1,108,88,19,0,27.1,0.4,24,tested_negative 603 | 6,96,0,0,0,23.7,0.19,28,tested_negative 604 | 1,124,74,36,0,27.8,0.1,30,tested_negative 605 | 7,150,78,29,126,35.2,0.692,54,tested_positive 606 | 4,183,0,0,0,28.4,0.212,36,tested_positive 607 | 1,124,60,32,0,35.8,0.514,21,tested_negative 608 | 1,181,78,42,293,40,1.258,22,tested_positive 609 | 1,92,62,25,41,19.5,0.482,25,tested_negative 610 | 0,152,82,39,272,41.5,0.27,27,tested_negative 611 | 1,111,62,13,182,24,0.138,23,tested_negative 612 | 3,106,54,21,158,30.9,0.292,24,tested_negative 613 | 3,174,58,22,194,32.9,0.593,36,tested_positive 614 | 7,168,88,42,321,38.2,0.787,40,tested_positive 615 | 6,105,80,28,0,32.5,0.878,26,tested_negative 616 | 11,138,74,26,144,36.1,0.557,50,tested_positive 617 | 3,106,72,0,0,25.8,0.207,27,tested_negative 618 | 6,117,96,0,0,28.7,0.157,30,tested_negative 619 | 2,68,62,13,15,20.1,0.257,23,tested_negative 620 | 9,112,82,24,0,28.2,1.282,50,tested_positive 621 | 0,119,0,0,0,32.4,0.141,24,tested_positive 622 | 2,112,86,42,160,38.4,0.246,28,tested_negative 623 | 2,92,76,20,0,24.2,1.698,28,tested_negative 624 | 6,183,94,0,0,40.8,1.461,45,tested_negative 625 | 0,94,70,27,115,43.5,0.347,21,tested_negative 626 | 2,108,64,0,0,30.8,0.158,21,tested_negative 627 | 4,90,88,47,54,37.7,0.362,29,tested_negative 628 | 0,125,68,0,0,24.7,0.206,21,tested_negative 629 | 0,132,78,0,0,32.4,0.393,21,tested_negative 630 | 5,128,80,0,0,34.6,0.144,45,tested_negative 631 | 4,94,65,22,0,24.7,0.148,21,tested_negative 632 | 7,114,64,0,0,27.4,0.732,34,tested_positive 633 | 0,102,78,40,90,34.5,0.238,24,tested_negative 634 | 2,111,60,0,0,26.2,0.343,23,tested_negative 635 | 1,128,82,17,183,27.5,0.115,22,tested_negative 636 | 10,92,62,0,0,25.9,0.167,31,tested_negative 637 | 13,104,72,0,0,31.2,0.465,38,tested_positive 638 | 5,104,74,0,0,28.8,0.153,48,tested_negative 639 | 2,94,76,18,66,31.6,0.649,23,tested_negative 640 | 7,97,76,32,91,40.9,0.871,32,tested_positive 641 | 1,100,74,12,46,19.5,0.149,28,tested_negative 642 | 0,102,86,17,105,29.3,0.695,27,tested_negative 643 | 4,128,70,0,0,34.3,0.303,24,tested_negative 644 | 6,147,80,0,0,29.5,0.178,50,tested_positive 645 | 4,90,0,0,0,28,0.61,31,tested_negative 646 | 3,103,72,30,152,27.6,0.73,27,tested_negative 647 | 2,157,74,35,440,39.4,0.134,30,tested_negative 648 | 1,167,74,17,144,23.4,0.447,33,tested_positive 649 | 0,179,50,36,159,37.8,0.455,22,tested_positive 650 | 11,136,84,35,130,28.3,0.26,42,tested_positive 651 | 0,107,60,25,0,26.4,0.133,23,tested_negative 652 | 1,91,54,25,100,25.2,0.234,23,tested_negative 653 | 1,117,60,23,106,33.8,0.466,27,tested_negative 654 | 5,123,74,40,77,34.1,0.269,28,tested_negative 655 | 2,120,54,0,0,26.8,0.455,27,tested_negative 656 | 1,106,70,28,135,34.2,0.142,22,tested_negative 657 | 2,155,52,27,540,38.7,0.24,25,tested_positive 658 | 2,101,58,35,90,21.8,0.155,22,tested_negative 659 | 1,120,80,48,200,38.9,1.162,41,tested_negative 660 | 11,127,106,0,0,39,0.19,51,tested_negative 661 | 3,80,82,31,70,34.2,1.292,27,tested_positive 662 | 10,162,84,0,0,27.7,0.182,54,tested_negative 663 | 1,199,76,43,0,42.9,1.394,22,tested_positive 664 | 8,167,106,46,231,37.6,0.165,43,tested_positive 665 | 9,145,80,46,130,37.9,0.637,40,tested_positive 666 | 6,115,60,39,0,33.7,0.245,40,tested_positive 667 | 1,112,80,45,132,34.8,0.217,24,tested_negative 668 | 4,145,82,18,0,32.5,0.235,70,tested_positive 669 | 10,111,70,27,0,27.5,0.141,40,tested_positive 670 | 6,98,58,33,190,34,0.43,43,tested_negative 671 | 9,154,78,30,100,30.9,0.164,45,tested_negative 672 | 6,165,68,26,168,33.6,0.631,49,tested_negative 673 | 1,99,58,10,0,25.4,0.551,21,tested_negative 674 | 10,68,106,23,49,35.5,0.285,47,tested_negative 675 | 3,123,100,35,240,57.3,0.88,22,tested_negative 676 | 8,91,82,0,0,35.6,0.587,68,tested_negative 677 | 6,195,70,0,0,30.9,0.328,31,tested_positive 678 | 9,156,86,0,0,24.8,0.23,53,tested_positive 679 | 0,93,60,0,0,35.3,0.263,25,tested_negative 680 | 3,121,52,0,0,36,0.127,25,tested_positive 681 | 2,101,58,17,265,24.2,0.614,23,tested_negative 682 | 2,56,56,28,45,24.2,0.332,22,tested_negative 683 | 0,162,76,36,0,49.6,0.364,26,tested_positive 684 | 0,95,64,39,105,44.6,0.366,22,tested_negative 685 | 4,125,80,0,0,32.3,0.536,27,tested_positive 686 | 5,136,82,0,0,0,0.64,69,tested_negative 687 | 2,129,74,26,205,33.2,0.591,25,tested_negative 688 | 3,130,64,0,0,23.1,0.314,22,tested_negative 689 | 1,107,50,19,0,28.3,0.181,29,tested_negative 690 | 1,140,74,26,180,24.1,0.828,23,tested_negative 691 | 1,144,82,46,180,46.1,0.335,46,tested_positive 692 | 8,107,80,0,0,24.6,0.856,34,tested_negative 693 | 13,158,114,0,0,42.3,0.257,44,tested_positive 694 | 2,121,70,32,95,39.1,0.886,23,tested_negative 695 | 7,129,68,49,125,38.5,0.439,43,tested_positive 696 | 2,90,60,0,0,23.5,0.191,25,tested_negative 697 | 7,142,90,24,480,30.4,0.128,43,tested_positive 698 | 3,169,74,19,125,29.9,0.268,31,tested_positive 699 | 0,99,0,0,0,25,0.253,22,tested_negative 700 | 4,127,88,11,155,34.5,0.598,28,tested_negative 701 | 4,118,70,0,0,44.5,0.904,26,tested_negative 702 | 2,122,76,27,200,35.9,0.483,26,tested_negative 703 | 6,125,78,31,0,27.6,0.565,49,tested_positive 704 | 1,168,88,29,0,35,0.905,52,tested_positive 705 | 2,129,0,0,0,38.5,0.304,41,tested_negative 706 | 4,110,76,20,100,28.4,0.118,27,tested_negative 707 | 6,80,80,36,0,39.8,0.177,28,tested_negative 708 | 10,115,0,0,0,0,0.261,30,tested_positive 709 | 2,127,46,21,335,34.4,0.176,22,tested_negative 710 | 9,164,78,0,0,32.8,0.148,45,tested_positive 711 | 2,93,64,32,160,38,0.674,23,tested_positive 712 | 3,158,64,13,387,31.2,0.295,24,tested_negative 713 | 5,126,78,27,22,29.6,0.439,40,tested_negative 714 | 10,129,62,36,0,41.2,0.441,38,tested_positive 715 | 0,134,58,20,291,26.4,0.352,21,tested_negative 716 | 3,102,74,0,0,29.5,0.121,32,tested_negative 717 | 7,187,50,33,392,33.9,0.826,34,tested_positive 718 | 3,173,78,39,185,33.8,0.97,31,tested_positive 719 | 10,94,72,18,0,23.1,0.595,56,tested_negative 720 | 1,108,60,46,178,35.5,0.415,24,tested_negative 721 | 5,97,76,27,0,35.6,0.378,52,tested_positive 722 | 4,83,86,19,0,29.3,0.317,34,tested_negative 723 | 1,114,66,36,200,38.1,0.289,21,tested_negative 724 | 1,149,68,29,127,29.3,0.349,42,tested_positive 725 | 5,117,86,30,105,39.1,0.251,42,tested_negative 726 | 1,111,94,0,0,32.8,0.265,45,tested_negative 727 | 4,112,78,40,0,39.4,0.236,38,tested_negative 728 | 1,116,78,29,180,36.1,0.496,25,tested_negative 729 | 0,141,84,26,0,32.4,0.433,22,tested_negative 730 | 2,175,88,0,0,22.9,0.326,22,tested_negative 731 | 2,92,52,0,0,30.1,0.141,22,tested_negative 732 | 3,130,78,23,79,28.4,0.323,34,tested_positive 733 | 8,120,86,0,0,28.4,0.259,22,tested_positive 734 | 2,174,88,37,120,44.5,0.646,24,tested_positive 735 | 2,106,56,27,165,29,0.426,22,tested_negative 736 | 2,105,75,0,0,23.3,0.56,53,tested_negative 737 | 4,95,60,32,0,35.4,0.284,28,tested_negative 738 | 0,126,86,27,120,27.4,0.515,21,tested_negative 739 | 8,65,72,23,0,32,0.6,42,tested_negative 740 | 2,99,60,17,160,36.6,0.453,21,tested_negative 741 | 1,102,74,0,0,39.5,0.293,42,tested_positive 742 | 11,120,80,37,150,42.3,0.785,48,tested_positive 743 | 3,102,44,20,94,30.8,0.4,26,tested_negative 744 | 1,109,58,18,116,28.5,0.219,22,tested_negative 745 | 9,140,94,0,0,32.7,0.734,45,tested_positive 746 | 13,153,88,37,140,40.6,1.174,39,tested_negative 747 | 12,100,84,33,105,30,0.488,46,tested_negative 748 | 1,147,94,41,0,49.3,0.358,27,tested_positive 749 | 1,81,74,41,57,46.3,1.096,32,tested_negative 750 | 3,187,70,22,200,36.4,0.408,36,tested_positive 751 | 6,162,62,0,0,24.3,0.178,50,tested_positive 752 | 4,136,70,0,0,31.2,1.182,22,tested_positive 753 | 1,121,78,39,74,39,0.261,28,tested_negative 754 | 3,108,62,24,0,26,0.223,25,tested_negative 755 | 0,181,88,44,510,43.3,0.222,26,tested_positive 756 | 8,154,78,32,0,32.4,0.443,45,tested_positive 757 | 1,128,88,39,110,36.5,1.057,37,tested_positive 758 | 7,137,90,41,0,32,0.391,39,tested_negative 759 | 0,123,72,0,0,36.3,0.258,52,tested_positive 760 | 1,106,76,0,0,37.5,0.197,26,tested_negative 761 | 6,190,92,0,0,35.5,0.278,66,tested_positive 762 | 2,88,58,26,16,28.4,0.766,22,tested_negative 763 | 9,170,74,31,0,44,0.403,43,tested_positive 764 | 9,89,62,0,0,22.5,0.142,33,tested_negative 765 | 10,101,76,48,180,32.9,0.171,63,tested_negative 766 | 2,122,70,27,0,36.8,0.34,27,tested_negative 767 | 5,121,72,23,112,26.2,0.245,30,tested_negative 768 | 1,126,60,0,0,30.1,0.349,47,tested_positive 769 | 1,93,70,31,0,30.4,0.315,23,tested_negative 770 | --------------------------------------------------------------------------------