<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:space="preserve" xmlns="http://www.tei-c.org/ns/1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.tei-c.org/ns/1.0 https://raw.githubusercontent.com/kermitt2/grobid/master/grobid-home/schemas/xsd/Grobid.xsd"
 xmlns:xlink="http://www.w3.org/1999/xlink">
	<teiHeader xml:lang="en">
		<fileDesc>
			<titleStmt>
				<title level="a" type="main">Teaching Pure LP with Prolog and a Fair Search Rule ⋆</title>
			</titleStmt>
			<publicationStmt>
				<publisher/>
				<availability status="unknown"><licence/></availability>
			</publicationStmt>
			<sourceDesc>
				<biblStruct>
					<analytic>
						<author>
							<persName><forename type="first">Manuel</forename><forename type="middle">V</forename><surname>Hermenegildo</surname></persName>
							<email>manuel.hermenegildo@imdea.org</email>
							<affiliation key="aff0">
								<orgName type="institution">Universidad Politécnica de Madrid (UPM)</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
							<affiliation key="aff1">
								<orgName type="institution">IMDEA Software Institute</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Jose</forename><forename type="middle">F</forename><surname>Morales</surname></persName>
							<email>josef.morales@imdea.org</email>
							<affiliation key="aff0">
								<orgName type="institution">Universidad Politécnica de Madrid (UPM)</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
							<affiliation key="aff1">
								<orgName type="institution">IMDEA Software Institute</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Pedro</forename><surname>Lopez-Garcia</surname></persName>
							<affiliation key="aff1">
								<orgName type="institution">IMDEA Software Institute</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
							<affiliation key="aff2">
								<orgName type="institution">Spanish Council for Scientific Research (CSIC)</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
						</author>
						<author>
							<affiliation key="aff3">
								<orgName type="department">𝑛𝑑 Workshop on Prolog Education</orgName>
								<address>
									<postCode>2024</postCode>
									<settlement>October, Dallas</settlement>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<title level="a" type="main">Teaching Pure LP with Prolog and a Fair Search Rule ⋆</title>
					</analytic>
					<monogr>
						<idno type="ISSN">1613-0073</idno>
					</monogr>
					<idno type="MD5">82AD507CB01091F8F6BAB03F18FB9D88</idno>
				</biblStruct>
			</sourceDesc>
		</fileDesc>
		<encodingDesc>
			<appInfo>
				<application version="0.7.2" ident="GROBID" when="2025-04-23T19:51+0000">
					<desc>GROBID - A machine learning software for extracting information from scholarly documents</desc>
					<ref target="https://github.com/kermitt2/grobid"/>
				</application>
			</appInfo>
		</encodingDesc>
		<profileDesc>
			<textClass>
				<keywords>
					<term>Teaching Prolog</term>
					<term>Teaching Logic Programming</term>
					<term>Logic Programming</term>
					<term>Constraint Logic Programming</term>
				</keywords>
			</textClass>
			<abstract>
