Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Logic programming
(section)
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!
===Concurrent logic programming=== {{Main|Concurrent logic programming}} Concurrent logic programming integrates concepts of logic programming with [[concurrent programming]]. Its development was given a big impetus in the 1980s by its choice for the systems programming language of the [[Fifth generation computer|Japanese Fifth Generation Project (FGCS)]].<ref>Shunichi Uchida and Kazuhiro Fuchi. ''Proceedings of the FGCS Project Evaluation Workshop''. Institute for New Generation Computer Technology (ICOT). 1992.</ref> A concurrent logic program is a set of guarded [[Horn clauses]] of the form: ::<code>H :- G<sub>1</sub>, ..., G<sub>n</sub> | B<sub>1</sub>, ..., B<sub>n</sub>.</code> The conjunction <code>G<sub>1</sub>, ... , G<sub>n</sub></code> is called the [[guard (computer science)|guard]] of the clause, and {{char|{{!}}}} is the commitment operator. Declaratively, guarded Horn clauses are read as ordinary logical implications: ::<code>H if G<sub>1</sub> and ... and G<sub>n</sub> and B<sub>1</sub> and ... and B<sub>n</sub>.</code> However, procedurally, when there are several clauses whose heads <code>H</code> match a given goal, then all of the clauses are executed in parallel, checking whether their guards <code>G<sub>1</sub>, ... , G<sub>n</sub></code> hold. If the guards of more than one clause hold, then a committed choice is made to one of the clauses, and execution proceeds with the subgoals <code>B<sub>1</sub>, ..., B<sub>n</sub></code> of the chosen clause. These subgoals can also be executed in parallel. Thus concurrent logic programming implements a form of "don't care nondeterminism", rather than "don't know nondeterminism". For example, the following concurrent logic program defines a predicate <code>shuffle(Left, Right, Merge)</code>, which can be used to shuffle two lists <code>Left</code> and <code>Right</code>, combining them into a single list <code>Merge</code> that preserves the ordering of the two lists <code>Left</code> and <code>Right</code>: <syntaxhighlight lang="prolog"> shuffle([], [], []). shuffle(Left, Right, Merge) :- Left = [First | Rest] | Merge = [First | ShortMerge], shuffle(Rest, Right, ShortMerge). shuffle(Left, Right, Merge) :- Right = [First | Rest] | Merge = [First | ShortMerge], shuffle(Left, Rest, ShortMerge). </syntaxhighlight> Here, <code>[]</code> represents the empty list, and <code>[Head | Tail]</code> represents a list with first element <code>Head</code> followed by list <code>Tail</code>, as in Prolog. (Notice that the first occurrence of {{char|{{!}}}} in the second and third clauses is the list constructor, whereas the second occurrence of {{char|{{!}}}} is the commitment operator.) The program can be used, for example, to shuffle the lists <code>[ace, queen, king]</code> and <code>[1, 4, 2]</code> by invoking the goal clause: <syntaxhighlight lang="prolog"> shuffle([ace, queen, king], [1, 4, 2], Merge). </syntaxhighlight> The program will non-deterministically generate a single solution, for example <code>Merge = [ace, queen, 1, king, 4, 2]</code>. [[Carl Hewitt]] has argued<ref name="Hewitt">{{cite web | url=https://hal.archives-ouvertes.fr/hal-01148496v6/document | title=Inconsistency Robustness for Logic Programs | publisher=Hal Archives | date=27 April 2016 | access-date=7 November 2016 | author=Hewitt, Carl | pages=21β26}}</ref> that, because of the [[Indeterminacy in concurrent computation|indeterminacy of concurrent computation]], concurrent logic programming cannot implement general concurrency. However, according to the logical semantics, any result of a computation of a concurrent logic program is a logical consequence of the program, even though not all logical consequences can be derived.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)