2008-04-27

Software Engineering

今日はTOEFL受けて、爆死してきました。orz
まだまだ俺の英語レベルなんてちっぽけなもんなんだと実感。

で、その後は上級英語の課題を終えて、ソフトウェア工学の勉強。帰ったらJudeの課題取り掛かろう。ところで、Judeってジュードって読むのか。ユダって読んでた俺涙目w

あとは論理回路の実験レポートもそろそろやらんとな。Basic mathの予習もさらっと終わらせて、回路理論の課題は気合で。言語処理は小テストあるし、構文解析・構文規則んところをもっと深く理解しとこう。その後は、OSをガリガリ勉強!

GWもバリバリ引き篭もって勉強するぜぃ。



----- note@apr 14th -----
Software Engineering@wikipedia

コンピュータのソフトウェアの開発方法を研究対象とする情報工学の一分野である。 具体的には、高度かつ安全なコンピュータのソフトウェアを短期間で設計するための研究などを行なう。難易度の高い大規模ソフトウェアの開発に焦点を当てることが多い。

ソフトウェア工学では、通常、開発対象となるソフトウェアの開発を思いついた時点から、実際に動くソフトウェアが完成し、使用されるまでを、いくつかの工程に分けて考察する (ソフトウェア開発工程) 。これらの工程ごとに典型的な課題が存在し、課題に立ち向かう方法を明確にしようとする。 このため、ソフトウェア工学の対象は広範囲にわたる。

また、他分野とクロスオーバーしていたり、もしくはソフトウェア工学の1分野だったものが独立して別分野を形成したり(例:データベース設計)、別分野で培われた技術や概念がソフトウェア工学の対象となることもある(例:オブジェクト指向技術)。




[ソフトウェア工学]
・Judeのダウンロード(演習のため)
Course Naviから講義資料のダウンロード→プリントアウト



The way of making software
approach management maintenance retirement

ソフトウェア工学の定義
→良いsoftwareを、簡単に作成するための方法論、toolを開発する学問(工学)
e.g. UML,Jude, How to use tool, method

ソフトウェア工学の対象
・大規模なsoftware(10,000 lines)
・多人数で開発するソフトウェア
・開発者と利用者が異なるソフトウェア
・使い捨てでないソフトウェア

ソフトウェア品質特性-ISO/IEC 9126
・機能性
・信頼性 おつりが
・使用性 コンピュータが扱えない人、盲目の人はどうすればよいか?
・効率性 何秒以内に返答が来るか?メモリはいくつあればよいか?
・保守性 
・移植性 違うOSに移植するときどの程度楽になるか?

さらに細かい話 
機能性
合目的性、正確性…など。

