Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
磯野家で学ぶ Prolog
Search
ckazu
June 06, 2018
Programming
43
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
磯野家で学ぶ Prolog
ckazu
June 06, 2018
More Decks by ckazu
See All by ckazu
2024 コーディング研修
ckazu
2
1.9k
Introduction fasttext
ckazu
0
43
Query selecterの話
ckazu
0
34
仮想電子工作のすすめ
ckazu
0
61
ウェブエンジニアのための色の話
ckazu
0
31
これさえ読めば知ったかできるかもしれない人工知能の歴史と機械学習の今
ckazu
0
35
Shinjuku.html5.lunch #11
ckazu
0
46
typo の傾向と対策
ckazu
0
54
ずぶの素人がRails開発できるようになるために必要な5つのこと
ckazu
0
47
Other Decks in Programming
See All in Programming
Build-to-own AI: Agentic Development for Humans
inesmontani
PRO
0
160
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
520
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
470
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
140
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
1
110
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
150
Google Apps Script で Ruby を動かす
kawahara
0
130
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
3.5k
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
240
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
380
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
500
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
450
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
The Cult of Friendly URLs
andyhume
79
7k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Crafting Experiences
bethany
1
240
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
470
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
270
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
190
Designing for Performance
lara
611
70k
sira's awesome portfolio website redesign presentation
elsirapls
0
310
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Making the Leap to Tech Lead
cromwellryan
135
10k
Transcript
磯野家で学ぶ Prolog
About Prolog PROgramming in LOGic 論理プログラミング言語 初期の人工知能研究。 1972年フランス発 一階述語論理の表現 P
⇒ Q 最近だと、 IBM watson Softbank pepper 論理憲法
prolog の基本 事実 (facts) を記述し、 規則 (rules) を定義し、 質問 (queries)
をする
install http://swi-prolog.org $ brew install swi-prolog インタプリタの起動 $ swipl <FILENAME>
終了 ?- halt. ファイルの再読込 ?- reload.
None
事実(facts) 親子関係を列挙してみる $ vi sazae-san.pl parent(波平, サザエ). parent(波平, カツオ). parent(波平,
ワカメ). parent(フネ, サザエ). parent(フネ, カツオ). parent(サザエ, タラ). parent(マスオ, タラ).
質問(queries) ファイルを読み込んでインタプリタを起動する $ swipl sazae-san.pl ?- parent(波平, サザエ). ?- parent(波平,
タラ). ?- parent(サザエ, X). ?- parent(波平, X). ?- parent(カツオ, X). ?- parent(X, タラ).
規則(rules) タラちゃんのおじいちゃん(おばあちゃん)は誰?
規則(rules) タラちゃんのおじいちゃん(おばあちゃん)は誰? ?- parent(X, Y), parent(Y, タラ).
規則(rules) タラちゃんのおじいちゃん(おばあちゃん)は誰? ?- parent(X, Y), parent(Y, タラ). :- (ならば)
規則(rules) タラちゃんのおじいちゃん(おばあちゃん)は誰? ?- parent(X, Y), parent(Y, タラ). :- (ならば) grandparent(X,Z):-
parent(X,Y), parent(Y,Z).
規則(rules) タラちゃんのおじいちゃん(おばあちゃん)は誰? ?- parent(X, Y), parent(Y, タラ). :- (ならば) grandparent(X,Z):-
parent(X,Y), parent(Y,Z). ?- grandparent(X, タラ).
父親と母親を 区別する 事実として性別を列挙する male(波平). male(カツオ). male(タラ). male(マスオ). female(フネ). female(ワカメ). female(サザエ).
?- male(カツオ). ?- female(カツオ). ?- femaile(X).
父親と母親を 区別する father(X, Y):- parent(X, Y), male(X). mother(X, Y):- parent(X,
Y), female(X). ?- parent(X, タラ). ?- mother(X, タラ).
祖父母を定義する
祖父母を定義する grandfather(X, Z):- grandparent(X, Z), male(X). grandmother(X, Z):- grandparent(X, Z),
female(X).
None
ノリスケとカツオの関係 は?
ノリスケとカツオの関係 は? male(波平の父). female(波平の母). parent(波平の父, 波平). parent(波平の父, 海平). parent(波平の父, なぎえ).
parent(波平の母, 波平). parent(波平の母, 海平). parent(波平の母, なぎえ). parent(なぎえ, ノリスケ). parent(ノリスケ, イクラ).
ノリスケとカツオの関係 は? いとこ(X, Y):- parent(A, X), parent(B, Y), sibling(A, B).
はとこ(X, Y):- grandparent(A, X), grandparent(B, Y), sibling(A, B).
宿題 夫婦関係を知るには? 子供がいることを知るには? 娘、息子の定義 離婚している場合 家族の定義 n 等親を知るには? リスト表現を使ってみる 兄弟,
姉妹の生まれ順
https://gist.github.com/ckazu/06697521ab2baee813 44bda1904daee9