<div xmlns="http://www.tei-c.org/ns/1.0"><p>Classic Prolog has many features, and even more in its modern incarnations. Many of these features are well aligned with the view of pure Logic Programming as both a specification tool and a programming language. However, some other Prolog aspects depart from this view. Classic examples that have received much attention are assert/retract or the cut. Our focus here is however on the depth-first search rule. While well justified by practical concerns, using only depth-first from the start also introduces early on the need to reason about termination, and also possibly a need to use impure features to make different modes produce answers in finite time. Termination of course has to be faced sooner or later by any programmer, but having to do it right at the start can detract from being able to convey early on the vision of Prolog as a declarative language where one can first concentrate on problem specification and/or knowledge representation and only later worry about efficiency. We review a number of ways in which some of these issues can be tackled when teaching Prolog, while still using throughout a Prolog system. The aim is tutorial, in the hope that these ideas can help other instructors that are teaching or plan to teach Prolog. We believe that some of these considerations may also come in handy when combining Prolog with modern, AI-assisted programming methodologies.</p></div>
			</abstract>
		</profileDesc>
	</teiHeader>
	<text xml:lang="en">
		<body>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.">Introduction</head><p>In <ref type="bibr" target="#b0">[1,</ref><ref type="bibr" target="#b2">3]</ref> we presented some thoughts and lessons learned over time about how to teach (Constraint) Logic Programming -(C)LP-in general and Prolog in particular. We argued that teaching (C)LP and Prolog is necessary because it brings in many useful concepts and characteristics that are not present in other programming paradigms such as imperative, object-oriented, or functional programming. We also addressed different aspects of how to teach Prolog, covering from how to show the beauty and usefulness of the language to how to avoid some common pitfalls, misconceptions, and myths about this unique programming paradigm.</p><p>Our aim herein is to expand on the fundamental aspect of transmitting to students the beauty and power of Prolog. The (C)LP paradigm is based on logic and includes search as an intrinsic component, as well as the use of unification, and generalized pattern matching. This brings about interesting and distinctive aspects, such as the reversibility of programs and the ability to represent and reason about knowledge. It also makes it possible to formulate runnable specifications and efficient algorithms within the same formalism, making (C)LP not only a singular programming paradigm, but also a modeling and reasoning tool. We would like to explore how to convey these concepts already in the first steps of teaching (C)LP and Prolog, as well as to provide some ideas on how to do this using the same tool -a modern Prolog system-that will be used in the later, more algorithmically-oriented parts of a Prolog course.</p><p>Classic Prolog has many features, with even more in its modern incarnations. Many of these features are well aligned with the view of pure Logic Programming as both a specification tool and a programming language. However, some other Prolog aspects depart from this view. Classic examples that have received much attention are assert/retract and the cut. Our focus here is however on the depth-first search rule: while well-justified by practical concerns, using only depth-first from the start also introduces early on the need to reason about termination, and also possibly a need to use impure features to make different modes produce answers in finite time. Termination of course has to be faced sooner or later by any programmer, but having to do it right at the start can detract from being able to convey early on the vision of Prolog as a declarative language where one can first concentrate on problem specification and/or knowledge representation and only worry later about efficiency.</p><p>In the rest of the paper we review a number of ways in which some of these issues can be tackled when teaching Prolog, while still using throughout a Prolog system. The aim is tutorial, in the hope that these ideas can help other instructors that are teaching or plan to teach Prolog.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">The main message</head><p>As we have also argued in <ref type="bibr" target="#b0">[1]</ref>, perhaps the most important objective during the first steps of teaching Prolog is to succeed in showing the great beauty of the (C)LP paradigm in general and of Prolog in particular. We believe that in order to achieve this, one needs to convey the original inspiration behind the paradigm of being at the same time a specification and knowledge representation language and a practical and highly productive programming language. We find it very useful to explicitly expose students to the ideas put forward by Cordell Green <ref type="bibr" target="#b3">[4]</ref>. Green suggested that, provided an effective deduction procedure is available, i.e., a mechanical proof method, inspired at the time by Robinson's recent proposal of the resolution principle <ref type="bibr" target="#b4">[5]</ref>, a different view of problem solving and computing would be possible (Figure <ref type="figure" target="#fig_0">1</ref>, top). In this approach, the automated deduction procedure is programmed once and for all in the computer. Then, for each problem we want to solve, we just need to find a suitable representation for it in logic (i.e., its specification), and, to obtain solutions, we simply ask questions and let the deduction procedure do the rest. Prolog (and (C)LP in general) are the materialization of this idea by Colmerauer and Kowalski <ref type="bibr" target="#b5">[6,</ref><ref type="bibr" target="#b6">7]</ref>, where (Figure <ref type="figure" target="#fig_0">1</ref>, bottom) the problem representation or specification is written in logic using the Prolog language, and the efficient deduction mechanism is Kowalski and Kuhnen's SLD resolution <ref type="bibr" target="#b8">[8,</ref><ref type="bibr" target="#b9">9]</ref>, combined with the practicality brought about by Warren et al. 's Dec-10 Prolog implementation and compilation techniques <ref type="bibr">[10,</ref><ref type="bibr" target="#b11">11]</ref>.   Description of the topology of a circuit: resistor (power ,n1). resistor (power ,n2). transistor (n2 ,ground ,n1). transistor (n3 ,n4 ,n2). transistor (n5 ,ground ,n4). run ▶ Figure <ref type="figure">3</ref>: A simple pure logic program for circuit topology.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">The first simple examples</head><p>The vision that with Prolog one can just represent/specify the problem and then obtain answers automatically is relatively easy to convey with the first simple examples such as, e.g., the classical family relationships (Figure <ref type="figure">2</ref>), circuit topology (Figure <ref type="figure">3</ref>), simple puzzles, etc. <ref type="foot" target="#foot_1">2</ref> For example, with the family facts and rules of Figure <ref type="figure">2</ref> students can get answers to questions in different modes such as ?-mother_of(susan,Y)., ?-mother_of(X,mary)., ?-grandmother_of(X,Y)., etc. Similarly, with the "digital circuit theory" at the top of Figure <ref type="figure">3</ref>, which describes how inverters, nand-gates, and and-gates are made up of resistors and transistors connected to ground or power, and the concrete circuit at the bottom, described by enumerating the components to which the circuit nodes are attached, students can also get answers to questions in different modes, such as, e.g.: <ref type="foot" target="#foot_2">3</ref>run ▶ ?-and_gate (In1 ,In2 ,Out).</p><p>i,e., "is there an and-gate somewhere in this circuit?, " and Prolog finds the answer:</p><formula xml:id="formula_0">In1 = n3 , In2 = n5 , Out = n1 ?</formula><p>run ▶ mother_of (susan , mary). mother_of (susan , john). mother_of (mary , michael ). father_of (john , david ). parent (X,Y) :-mother_of (X,Y). parent (X,Y) :-father_of (X,Y).</p><p>ancestor (X,Y) :ancestor (X,Z), parent (Z,Y). ancestor (X,Y) :parent (X,Y). The issue most relevant to our discussion is that all these queries will return the correct solution and terminate using standard Prolog. I.e., in these examples students can use just the logical reading when writing and reading clauses, and then, assuming that the logic is correct, have confidence that the system will answer correctly any question providing all possible solutions in finite time. However, things can quickly get more complicated.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.">A first source of non-termination</head><p>Returning to the family example of Figure <ref type="figure">2</ref>, consider adding to it the classical ancestor predicate, as in Figure <ref type="figure" target="#fig_2">4</ref>. Now for any query to ancestor/2 the program hangs in standard Prolog without giving any answers:</p><p>run ▶ ?ancestor (X,Y).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&lt;hangs &gt;</head><p>Of course, we can change the order of the ancestor/2 clauses and the program will now behave better in standard Prolog. E.g., for: run ▶ ?ancestor (X,Y).</p><p>We will obtain all the answers:</p><formula xml:id="formula_1">X = susan , Y = mary ? ; X = susan , Y = john ? ; X = mary , Y = michael ? ; X = john , Y = david ? ; X = susan , Y = michael ? ; X = susan , Y = david ? ; &lt;hangs &gt;</formula><p>but the program will still hang at the end. It is an inevitable fact that, sooner or later, students will be confronted with non-termination. It can be hard for them to get around this stumbling block at the early stages of learning the paradigm, and this may lead to disenchantment and/or confusion if no additional tools and understanding of the issues involved are provided.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.">Tabling to the (partial) rescue</head><p>Fortunately the technique of tabling, pioneered by XSB <ref type="bibr" target="#b12">[12]</ref>, and now supported by several other modern Prologs <ref type="bibr" target="#b13">[13]</ref>, including B-Prolog <ref type="bibr" target="#b14">[14]</ref>, Ciao Prolog <ref type="bibr" target="#b15">[15]</ref>, SWI Prolog <ref type="bibr" target="#b16">[16]</ref>, and Yap <ref type="bibr" target="#b17">[17]</ref>, comes to the rescue for a good number of these cases. Tabling ensures termination of programs for which the "bounded term-size property" holds: programs where all the sizes of subgoals and answers produced during an evaluation are smaller than some fixed number. This is indeed the case for the program of Figure <ref type="figure" target="#fig_2">4</ref>, since there are only a finite number of constants in the program and thus any query, subgoal, or answer will be of bounded size. This is also the case for all "Datalog" programs. In order to ensure termination we can declare ancestor/2 as a tabled predicate as follows:<ref type="foot" target="#foot_3">4</ref> </p><p>:table ancestor /2.</p><p>Now we not only get all the answers without having to invert the order of the ancestor/2 clauses:</p><formula xml:id="formula_2">X = susan , Y = mary ? ; X = susan , Y = john ? ; X = mary , Y = michael ? ; X = john , Y = david ? ; X = susan , Y = michael ? ; X = susan , Y = david ? ; no</formula><p>but the program also ends stating in finite time that there are no more solutions. Note that switching the order of the literals in the recursive clause of ancestor/2: run ▶</p><p>ancestor (X,Y) :parent (X,Z), ancestor (Z,Y).</p><p>we obtain all the answers and the program also terminates at the end with standard Prolog. However, this is not always the case, and tabling offers in general a more powerful mechanism than just switching the order of clauses and body literals. A relevant issue in tabling is which predicates to declare as tabled, which is a subject onto itself, but beyond the scope of our discussion here. However, in the first stages students can simply be told to try declaring different or all predicates as tabled. <ref type="foot" target="#foot_4">5</ref>Overall, tabling can be very useful in our quest to transmit the beauty of the Prolog language. However, it will obviously not cover the cases which fall outside the bounded term-size property. Unfortunately, this can often happen once nested data structures are introduced and combined with recursion.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.">More complex cases</head><p>Consider natural/1 defining the natural numbers in Peano representation: <ref type="foot" target="#foot_5">6</ref>run ▶ natural (0). natural (s(X)) :natural (X).</p><formula xml:id="formula_3">add (0,Y,Y) :-natural (Y). add(s(X),Y,s(Z)) :-add(X,Y,Z). mult (0,Y ,0) :-natural (Y). mult(s(X),Y,Z) :-add(W,Y,Z), mult(X,Y,W).</formula><p>nat_square (X,Y) :natural (X), natural (Y), mult(X,X,Y). and pair/2 defining a pair of natural numbers:</p><formula xml:id="formula_4">pair(X,Y) :-natural (X), natural (Y).</formula><p>A query such as the following:</p><p>run ▶ ?pair(X,Y), X=s(0).</p><p>will hang in standard Prolog, because of course the search never progresses beyond X=0, since there are infinite possible solutions for Y that will be explored first. The initially surprised student may eventually realize that in this case it suffices with simply reversing the order of the literals in the query: 7</p><p>?-X=s(0) , pair(X,Y).</p><p>and see that now all the answers are enumerated:</p><formula xml:id="formula_5">X = s(0) , Y = 0 ? ; X = s(0) , Y = s(0) ? ; X = s(0) , Y = s(s(0)) ? ; X = s(0) , Y = s(s(s(0))) ? ...</formula><p>However, consider the more complex program of Figure <ref type="figure" target="#fig_3">5</ref>, defining nat_square(X,Y) that holds if X and Y are both naturals and Y is equal to X multiplied by itself. We have also included the auxiliary predicates defining addition and multiplication. In our classes, we develop each of these predicate definitions with the students by reasoning about the (infinite) set of (ground) facts we want to capture, thereby informally introducing the notion of declarative semantics. We also work with the students on generating the definitions by generalization from tables of facts, thinking inductively, and more. See also <ref type="bibr" target="#b19">[19]</ref> for an ample discussion of how to build programs inductively.</p><p>Standard Prolog execution provides useful answers for, e.g., mode nat_square(+,-): run ▶ ?-nat_square (s(s(0)), X). X = s(s(s(s(0)))) ?</p><p>an even for mode nat_square(-,+):</p><p>?-nat_square (X,s(s(s(s(0))))). X = s(s(0)) ?</p><p>which invariably nicely surprises students, even if in both cases standard Prolog hangs if one asks for more, non-existent, answers. However, the next obvious temptation is to try:</p><formula xml:id="formula_6">?-nat_square (X,Y).</formula><p>but this time standard Prolog only produces the first, trivial answer and then hangs: 7 At this point it can also be pointed out that there exist other techniques like delays for changing dynamically the goal order.</p><p>X = 0, Y = 0 ? ; &lt;hangs &gt; despite the fact that there are obviously infinitely many additional valid answers.</p><p>Unfortunately, these cases of non-termination cannot be avoided with just tabling, since the program is producing continuously growing Peano numbers, i.e., continuously growing terms. Unfortunately, non-termination issues of this sort are often encountered early on by students -basically as soon as recursive data structures are introduced.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.">Fairness to the (partial) rescue</head><p>In order to address these more complex cases, we have found it useful to provide students with a means for selectively switching between depth-first and other search rule(s), including in particular at least one that is fair. Ciao Prolog, which has incorporated over time a number of features to facilitate teaching Prolog and (C)LP, supports declarations such as:</p><formula xml:id="formula_7">:-use_package (sr/bfall).</formula><p>which students can use to specify alternative search rules and run some or all predicates using breadthfirst, as well as iterative deepening, etc., in addition to depth-first and tabling. Such alternative search rules are in fact relatively straightforward to implement in any Prolog system, for example via metainterpretation and/or code expansions. <ref type="foot" target="#foot_6">8</ref>The relevant fact for our discussion is that if students set their predicates to run in, e.g., breadth-first mode, then all examples will "work well" for all possible queries. This, in the sense that all valid solutions will be found, even if possibly inefficiently. For example, our problematic query: run ▶ ?-nat_square (X,Y).</p><p>will now enumerate the infinite set of correct answers:</p><p>?-nat_square (X,Y). X = 0, Y = 0 ? ; X = s(0) , Y = s(0) ? ; X = s(s(0)), Y = s(s(s(s(0)))) ? ; X = s(s(s(0))), Y = s(s(s(s(s(s(s(s(s(0))))))))) ? ; X = s(s(s(s(0)))), Y = s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(0</p><formula xml:id="formula_8">)))))))))))))))) ? ...</formula><p>Another interesting consequence of using a fair search rule, even for the cases where depth-first works, is that the "quality" in the enumeration of solutions also improves with respect to depth-first. For example, the query:</p><formula xml:id="formula_9">run ▶ ?-mult(X,Y,Z).</formula><p>does not hang in standard Prolog. However, it produces the following answers:</p><formula xml:id="formula_10">X = 0, Y = 0, Z = 0 ? ; X = 0, Y = s(0) , Z = 0 ? ; X = 0, Y = s(s(0)), Z = 0 ? ; X = 0, Y = s(s(s(0))), Z = 0 ? ; ↶ ↷ X = 0, Y = s(s(s(s(0)))), Z = 0 ? ; X = 0, Y = s(s(s(s(s(0))))), Z = 0 ? ; X = 0, Y = s(s(s(s(s(s(0)))))), Z = 0 ? X = 0, Y = s(s(s(s(s(s(s(0))))))), Z = 0 ? ...</formula><p>It becomes clear that some answers will never be generated by the depth-first search: it will generate infinitely many mult(0,X,0) tuples, with X being any Peano number, without ever having a chance to generate tuples where the first and third arguments are different from 0. In contrast, breadth-first will produce all solutions:</p><formula xml:id="formula_11">X = 0, Y = 0, Z = 0 ? ; X = 0, Y = s(0) , Z = 0 ? ; X = 0, Y = s(s(0)), Z = 0 ? ; X = 0, Y = s(s(s(0))), Z = 0 ? ; X = s(0) , Y = 0, Z = 0 ? ; X = 0, Y = s(s(s(s(0)))), Z = 0 ? ; ↶ ↷ X = 0, Y = s(s(s(s(s(0))))), Z = 0 ? ; X = s(0) , Y = s(0) , Z = s(0) ? ; X = 0, Y = s(s(s(s(s(s(0)))))), Z = 0 ? ; X = s(s(0)), Y = 0, Z = 0 ? ; X = 0, Y = s(</formula><p>s(s(s(s(s(s(0))))))), Z = 0 ? ; X = s(0) , Y = s(s(0)), Z = s(s(0)) ? ; ... which, in addition, are clearly more informative, satisfying, and useful for subsequent predicates as the solutions obtained using the depth-first search.</p><p>In summary, we argue that the use of a fair search rule helps students visualize the true potential of the (C)LP paradigm and Prolog and that it is possible indeed to solve problems by simply thinking logically and/or inductively.</p><p>It is interesting to note that this fairness in enumeration also comes in handy in several other areas, such as for example for type definitions. Fig. <ref type="figure" target="#fig_4">6</ref> shows the definition of two types (they are marked as regular types by the regtype directive): color/1, defined as the set of values {red, green, blue}, and colorlist/1, representing the infinite set of lists whose elements are of type color. <ref type="foot" target="#foot_7">9</ref> In Ciao Prolog marking predicates as types (or in general as properties) allows them to be used in assertions. However, they remain regular predicates, and can be called as any other, used as run-time tests (dynamic checking), "run backwards" to generate examples or test cases, etc. See, e.g., <ref type="bibr" target="#b20">[20]</ref> for a recent more complete presentation of these aspects.</p><p>For example, calling: run ▶ ?colorlist (L).</p><p>run ▶ :-use_package ([ assertions , regtypes ]). % :-use_package (sr/ bfall ).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>:regtype color /1. color (red). color ( green ). color (blue).</head><p>:regtype colorlist /1. colorlist ([]). colorlist ([H|T]) :color (H), colorlist (T).  </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.">Going from executable specifications to efficient algorithms</head><p>With all these tools, the student can also be shown with examples (and through benchmarking them) how in Prolog it is possible to go from executable specifications to efficient algorithms gradually, as needed. One of the examples we use is the modulo operation mod(X,Y,Z) , where Z is the remainder from dividing X by Y. A mathematical definition or specification for this operation is:</p><formula xml:id="formula_12">𝑚𝑜𝑑(𝑋, 𝑌, 𝑍) ⇐⇒ ∃𝑄𝑠.𝑡. 𝑋 = 𝑌 * 𝑄 + 𝑍 ∧ 𝑍 &lt; 𝑌</formula><p>This can be expressed directly in Prolog as:</p><formula xml:id="formula_13">run ▶ mod(X,Y,Z) :-less(Z, Y), mult(Y,Q,W), add(W,Z,X).</formula><p>This version is clearly correct (since it is directly the specification) and, using, e.g., breadth-first search, works in multiple directions, always finding all solutions:</p><p>?-op (500 ,fy ,s). yes ?-mod(X,Y, s 0). X = s 0, Y = s s 0 ? ; X = s 0, Y = s s s 0 ? ; X = s s s 0, Y = s s 0 ? ; X = s 0, Y = s s s s 0 ? ; ... but it can of course be quite inefficient. However, also in Prolog, we can write another version such as this one:</p><formula xml:id="formula_14">run ▶ mod(X,Y,X) :-less(X, Y). mod(X,Y,Z) :-add(X1 ,Y,X), mod(X1 ,Y,Z).</formula><p>which is much more efficient -one can time some queries or reason about the size of the proof trees to show this. Also, this version works well with the default depth-first search rule for several modes. However, the enumeration of solutions is again biased and thus less elegant and useful than the one obtained using breadth-first search.</p><p>We do not mean to imply however that the use of a fair search rule or pure programs are a requirement for traveling the path from executable specifications to efficient algorithms. Figure <ref type="figure">8</ref> shows an additional example, where we have a specification and two implementations for computing the maximum of a list of numbers: max/2 on the left is a direct transliteration of the mathematical specification and max2/2 on the right is a much more efficient, algorithmic implementation. Here both programs can only be used in max(+,-) mode because of the use of non-reversible standard Prolog built-ins, but are still quite suitable as an example of writing both the specification and an algorithm in Prolog.</p><p>Regarding the examples to show, if only small and simple ones are chosen, sophisticated Prolog implementations running on fast modern computers can also create the misconception that Prolog provides solutions effortlessly. Thus, it is important to eventually also tackle larger and more complex problems and stress that, as a Turing complete language, also Prolog programmers eventually need to care about algorithmic time and memory complexity of both their programs and the libraries/features they utilize, which of course includes, at the limit, termination. Here it is also important to explain at an early stage how to control search, via clause order and literal order, as well as pruning in later stages. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="9.">Explaining what is really going on</head><p>After students have written just a few examples using both depth-first and a fair search rule, they will have observed that the fair search rule does provide all the expected answers, but that execution sometimes hangs after that. It is important thus to explain better what is really happening with their programs, which also implies coming to terms with the realities of non-termination in Turing complete programming languages.</p><p>To this end, we have found it very useful to use depictions such as those in Figures 9 and-10 to introduce students in a graphical way to the basic theoretical results at play, i.e., the soundness and (refutation-)completeness of the SLD(NF)-resolution proof procedure used by Prolog.</p><p>The idea is to convey that the search tree has in general the shape of Figure <ref type="figure">9</ref>, i.e., that all solutions and some failures are at finite depth, but that there may be branches leading to failure that are infinite. While techniques such as tabling, as we have seen before, can help detect and avoid traversing some of these infinite failure branches when the bounded term-size property holds, it is not possible to always do so. At this point, it can be interesting to recall or introduce them to the notions of undecidability and the halting problem, and relate these concepts to the graphical depiction of the search tree. The level of discussion will depend of course on the students' level, but it can always be done informally and adapted to their background. At the same time one should underline that this is of course not a particular problem of Prolog or Logic Programming, but rather the essence of computability, and no language (Prolog, logic, nor any other Turing-complete programming language) or proof system can provide a magic formula that guarantees termination in all cases.</p><p>This schematic search tree depiction makes it then easy to explain why breadth-first (or iterative deepening, or any other fair search rule) is guaranteed to produce all solutions if they exist (Figure <ref type="figure" target="#fig_0">10</ref>, left). If there is a finite number of solutions, such fair search rules find them in finite time, even if perhaps they do not terminate in some cases after producing all the answers. And it is also easy to explain why depth-first search (Figure <ref type="figure" target="#fig_0">10</ref>, right) may sometimes hang before producing some of the answers: those that are in the tree to the right of the leftmost infinite branch. This is also a good opportunity for introducing and explaining graphically other alternative fair search rules such as iterative deepening and compare them with the students to depth-first search. One can then discuss the advantages and disadvantages of these search rules in terms of time, memory, etc. E.g., that the price to pay for breadth-first execution's advantages is larger memory consumption and execution time, while depth-first can be implemented very efficiently with a stack, with iterative deepening representing an interesting middle ground. This can be shown very practically by benchmarking actual examples, motivating the practical choices made for Prolog, which bring in great efficiency at the (arguably reasonable) price of having to think about the order of query goals, clauses, and body literals.</p><p>As an example, Figure <ref type="figure" target="#fig_7">11</ref> shows some results comparing depth-first (df), breadth-first (bf), and iterative deepening (id) for queries to the nat_square/2 predicate of Figure <ref type="figure" target="#fig_3">5</ref> for two modes: nat_square(+N,-N2) and nat_square(-N,-N2) , i.e., providing a Peano number N and calculating its Peano square, and generating all the pairs of Peano numbers and their squares. For the first mode the graph provides execution times in mS for calls with increasing numbers of N, starting from 0, i.e., ?-nat_square(0,R)., ?-nat_square(s(0),R)., etc. For the second mode, the numbers on the 𝑦 axis are the timings for each one of the answers to ?-nat_square(N,R)., i.e., the time to get the first values of N and R, then for the second, etc. In this case no curve is given for depth-first, since as we saw it hangs after the first solution.</p><p>It is important to note that these numbers are for sub-optimal implementations of the fair rules and that they are for a single problem, so obviously no general conclusions can be drawn and the trade-offs between these search rules are well studied anyway. Here the results are only intended as an illustrative example.</p><p>In any case, breadth first search is slower than iterative deepening in most, but not all, cases, and both are slower than depth-first, but obviously only for the cases in which depth-first works. It is also interesting to see that depth-first and iterative deepening are relatively close, as expected.</p><p>The important point however is that the fair rules are usable for both (and all) modes, at least for small queries, and can thus be really useful as default rules in the first steps in a teaching environment, which is our concern herein.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="10.">Final remarks</head><p>Our starting point has been the observation that having to deal with the complexities of termination using Prolog's depth-first rule during the first stages of teaching Prolog often detracts from the objective of conveying to students the beauty and usefulness of the language. Motivated by this observation, we have reviewed some ways of addressing these issues in practice, while still using a Prolog system for all stages, such as the use of tabling and fair search rules. If time permits, it is important to also discuss how the constraint systems built into most current Prolog systems (Q, R, fd, . . . ), can bring about many other improvements to search (e.g., constrain and generate vs. generate and test).</p><p>More generally, teaching Prolog and (C)LP is an extremely rich subject and there are of course many other important aspects that we have not been able to address here, including of course all of the traditional subjects of a Prolog course beyond the first steps. For a more complete picture, we have covered previously some of these other issues in <ref type="bibr" target="#b0">[1,</ref><ref type="bibr" target="#b2">3]</ref>; here we have expanded on one of the points we raised there. Much of our experience over the years is materialized in a) the courses that we have developed, for which, as pointed out before, all materials such as slides, Active Logic Documents <ref type="bibr" target="#b2">[3]</ref>, examples, etc. are publicly available, 10 and b) the many teaching-oriented special features that we have incorporated over time in our own Ciao Prolog system. 11 Here we have touched upon some of these features: being able to choose different search rules and use of the playground from documents for the examples, but there are many others.</p><p>We hope that at least some of the ideas presented and these materials and systems are helpful and inspiring to both Prolog instructors that are teaching or plan to teach Prolog and students.</p></div><figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_0"><head>Figure 1 :</head><label>1</label><figDesc>Figure 1: A motivational view of (C)LP and Prolog: Green's proposal and Prolog as its materialization.</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_2"><head>Figure 4 :</head><label>4</label><figDesc>Figure 4: A more involved pure logic program for family relationships.</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_3"><head>Figure 5 :</head><label>5</label><figDesc>Figure 5: Defining squares of naturals.</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_4"><head>Figure 6 :</head><label>6</label><figDesc>Figure 6: Defining some basic types.</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_5"><head>Figure 7 :</head><label>7</label><figDesc>Figure 7: Defining some basic types using functional notation (fsyntax).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_6"><head>Figure 8 : 8 Figure 9 :Figure 10 :</head><label>88910</label><figDesc>Figure 8: Specification for maximum and two implementations.run ▶ "Max is the maximum element of a set if there is no element in the set that is larger than it. "𝑚𝑎𝑥(𝐿, 𝑀 𝑎𝑥) ← 𝑀 𝑎𝑥 ∈ 𝐿 ∧ ∄𝐸 | 𝐸 ∈ 𝐿 ∧ 𝐸 &gt; 𝑀 𝑎𝑥</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_7"><head>Figure 11 :</head><label>11</label><figDesc>Figure 11: Comparing search rules.</figDesc></figure>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0">Of course, other proof methods such as, e.g., the bottom-up execution of Datalog and ASP systems are also used as a basis for logic programming. Our focus here however is on the Prolog family of (C)LP languages.</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1">The level of complexity of these initial examples depends on the background of the students (it is of course not the same to be teaching in schools or to CS students in college). We are using here simple examples that suffice to make the points of discussion.</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="3" xml:id="foot_2">Clicking on the run ▶ links is perfectly safe!</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="4" xml:id="foot_3">In the case of Ciao Prolog, used in our examples, the tabling functionality is loaded with the directive: :-use_package(tabling).</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="5" xml:id="foot_4">In fact, XSB includes an ":-auto_table." declaration for this purpose, which tables automatically enough predicates so that all possible loops have a tabled predicate.</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="6" xml:id="foot_5">We find Peano arithmetic useful as an instructive, reversible substitute for the non-reversible standard Prolog built-in arithmetic (is/2, etc.) in the first parts of the course. An interesting alternative is using constraints. This is well argued in<ref type="bibr" target="#b18">[18]</ref> and different constraint systems are available in most modern Prologs. However, using constraints requires the introduction of a 'black box' (the solver, performing constraint propagation, etc.) and we find it convenient, specially at the early stages, that Peano arithmetic does not require anything beyond the standard unification/resolution operational semantics, which has been presented at this stage. In any case, we do mention the existence of both arithmetic constraint domains and is/2 when first mentioning Peano arithmetic, and sometimes use constraints anyway in early examples. Beyond these considerations, we also find Peano arithmetic motivating and elegant in itself for developing Prolog examples, specially in the first stages of learning to use recursive data types and recursive programs.</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="8" xml:id="foot_6">In our courses we used to teach the first part of the course, centered around pure LP, with a separate system: a metainterpreterbased standalone system, implemented in Prolog, that ran programs with a breadth-first search rule. However, we eventually found it more didactic and convenient to incorporate the idea of supporting alternative search rules within Ciao Prolog, making use of its facilities for defining language extensions.</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="9" xml:id="foot_7">Fig.7shows the same properties of Fig.6but written instead using Ciao Prolog's functional notation. The two definitions are equivalent, and thus the answers obtained, functional syntax being just syntactic sugar.</note>
		</body>
		<back>
			<div type="references">

				<listBibl>

