Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Warren Abstract Machine
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Abstract machine for the execution of Prolog}} 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]].<ref>{{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 }}</ref><ref>{{cite book | author = Hassan Aït-Kaci | title = Warren'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 }}</ref><ref>{{cite web | author = Hassan Aït-Kaci | title = Warren's Abstract Machine: A Tutorial Reconstruction; the book, errata and slides | url = http://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 }}</ref> This design became known as the '''Warren Abstract Machine''' (WAM) and has become the ''de facto'' standard target for Prolog [[compiler]]s. ==Purpose== 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. 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. ==Memory areas== The WAM has the following memory areas: * The ''global stack'' or ''heap'', used to store compound terms * The ''local stack'' for environment frames and choice-points * The ''trail'' to record which variables bindings ought to be undone on backtracking ==Example== Here is a piece of Prolog code: <syntaxhighlight lang="prolog"> girl(sally). girl(jane). boy(B) :- \+ girl(B). </syntaxhighlight> A WAM-based Prolog compiler will compile this into WAM instructions similar to the following: <syntaxhighlight lang="prolog"> predicate(girl/1): switch_on_term(2,1,fail,fail,fail), label(1): switch_on_atom([(sally,3),(jane,5)]) label(2): try_me_else(4) label(3): get_atom(sally,0) proceed label(4): trust_me_else_fail label(5): get_atom(jane,0) proceed predicate(boy/1): get_variable(x(1),0) put_structure(girl/1,0) unify_local_value(x(1)) execute((\+)/1)]) </syntaxhighlight> 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 "switch" instructions handle the different cases. ==References== {{reflist}} {{DEFAULTSORT:Warren Abstract Machine}} [[Category:Logic programming]] [[Category:Abstract machines]] [[Category:Virtual machines]] [[Category:SRI International software]]
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Search
Search
Editing
Warren Abstract Machine
Add topic