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
0
9
磯野家で学ぶ Prolog
ckazu
June 06, 2018
Tweet
Share
More Decks by ckazu
See All by ckazu
2024 コーディング研修
ckazu
2
950
Introduction fasttext
ckazu
0
5
Query selecterの話
ckazu
0
2
仮想電子工作のすすめ
ckazu
0
5
ウェブエンジニアのための色の話
ckazu
0
6
これさえ読めば知ったかできるかもしれない人工知能の歴史と機械学習の今
ckazu
0
4
Shinjuku.html5.lunch #11
ckazu
0
5
typo の傾向と対策
ckazu
0
5
ずぶの素人がRails開発できるようになるために必要な5つのこと
ckazu
0
13
Other Decks in Programming
See All in Programming
Towards Structured Data: LLMs from Prototype to Production
inesmontani
PRO
1
150
C++ MIX #11 これどう読むの...?
5mingame2
0
180
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
1
630
2024/7/11発刊!開発生産性の教科書がざっとわかるスライド 2024/06/20 / A Brief Overview of the Textbook on Development Productivity
ma3tk
0
100
Automatisiere deine Prozesse mit GitHub Actions!
ahus1
0
260
#KotlinFest 2024 : Kotlin sealed classを用いた、ユーザーターゲティングDSL(専用言語)と実環境で秒間1,000万評価を行う処理系の事例紹介
kazukima
0
280
Web 開発における Deno Fresh の活用例:ペアプロタイマー timer.team の開発
lef237
1
520
30分でわかるつくって、壊して、直して学ぶ Kubernetes入門
aoi1
6
710
2024年版 Kotlin サーバーサイドプログラミング実践開発
n_takehata
3
510
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
630
有効な使い方を正しく理解して実装する PHP8.3の最新機能 / Proper understanding and implementation of effective usage Latest features in PHP 8.3
seike460
PRO
2
150
いまどきの分析設計パターン10選
masuda220
PRO
29
9.9k
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
20
1.7k
Faster Mobile Websites
deanohume
300
30k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
73
15k
What's in a price? How to price your products and services
michaelherold
238
11k
We Have a Design System, Now What?
morganepeng
45
6.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
Designing the Hi-DPI Web
ddemaree
276
33k
Creatively Recalculating Your Daily Design Routine
revolveconf
213
11k
Clear Off the Table
cherdarchuk
87
320k
The Art of Programming - Codeland 2020
erikaheidi
46
12k
Automating Front-end Workflow
addyosmani
1360
200k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
359
22k
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