<biblStruct xml:id="b0">
	<analytic>
		<title level="a" type="main">Some Thoughts on How to Teach Prolog</title>
		<author>
			<persName><forename type="first">M</forename><surname>Hermenegildo</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Morales</surname></persName>
		</author>
		<author>
			<persName><forename type="first">P</forename><surname>Lopez-Garcia</surname></persName>
		</author>
		<ptr target="http://cliplab.org/papers/TeachingProlog-PrologBook.pdf" />
	</analytic>
	<monogr>
		<title level="m">Prolog -The Next 50 Years, number 13900 in LNCS</title>
				<editor>
			<persName><forename type="first">D</forename><forename type="middle">S</forename><surname>Warren</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">V</forename><surname>Dahl</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">T</forename><surname>Eiter</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">M</forename><surname>Hermenegildo</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">R</forename><surname>Kowalski</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><surname>Rossi</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer</publisher>
			<date type="published" when="2023">2023</date>
			<biblScope unit="page" from="107" to="123" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b1">
	<analytic>
		<title level="a" type="main">Prolog as a Knowledge Representation Language -the Nature and Importance of Prolog</title>
		<author>
			<persName><forename type="first">M</forename><forename type="middle">R</forename><surname>Genesereth</surname></persName>
		</author>
		<idno type="DOI">10.1007/978-3-031-35254-6_3</idno>
		<idno>doi:</idno>
		<ptr target="10.1007/978-3-031-35254-6\_3" />
	</analytic>
	<monogr>
		<title level="m">Prolog: The Next 50 Years</title>
		<title level="s">Lecture Notes in Computer Science</title>
		<editor>
			<persName><forename type="first">D</forename><forename type="middle">S</forename><surname>Warren</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">V</forename><surname>Dahl</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">T</forename><surname>Eiter</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">M</forename><forename type="middle">V</forename><surname>Hermenegildo</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">R</forename><forename type="middle">A</forename><surname>Kowalski</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><surname>Rossi</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer</publisher>
			<date type="published" when="2023">2023</date>
			<biblScope unit="volume">13900</biblScope>
			<biblScope unit="page" from="38" to="47" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b2">
	<analytic>
		<title level="a" type="main">Teaching Prolog with Active Logic Documents</title>
		<author>
			<persName><forename type="first">J</forename><surname>Morales</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><surname>Abreu</surname></persName>
		</author>
		<author>
			<persName><forename type="first">D</forename><surname>Ferreiro</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Hermenegildo</surname></persName>
		</author>
		<ptr target="http://cliplab.org/papers/ActiveLogicDocuments-PrologBook.pdf" />
	</analytic>
	<monogr>
		<title level="m">Prolog -The Next 50 Years, number 13900 in LNCS</title>
				<editor>
			<persName><forename type="first">D</forename><forename type="middle">S</forename><surname>Warren</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">V</forename><surname>Dahl</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">T</forename><surname>Eiter</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">M</forename><surname>Hermenegildo</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">R</forename><surname>Kowalski</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><surname>Rossi</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer</publisher>
			<date type="published" when="2023">2023</date>
			<biblScope unit="page" from="171" to="183" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b3">
	<monogr>
		<title level="m" type="main">The Application of Theorem Proving to Question-Answering Systems</title>
		<author>
			<persName><forename type="first">C</forename><surname>Green</surname></persName>
		</author>
		<imprint>
			<date type="published" when="1969">1969</date>
		</imprint>
		<respStmt>
			<orgName>Stanford University</orgName>
		</respStmt>
	</monogr>
	<note type="report_type">Ph.D. thesis</note>
