Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
自作ラムダ計算インタプリタで不動点演算をする
Search
Arata Sato
August 30, 2021
Programming
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
自作ラムダ計算インタプリタで不動点演算をする
https://github.com/atrn0/lambda
Arata Sato
August 30, 2021
More Decks by Arata Sato
See All by Arata Sato
Flutterでやっていくアプリケーション開発
atrn0
0
1.1k
Other Decks in Programming
See All in Programming
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
パスワード再設定メールのURLについて知っておこう
uyuki234
0
160
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
630
Domain-Driven Transformation
hschwentner
2
2.3k
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
sbt 2.0: takeoff
eed3si9n
0
160
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.6k
ActionController meets Protocol Buffers
sorah
0
560
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
ジョジョの世界をXRで再現する
mofurune
0
170
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
620
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
270
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Deep Space Network (abreviated)
tonyrice
0
370
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
830
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Visualization
eitanlees
153
17k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
For a Future-Friendly Web
brad_frost
184
10k
Transcript
自作ラムダ計算インタプリタで 不動点演算をする CAMPHOR- 定例LT @atrn0
(単純型無し)ラムダ計算とは - 関数の作成と関数の適用のみからなる計算モデル - これだけでチューリング完全 - シンタックスはこんな感じ
言語の定義 文法(シンタックス)と意味(セマンティクス)を決める
シンタックス - 関数適用は左結合: s t u = (s t) u
- 適当にかっこはつけて良い - 変数のスコープはその関数の本体
セマンティクス (λx. s) t という形が来たら、sの中に出てくるxをtで置き換える(簡約) 例えば (λx.x) ((λx.x) (λz. (λx.x)
z)) → (λx. x) (λz. ((λx. x) z)) → (λz. ((λx. x) z)) → (λz. z)
目標: nの階乗を求めたい f(0) = 1 f(n) = f(n-1) * n
必要なもの: - 条件分岐 - 数 - 掛け算 - 再帰
複数引数 複数の引数は高階関数(関数を返す関数)で表す λx. λy. s つまり λx. (λy. s) *任意の複数引数の関数はカリー化によって高階関数に変換できる
Boolean - プリミティブな定数がない代わりにエンコードで表す - Booleanは true = λt. λf. t
false = λt. λf. f とエンコードする - 条件分岐は次のように書けたりする λl. λm. λn. l m n
Number c0 = λs. λz. z c1 = λs. λz.
s z c2 = λs. λz. s (s z) c3 = λs. λz. s (s (s z)) etc. - 例えば加算は λm. λn. λs. λz. m s (n s z) と書けたりする
再帰演算 不動点コンビネータを使う - 不動点コンビネータ: F g → g (F g)
となるようなFのこと。 g = λf. <fを含む本体> とすると、 F g x → g (F g) x より、<fを含む本体>でgを複製して繰り返し使える。
Yコンビネータ 不動点コンビネータの一つ Y = λf. (λx. f (x x)) (λx.
f (x x))
階乗の計算 f(0) = 1 f(n) = f(n-1) * n 必要なもの:
- 条件分岐: test = λl. λm. λn. l m n - 数: c2 = λs. λz. s (s z) など - 掛け算: times = λm. λn. m (plus n) c0 - 再帰: 不動点コンビネータ
階乗の計算 このぐらいマクロを定義するとできます。
デモ g = λf. λn. test (iszro n) (λx. c1)
(λx. (times n (f (prd n)))) c0 (fix g) cn → g (fix g) cn = (λf. λn. test (iszro n) (λx. c1) (λx. (times n (f (prd n)))) c0) (fix g) cn → test (iszro cn) (λx. c1) (λx. (times cn ((fix g) (prd cn)))) c0 ...
参考 - Types and Programming Languages (https://www.cis.upenn.edu/~bcpierce/tapl/)