2003 LMNtal : : : 1G00P102-2

Similar documents
新・明解Java入門

K227 Java 2

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

,,,,., C Java,,.,,.,., ,,.,, i

Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説

Java演習(4) -- 変数と型 --

PowerPoint Presentation

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

haskell.gby


tkk0408nari

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

日 力力 生 行行 入 入 力力 生 用 方

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr

Web 1 p.2 1 Servlet Servlet Web Web Web Apache Web Servlet JSP Web Apache Tomcat Jetty Apache Tomcat, Jetty Java JDK, Eclipse

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

アルゴリズムとデータ構造1

データ構造とアルゴリズム論

Part y mx + n mt + n m 1 mt n + n t m 2 t + mn 0 t m 0 n 18 y n n a 7 3 ; x α α 1 7α +t t 3 4α + 3t t x α x α y mx + n

ALG ppt

II 1 p.1 1 Servlet 1.1 Web Web WWW HTML CGI Common Gateway Interface Web HTML Web Web CGI CGI CGI Perl, PHP C JavaScript Web CGI HTML 1.2 Servlet Java

解きながら学ぶJava入門編

ALG ppt

untitled

JavaプログラミングⅠ

A B 1: Ex. MPICH-G2 C.f. NXProxy [Tanaka] 2:

HTML Java Tips dp8t-asm/java/tips/ Apache Tomcat Java if else f

Condition DAQ condition condition 2 3 XML key value


Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版  

PowerPoint Presentation

JAVA とテンプレート

TopLink å SampleClient.java... 5 Ò readallsample() querysample() cachesample() Ç..

II 2 p.2 2 GET POST form action URL Aisatsu 2.1 Servlet GET GET : Query String QueryStringTest.java 1 import java.io.ioexception; 2 import java.io.pri

オブジェクト指向プログラミング・同演習 5月21日演習課題

r1.dvi

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版   None

HTML Java Tips dp8t-asm/java/tips/ Apache Tomcat Java if else f

r02.dvi

ohp02.dvi

文字列操作と正規表現

「Android Studioではじめる 簡単Androidアプリ開発」正誤表

1: Preference Display 1 package sample. pref ; 2 3 import android. app. Activity ; 4 import android. content. Intent ; 5 import android. content. Shar

LMNtal LMNtal LMNtal JAVA JAVA JAVA LMNtal LMNtal LMNtal

(Java/FX ) Java CD Java version Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas C

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flow


Microsoft PowerPoint - Lecture_3

Programming-C-9.key

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

O E ( ) A a A A(a) O ( ) (1) O O () 467

CX-Checker CX-Checker (1)XPath (2)DOM (3) 3 XPath CX-Checker. MISRA-C 62%(79/127) SQMlint 76%(13/17) XPath CX-Checker 3. CX-Checker 4., MISRA-C CX- Ch

Oracle Forms Services R6i

/ ( ) 8/7/ :21 p.2/64

