<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sarg.dev/index.php?action=history&amp;feed=atom&amp;title=Warren_Abstract_Machine</id>
	<title>Warren Abstract Machine - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sarg.dev/index.php?action=history&amp;feed=atom&amp;title=Warren_Abstract_Machine"/>
	<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Warren_Abstract_Machine&amp;action=history"/>
	<updated>2026-04-20T16:42:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Warren_Abstract_Machine&amp;diff=122854&amp;oldid=prev</id>
		<title>imported&gt;Bender the Bot: /* top */ HTTP to HTTPS for SourceForge</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Warren_Abstract_Machine&amp;diff=122854&amp;oldid=prev"/>
		<updated>2025-08-11T04:13:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;top: &lt;/span&gt; HTTP to HTTPS for &lt;a href=&quot;/index.php/SourceForge&quot; title=&quot;SourceForge&quot;&gt;SourceForge&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Abstract machine for the execution of Prolog}}&lt;br /&gt;
In 1983, [[David H. D. Warren]] designed an [[abstract machine]] for the execution of [[Prolog]] consisting of a [[computer storage|memory]] architecture and an [[instruction set]].&amp;lt;ref&amp;gt;{{cite book | author = David H. D. Warren | title = An abstract Prolog instruction set | publisher = [[Artificial Intelligence Center]] at [[SRI International]] | location = Menlo Park, CA, USA | date = October 1983 | url = https://www.sri.com/wp-content/uploads/2021/12/641.pdf | archive-url = https://web.archive.org/web/20220619231625/https://www.sri.com/wp-content/uploads/2021/12/641.pdf | archive-date = 2022-06-19 | url-status = live }}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite book | author = Hassan Aït-Kaci | title = Warren&amp;#039;s Abstract Machine: A Tutorial Reconstruction | date = February 18, 1999 | url = http://www.vanx.org/archive/wam/wambook.pdf | url-status=usurped | archiveurl = https://web.archive.org/web/20030213072337/http://www.vanx.org/archive/wam/wambook.pdf | archivedate = 2003-02-13 }}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web | author = Hassan Aït-Kaci | title = Warren&amp;#039;s Abstract Machine: A Tutorial Reconstruction; the book, errata and slides | url = https://wambook.sourceforge.net/ | accessdate = 7 March 2011 | archive-date = 19 January 2022 | archive-url = https://web.archive.org/web/20220119110941/http://wambook.sourceforge.net/ | url-status = dead }}&amp;lt;/ref&amp;gt; This design became known as the &amp;#039;&amp;#039;&amp;#039;Warren Abstract Machine&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;WAM&amp;#039;&amp;#039;&amp;#039;) and has become the &amp;#039;&amp;#039;de facto&amp;#039;&amp;#039; standard target for Prolog [[compiler]]s.&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
The purpose of compiling Prolog code to the more low-level WAM code is to make subsequent interpretation of the Prolog program more efficient. Prolog code is reasonably easy to translate to WAM instructions, which can be more efficiently interpreted. Also, subsequent code improvements and compilations to native code are often easier to perform on the more low-level representation.&lt;br /&gt;
&lt;br /&gt;
In order to write efficient Prolog programs, a basic understanding of how the WAM works can be advantageous. Some of the most important WAM concepts are first argument indexing and its relation to choice-points, [[tail call optimization]], and memory reclamation on failure.&lt;br /&gt;
&lt;br /&gt;
==Memory areas==&lt;br /&gt;
The WAM has the following memory areas:&lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;global stack&amp;#039;&amp;#039; or &amp;#039;&amp;#039;heap&amp;#039;&amp;#039;, used to store compound terms&lt;br /&gt;
* The &amp;#039;&amp;#039;local stack&amp;#039;&amp;#039; for environment frames and choice-points&lt;br /&gt;
* The &amp;#039;&amp;#039;trail&amp;#039;&amp;#039; to record which variables bindings ought to be undone on backtracking&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
Here is a piece of Prolog code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;prolog&amp;quot;&amp;gt;&lt;br /&gt;
 girl(sally).&lt;br /&gt;
 girl(jane).&lt;br /&gt;
 &lt;br /&gt;
 boy(B) :- \+ girl(B).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A WAM-based Prolog compiler will compile this into WAM instructions similar to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;prolog&amp;quot;&amp;gt;&lt;br /&gt;
 predicate(girl/1):&lt;br /&gt;
    switch_on_term(2,1,fail,fail,fail),&lt;br /&gt;
 label(1): switch_on_atom([(sally,3),(jane,5)])&lt;br /&gt;
 label(2): try_me_else(4)&lt;br /&gt;
 label(3): get_atom(sally,0)&lt;br /&gt;
           proceed&lt;br /&gt;
 label(4): trust_me_else_fail&lt;br /&gt;
 label(5): get_atom(jane,0)&lt;br /&gt;
           proceed&lt;br /&gt;
 &lt;br /&gt;
 predicate(boy/1):&lt;br /&gt;
    get_variable(x(1),0)&lt;br /&gt;
    put_structure(girl/1,0)&lt;br /&gt;
    unify_local_value(x(1))&lt;br /&gt;
    execute((\+)/1)])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
An important characteristic of this code is its ability to cope with the various modes in which the predicates can be evoked: any argument might be a variable, a [[ground term]], or a partly instantiated term. The &amp;quot;switch&amp;quot; instructions handle the different cases.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Warren Abstract Machine}}&lt;br /&gt;
[[Category:Logic programming]]&lt;br /&gt;
[[Category:Abstract machines]]&lt;br /&gt;
[[Category:Virtual machines]]&lt;br /&gt;
[[Category:SRI International software]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Bender the Bot</name></author>
	</entry>
</feed>