[metorics]
coding規約
if(a>b){
↑↓
if(a>b)
{

ELOC = プログラムの全体行数?
ELOC 全部で一万行のプログラムのとき、実際に動くのは5,000行だけかもしれない

10人月
→10人でやれば1ヶ月で終わるソフトウェア。
ソフトウェアの規模を図るときに使う。

ソフトウェアは実世界のシミュレーションである。
従来の機能中心的な開発よりは失敗した。
実世界とのギャップが大きかったからである。
実世界はモノとモノとの関係を中心にして存在している。
よって、モノとモノとの関係を(データ+手続き)中心にした開発の方が
実世界に適している。つまり、開発で失敗しにくくなる。

複雑さに挑戦するための基本手段
本質的なこと
e.g.性別、特徴などは本質的ではない。
→授業を聞いている人の態度が本質にある。他はたいした事ではない。
これは、ソフトウェア制作に関しても同じことが言える。

Stractured Programming
・仕組み
メソッドのようなものを頻繁に書いていく。

オブジェクト指向プログラミング(Object Oriented Programming)
実際にあるもの→インスタンス e.g.一人一人の人間、犬
e.g.両方とも犬でもあるが、違いが生まれるのは名前、種類、体重が違う。
→これを、属性(名前、種類、体重など)が違うという。
属性値=属性の値

例:犬のポチ
・えさを食べる というメソッド
↑パラメータ

ポチとタローの違い→属性値
ポチとタローはクラスが同じ
→クラス=犬

【関連】
色んな関係がある

【仕組み2】
継承:親の特徴を子が受け継ぐ。

カプセル化:要されたメソッドを通してのみ変数にアクセスできる

継承例
SUPRE CLASS1:Pet
SUB CLASS2:dog,cat

多重継承
SUPER CLASS:豚クラス、猪クラス
SUB CLASS:猪豚クラス

どのように継承すればよいかが難しい→JAVAは多重継承を許していない

【抽象クラス】
抽象クラス:インスタンスを持たないクラス
人間クラス
男クラス,女クラス

例:ペットは犬でも猫でもないペットが存在する。
それを表したい場合、ペットクラスのインスタンスを作成するしかない。
男でも女でもない人間はいない→人間クラスのインスタンスはいらない?
→男も女も衣食住は同じメソッド、2度書く手間が省ける。

【override】再定義
例:脅すと逃げるペットが存在する。
猫の逃げ方は少し異なる。
猫クラスのインスタンスに対して脅された場合のメソッドを
書き換える必要がある。
→ペットクラスの脅すメソッドを書き換える

【polymolfism】多相性
例:色んな図形がある。

shape class
draw()
erase()
↑まだ何も定義されていない。

Circle class
円を書くメソッド
円を消すメソッド

square class
四角を書くメソッド
消すメソッド

例:何かを消して、何かを書くメソッドを書いたとする。
書くクラスで定義されたものが適宜作られる。
→何を書くか、何を消すかを動的に決められる。
→呼び出されるまで何が描かれるか分からない。
→いずれ新しいメソッドを加えるときに何も影響が出ない。
→再利用性が高い!

【動的結合】
コンパイル時には、何が描かれるか分からない。
実行時になって分かる。
問題:実行効率の問題
-呼び出し処理にかかる時間
-最適化が出来ない。
java Final修飾詞

polymorphism
オブジェクト指向プログラミング(OOP)の複雑さへの挑戦
・抽象化
-カプセルか
-継承
-polymorphism
-composition?


新しい言語の定義
-smalltalk
--eiffel

手続き型プログラムのオブジェクト指向的解釈
int x;
int y;

x=1;
x=x+3;

これをどのように頭の中で解釈するか?

例:stack program
手続き型とオブジェクト指向型のプログラムの違いについて。
→引数の数。

このような考え方は要求分析や、実装・設計まで幅広くcoverされている。

例:
手続き思考
普通口座開設 2引数
当座預金開設 2引数
普通預金引出 2引数
当座預金引出 2引数

オブジェクト指向で実装する。
誤り例:動作をクラスにする。

来週UMLの話
・機能側面
-use case graph 例:レンタルビデオ屋はどんなシステムが存在するか。
・静的側面 
-class graph
-object graph
…など9種類ある。

再来週はJudeで書き始める。

2008-04-25

Lexical Analysis

眠い。睡眠時間ってやっぱし大事だ。

春休みの間課題の多い生活から離れていたせいか、時間管理が下手になってるorz
さっそく、実験レポの時間管理で失敗してるしorz orz
想像していた時間より、2倍近くかかった。
まずいな。修正しなくては。

加えて、OS実践の課題も今のうちにある程度進めておかないと、
後半戦で死亡フラグ立つわ。毎日ガリガリやるしかねぇw

とりあえず、SoC設計取り消しといて正解だったといえるな。
当時の俺Good job。


----------- note -------------
字句解析(Lexical Analysis)@wikipedia

連続した文字の並びを、意味における最小単位である字句(一般にはトークン、英文なら単語など。)に分割すること。字句解析を行うプログラムを字句解析器(lexical analyzer)と呼ぶ。英語ではlexerとも。字句解析器はスキャナとトークナイザから構成される。

プログラミング言語の仕様には規則群があり、一般に何らかの構文記法で示され、トークンや語彙素を形成する文字の並びを指定する。空白文字は字句解析では無視されることが多い。自然言語の字句解析を形態素解析と呼ぶ。なお、字句解析によって得られたトークンのならびについて、トークン間の関係を解析することを構文解析という。字句解析は、構文解析の前段階として広く行われている。しかし、高速な動作が必要でない場合は1文字を1トークンとみなすことで字句解析を無くし、構文解析のみで文字列の解析を行うシンプルな手法が使われる場合もある。




約束:一文字先読み

次の一字句を読み取る関数を使う。
get_char()
ch
get_token()
token
spell
value

spellかvalueのどっちかがとる。
・名前が同じかどうかがわからなくてはいけない。

1. 英字だったら読み飛ばす
2. (が出たのでmainが読める。
3. )が出るけど、一次先読みの取り決めがあるため、次の文字を読んでから()を理解する
4. {
5. intを読み込む
6. + 空白が来るので、intが予約語かどうか調べる。予約語だった!
7. two
8. ;が来るので、予約語かどうかを調べて、そうでなかったら大丈夫!
以下省略


・字句読み取り
変な文字列がきたら、それを格納するものを作る - nontoken
endffile EOF
comment /**/

enum {} 定数名をデータ番号をそれぞれ違う番号にして、使い分けるための整数型。
→それぞれ違う番号になることに意味があり、番号自体には意味はない。
→コンパイラが勝手に決めてくれえる。

get_char()で一文字先を読んでおく。

v = v*10 + (c + -'0')

・予約語の同定→一致しているかどうか
適当なhash関数をかけて、綴りがすべて違えばいい。

たとえば、予約語が10個あったら、場所は10個以上必要。

・具現
if文でやると無駄に多く比較してしまう。
switch文でやるのが

配列[数十個]を英数字分用意して、それぞれの配列に入っている中身を参照して処理を決めればよい!
→それを作ってね。
というのがswitch文。

WL言語ではswitchがかけないので、手で書く。
さらに早くするためには、実行頻度が多い部分を早めにif文を持っていく。
二分岐する。

字句解析は自習。自分で呼んでくること。


英字からはじまるabcdからなる文字列で
末尾がabでおわっているもの。
ただし、末尾を除いて、bc(正:ab)という部分列は現れていないものに限る。


-------------------------------
課題

課題内容: WLの字句解析を読み,実習課題のLEX-1を行え。

LEX-1
get_token を呼び出して,次々と字句を切り出し,その結果を 表示する 簡単な主算譜 と これらの関数を一緒にして WL処理系で翻訳し,実行して見よ。
実行に際しては,これまでに入手している算譜を試料 (test data) として使って見るのもよい。

レポートとしては,つぎのものを記載すること。
 ・でき上がった字句解析のソースプログラム
 ・入力例
 ・その入力例に対する出力結果
 ・考察
レポートは,ファイルの形で用意し,それを添付することによって提出せよ。

-------------------------------
テストは小テストと同じ方式で出題する。

次回:
エラーが出たときの処理。
宣言の結果を表に記録し、型があっているかどうかをチェックする方法。

2008-04-22

C language

風邪が悪化orz orz
講義聴いてるだけなのに、
謎の全身筋肉痛w
でも、休むわけにはいかなんだ。



Eyebotは朝一で実験実にいき、
メニュー画面とかoption画面とか作成。
とりあえずはこれでプログラムは完成としよう。
さっさとレポートだ。

----- assignment -----
Operating System 2008/04/22

実践OS課題群
・プロセスのスケジューリングの中にある小さなプロセスにさらにスケジューリング機能を搭載?
・SH4aに移植(難易度:高)
・期限は最終講義日まで
・拡張機能も可
・スケジューリングのアルゴリズム変更(難易度:易)
・ある時間のときの設定を保存して、プログラムが動いたとき元に戻す。
→システムの復旧?
・メモリ内プロセスバック?
・使っていないprocessに対して、ある一定の時間がたったら勝手に圧縮するプログラム。
・終わったらレポート

----- note -----

システムコール = OSを呼び出すための関数
普通は、OSのデータ構造にはアクセスできない。

システムコールを介してのみ、アクセス可能。

Index
・カーネルの中身
・C言語の復習
-header, structについて

C言語とは
OSを作るのに適切な言語。
低水準programming

assembly言語はCPU毎にソースコードが違う
→移植するときは全部変更しなくてはいけない。

C言語の場合、大抵使いまわせる。
→移植するときの楽。

C言語には予約語が一杯ある。
→JAVAに似ているが、CLASSの概念はない。

C言語は分割しても一括してもどちらでも大丈夫。
→どの関数をどのファイルに置くかを考える必要がある。

Structure
-宣言部
-main関数
-そのほかの関数

C言語を使うときは、型のbyte数を把握する必要がある。
JAVAの"NEW"に近いallocateをするためには、
sizeof(型)をやって自分でbyte数を確保する必要がある。

・auto(自動変数)
関数内部の変数とか。
関数から出たら、解放する。

・static(静的変数)
呼び出すかどうかに関わらず、いつでも存在する。

EX:staticで大きい配列はダメ

・Register(レジスタ変数)
register上に置くので、早くなるかもしれない。
現在は、compilerが勝手にやってくれるので、
使っても無視されることがしばしばある。

・exterm(外部参照変数)
プログラムの外に変数を書く。
グローバル変数 = static変数

main()内はauto変数
関数内の変数をstaticにすると、以前使ったときの
結果が残っている。

int foo(void)
int main()
引数の数は自分で数える。

GNU gccは良いが、他のコンパイラには
引数をカウントしないものもある。
→clashしてdownする可能性がある。

・prototype宣言
int foo(int);
compilerがcheckしてくれる。

Ex:型のミス
void foo(void);
int x = foo;

---------------------------------

・C言語のsequence

C sourve(*.c)
↓ 
↓ preprocessor

preprocessor後のsource(*.i)

↓ C compiler

Object file
↓ linker
↓←←←←←←library

実行ファイル


・header
#include "queue.h"

preprocessorがlibraryの中にある"queue.h"を
ソースファイル内に展開する。

・マクロ展開
#define MAX 10
MAXを10に置き換える

#define putchar(x) fputc(x, stdout)
xは引数としてマクロ展開する。

用途:何行も使うものをまとめるときに使う。
「何故methodにしないのか」
methodの呼び出しのために、サイクルカウント値を消費してしまい、
動作が遅くなるから。

OSでは、致命的。C言語では重要な部分。
→overflowはなるべく少なくする。

・他の記号
#include"hoge.h"
#if DEBUG == TRUE
print("value = %d\n", val);

→hoge.hが
#define DEBUG TRUEならば
print文がマクロ展開される。

→#include"hoge.h"の文があるかどうかで
実行の有無がわかる。

debugに便利!

・gcc -DTEST ~~~
オプションの-DTESTがあれば
#ifdef TEST以下の文が展開
そうでなければ
#else以下の文が展開される。

用途:
#ifdef LINUX #else WINDOWS
Linux用とwindows用にわけてマクロ展開させることが可能。

・#incledeファイルの場所
→/usr/include/
or
/usr/include/sys/
and
/usr/include/linux/

・include fileのpathを指定したいとき
gcc -I/usr/local/hoge.h


・ifdef~else~endif
#ifdef MAIN
/* MAIN が #define してあったらここの部分がコンパイルされる。#define されていなかったらここの部分は無視される */
#else
/* MAIN が #define されていなかったらここの部分がコンパイルされる。#define してあったらここの部分は無視される */
#endif


・Compilerとlink
実行ファイルの中身
hm -g a.out | grep't'
00001c64 T __darmin_~~~
00001d44 T _main
0000166c T start 
プログラムが実行させるときは、まず最初にstartを探す!
startの位置をprogram counterに設定する。

※start -> _mainまでに
色々と初期化している。
mainかんすを呼ぶためにlibraryの中で、
色々と初期化されている。

・動的リンク
必要になったときにlibraryを呼ぶ
複数のプログラムから同じlibraryを使う場合、
共有ライブラリにする

*.so (shared object)

・コンパイラの最適化
program -> binaryにする場合
defaultで -O2 optionが入る。
→-O3以上にしても、あまり結果は変わらない。

・library
-lnew 自分が定義したもの?

-L/usr/local/mylibs
↑このdirectoryの中から優先的に探しだしてlinkする。

・libraryを作る場合
gcc -c newlib.c
ar rcs libnew.a newlib.o
で"new"ライブラリにnewlibを追加
nm/usr/lib/libc

・静的リンク
全部取り込む
→programが大きくなりやすい!注意!

・構造体
データ構造のみを定義。

struct tag名{
type member1;
type member2;
};

struct log{
char time[10];
long ch0;
long ch1;
};
↑この場合
1 structure = 10B+4B+4B = 18B

struct log logger1, logger2;
typedef struct{
~~
~~
~~
}LOG;

LOG logger1;
LOG logger2;
→structを宣言しないで済む。
typedefが主流。

・Pointer
※2000番地に10が入っているものとする。
int a;
int *p;
p=2000;
p=&a;

int *p;
int c = *p;
→integer型のpointerに10が入る。

func(&val);

→OSがCで書かれている理由の一つ
→pointer

予断:javaの場合classはcall-by-referenceになる

☆文字列の最後は必ず'0'が入っている。
"abcd"

'a'+'b'+'c'+'d'+'0'

while(*str) str++;
→文字列を読み終わったら0が入る
→偽になる→while文終了

予断:NULL = 0


・配列とポインタ
&array[0] と arrayは同じ意味
++arrayとすると
array[1]から読み込まれる。

データ構造の文だけincrementされるから。
→箱のサイズは気にしなくてもよい。


・character型の場合
char str[] ⇔ char *str
同じ

一般的に、*pには乗算や除算は使わない
structureをコピーするかpointerで指定するかで、
作業効率が大幅に変わってくる。

struct hm_time{
int hour;
int minute;
};

アクセスするには2つの方法がある。
①time.hour or time.minute

②void addtime(struct hm_time *t1, struct hm_time *t2){
t1->hour += t2->hour; ←メンバーアクセスと呼ぶ
t1->minute += t2->minute;
}

・command line
javaとはちょっと違う。
main(int argc, char argc[]){~~~

argc = コマンド(1)+引数の数
argv[] = コマンド及び引数へのポインタ

・pointerの危険性
異常終了or迷子のポインタ
エラーのとき
int *p;
int c = *p;
malloc <- 動的に領域を割り当てる。
malloc(10) = 10byte確保する
↑うまく確保できない場合は0を返すので
if文を使ってエラー処理することも可能!

☆確保したものはfree()で解放すること!
解放し忘れると、メモリがドンドン減ってくる!

2008-04-21

Computational Intelligence


風邪引いたっぽいorz


OS実践コースにどうやらGeekがいるみたい。
指定された教科書は既に読破済みみたいで、
(出版された年に既に読破?)
今は研究室でOSの研究を始めてるそうな。

CSの世界はほんと頭の回転が早い人が多すぎて困る。
でも、俺もそん中で負けないように、かつ、
そういう人達に追いついていかなくてはな。





Eyebotのプログラミングようやく終了です。
とりあえず言われた仕様は満たしているはず。

あとは、optionの機能とか追加してみようかと思ってるけど、
まぁ…、まずはレポートの必須項目書き始めてからかな。
時間が余ったら、考察で書きまくろう。

今年はフィルターみたいなレポートありませんように!




----- note ------
2008/04/21

Index
知的とは?

シンボルとは?

prologとは?

課題

---------------------------------
AIについて
認知科学とは cognitive science
知的機能の科学的研究。
科学のほう。コンピュータを使うとはかぎらない。
心理学とか言語学とか

知識工学とは knowledge engineering
expert system
30年ぐらい歴史があり、そこそこ役に立ってる。


Expert Systemとは
微分積分をプログラムにやらせるのは簡単。
難しいことは、小学校の友達の顔を見分ける。
二歳の子供が子供を覚えるプロセス。

→一般知能は実現困難。
でも分野を限定すれば役立つ知的機能が実現できる。。。はず
役立つためには知識量が重要。

実績がたくさんある。
例:化学の分子構造の同定、株価予測
電子回路故障診断、計算機operation監視、医療監視、
分子生物学実験実験計画、機械設計etc.

・特徴
知識ベースと推論エンジンの文理。
なぜ分離する必要があるか。
知識の管理がしやすくなってなくてはいけない

知識を組み立てるプログラムと
知識を組み合わせて推論するプログラム
を明確に分けなくてはいけない。
→簡単に改善できるようにするため

・ユーザーが聞きたいこと
推論の結果を聞いた場合、
どのようなプロセスを経てその結論を得たのか?

・思ったほど楽じゃない
原理的には可能だが、
専門家の頭の中にある知識を
知識エンジニアが入力する作業がとても大変!

→専門家の技術を、機械がモニタを通して盗むほうが効率的!

機械学習とdata mining
実世界から得た大量のデータから法則性を発見する。

・応用例
遺伝子情報処理
セールスデータの解析-コンビニとか
ビール買った人はつまみも買う。
→商売のチャンスが生まれるかもしれない

cf.コンビニの法則
ビールとつまみを同じ棚に置かない。
同時に買うと分かっているものは、なるべきはなれたところに置く。
→他の品もかってもらうため。

クレジットカードの与信 cf. e-commerce
天体の識別。
コンピュータが識別できなかった場合は、新発見の可能性が高い。
機械の自動診断・自動運転
紙は状況により性質が変わる。
インクも同じ。
→輪転機は職人技だが、職人が減っていき、職人の需要が増えてきていることから
expert systemの需要が高まっている。

Can Machines Think?
哲学者によく議論される。とても微妙。
Can machines fly?
Yes, airplanes can fly!
おk

Can machines swim?
Yes, ships can swim!
???

???
そもそもflyとかswimでも
われわれの認識は微妙である。

→定義をしなくては議論が進まない!

Turing Test
Turingの同期:上記の問いを科学的名(well-definedな)ものにしたい

・排除したい答えの例
人間は一種の人造機械なのだからyes
thinkは人間固有の行為であるからno
→議論がつまらなくなる

The Alan Turing Home Page
Who was Alan?
codebreaker = ドイツの暗号を破って貢献した。
strange visionary and a gay man.
1950, Turing test

Turing test - Imitation Game
男と女(同部屋)とsomeoneがチャットする。
最初の五分間ぐらいどちらかと話する。
次の五分間もう一方の人と話する。

女性は普通に話す。
男はなるべく女っぽく話す。

someoneが性別を見分けられたらsomeoneの勝ち



・次
someoneが男女とcomputerに順不同で5分間ずつチャットする。
見分けられたらsomeoneの勝ち。

2000年予測
10GBのメモリが乗ったstrageでimitation gameをやたら
3割以上不正解になるだろう。→当たってる?

大事なこと→プログラミング
Turing Test
"Computing machinery and intelligence"

5分間の会話では難しい。
自然言語をチャットだけで判断するのは難しいのでは?



Turing Testに勝つコンテストとかある
→生産性が無い?


知識のいろいろ
記号的でない知識→暗黙知
自分は分かるけど説明が難しいもの
EX自転車の乗り方、友達の顔

記号的名知識→形式知
言葉で説明できるもの
構成的な知識
方法を表現したもの
手続き型procedural = "how"の表現
例:逆行列を求めるプログラム

構成的でない知識
何であるかを表現したもの
宣言方:declarative = "what"の表現
例:逆行列の数学的な定義
これを聞いただけでは、


この授業でやりたいこと
howを言わなくても、コンピュータが推論でそこまで導いてくれる。



コンピュータは数値計算の需要から生まれた
コンピュータが登場すると、人間との類似性に注目して新たな使い方を考える人々が現れた。
→記号を扱う能力、具体的には、
・記号や記号の連鎖をコンピュータの中に気を駆使照り、読み出したり、変形したりする能力
・2つの記号が等しいかどうかの判別能力

記号Aと記号Bが同じかどうかを判断する処理をcomputerにもたせる

宣言的な知識:
"いとこ"って言葉を知らない人がいたとする。
家計図をinputさせて、この人はいとこかどうかを判断させる。

そのためには、定義を入れる必要がある。
コンピュータの中には記号を入れる。
記号=単語
名前の付け方には任意性がある。
例:12 vs. ⅩⅡ vs. twelve

りんごなら、りんごを表す概念があり、
りんごを表す記号自信がある。
動詞は名詞ではないが、"動詞"は名詞
""が付いている場合と付いていない場合では違う意味になる。
例:グ
レープフルーツはグレープとフルーツに分けられるか?

ばらしてしまってはそのものの意味がなくなってしまう。
動詞→動と詞では意味が伝わらない。

記号のつづり

記号≒単語
記号とは、概念をつけた名前のこと

記号を組み合わせることによって、より複雑な概念を表すことができる

単語動詞は相互に関係している

辞書:単語同士のポインターが張られている。

↑こんなようなことをコンピュータの中でやりたい!


単語は同じか違うか区別できれば良い。
javaのオブジェクトとかポインターに似ている。
中身はどうでもいい。何を指しているかが重要。

モデル化と解釈
問題→モデル化→プログラムデータ→計算結果→解決

物体の配置、光線状態→モデル化された物理状態と物理法則→二次元画像→情景

ソクラテスは人間、人間は皆死ぬ

計算機で記号を扱うための基本機能は
同意知性の判定
記号構造の形成と操作
記号のつづりは入出力用、内部の処理では使わない。
コンピュータが推論の作業をするときに使う。

同一性の判定が高速にできればよい。

Cf. heap
りんごが2回目にきたときには、オブジェクトへの参照を返す。
アドレス比較だけで済む。
外部から読み込んだ同一記号は常に同じ識別番号に変換される。

記号による知識表現
概念同士を関係付けることが知識表現の基本

現実世界での概念間の関係⇔計算機内での記号間の関係(link structure)
お互いに関係している。リンク構造で表現すればコンピュータの中で表現できる。
物理記号系(Newell an Simon)

6.5は自分で読むこと!

Ocamlという言語は物理記号系

今日の目標
知識をコンピュータに入れるとはどういうことなのか?

記号的名知識→構成的な知識、構成的でない知識。
辞書にはソートする方法とかは載ってない。
宣言的な知識が乗っている。

どういう風にコンピュータに入れればよいのか?
・個別的な知識 辞書に出ない
Tom is the father of Liz.
Pam is female.


・一般知識(辞書に出る)
a mother is a parent who is female.
a grandmother is a mother of a parent.
an ancestor is either (i) a parent or (ii) a parent of an ancestor
↑これらはすべて論理学の言葉でもかける!

個別知識。
Tom is the father of Liz.
is_father_of(tom, liz)
Pam is female.
is_female(pam)

特徴→述語 主語 目的語(目的格)
固有名詞が出現
単文

Tom and Liz and Pamなどの固有名詞は小文字からはじめる。

・一般知識
A mother is a parent whoo is female.
X is the mother of ' if X is a parent of Y and X is female.

is_mother_of(X,Y) ←
is_parent_of(X,Y) ∧ is_female(X)

A grandmother is a mother of a parent.
is_grandmother_of(X,Y) ←
is_mother_of(X,Z) ∧ is_parent_of(Z,Y)

・∀X∀Y(~~~)が抜けている!
→X,Y,Zという単語は全ての事象に対して成り立つという暗黙の了解がある

prologとは
PROgramming in LOGic = prolog
if文とは結論を実行するために、論理式を読む?
ocamlよりはるかに安定している処理系

-----------------------------------------------
レポートについては来週説明 5/8まで

主張1:「コンピュータが知的名はずが無い(P1),だって、プログラムされたことしか出来ない(Q1)のだから」
Q1は正しいか?Q1はP1を含意するか?

主張2:「人間が知的名はずが無い(P2),だって、遺伝子に組み込まれたことしか出来ない(Q2)のだから」
Q2は正しいか?Q2はP2を含意するか?
以上に関する自分の意見をレポートにまとめて提出。領主超の関係をよく分析してください。

主張1と主張2は全く同じ格好をしている。
同じロジックなら同じ答えになるはず。
答えが違っていたらどこかで言葉の認識のズレがある。

2008-04-17

Sensor Control Programming


今日はBasic Mathの授業後、
情報ネットワーク実験の発展課題をこなすため、
一人黙々とEyebotと戯れてました。

あの広い実験室にEyebotにプログラムを打ち込んでる人が一人。
そして、壁はガラス製で、もちろん透明。

実験室の廊下を通る生徒or事務員の目から見たら
変質者にしか見えn(ry

とはいえ、羞恥心を克服し何とか発展課題は完成。
作ったプログラムは、rotally encodorを回すとServo motorが
自動車のアクセルっぽく動くプログラム(のはず)です。
加速度とかが考慮されて、モーターがそれっぽく動きます(多分

明日は風見鶏の設計か。
なんか物理学の基礎が頭から消えてる感が否めないが、
とりあえず、やれるところまでやってみる予定。



話し変わって、Eyebotと戯れてコメントやら印刷やらをした後、
自作OSのための勉強をはじめました。

去年、Micro computingとComputer Architectureを
頑張って勉強したおかげで、出だしは中々好調。

今日は電源入れると、自作OSが立ち上がって
hello worldが画面に表示されるOS(?)が出来ました。

ちなみに、終了機能はありません

一度立ち上げたら、例のボタンを長押しするか、

電源コードを抜くかです。

まぁ、初日なんでこんなもんです。
3ヵ月後にはこのOSが、それらしいOSになってることを期待。

2008-04-16

Language Processor



課題:
(a)
to sort positive integers given on the standard input (stdin)
and display the result from the smallest one up to the greatest.
The positive integers on stdin are terminated with a zero.

(b)
to display all the Fibonacci numbers smaller than 10~50.
The Fibonacci numbers f(i) (i= 0, 1, 2, ...) are degined
by the following recurrent relation:

f(0)=0, f(1)=1, f(i+2)=f(i+1)+f(i) (i=0,1,2,....)

とりあえず課題は完成(多分)。
課題は、どこかの誰かさんが作った自作Compiler上で
上記の仕様を満たすprogramの作成。

今回のprogrammingで
CとかJAVAとかPythonがいかに優れているかを実感。
オブジェクト指向万歳!

なんせ、そのCompilerだと、
incrementはできないし、for文は書けないし、型宣言はintしかないし(以下自主規制)
などなど、色々な規制がいっぱいある。

まぁ、でも今回の目的は言語処理系を作るで、
課題の目的は(多分)そのコンパイラでのプログラミングに
慣れることだからいたしかたない


さて、話変わって今年はOS実践コースに応募してみました。
演習内容はOSを作成することで、最終課題は違うprocessor上でprogramを動かすことだそうな。
ただ、教授いわく受講者は少数精鋭(2~3人?)にするみたい。

そのくせ、調子乗って、 受講が決定したわけでもないのに
そのコース用の教科書を買ってしまったもんだから、
面接やらなんやらで受講できなかったら教科書代が…(´・ω・`)

きっと受かると信じたい。


で、見事そのコースが取れたら、
演習や課題に対してそれなりに時間を割かなくちゃいけないから、
レポート地獄という噂のSTARC寄附講座SoC設計は辞退する予定。

といわけで、今年の前期は

OS実践コース合格→ Enjoy OS life!
OS実践コース選外→ Enjoy SoC life!

的な形で行こうかと。





SoC設計(笑)

Computer Architectureとか
Micro Computingは得意な方だと思うけど、
回路理論とか電子回路は全くダメ。

Microsoft寄附講座のセキュリティに関する講義が
今年もあれば取ったのになぁ… (´・ω・`)

2008-04-12

Laboratory

若干鬱。

行きたい研究室について色々調べてみた結果、
入るためには成績の平均がAとA+の中間ぐらいは必要みたいだ。

絶望的数値乙orz。

でも、別のアプローチ方法もある。
どうせ何もしなきゃ入れるわけがない研究室なんだから、
最後までもがいてみるテスト。



[Advanced English]
Title: Learn how to control a robot by using C language

My last experiment class was to learn how to control a robot in order to move a robot against the wind automatically. For that, I got two tasks. The tasks were to control a robot in simple ways as a Teach Assistant said. It’s because to learn how to control a robot at first. The robot has a display, terminal, and some architecture to be needed to compile C source code. In addition, there is a library which contains a lot of C source codes to control the robot. So, I can control the robot by C language, and I learned how to control the robot through the tasks. Therefore I’ll be able to move the robot against the wind automatically in next experiment class.

2008-04-08

composition 02

大部分を変更。っていうか時間的にまずいな。
明日から授業が始まるというのに…

Do you want to know about vending machines? That’s great! It’s because the vending machines have enhancement right now. So, I'll tell you all about them from general description to advanced example for the future, in order to understand them deeply and why they have enhancement.
Generally speaking to a feature and appearance, a vending machine is an automated machine where we can buy various goods such as drinks and foods. The machine is fully automated, and is thus unmanned. It’s as big as a refrigerator and has three parts. One is a slot part where we can insert coins and bills. Another is a selection part which has a display and buttons for showing and choosing the goods. The Other is a covered area where we can collect the goods.
Next, let’s move on how to use vending machines. It’s quite simple to use them. There are only two steps to buy goods from a vending machine. First, insert the appropriate amount of money into the slots, and then choose the goods by using buttons on the display. That’s all! After making a selection, the goods will drop into the covered area, so you’re able to take the goods out of the vending machine. It’s quite simple, isn’t it? Up until now, most vending machines functioned in this manner around the world. However, that’s the general description just until now. There is a new generation of vending machines in some parts of the world. I mean that there are possibilities that the description of vending machine will be added. As an example, I’ll tell you two unique functions which the latest vending machines in Japan have.
The functions are electronic money and a wireless LAN functions. These functions are expanding two possibilities of a traditional vending machine. Those are on the points that more users friendly and multi-functional. One, the new machine is users friendly in that we can purchase goods with electronic money such as a prepaid card. So, we need only to tap the panel with the prepaid card. The other, with the having wireless LAN application built-in, the new machine can be used in various ways. For example, in Japan, there are some vending machines that we can access the Internet via using our own computer. Other, some machines can show information such as advertisements or a weather forecast like a television. In addition, some new machines can also provide food and drinks for free in the event of a natural disaster. They all examples are based on the reason why manufactures can manipulate the machines using the wireless LAN.
These are the unique functions. The functions mean the new vending machines are expanding possibilities. Additionally, if the new vending machines are set up everywhere, the new vending machines will become an essential tool of the ubiquitous society and reserve supply for the natural disaster.
Hence, the vending machine is enhancing right now. If you are interested in the vending machine, you should come to Japan, and feel that on your eyes. That’s all. Thank you for your listening!

2008-04-07

Philosophy (Full Spoken Mix)

衝動でやってしまった。時間は有限だというのにorz

Mondogross Album - Fantastic Plastic Machine -
07 - Philosophy (Full Spoken Mix)より

philosophy
the study of the nature and meaning of the universe and of human life:

quarantine
a period of time when an animal or a person
that has or may have a disease is kept away from others in order to prevent the disease from spreading

sound

isolation

apocalypse
the destruction of the world: Civilization is on the brink of apocalypse.

faith

oppotunity

crime

subconscious

idealist

stubbornness

adolescence
when he or she develops from a child into an adult

domination

paradice

light

perjury
the crime of telling a lie in court:

prisoner

affair
events that are of public interest or political importance:
an event that people are talking about or describing in a particular way:
a sexual relationship between two people, usually when one or both of them is married to sb else:
matters connected with a person’s private business and financial situation:

unity 統一体
the state of being in agreement and working together;
the state of being joined together to form one unit:

innocence

jealousy

mischief
bad behaviour (especially of children)
that is annoying but does not cause any serious damage or harm:

parvenu
a person from a low social or economic position
who has suddenly become rich or powerful

music

decadence
behaviour, attitudes, etc. which show a fall in standards, especially moral ones,
and an interest in pleasure and enjoyment rather than more serious things

stranger

irony
the amusing or strange aspect of a situation that is very different from what you expect;
a situation like this:

madness

strife
(formal or literary)
angry or violent disagreement between two people or groups of people

disaster

language

deadlock

ignorance

alcohol

economy

motivation

memory

principle

judgement

individual
[only before noun]
(often used after each) considered separately rather than as part of a group:

privilege
a special right or advantage that a particular person or group of people has:

malevolence
having or showing a desire to harm other people

affection
(for sb/sth)
the feeling of liking or loving sb/sth very much and caring about them:

disappointment
sadness because sth has not happened or been as good, successful, etc. as you expected or hoped

skull

indignation
feeling of anger and surprise caused by sth that you think is unfair or unreasonable

privacy

spoil
goods taken from a place by thieves or by an army that has won a battle or war

nature

misdemeanor
(formal)
an action that is bad or unacceptable, but not very serious: youthful misdemeanours

art

irritation

echo

inspiration
the process that takes place when sb sees or hears sth
that causes them to have exciting new ideas or makes them want to create sth,
especially in art, music or literature:

life

metaphor
a word or phrase used to describe sb/sth else, in a way
that is different from its normal use,
in order to show that the two things have the same qualities
and to make the description more powerful,
for example She has a heart of stone;

encouragement

genius

scandal
behaviour or an event that people think is morally or legally wrong
and causes public feelings of shock or anger

intervene(intervention)
to become involved in a situation in order to improve or help it: The President intervened personally in the crisis.

dream

obscene(opscenity)
connected with sex in a way that most people find offensive: obscene gestures / language / books

poet

eclipse
an occasion when the moon passes between the earth and the sun
so that you cannot see all or part of the sun for a time;
an occasion when the earth passes between the moon and the sun
so that you cannot see all or part of the moon for a time:

media
the main ways that large numbers of people receive information and entertainment,
that is television, radio, newspapers and the Internet

pursuit
the act of looking for or trying to find sth:
the pursuit of happiness / knowledge / profit

compromise
an agreement made between two people or groups in which each side gives up some of the things
they want so that both sides are happy at the end:

obsession
the state in which a person’s mind is completely filled with thoughts of one particular thing or person
in a way that is not normal: Her fear of flying is bordering on obsession

rock

beauty

anesthesia
the state of being unable to feel anything, especially pain

hope

moaner
to make a long deep sound, usually expressing unhappiness, suffering or sexual pleasure

peace

destruction

solitude
the state of being alone, especially when you find this pleasant

moment

message

nessesity

planet

brain

revelation
a fact that people are made aware of, especially one that has been secret and is surprising

money

construction

fame

soul

misery
great suffering of the mind or body

envy
the feeling of wanting to be in the same situation as sb else;
the feeling of wanting sth that sb else has:

fountain
a structure from which water is sent up into the air by a pump,
used to decorate parks and gardens/yards

imitation
a copy of sth, especially sth expensive: a poor / cheap imitation of the real thing

time

backlash
strong negative reaction by a large number of people,
for example to sth that has recently changed in society:

history

factor

provocation
the act of doing or saying sth deliberately in order to make sb angry or upset;
something that is done or said to cause this:

enlightenment
knowledge about and understanding of sth;
the process of understanding sth or making sb understand it:

muse
a person or spirit that gives a writer, painter, etc.
ideas and the desire to create things

disease

perspiration
drops of liquid that form on your skin when you are hot

purity
the state or quality of being pure:

confusion

drive
a strong desire or need in people: a strong sexual drive

expectation

universe
the whole of space and everything in it,
including the earth, the planets and the stars:

god

annoyance
the feeling of being slightly angry

despair

flower

wealth

depression

hate

quarrel

rejection

experience

permission

virtue

supreme
highest in rank or position
very great or the greatest in degree

assertion
a statement saying that you strongly believe sth to be true

guilt

winderness
large area of land that has never been developed or used for growing crops
because it is difficult to live there

victim
person who has been attacked, injured or killed as the result of a crime, a disease, an accident, etc

propaganda
ideas or statements that may be false or exaggerated and
that are used in order to gain support for a political leader, party, etc

rapture
(formal) a feeling of extreme pleasure and happiness

distraction
a thing that takes your attention away from what you are doing or thinking about:

sex

reflex

suicide

anthem
a song which has a special importance for a country, an organization, or a particular group of people and is sung on special occasions:

restraint
a rule, a fact, an idea, etc. that limits or controls what people can do:

fanaticism
disapproving)
extreme beliefs or behaviour, especially in connection with religion or politics

superstition
(often disapproving)
the belief that particular events happen in a way
that cannot be explained by reason or science;
the belief that particular events bring good or bad luck:

dignity
a calm and serious manner that deserves respect:
She accepted the criticism with quiet dignity.

egotism
(disapproving)
the fact of thinking that you are better or more important than anyone else

mask

degeneretion
the process of becoming worse or less acceptable in quality or condition:

era
a period of time, usually in history,
that is different from other periods because of particular characteristics or events:

star

machine

dynamism
energy and enthusiasm to make new things happen or to make things succeed:

reality

underdog
a person, team, country, etc.
that is thought to be in a weaker position than others
and therefore not likely to be successful, win a competition, etc

love
death

2008-04-06

composition 01

Draft ver 0.01

インパクト重視で書いてしまった。だが反省はs(ry
正直、シリアスで堅い文章が求められてたら間違いなくorz



[QUESTION]
Now, a Vending Machine is so popular in Japan that we can say it as a Japanese culture. So, explain it FREELY to the foreigner who doesn’t know it, as UNIQUE as you can.

[COMPOSITION]
You wanna know about a vending machine? OK, I'll explain to you what it is.
In the general meaning, a vending machine is the machine for vending various goods such as food and drink automatically. So there is nobody to vend without the machine. The size of it is as big as a fridge, and there are some objects on it for a costumer to buy goods. Generally, those are three slots, buttons, and a display.
The two slots are fit on for dropping into a coin and paper currency. The other one is fit on a bottom part of a vending machine for taking goods. Addition to it, a display and buttons are also necessary for showing and choosing goods.

But it’s quite simple to use it. If you want to buy goods from a vending machine, you have only to take two steps. First, drop enough money to buy goods into the slots, and then choose the goods on a display by using buttons on it. That’s all. After choosing goods, it drops a bottom slot, so you’re able to take the goods from a vending machine. It’s simple, isn’t it? Anyway, that’s the general way to buy goods from a vending machine.

But, that’s the just general expression what a vending machine is, until now. A vending machine in particular place has changed for next-generation. Guess what? Recently, as improving IT, a vending machine is going to progress. For example, a vending machine in Japan is so popular and unique in the world that we can say it as one of Japanese cultures. It’s just because it has unique functions. So, let me extra explain about what it is.

Some vending machine in Japan has an electric money function and wireless LAN application built-in, and it makes Japanese circumstance better on three points. Those points are friendly, serviceable, and safe.
At the friendly point, the vending machine has a terminal to pay electric money by using a prepaid card. It means that it’s no time to buy goods. So, we have only to touch a prepaid card to the terminal. So to speak, Japanese circumstance will become friendly.
At the serviceable point, having wireless LAN application built-in, we’re able to have the access zone to connect a personal computer to the web. In addition, if it also has the display like a TV, it can show information such as advertisement and forecast. Therefore, we’re able to get information conveniently from the vending machine.
At the safe point, drinks or foods in the vending machine can be essential goods when natural disaster happens. It means that goods in can be retrieved from the vending machine in disaster area for free. It’s because a maker of the vending machine can switch the mode of the vending machine, by using the wireless LAN.

That’s the expression of the vending machine in Japan. How do you think about that? I think a vending machine has more possibility to progress than the Japan case. Don’t you think so?