PL : pl0 ( ) 1 SableCC ( sablecc ) 1.1 sablecc sablecc Étienne Gagnon [1] Java sablecc sablecc ( ) Visitor DepthFirstAdapter 1 (Depth

B 10 : N ip2003f10.tex B : 9/12/ :02 p.1/71

1: JX-model XML File Package Import Class Intf Ctor Method SInit Field Param Local ExtdOpt ImplOpt ThrwOpt Members QName Type Stmt Label Expr ident li

1 VisBAR edu H 2 O.....

untitled

Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文

Q&A集

JavaプログラミングⅠ

fp.gby


Gartner Day

JavaScript の使い方


test.gby

2: 3: A, f, φ f(t = A sin(2πft + φ = A sin(ωt + φ ω 2πf 440Hz A ( ( 4 ( 5 f(t = sin(2πf 1t + sin(2πf 2 t = 2 sin(2πt(f 1 + f 2 /2 cos(2πt(f 1 f

コーディング基準.PDF

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

インターネットマガジン2001年4月号―INTERNET magazine No.75


Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac


(CC Attribution) Lisp 2.1 (Gauche )

データ構造とアルゴリズム論

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap

Java学習教材

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

そして 取得した OutputStream インスタンスを使い 文字コードは UTF-8 として PrintWriter インスタンスを生成して あとは PrintWriter.append() で書き込みたい文字 列を渡して close() で保存する というだけです ファイルの読込み方法 それで

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi

presen.gby

0226_ぱどMD表1-ol前

オブジェクト脳のつくり方

JAVA H13 OISA JAVA 1

リファレンス,配列 例外処理

Assignment_.java 課題 : 転置行列 / class Assignment_ public static void main(string[] args) int i,j; int[][] array = 1,,,,,,,,,,,,,1,1,; 行 列行列 i

OOCOBOL紹介

main.dvi

Thread

新版明解C言語 実践編

java_servlet2_見本

55 7 Java C Java TCP/IP TCP/IP TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] a

syspro-0405.ppt

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

Transcription:

2003 LMNtal : 2004 2 5 : : 1G00P102-2

LMNtal LMNtal (1) (2) (3) (OS) LMNtal LMNtal LMNtal

i 1 1 1.1 LMNtal....................... 1 1.2 LMNtal................ 1 1.2.1..................... 2 1.2.2.............. 2 1.3............................. 2 2 LMNtal 4 2.1 Atom............................ 4 2.2 -.................... 5 2.3.............................. 6 2.4 LMNtal............................ 7 2.5............................. 8 2.5.1..................... 8 2.5.2........................ 9 2.5.3................... 9 2.6.............................. 10 2.7......................... 10 2.8......................... 11 2.8.1..................... 11 2.8.2..................... 11 3 12 3.1.............................. 12 3.1.1......................... 12 3.1.2......................... 12 3.1.3.................. 13 3.2.............. 13 3.2.1 Java................ 13 3.2.2................... 13 3.2.3............. 14 3.2.4................... 15

ii 3.2.5........... 15 3.2.6 INLINE.................. 17 4 19 4.1.............................. 19 4.1.1......... 19 4.1.2................... 20 4.1.3........... 20 4.2...................... 20 4.2.1............. 20 4.2.2............. 22 4.2.3................... 24 4.2.4........... 31 5 32 5.1 Inline............................. 32 5.1.1........................ 32 5.1.2......................... 32 5.1.3......................... 33 5.2 module............................ 34 5.2.1........................ 34 5.2.2......................... 35 5.2.3......................... 35 6 37 6.1 - I/O....................... 37 6.1.1 I/O.................... 37 6.2 - map....................... 38 6.2.1 map.................... 38 6.3 - semaphore................... 39 6.3.1 semaphore................ 39 6.4 -................... 40 6.4.1 amidakuji.lmn -....... 40 6.4.2.......... 40 6.5.................... 41 6.5.1.................... 41 6.5.2................... 41 6.5.3......... 42 6.5.4.......... 42

iii 43 44 Appendix.A 45 A.1 Inline.java............................... 45 A.2 Module.java.............................. 48 A.3.java.................................. 53 Appendix.B 54 B.1 I/O (io.lmn)....................... 54

iv 2.1............... 4 2.2 Append :........... 5 2.3............ 7 2.4.............. 8 3.1........... 14 3.2............ 16 4.1......................... 23 4.2..................... 27 4.3..................... 28 4.4..................... 29 6.1.............. 43

v 2.1 LMNtal.............................. 7 2.2...................... 9 3.1 INLINE........................ 18 4.1 LOADMODULE................... 24

1 1 1.1 LMNtal LMNtal[1], [2] LMNtal Atom LMNtal LMNtal LMNtal CHR gamma LMNtal LMNtal LMNtal 1.2 LMNtal LMNtal

1.3. 2 1.2.1 1.2.2 LMNtal LMNtal 1.3 2 LMNtal 3 4 5

1.3. 3 6 Appendix Module Inlin 7

4 2 LMNtal LMNtal(Linked Multisets of Nodes transformation language) LMNtal [1][2] TODO cite 2.1 Atom Atom LMNtal Atom 0 Atom 1 1 X a Atom a(x) Atom a(x,y) a(y,x) Atom h(neck). a(neck, Hand1, Body, Hand2). h(hand1). h(hand2). b(body, Foot1, Foot2). f(foot1). f(foot2). h h Hand2 h Neck a Body Hand1 b Foot1 Foot2 f f 2.1: LMNtal 2.4 Atom Atom Atom KL1 CHR

2.2. - 5 X 2.2 - start1 start2 start3 start1 start2 start3 start1 start2 start3 you c c c c c c you c c c c c c c c c c c c you goal1 goal2 goal3 goal1 goal2 goal3 goal1 goal2 goal3 << Rule >> you c c :- c c you 2.2: Append : you LMNtal 2.2

2.3. 6 start1(you). start2(r20). start3(r30). you(you, R10). c(r10, C1, R11). c(r11, C3, R12). c(r20, C1, R21). c(r21, C2, R22). c(r22, C3, R23). c(r30, C2, R31). goal1(r12). goal2(r23). goal3(r31). you(t1,m1), c(m1,c,d1), c(t2,c,d2) :- c(t1,c,d1), c(t2,c,m2), you(m2,d2). 2 1 1 Atom c c you you c 2 a(x), b(x) a(y), b(y) 2.3 Atom { compound Cell 1 Python 2 LMNtal you

2.4. LMNtal 7 { { {a(x), b(x,y), ({a(x) :- {d(x)), c(y) a b c : Cell : Atom a :- d : Rule 2.3: (stable) Atom a b c a,b,c LMNtal 2.4 LMNtal LMNtal P P ::= 0 (null) p( X) (atom) P,P (composition) {P (cell) {P/ (stable cell) (T :- T) (reaction rule) T T ::= 0 (null) p( X) (atom) T,T (composition) {T (cell) {T/ (stable cell) T:-T (rule) @p (rule variable) $p[ X A] (process variable) p(* X) (aggregate) A ::= [ ] (null) *X (bundle) 2.1: LMNtal X X X

2.5. 8 X p p Atom Atom p P P P P P {P P P 2.4: 2.5 2.5.1 Atom Node1 : { kake. ue. { { kashi. { kake. $p. $p ue. { { kashi. kake Node1 { ue { ue Node1 ue

2.5. 9 2.5.2 $p[x 1,...X m A] [X 1,...X m A] $p $p Atom 3 $p[x 1,...X m A] X 1,...X m $p X 1,...X m m A X 1,...X m [ ] 0 *X 0 A [ ] $p[x,y] $p X,Y $p[x *Y] $p X $p[ [ ] ] $p $p[ ] $p[ *X] $p $p 2.2: 2.5.3 1 3 {a(x), {b(x) {$p(x),{b(x) $p b(x) X a(x) X $p

2.6. 10 2.6 1 { order_area, @rule, { lawless_area :- { order_area, @rule, { lawless_area, @rule order lawless area 4 2.7 1 5 6 number(n) :- 7 < N greater_than_seven(n). { number(n) :- greater_than_seven(n) n(n Z n > 7) number( 8) :- greater_than_seven( 8). number( 9) :- greater_than_seven( 9). 4 lawless area :) 5 6

2.8. 11 number(10) :- greater_than_seven(10). number(11) :- greater_than_seven(11). number(12) :- greater_than_seven(12). : : number(5). number(19). number(5). greater_than_seven(19). 2.8 LMNtal Java 2.8.1 LMNtal LMNtal 2.8.2 1 LMNtal

12 3 LMNtal 5 3.1 3.1.1 OS LMNtal LMNtal 3.1.2 OS LMNtal LMNtal LMNtal

3.2. 13 3.1.3 LMNtal 3.2 4 LMNtal 3.2.1 Java Java Java Java 3.2.2 LMNtal

3.2. 14 LMNtal LMNtal LMNtal LMNtal 3.2.3 /*inline*/ System.out.println("test") print_test 3.1:

3.2. 15 3.2.4 2 /*inline*/ (NEWATOM, LINK ) Java runtime.atom me 2 /*inline_define*/ Java Java 3.2.5 Java

3.2. 16 /*inline*/ String s=do_input(); me.nthatom(0).changename(s); me.changename("done"); null (You inputted "ABC") done ABC 3.2: MyInlineCode.java runtime.inlinecode run(atom a, int codeid) interface runtime.inlinecode package runtime; public interface InlineCode { public void run(atom a, int codeid); codeid MyInlineCode.java

3.2. 17 import runtime.*; /*** ***/ public class MyInlineCode implements InlineCode { public void run(atom me, int codeid) { switch(codeid) { case 0: { /*** ID = 0 ***/ break; case 1: { /*** ID = 1 ***/ break; : : case N: { /*** ID = N ***/ break; 3.2.6 INLINE

3.2. 18 INLINE ID 3.1: INLINE LMNtal ( a :- [[/*inline*/system.out.println(123);]] ), a spec [2, 0] findatom [1, 0, a_0] react [( a :- /*inline*/... ), [0], [1]] spec [2, 3] dequeueatom [1] removeatom [1, 0, a_0] newatom [2, 0, /*inline*/...] enqueueatom [2] inline [2, 0] freeatom [1] proceed [] import runtime.*; public class MyInlineCode implements InlineCode { public void run(atom me, int codeid) { switch(codeid) { case 0: { /*inline*/system.out.println(123); break;

19 4 LMNtal 5 4.1 4.1.1 LMNtal

4.2. 20 4.1.2 Java static 4.1.3 2 2 4.2 4.2.1 LMNtal LMNtal

4.2. 21 LMNtal { C Java 2 1 name/1 1 name/1 name/1 1 name/1 1 % io { name(io), ( fprint(stream, String) :-??? ) 2 ::= [ : ] {

4.2. 22 1 2 2 1 % io io : { ( fprint(stream, String) :-??? ) 1 2 foo 2 % foo : { some_atom, foo : { another_atom java 4.2.2 4.1

4.2. 23 << Module m >> m.a m.a :- m.b (rule N) (Copy m s rule to user membrane) << Module m >> m.a :- m.b (rule N) m.a m.a :- m.b (rule N) (Apply m.a :- m.b) << Module m >> m.a :- m.b (rule N) m.b m.a :- m.b (rule N) 4.1:

4.2. 24 1. LOADMODULE LOADMODULE 4.1: LOADMODULE 4.2.3 4

4.2. 25 {{mv($m),$p,@q,$r,@s :- unary($m) {$r,@s,{mv($m),$p,@q. mv 1 {mv($m1),$p,@q,{name($m2),$r,@s :- $m1=$m2 {name($m2),$p,@q,$r,@s. 1 mv LMNtal 1 name(module_name) name {find_and_link($m1,x),ready($m2), $p, @q :- $m1=$m2 {msg(x,$m2), $p, @q. mv call($m,$method,x) :- unary($m),unary($method) {mv($m).find_and_link($method,x).. 4 module : { name(module). static.load. module.static_method(ready). module.static_method(msg(x)) :- some process..., module.static_method(ready). call(module, module.static_method, result)

4.2. 26 4.2 4.3 4.4 call(m, m.incr, X) m io.print(x) {{{ io.print(call(m, m.incr)). m:{ name(m). id(0). m.incr(ready). m.incr(msg(x)), id($o) :- int($o),$n=$o+1 cp($n, C1, C2), id(c1), X=C2, m.incr(ready).. {{{ io.print(x). {mv(m). find_and_link(m.incr,x).. m:{... 1 {{{ io.print(x). {mv(m). find_and_link(m.incr,x).. m:{... 1 {{{ io.print(x). {mv(m). find_and_link(m.incr,x).. m:{... 1 {{{ io.print(x).. {mv(m). find_and_link(m.incr,x).. m:{...

4.2. 27 << Module m >> m.incr ready id 0 io.print call m.incr,..., :- cp($n,... m m.incr Generate agent << Module m >> id 0 io.print m.incr ready m.incr,..., :- cp($n,... find_and_link m.incr mv m Agnet go up << Module m >> id 0 io.print m.incr ready m.incr,..., :- cp($n,... find_and_link m.incr mv m 4.2:

4.2. 28 Agnet go up << Module m >> id 0 io.print m.incr ready find_and_link m.incr,..., :- cp($n,... m.incr mv m Agnet go up << Module m >> id 0 io.print m.incr ready find_and_link m.incr,..., :- cp($n,... m.incr mv m Agnet go down << Module m >> find_and_link m.incr m.incr ready id 0 io.print m.incr,..., :- cp($n,... 4.3:

4.2. 29 Find and link << Module m >> msg m.incr id 0 io.print m.incr,..., :- cp($n,... Apply m s rule << Module m >> 1 cp m.incr ready id io.print m.incr,..., :- cp($n,... Finish << Module m >> 1 m.incr 1 id io.print ready m.incr,..., :- cp($n,... 4.4:

4.2. 30 {{{ io.print(x).. m:{ name(m). find_and_link(m.incr, X). id(0). m.incr(ready). m.incr(msg(x)), id($o) :- int($o),$n=$o+1 cp($n, C1, C2), id(c1), X=C2, m.incr(ready).. find_and_link {{{ io.print(x).. m:{ name(m). id(0). m.incr(msg(x)). m.incr(msg(x)), id($o) :- int($o),$n=$o+1 cp($n, C1, C2), id(c1), X=C2, m.incr(ready).. {{{ io.print(x).. m:{ name(m). cp(1, C1, C2). id(c1). X=C2. m.incr(ready). m.incr(msg(x)), id($o) :- int($o),$n=$o+1 cp($n, C1, C2), id(c1), X=C2, m.incr(ready).. {{{ io.print(x).. m:{ name(m). id(1). 1(X). m.incr(ready). m.incr(msg(x)), id($o) :- int($o),$n=$o+1 cp($n, C1, C2), id(c1), X=C2, m.incr(ready).. io.print 1 id(0) id(1) call(m, m.incr, X) 2(X), id(2)

4.2. 31 4.2.4 system_ruleset

32 5 5.1 Inline 5.1.1 public static InlineCode inlinecode Process cp public static Map code static List defs Map List static int codecount 5.1.2 public static void initinline() MyInline.class public static int getcodeid(string codestr) ID

5.1. Inline 33 public static void add(string funcname) public static void makecode() MyInline.java public static void callinline(atom atom, int codeid) ID 5.1.3 Inline.add /*inline*/ Map code ID /*inline_define*/ List defs runtime.inline.makecode() Java compile.rulecompiler.addinline INLINE

5.2. module 34 compile.rulecompiler.addinline /** */ private void addinline() { Iterator it = rhsatoms.iterator(); while(it.hasnext()) { Atom atom = (Atom)it.next(); int atomid = rhsatomtopath(atom); int codeid = Inline.getCodeID(atom.functor.getName()); if(codeid == -1) continue; body.add( new Instruction (Instruction.INLINE, atomid, codeid)); INLINE MyInlineCode.run INLINE case Instruction.INLINE : //[atom, inlineref] Inline.callInline ( atoms[inst.getintarg1()], inst.getintarg2() ); break; 5.2 module 5.2.1 public static String libpath "../lmntal_lib/" public static Map memnametable

5.2. module 35 5.2.2 public static void regmemname(string name, Membrane m) public static void loadmodule(membrane m, String modname) public static void resolvemodules(membrane m) C Linker static void getneedmodules(membrane m, List need) need 5.2.3 regmemname Module.resolveModules LMNtal

5.2. module 36 LOADMODULE LOADMODULE case Instruction.LOADMODULE: //[dstmem, module_name] // compile.structure.membrane m = (compile.structure.membrane) compile.module.memnametable.get(inst.getarg2()); if(m==null) { Env.e("Undefined module "+inst.getarg2()); else { Iterator i = m.rulesets.iterator(); while (i.hasnext()) { mems[inst.getintarg1()].loadruleset ((Ruleset)i.next() ); break;

37 6 6.1 - I/O 6.1.1 I/O io:{ io.print(string) :- unary(string) [[/*inline*/ System.out.println(me.nth(0)); ]](String). io.input(message) :- [[/*inline*/ String s = javax.swing.joptionpane.showinputdialog(null, me.nth(0)); me.changename(s); me.nthatom(0).changename("done"); ]](Message). io.input(message, X) :- [[/*inline*/ String s = javax.swing.joptionpane.showinputdialog(null, me.nth(0)); me.changename("done"); me.nthatom(0).changename(s); ]](Message, X). io.input :- [[/*inline*/ String s = javax.swing.joptionpane.showinputdialog(null, "Input text."); me.changename(s); ]]. Java io.print io.input 1 done

6.2. - map 38 2 done LMNtal 6.2 - map 6.2.1 map // unary map map : { map.new($self) :- unary($self) {name($self). // override exist key map.put($self, $k, $v), {name($name), assoc($ok, $ov), $p :- unary($k),unary($v),$name=$self,$ok=$k,unary($ov) {name($name), assoc($k, $v), $p. // add new key map.put($self, $k, $v), {name($name), $p :- unary($k),unary($v),$name=$self {name($name), assoc($k, $v), $p. map.get($self, $k, V), {name($name), assoc($mk, $mv), $p :- unary($k),$name=$self,$k=$mk,unary($mv) V=$mv, {name($name), assoc($mk, $mv), $p.. key value (map.put) key value (map.get) map.new map map.get map.put map map.get 1

6.3. - semaphore 39 LMNtal (bless ) 1 Perl5 OOP Perl5 OOP Java C++ OOP 6.3 - semaphore 6.3.1 semaphore // Semaphore sem : { name(sem). static.load. // public static method interface defs. sem.new(ready). sem.up(ready). sem.new(msg($self)) :- unary($self) {sem($self), state(notbusy), sem.new(ready). // up -> state(busy) if state(notbusy) sem.up(msg($self)), {sem($name), state(notbusy) :- $self==$name {sem($name), state(busy), allowed($self), sem.up(ready). // down -> state(notbusy) sem.down(msg($self)), {sem($name), state(busy) :- $self==$name {sem($name), state(notbusy), sem.down(ready)..

6.4. - 40 6.4-6.4.1 amidakuji.lmn - /* SYNOPSIS amidakuji.start_at(start2). ==> amidakuji.done(goal??). */ amidakuji : { amidakuji.start_at($y),c($s,c,d) :- $s=$y you($s,u),c(u,c,d). you(t1,m1), c(m1,c,d1), c(t2,c,d2) :- c(t1,c,d1), c(t2,c,m2), you(m2,d2).. c(u,c,m), you(m,$goal) :- unary($goal) c(u,c,$goal), amidakuji.done($goal). 2.2 amidakuji.start_at( ) you you you amidakuji.done( ) 6.4.2 // Amida data start1(r10). start2(r20). start3(r30). c(r10, C1, R11). c(r20, C1, R21). c(r21, C2, R22). c(r30, C2, R31). c(r11, C3, R12). c(r22, C3, R23). goal1(r12). goal2(r23). goal3(r31).

6.5. 41 // Main program io.input([[this is amidakuji. Where to start today? Input start1, start2 or start3.]], input_str). input_str(done(you)) :- amidakuji.start_at(you). amidakuji.done($goal) :- unary($goal) io.print([[you got to ]]), io.print($goal). start1 3 amidakuji.start_at you 6.5 6.5.1 module : {... { name(module) 6.5.2 system_ruleset name(module) module:{ property:{ atom.... module.property.atom

6.5.3. Objective Caml LMNtal 6.5.4

43 6.1: 2004 2

44 [1], : Programming with Logical Links, 19, 2002. [2] Kazunori Ueda and Norio Kato : Programming with Logical Links, Design of the LMNtal language, In Proc. 3rd Asian Workshop on Programming Languages and Systems (APLAS 2002), pp.115-126, 2002. [3] : Inside KLIC Version 1.0, KLIC Task Group/AITEC/JIPDEC, 1998. http://www.klic.org/software/klic/inside/master.html [4] : DKLIC,,, 2002.

45 Appendix.A A.1 Inline.java package runtime; import java.io.*; import java.util.*; /** * <BR> * * <UL> * <LI>"/ inline /" * * <LI>"/ inline_define /" * * <LI> * * <LI> * * * <LI> INLINE * * <LI> NEWATOM, LINK * INLINE * * <LI> * </UL> * <PRE> * NEWATOM [1, 0, abc_0] *... * INLINE [1, 0] * </PRE> * * @author hara */ public class Inline { /** */ public static InlineCode inlinecode; /** */

A.1. Inline.java 46 static Process cp; /** Hash { -> */ public static Map code = new HashMap(); /** List */ public static List defs = new ArrayList(); /** */ static int codecount = 0; /** * * */ public static void initinline() { try { if(cp!=null) { // // BufferedReader br = new BufferedReader(new InputStreamReader(cp.getErrorStream() String el; while( (el=br.readline())!=null ) { System.err.println(el); cp.waitfor(); Env.d("Compile result : "+cp.exitvalue()); cp = null; // jar ClassLoader cl = new FileClassLoader(); Object o = cl.loadclass("myinlinecode").newinstance(); if (o instanceof InlineCode) { inlinecode = (InlineCode)o; //inlinecode = (InlineCode)Class.forName("MyInlineCode").newInstance(); //Env.d(Class.forName("MyInlineCode").getField("version")); catch (Exception e) { //Env.e("!! catch!! "+e.getmessage()+"\n"+env.parray(arrays.aslist(e.getstacktrace( if (inlinecode!= null) { Env.d("MyInlineCode Loaded"); else if (inlinecode == null) { Env.d("Failed in loading MyInlineCode"); /** * ID * @param name * @return codeid */ public static int getcodeid(string name) { try {

A.1. Inline.java 47 return ((Integer)code.get(name)).intValue(); catch (Exception e) { return -1; /** * * * @param atom */ public static void add(string src) { if(src.startswith("/*inline*/")) { //if(src.startswith("a")) { // Env.d("Register inlinecode : "+src); code.put(src, new Integer(codeCount++)); else if(src.startswith("/*inline_define*/")) { // Env.d("Register inlinedefinecode : "+src); defs.add(src); /** * * TODO java oneliner REPL "-" * TODO */ public static void makecode() { try { if(code.isempty() && defs.isempty()) return; Iterator i; PrintWriter p = new PrintWriter(new FileOutputStream("MyInlineCode.java")); Env.d("make inline code "+code); //p.println("package runtime;"); p.println("import runtime.*;"); i = defs.iterator(); while(i.hasnext()) { String s = (String)i.next(); p.println(s); p.println("public class MyInlineCode implements InlineCode {"); p.println("\tpublic static String version=\"static string.\";"); p.println("\tpublic void run(atom me, int codeid) {"); //p.println("\t\tenv.p(\"-------------------------- \");"); //p.println("\t\tenv.d(\"exec Inline \"+me+codeid);"); p.println("\t\tswitch(codeid) {"); i = code.keyset().iterator(); while(i.hasnext()) {

A.2. Module.java 48 String s = (String)i.next(); int codeid = ((Integer)(code.get(s))).intValue(); p.println("\t\tcase "+codeid+": "); //p.println("\t\t\t/*"+s.replaceall("\\*\\/", "* /").replaceall("\\/\\*", "/ *") p.println("\t\t\t"+s); p.println("\t\t\tbreak;"); p.println("\t\t"); p.println("\t"); p.println(""); p.close(); // cp = Runtime.getRuntime().exec("javac -classpath.;lmntal.jar MyInlineCode.java"); catch (Exception e) { Env.d("!!! "+e.getmessage()+arrays.aslist(e.getstacktrace())); /** * * @param atom */ public static void callinline(atom atom, int codeid) { //Env.d(atom+" "+codeid); if(inlinecode==null) return; //Env.d("=> call Inline "+atom.getname()); inlinecode.run(atom, codeid); A.2 Module.java package compile; import java.io.bufferedreader; import java.io.fileinputstream; import java.io.inputstreamreader; import java.util.*; //import runtime.functor; import runtime.env; import compile.parser.lmnparser; import compile.structure.*; /** * <br><br> * *

A.2. Module.java 49 * <li> * <li> module_name : {... * <li> * <li> * <li> LOADMODULE * * <ul> * <li> module_name : {... * <li> [1] module_name.name * <li> [2] use(module_name), name<br> * <br> * * <li> * * </ul><br> * * * * <ul> * <li> [.] * <dl> * <dt>string Functor.path</dt> * <dd> * * * (n-kato)</dd> * <dt>boolean Functor.pathFree</dt> * <dd> </dd> * ModuleName$AtomName (n-kato) * </dl> * <li>. LOADMODULE *.lmn * <li> FINDATOM AtomSet * func * <ul> * <li>!func.pathfree name, arity, path * <li> func.pathfree name, arity * </ul> * (n-kato) * </ul> * * * * m.p

A.2. Module.java 50 * * runtime.functor p * runtime.atom * * [1] m.p m.p m.p m,p * findatom dstatom,srcmem,p * path dstatom,m * [2] p p (*A) * findatom dstatom,srcmem,p * [3] m.p m.p * newatom dstmem,p,m * [4] p m.p * newatom dstmem,p,m * [5] m.p m.p * [6] p m.p * * m.p * * m.p m,p * * [1] m.p m.p m.p * findatom dstatom,srcmem, m,p * [2] p p * findatom dstatom,srcmem,p * [3] m.p m.p * newatom dstmem,mem, m,p * [4] p p * newatom dstmem,mem,p * [5] m.p m.p * [6] p p * * m.p p (*A) * * * * m.p * * * * * * inline * >>>1

A.2. Module.java 51 ({{up,$p,@q,$s,@t:-{$s,@t,{up,$p,@q) #, {{up,1,2,3 down {down ({down,$p,@q,{$r,@s:-! ($r match {down, $t) {down,$p,@q, {{down,$p,@q,$r,@s) #, {down,1,{2,3,{4,5 >>>2 ( { find_and_link($name1, X), $Name2, decl :- $Name1 eq $Name2 $name2(x), decl ) ## { find_and_link(m, X), m, decl :- m(x), decl for all {m String(m) ## decl >>>3 ( $a(x) :- static($a) { up, down, find_and_link($a, X) ) 1, 2, 3 {{{ io.print(m.incr), m:{ decl, m.incr, id(0), ( m.incr(x), id(n) :- cp(s(n), Cp1, Cp2), id( -> {{{ io.print(x), { up, down, find_and_link(m.incr, X), m.incr(x), m:{... -> {{{ io.print(x), { up, down, find_and_link(m.incr, X), m:{... -> {{{ io.print(x), { up, down, find_and_link(m.incr, X), m:{... -> {{{ io.print(x), { up, down, find_and_link(m.incr, X), m:{... -> {{{ io.print(x), m:{ decl, m.incr, id, { up, down, find_and_link(m.incr, X), (... :-.. -> {{{ io.print(x), m:{ decl, id, m.incr(x), (... :-...) -> {{{ io.print(x), m:{ decl, id(1), 1(X), m.incr, (... :-...) * @author hara * */ public class Module { public static String libpath = "../lmntal_lib/"; public static Map memnametable = new HashMap(); /** * * @param m */ public static void regmemname(string name, Membrane m) { memnametable.put(name, m); /** * * @param m * @param mod_name */ public static void loadmodule(membrane m, String mod_name) {

A.2. Module.java 52 String filename = libpath+mod_name+".lmn"; StringBuffer sb = new StringBuffer("Loading Module "+mod_name+"..."); try { LMNParser lp = new LMNParser(new BufferedReader(new InputStreamReader(new FileInputS Membrane nm = RulesetCompiler.runStartWithNull(lp.parse()); // Env.p("MOD compiled "+nm); //memnametable GC //m.add(nm); sb.append(" [ OK ] "); catch (Exception e) { Env.e("!! catch!! "+e.getmessage()+"\n"+env.parray(arrays.aslist(e.getstacktrace()) sb.append(" [ FAILED ] "); Env.d(sb.toString()); /** * * @param m */ public static void resolvemodules(membrane m) { List need = new ArrayList(); getneedmodules(m, need); Iterator i = need.iterator(); while(i.hasnext()) { loadmodule(m, (String)i.next()); /** * * @param m * @param need */ static void getneedmodules(membrane m, List need) { Iterator i; i = m.atoms.listiterator(); while(i.hasnext()) { Atom a = (Atom)i.next(); String path = a.getpath(); if(path == null) continue; if(path.equals(m.name)) continue; // Env.p("Check module existence "+path); if(!memnametable.containskey(path)) { // Env.p("TODO: search lib file : " + path); need.add(path); i = m.rules.listiterator(); while(i.hasnext()) { RuleStructure rs = (RuleStructure)i.next(); getneedmodules(rs.leftmem, need); getneedmodules(rs.rightmem, need);

A.3..java 53 i = m.mems.listiterator(); while(i.hasnext()) { getneedmodules((membrane)i.next(), need); A.3.java

54 Appendix.B B.1 I/O (io.lmn) io:{ ( io.print(string) :- [[/*inline*/ System.out.println(me.nth(0)); ]](String) )