</biblStruct>

<biblStruct xml:id="b4">
	<analytic>
		<title level="a" type="main">A Machine Oriented Logic Based on the Resolution Principle</title>
		<author>
			<persName><forename type="first">J</forename><forename type="middle">A</forename><surname>Robinson</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Journal of the ACM</title>
		<imprint>
			<biblScope unit="volume">12</biblScope>
			<biblScope unit="page" from="23" to="41" />
			<date type="published" when="1965">1965</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b5">
	<analytic>
		<title level="a" type="main">The Birth of Prolog</title>
		<author>
			<persName><forename type="first">A</forename><surname>Colmerauer</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Second History of Programming Languages Conference</title>
				<imprint>
			<date type="published" when="1993">1993</date>
			<biblScope unit="page" from="37" to="52" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b6">
	<analytic>
		<title level="a" type="main">The Early Years of Logic Programming</title>
		<author>
			<persName><forename type="first">R</forename><forename type="middle">A</forename><surname>Kowalski</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Communications of the ACM</title>
		<imprint>
			<biblScope unit="volume">31</biblScope>
			<biblScope unit="page" from="38" to="43" />
			<date type="published" when="1988">1988</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b7">
	<monogr>
		<ptr target="https://cliplab.org/logalg" />
		<title level="m">Our teaching materials can</title>
				<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b8">
	<analytic>
		<title level="a" type="main">Linear resolution with selection function</title>
		<author>
			<persName><forename type="first">R</forename><surname>Kowalski</surname></persName>
		</author>
		<author>
			<persName><forename type="first">D</forename><surname>Kuehner</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Artificial Intelligence</title>
		<imprint>
			<biblScope unit="volume">2</biblScope>
			<biblScope unit="page" from="227" to="260" />
			<date type="published" when="1971">1971</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b9">
	<analytic>
		<title level="a" type="main">Predicate Logic as a Programming Language</title>
		<author>
			<persName><forename type="first">R</forename><forename type="middle">A</forename><surname>Kowalski</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings IFIPS</title>
				<meeting>IFIPS</meeting>
		<imprint>
			<date type="published" when="1974">1974</date>
			<biblScope unit="page" from="569" to="574" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b10">
	<monogr>
		<author>
			<persName><forename type="first">D</forename><surname>Warren</surname></persName>
		</author>
		<title level="m">Applied Logic-Its Use and Implementation as Programming Tool</title>
				<imprint>
			<date type="published" when="1977">1977</date>
		</imprint>
		<respStmt>
			<orgName>University of Edinburgh</orgName>
		</respStmt>
	</monogr>
	<note type="report_type">Ph.D. thesis</note>
	<note>Also available as SRI Technical Note 290</note>
