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
Logic programming
(section)
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!
===Metalogic programming=== [[Metaprogramming]], in which programs are treated as data, was already a feature of early Prolog implementations.<ref>Colmerauer, A. and Roussel, P., 1996. The birth of Prolog. In History of programming languages---II (pp. 331-367).</ref><ref name="Warren">Warren, D.H., Pereira, L.M. and Pereira, F., 1977. Prolog-the language and its implementation compared with Lisp. ACM SIGPLAN Notices, 12(8), pp.109-115.</ref> For example, the Edinburgh DEC10 implementation of Prolog included "an interpreter and a compiler, both written in Prolog itself".<ref name="Warren"/> The simplest metaprogram is the so-called "[[Vanilla (computing)|vanilla]]" meta-interpreter: <syntaxhighlight lang="prolog"> solve(true). solve((B,C)):- solve(B),solve(C). solve(A):- clause(A,B),solve(B). </syntaxhighlight> where true represents an empty conjunction, and (B,C) is a composite term representing the conjunction of B and C. The predicate clause(A,B) means that there is a clause of the form A :- B. Metaprogramming is an application of the more general use of a ''[[metalogic]]'' or ''[[metalanguage]]'' to describe and reason about another language, called the ''object language''. Metalogic programming allows object-level and metalevel representations to be combined, as in natural language. For example, in the following program, the atomic formula <code>attends(Person, Meeting)</code> occurs both as an object-level formula, and as an argument of the metapredicates <code>prohibited</code> and <code>approved.</code> <syntaxhighlight lang="prolog"> prohibited(attends(Person, Meeting)) :- not(approved(attends(Person, Meeting))). should_receive_sanction(Person, scolding) :- attends(Person, Meeting), lofty(Person), prohibited(attends(Person, Meeting)). should_receive_sanction(Person, banishment) :- attends(Person, Meeting), lowly(Person), prohibited(attends(Person, Meeting)). approved(attends(alice, tea_party)). attends(mad_hatter, tea_party). attends(dormouse, tea_party). lofty(mad_hatter). lowly(dormouse). ?- should_receive_sanction(X,Y). Person = mad_hatter, Sanction = scolding. Person = dormouse, Sanction = banishment. </syntaxhighlight>
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)
Search
Search
Editing
Logic programming
(section)
Add topic