Example Programs
[
Front page
|
List of pages
|
Search
|
Recent changes
|
Backup
|
Help
]
Start:
//[[Documentation]]
*Example Programs [#xab918dc]
A number of example programs are included in the distribu...
-programs with just one rewrite rule &color(#00d){(sortin...
-encodings of various calculi &color(#00d){(propositional...
-state-space search using SLIM's nondeterministic executi...
-model checking &color(#00d){(distributed and concurrent ...
-graph visualization using UNYO-UNYO &color(#00d){(fuller...
-those using LMNtal Java's GUI.
They can be found also in [[''this folder'' (click here)>...
-The [[''ltl'' subfolder>http://www.ueda.info.waseda.ac.j...
-The [[''unyo'' subfolder>http://www.ueda.info.waseda.ac....
//-The [[''wt'' subfolder>http://www.ueda.info.waseda.ac....
Let us introduce some simple examples.
**List Concatenation [#c822cef6]
Lists formed with c (cons) and n (nil) constructors can b...
append(X,Y,Z), n(X) :- Y=Z.
append(X,Y,Z), c(A,X1,X) :- c(A,Z1,Z), append(X1,Y,Z1).
Let them rewrite the following initial state:
append(c(1,c(2,c(3,n))),c(4,c(5,n)),result).
RESULT: result(c(1,c(2,c(3,c(4,c(5,n)))))) with the two r...
The above initial state is written using the '''term nota...
Z=append([], Y) :- Z=Y.
Z=append([A|X1],Y) :- Z=[A|append(X1,Y)].
result = append([1,2,3],[4,5]).
RESULT: result=[1,2,3,4,5] with the two rules above.
**Greatest Common Divisor [#v8af293e]
The following program computes the GCD of two numbers usi...
n=100, n=72.
n=$x, n=$y :- $x>$y | n=$x-$y, n=$y.
RESULT: n=4, n=4 with the rule above.
See [[Built-in Types]] and [[Guards]] for how to handle n...
**Self-Organizing Loops [#x13c986d]
Ten agents, each with two free hands, are going to hold h...
Is it possible that some agent is left alone?
a(free,free), a(free,free), a(free,free), a(free,free), ...
a(free,free), a(free,free), a(free,free), a(free,free), ...
a(X,free),a(free,Y) :- a(X,C),a(C,Y).
RESULT: There are 20 possible final configurations, which...
**Vending Machine [#uebe51a2]
Two customers with different hunger and the numbers of co...
are buying chocolates from a vending machine.
Each choc(olate) costs three
and only two kinds of coins are accepted: one and five.
{customer,a,five,one,one,hunger,hunger}. % Customer a h...
{customer,b,five,hunger}. % Customer b h...
{vending,choc,choc,choc,one,one}. % Vending mach...
{customer,$c,hunger,five}, {vending,$v,choc,one,one} :-
{customer,$c,choc,one,one}, {vending,$v,five}.
{customer,$c,hunger,one,one,one}, {vending,$v,choc} :-
{customer,$c,choc}, {vending,$v,one,one,one}.
SLIM/LaViT with ''--nd'' will compute two possible final ...
RESULT 1: {customer,a,choc,choc,one},
{customer,b,choc,one,one},
{vending,five,five,one}, <RULES>
RESULT 2: {customer,a,hunger,hunger,five,one,one}, // ...
{customer,b,choc,one,one},
{vending,choc,choc,five}, <RULES>
//Observe that applying each rule preserves the total num...
End:
//[[Documentation]]
*Example Programs [#xab918dc]
A number of example programs are included in the distribu...
-programs with just one rewrite rule &color(#00d){(sortin...
-encodings of various calculi &color(#00d){(propositional...
-state-space search using SLIM's nondeterministic executi...
-model checking &color(#00d){(distributed and concurrent ...
-graph visualization using UNYO-UNYO &color(#00d){(fuller...
-those using LMNtal Java's GUI.
They can be found also in [[''this folder'' (click here)>...
-The [[''ltl'' subfolder>http://www.ueda.info.waseda.ac.j...
-The [[''unyo'' subfolder>http://www.ueda.info.waseda.ac....
//-The [[''wt'' subfolder>http://www.ueda.info.waseda.ac....
Let us introduce some simple examples.
**List Concatenation [#c822cef6]
Lists formed with c (cons) and n (nil) constructors can b...
append(X,Y,Z), n(X) :- Y=Z.
append(X,Y,Z), c(A,X1,X) :- c(A,Z1,Z), append(X1,Y,Z1).
Let them rewrite the following initial state:
append(c(1,c(2,c(3,n))),c(4,c(5,n)),result).
RESULT: result(c(1,c(2,c(3,c(4,c(5,n)))))) with the two r...
The above initial state is written using the '''term nota...
Z=append([], Y) :- Z=Y.
Z=append([A|X1],Y) :- Z=[A|append(X1,Y)].
result = append([1,2,3],[4,5]).
RESULT: result=[1,2,3,4,5] with the two rules above.
**Greatest Common Divisor [#v8af293e]
The following program computes the GCD of two numbers usi...
n=100, n=72.
n=$x, n=$y :- $x>$y | n=$x-$y, n=$y.
RESULT: n=4, n=4 with the rule above.
See [[Built-in Types]] and [[Guards]] for how to handle n...
**Self-Organizing Loops [#x13c986d]
Ten agents, each with two free hands, are going to hold h...
Is it possible that some agent is left alone?
a(free,free), a(free,free), a(free,free), a(free,free), ...
a(free,free), a(free,free), a(free,free), a(free,free), ...
a(X,free),a(free,Y) :- a(X,C),a(C,Y).
RESULT: There are 20 possible final configurations, which...
**Vending Machine [#uebe51a2]
Two customers with different hunger and the numbers of co...
are buying chocolates from a vending machine.
Each choc(olate) costs three
and only two kinds of coins are accepted: one and five.
{customer,a,five,one,one,hunger,hunger}. % Customer a h...
{customer,b,five,hunger}. % Customer b h...
{vending,choc,choc,choc,one,one}. % Vending mach...
{customer,$c,hunger,five}, {vending,$v,choc,one,one} :-
{customer,$c,choc,one,one}, {vending,$v,five}.
{customer,$c,hunger,one,one,one}, {vending,$v,choc} :-
{customer,$c,choc}, {vending,$v,one,one,one}.
SLIM/LaViT with ''--nd'' will compute two possible final ...
RESULT 1: {customer,a,choc,choc,one},
{customer,b,choc,one,one},
{vending,five,five,one}, <RULES>
RESULT 2: {customer,a,hunger,hunger,five,one,one}, // ...
{customer,b,choc,one,one},
{vending,choc,choc,five}, <RULES>
//Observe that applying each rule preserves the total num...
Page: