LMNtal links represent point-to-point connection between atoms and form an ordinary graph. In some applications, however, natural modeling calls for hyperlinks, namely links that interconnect more than two atoms. A graph structure with hyperlinks forms a (hierarchical) hypergraph.
Accordingly, LMNtal now provides the syntax and operations for hypergraphs. The language with this extension is also called HyperLMNtal.
A hyperlink is created by a new construct specified in a guard.
hoge. hoge :- new($h) | a($h), b($h).
Since each hyperlink can be regarded as a unary atom with a fresh local name, we use the syntax of process contexts (starting with a $) to represent it.
Another view of hyperlinks is a generalization of ordinary links, and we allow them also to written by attaching ! to link names as
hoge. hoge :- a(!H), b(!H).
or just
a(!H), b(!H).
The result of all the above programs will be
a(!H4), b(!H4).
That is, a hyperlink will be printed as a "!H" followed by a hexadecimal number
The type constraint hlink($x) checks if $x represents a hyperlink.
main. main :- new($x) | a($y). a($x) :- hlink($x) | b($x).
or
a(!Y). a(!X) :- b(!X).
--> b(!H4).
Since an occurrence of a hyperlink is regarded as a unary atom with a special private na, the constructs == and \== can be used for comparing two hyperlinks, e.g.,
a($x), b($y) :- hlink($x), hlink($y), $x == $y | ok.
The above rule can be written also as
a($x), b($x) :- ok.
or
a(!X), b(!X).
Two hyperlinks can be fused into one using the "><" operator.
main. main :- new($x), new($y) | a($x), b($z). a($x), a($y) :- $x \== $y | a($x), b($y), $x >< $y.
or
a(!X), b(!Z). a(!X), b(!Y) :- !X \== !Y | a(!X), c(!Y), !X >< !Y.
If $x and $y represent different hyperlinks (i.e., have different hyperlink names), they will be merged into one; that is, they are made to have the same hyperlink name.
The num construct in a guard will return the number of occurrences of the specified hyperlink.
main. main :- new($x) | a($x), b($x). a($h) :- $n = num($h) | number($n).
or
a(!X), b(!X). a(!H) :- $n = num(!H) | number($n).
--> b(!H4), number(2).
Another use:
main. main :- new($x) | a($x). a($h) :- $n = num($h), $n < 5 | a($h), a($h).
or
a(!X). a(!H) :- num(!H) < 5 | a(!H), a(!H).
--> a(!H4), a(!H4), a(!H4), a(!H4), a(!H4).
Yet another use:
main :- new($x) | flag(!x), a(!x), a(!x), a(!x), a(!x). a($h) :- hlink($h) | . flag($h) :- $n = num($h), $n =:= 1 | ok.
or
flag(!X), a(!X), a(!X), a(!X), a(!X), a(!X). a(!H) :- . flag(!H) :- num(!H) =:= 1 | ok.
--> ok. // ok is created when all a(!H1)'s are removed
In this way, using hyperlinks, one can check the absence of a particular hyperlink.
When you execute your program under LaViT (recommended), select the Option tab and turn on the following checkboxes:
Please see below for the details of those options.
Currently, programs with hyperlinks can be executed only under SLIM. To compile them, both --slimcode and --hl (or --hl-opt) options need be specified, e.g.,
lmntal --slimcode --hl hoge.lmn > hoge.il
Specify --hl when running SLIM, e.g.,
slim --hl --show-hl hoge.il