//[[Documentation]]

*Hyperlinks
*Hyperlinks and hypergraphs

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 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.  A graph structure with hyperlinks forms a '''(hierarchical) 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.
LMNtal provides syntax and operations for hypergraphs, which will be described below.

Currently, hyperlinks are supported by the '''SLIM''' runtime
running in the '''ordinary''' (as opposed to non-deterministic) execution mode.

**Creating a hyperlink

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

A hyperlink is created by a ''new'' construct specified in a guard.
 hoge.
 hoge :- new($h) | a($h), b($h).
 *--> a(!1), b(!1).
 
 --> a(!1), b(!1).
Each hyperlink is given a fresh private name, which will be printed as a "''!''" followed by a hexadecimal number. 

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


**Type checking

-The type constraint "hlink($x)" checks if $x represents a hyperlink.  

The type constraint ''hlink''($x) checks if $x represents a hyperlink.  
 main.
 main :- new($x) | a($x).
 a($x) :- hlink($x) | b($x).
 *--> b(!1).
 
 --> 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.,

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.,
 a($x), b($y) :- hlink($x), hlink($y), $x == $y | ok.

In addition, the above rule can be written as

The above rule can be written also as
 a($x), b($x) :- ok.


**Fusing two hyperlinks

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

 a(!1), b(!2).
Two hyperlinks can be fused into one using the "''><''" operator.
 main.
 main :- new($x), new($y) | a($x), b($y).
 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.

-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).
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).
 *--> b(!1), number(2). 
 
--Another use

 a(!1).
 --> b(!1), number(2). 
Another use:
 main.
 main :- new($x) | a($x).
 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).
 
 --> a(!1), a(!1), a(!1), a(!1), a(!1).
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.
 *--> ok. // ok is created when all a(!1)'s are removed
 
 --> ok. // ok is created when all a(!1)'s are removed
In this way, using hyperlinks, one can check the '''absence''' of a particular hyperlink.

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

*How to use

**Compiling
**LaViT

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.,
When you execute your program under LaViT (recommended), select the Option tab and turn on the following checkboxes:
- Slimcode Compile Option: ''--slimcode'' and ''--hl-opt''
- Slim Option: ''--hl''

 lmntal --slimcode --hl hoge.lmn > hoge.il
Please see below for the details of those options.

-- --hl     : uses hyperlinks.
//[[&#21516;&#21517;&#22411;&#20184;&#12365;&#12503;&#12525;&#12475;&#12473;&#25991;&#33032;&#27083;&#25991;>http://www.ueda.info.waseda.ac.jp/~seiji/wiki/index.php?%B8%A6%B5%E6%C6%FC%BB%EF%A4%C8%A4%A6%A4%E1%A4%AD#r3fa6a93]]&#12434;&#35377;&#12377;
-- --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;
// --- &#12460;&#12540;&#12489;&#12395;&#33258;&#21205;&#30340;&#12395;hlink&#21046;&#32004;&#12434;&#25407;&#20837;&#12371;&#12392;&#12391;&#12289;ground&#23550;ground&#12398;&#27083;&#36896;&#27604;&#36611;&#12434;&#12501;&#12449;&#12531;&#12463;&#12479;&#23550;&#12501;&#12449;&#12531;&#12463;&#12479;&#12391;&#28168;&#12414;&#12379;&#12427;&#12424;&#12358;&#12395;&#12375;&#12390;&#12356;&#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;
**Compiling

***Executing 
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
- ''--hl''     : turn on hyperlinks.
- ''--hl-opt'' : turn on hyperlinks and optimize graph matching using hyperlink connection.

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

Specify ''--hl'' when running SLIM, e.g.,
 slim --hl --show-hl hoge.il
- ''--hl''      : turn on hyperlinks
-- currently, this cannot be specified with ''-nd''.
- ''--show-hl'' : prints the details of hyperlinks.
-- Without this option, different occurrences of a hyperlink are printed with the same name.
-- With this option, each occurrence of a hyperlink is printed with its own ID.  In addition, a table of hyperlink occurrences will be printed.

-- --hl      : uses hyperlinks
--- currently, this cannot be specified with -nd
-- --show-hl : prints the details of hyperlinks
--- Without this option, different occurrences of a hyperlink are printed with the same name.
--- With this option, each occurrence of a hyperlink is printed with its own ID.  In addition, a table of hyperlink occurrences will be printed.


Front page List of pages Search Recent changes Backup   Help   RSS of recent changes