```//[[Documentation]]

LMNtal links represent point-to-point connection between atoms and form an ordinary graph.  In some applications, however, we may want '''hyperlinks''', namely links that interconnect more than two atoms and form a '''hypergraph'''.

LMNtal provides syntax and operations for hypergraphs, which will be described below.  Currently, hyperlinks are supported by the slim runtime
in the ordinary (as opposed to non-deterministic) execution mode.

-A hyperlink is created by a "new" construct specified in a guard.

hoge.
hoge :- new(\$h) | a(\$h), b(\$h).
*--> a(!1), b(!1).

-Each hyperlink is given a fresh private name, which will be printed as a "!" followed by a hexadecimal number.

**Type checking

main.
main :- new(\$x) | a(\$x).
*--> b(!1).

**Equality checking

-An occurrence of a hyperlink is regarded as a unary atom (with a special, private name).  Therefore, the constructs == and \= can be used for comparing two hyperlinks, e.g.,

In addition, the above rule can be written as

a(\$x), b(\$x) :- ok.

-Two hyperlinks can be fused into one using the "><" operator.

a(!1), b(!2).
a(\$x), a(\$y) :- \$x \= \$y | a(\$x), b(\$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.

**Number of occurrences
-The "num" construct in a guard will return the number of occurrences of the specified hyperlink.

a(!1), b(!1).
a(\$h) :- \$n = num(\$h) | number(\$n).
*--> b(!1), number(2).

--Another use

a(!1).
a(\$h) :- \$n = num(\$h), \$n < 5 | a(\$h), a(\$h).
*--> a(!1), a(!1), a(!1), a(!1), a(!1).

--Yet another use

flag(!1), a(!1), a(!1), a(!1), a(!1).
flag(\$h) :- \$n = num(\$h), \$n =:= 1 | ok.
*--> ok. // ok is created when all a(!1)'s are removed

---Thus, using hyperlinks, one can check the absence of a particular atom.

*How to use

**Compiling

Currently, programs with hyperlinks can be executed only under slim.  To compile, both --slimcode and --hl (or --hl-opt) options need be specified, e.g.,

lmntal --slimcode --hl hoge.lmn > hoge.il

-- --hl-opt : uses hyperlinks and optimizes matching
// --- &#20197;&#19979;&#12399;&#23455;&#35013;&#12398;&#12371;&#12392;
// --- &#20013;&#38291;&#21629;&#20196;findproccxt&#12364;&#25407;&#20837;&#12373;&#12428;&#12427;
// ---&#12385;&#12394;&#12415;&#12395;&#21516;&#21517;&#22411;&#20184;&#12365;&#12503;&#12525;&#12475;&#12473;&#25991;&#33032;&#12399;&#12289;&#20966;&#29702;&#31995;&#20869;&#37096;&#12398;&#12467;&#12540;&#12489;&#12391;&#12399;sameproccxt&#12394;&#12393;&#12392;&#21628;&#31216;

***Executing

Specify --hl when running slim, e.g.,

slim --hl --show-hl hoge.il