ラベル LiLFeS の投稿を表示しています。 すべての投稿を表示
ラベル LiLFeS の投稿を表示しています。 すべての投稿を表示

2010/06/01

天空への LiLFeS 入門 (QM 法編)

こんにちは。team C# の花元です。今回は学科の後輩向けにLiLFeS (参照1 / 参照2) による QM 法の実装について書きたいと思います。えっ、なんか大変そうなんだけど大丈夫?との声が聞こえてきそうですが、実は QM 法の実装に LiLFeS はとてもオススメです。以下その理由。

  1. 論理型言語である
  2. lexer / parser がいらない

つまるところ QM 法とは論理圧縮ですから、論理型言語であるというのは大きなアドバンテージです。Prolog? そんな軟弱な言語有り得ません。lexer / parser がいらないというのも良いですね。LiLFeS ならクエリを実行するだけで大丈夫です。ocamllex / ocamlyacc に飽きてしまった人も是非。

2009/10/21

悟りに近づく LiLFeS 入門 (インストール編)

また出てきた Team C# の新井です。今日は度々ネタにされる LiLFeS について書こうと思います。簡単に言うと LiLFeS は「Prolog みたいなもの」で、論理型言語の一種です。東大の研究室で開発されました。

第一回ということで、まずはインストール編です。学科で貸与されるノートパソコンには最初から Ubuntu が入っているため、Ubuntu(Debian でも殆ど同じですが)へインストールするつもりで書きます。

~$ wget http://www-tsujii.is.s.u-tokyo.ac.jp/downloads/files/lilfes/liblilfes-1.3.8.tar.gz
~$ tar xzvf liblilfes-1.3.8.tar.gz
~$ cd liblilfes-1.3.8/
~/liblilfes-1.3.8$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
(略)
checking for sys/ioctl.h... yes
checking util.h usability... no
checking util.h presence... no
checking for util.h... no
checking FlexLexer.h usability... no
checking FlexLexer.h presence... no
checking for FlexLexer.h... no
configure: error: Cannot find FlexLexer.h (distributed with flex 2.5.4a)
おっと、flex が必要だったようです。
~/liblilfes-1.3.8$ sudo aptitude install flex
~/liblilfes-1.3.8$ ./configure
~/liblilfes-1.3.8$ make
(略)
code.cpp:44: warning: deprecated conversion from string constant to 'char*'
code.cpp:45: warning: deprecated conversion from string constant to 'char*'
code.cpp:46: warning: deprecated conversion from string constant to 'char*'
code.cpp:47: warning: deprecated conversion from string constant to 'char*'
code.cpp:48: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
code.cpp:655: warning: deprecated conversion from string constant to 'char*'
(以下引き続き warning)
大量の warning に負けないでもう少し
~/liblilfes-1.3.8$ sudo make install
これでインストール完了です。 お決まりの Hello, world! を走らせてみましょう。
~/liblilfes-1.3.8$ lilfes
LiLFeS 1.3.8    [PROFILE] [REGEX]
Copyright (c) 1997-2006, Takaki Makino and Tsujii lab., Tokyo Univ.
> ?- print("Hello, world!").
セグメンテーション違反です
~/liblilfes-1.3.8$

(゚д゚ )

( ゚д゚ )


?- halt. でLiLFeSインタプリタを終了できます。

~/liblilfes-1.3.8$ lilfes
LiLFeS 1.3.8    [PROFILE] [REGEX]
Copyright (c) 1997-2006, Takaki Makino and Tsujii lab., Tokyo Univ.
> ?- halt.
セグメンテーション違反です
~/liblilfes-1.3.8$


確かに終了した

初回授業のあと地下へ行ってみんなでインストールして爆笑





とここでネタばらし!
実は flex パッケージではなく flex-old パッケージが必要だったのです。

地下の人が気づいて既に動かせてはいましたが、TA から連絡が来たのは数日後でしたね!

~/liblilfes-1.3.8$ sudo aptitude purge flex ← configure 辺りで指定すれば必要なかったかも
~/liblilfes-1.3.8$ sudo aptitude install flex-old
~/liblilfes-1.3.8$ ./configure
~/liblilfes-1.3.8$ make
~/liblilfes-1.3.8$ sudo make install

続きはきっと班員の誰かが書くので請うご期待