</biblStruct>

<biblStruct xml:id="b11">
	<monogr>
		<title level="m" type="main">User&apos;s Guide to DECsystem-10 Prolog</title>
		<author>
			<persName><forename type="first">L</forename><surname>Pereira</surname></persName>
		</author>
		<author>
			<persName><forename type="first">F</forename><surname>Pereira</surname></persName>
		</author>
		<author>
			<persName><forename type="first">D</forename><surname>Warren</surname></persName>
		</author>
		<imprint>
			<date type="published" when="1978">1978</date>
		</imprint>
		<respStmt>
			<orgName>Dept. of Artificial Intelligence, Univ. of Edinburgh</orgName>
		</respStmt>
	</monogr>
</biblStruct>

<biblStruct xml:id="b12">
	<analytic>
		<title level="a" type="main">XSB: Extending Prolog with Tabled Logic Programming</title>
		<author>
			<persName><forename type="first">T</forename><surname>Swift</surname></persName>
		</author>
		<author>
			<persName><forename type="first">D</forename><forename type="middle">S</forename><surname>Warren</surname></persName>
		</author>
		<idno type="DOI">10.1017/S1471068411000500</idno>
	</analytic>
	<monogr>
		<title level="j">Theory and Practice of Logic Programming</title>
		<imprint>
			<biblScope unit="volume">12</biblScope>
			<biblScope unit="page" from="157" to="187" />
			<date type="published" when="2012">2012</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b13">
	<analytic>
		<title level="a" type="main">Fifty Years of Prolog and Beyond, Theory and Practice of Logic Programming</title>
		<author>
			<persName><forename type="first">P</forename><surname>Körner</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Leuschel</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Barbosa</surname></persName>
		</author>
		<author>
			<persName><forename type="first">V</forename><surname>Santos-Costa</surname></persName>
		</author>
		<author>
			<persName><forename type="first">V</forename><surname>Dahl</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><forename type="middle">V</forename><surname>Hermenegildo</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><forename type="middle">F</forename><surname>Morales</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Wielemaker</surname></persName>
		</author>
		<author>
			<persName><forename type="first">D</forename><surname>Diaz</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><surname>Abreu</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Ciatto</surname></persName>
		</author>
		<idno type="DOI">10.1017/S1471068422000102</idno>
		<ptr target="https://arxiv.org/abs/2201.10816.doi:10.1017/S1471068422000102" />
	</analytic>
	<monogr>
		<title level="j">20th Anniversary Special Issue</title>
		<imprint>
			<biblScope unit="volume">22</biblScope>
			<biblScope unit="page" from="776" to="858" />
			<date type="published" when="2022">2022</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b14">
	<analytic>
		<title level="a" type="main">The Language Features and Architecture of B-Prolog</title>
		<author>
			<persName><forename type="first">N</forename><surname>Zhou</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Theory and Practice of Logic Programming</title>
				<imprint>
			<date type="published" when="2012">2012</date>
			<biblScope unit="page" from="189" to="218" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b15">
	<analytic>
		<title level="a" type="main">An Overview of Ciao and its Design Philosophy</title>
		<author>
			<persName><forename type="first">M</forename><forename type="middle">V</forename><surname>Hermenegildo</surname></persName>
		</author>
		<author>
			<persName><forename type="first">F</forename><surname>Bueno</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Carro</surname></persName>
		</author>
		<author>
			<persName><forename type="first">P</forename><surname>Lopez-Garcia</surname></persName>
		</author>
		<author>
			<persName><forename type="first">E</forename><surname>Mera</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Morales</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Puebla</surname></persName>
		</author>
		<idno type="DOI">10.1017/S1471068411000457</idno>
		<ptr target="http://arxiv.org/abs/1102.5497.doi:10.1017/S1471068411000457" />
	</analytic>
	<monogr>
		<title level="j">Theory and Practice of Logic Programming</title>
		<imprint>
			<biblScope unit="volume">12</biblScope>
			<biblScope unit="page" from="219" to="252" />
			<date type="published" when="2012">2012</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b16">
	<analytic>
		<title level="a" type="main">SWI-Prolog</title>
		<author>
			<persName><forename type="first">J</forename><surname>Wielemaker</surname></persName>
		</author>
		<author>
			<persName><forename type="first">T</forename><surname>Schrijvers</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Triska</surname></persName>
		</author>
		<author>
			<persName><forename type="first">T</forename><surname>Lager</surname></persName>
		</author>
		<idno type="DOI">10.1017/S1471068411000494</idno>
	</analytic>
	<monogr>
		<title level="j">Theory and Practice of Logic Programming</title>
		<imprint>
			<biblScope unit="volume">12</biblScope>
			<biblScope unit="page" from="67" to="96" />
			<date type="published" when="2012">2012</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b17">
	<analytic>
		<title level="a" type="main">The YAP Prolog system</title>
		<author>
			<persName><forename type="first">V</forename><forename type="middle">Santos</forename><surname>Costa</surname></persName>
		</author>
		<author>
			<persName><forename type="first">R</forename><surname>Rocha</surname></persName>
		</author>
		<author>
			<persName><forename type="first">L</forename><surname>Damas</surname></persName>
		</author>
		<idno type="DOI">10.1017/S1471068411000512</idno>
	</analytic>
	<monogr>
		<title level="j">Theory and Practice of Logic Programming</title>
		<imprint>
			<biblScope unit="volume">12</biblScope>
			<biblScope unit="page" from="5" to="34" />
			<date type="published" when="2012">2012</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b18">
	<monogr>
		<title level="m" type="main">Better termination for prolog with constraints</title>
		<author>
			<persName><forename type="first">M</forename><surname>Triska</surname></persName>
		</author>
		<author>
			<persName><forename type="first">U</forename><surname>Neumerkel</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Wielemaker</surname></persName>
		</author>
		<idno>CoRR abs/0903.2168</idno>
		<ptr target="http://arxiv.org/abs/0903.2168.arXiv:0903.2168" />
		<imprint>
			<date type="published" when="2009">2009</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b19">
	<analytic>
		<title level="a" type="main">Writing Correct Prolog Programs</title>
		<author>
			<persName><forename type="first">D</forename><forename type="middle">S</forename><surname>Warren</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Prolog -The Next 50 Years, number 13900 in LNCS</title>
				<editor>
			<persName><forename type="first">D</forename><forename type="middle">S</forename><surname>Warren</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">V</forename><surname>Dahl</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">T</forename><surname>Eiter</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">M</forename><surname>Hermenegildo</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">R</forename><surname>Kowalski</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><surname>Rossi</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer</publisher>
			<date type="published" when="2023">2023</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b20">
	<analytic>
		<title level="a" type="main">Types, modes and so much morethe Prolog way</title>
		<author>
			<persName><forename type="first">M</forename><surname>Hermenegildo</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Morales</surname></persName>
		</author>
		<author>
			<persName><forename type="first">P</forename><surname>Lopez-Garcia</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Carro</surname></persName>
		</author>
		<ptr target="http://cliplab.org/papers/AssertionsAndOther-PrologBook.pdf" />
	</analytic>
	<monogr>
		<title level="m">Prolog -The Next 50 Years, number 13900 in LNCS</title>
				<editor>
			<persName><forename type="first">D</forename><forename type="middle">S</forename><surname>Warren</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">V</forename><surname>Dahl</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">T</forename><surname>Eiter</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">M</forename><surname>Hermenegildo</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">R</forename><surname>Kowalski</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><surname>Rossi</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer</publisher>
			<date type="published" when="2023">2023</date>
			<biblScope unit="page" from="23" to="37" />
		</imprint>
	</monogr>
</biblStruct>

				</listBibl>
			</div>
		</back>
	</text>
</TEI>
