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
Reasoned PHP (bephpug)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Igor Wiedler
August 06, 2014
Programming
800
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Reasoned PHP (bephpug)
Igor Wiedler
August 06, 2014
More Decks by Igor Wiedler
See All by Igor Wiedler
Redis Bedtime Stories
igorw
1
360
Wide Event Analytics (LISA19)
igorw
4
950
a day in the life of a request
igorw
0
170
production: an owner's manual
igorw
0
200
The Power of 2
igorw
0
340
LISP 1.5 Programmer's Manual: A Dramatic Reading
igorw
0
490
The Moral Character of Software
igorw
1
320
interdisciplinary computing (domcode)
igorw
0
320
miniKanren (clojure berlin)
igorw
1
330
Other Decks in Programming
See All in Programming
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.8k
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
270
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
330
1B+ /day規模のログを管理する技術
broadleaf
0
140
霧の中の代数的エフェクト
funnyycat
1
400
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
220
自作OSでスライド発表する
uyuki234
1
3.8k
共通化で考えるべきは、実装より公開する型だった
codeegg
0
250
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
3
1.5k
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
140
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
1.1k
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
340
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
150
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
320
Crafting Experiences
bethany
1
220
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The browser strikes back
jonoalderson
0
1.4k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
510
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Transcript
Reasoned PHP
@igorwhiletrue
Use logic to run your programs backwards!
Use logic to run your programs backwards!
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
Reasoned PHP
function appendᵒ($l, $s, $out) { return condᵉ([ [≡($l, []), ≡($s,
$out)], [fresh_all(($a, $d, $res) ==> [ consᵒ($a, $d, $l), consᵒ($a, $res, $out), appendᵒ($d, $s, $res), ])], ]); }
run٭($q ==> appendᵒ([1, 2, 3], [4, 5, 6], $q));
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
((lambda (_.0) (list _.0 (list 'quote _.0))) '(lambda (_.0) (list
_.0 (list 'quote _.0)))
None
((lambda (_.0) (list 'quote (list _.0 (list 'quote _.0)))) '(lambda
(_.0) (list 'quote (list _.0 (list 'quote _.0))))) ! ((lambda (_.0) (list 'quote (list _.0 (list 'quote _.0)))) '(lambda (_.0) (list 'quote (list _.0 (list 'quote _.0)))))
µKanren (define (var c) (vector c)) (define (var? x) (vector?
x)) (define (var=? x1 x2) (= (vector-ref x1 0) (vector-ref x2 0))) ! (define (walk u s) (let ((pr (and (var? u) (assp (lambda (v) (var=? u v)) s)))) (if pr (walk (cdr pr) s) u))) ! (define (ext-s x v s) `((,x . ,v) . ,s)) ! (define (== u v) (lambda (s/c) (let ((s (unify u v (car s/c)))) (if s (unit `(,s . ,(cdr s/c))) mzero)))) ! (define (unit s/c) (cons s/c mzero)) (define mzero '()) ! (define (unify u v s) (let ((u (walk u s)) (v (walk v s))) (cond ((and (var? u) (var? v) (var=? u v)) s) ((var? u) (ext-s u v s)) ((var? v) (ext-s v u s)) ((and (pair? u) (pair? v)) (let ((s (unify (car u) (car v) s))) (and s (unify (cdr u) (cdr v) s)))) (else (and (eqv? u v) s))))) (define (call/fresh f) (lambda (s/c) (let ((c (cdr s/c))) ((f (var c)) `(,(car s/c) . ,(+ c 1)))))) ! (define (disj g1 g2) (lambda (s/c) (mplus (g1 s/c) (g2 s/c)))) (define (conj g1 g2) (lambda (s/c) (bind (g1 s/c) g2))) ! (define (mplus $1 $2) (cond ((null? $1) $2) ((procedure? $1) (lambda () (mplus $2 ($1)))) (else (cons (car $1) (mplus (cdr $1) $2))))) ! (define (bind $ g) (cond ((null? $) mzero) ((procedure? $) (lambda () (bind ($) g))) (else (mplus (g (car $)) (bind (cdr $) g)))))
References • Propositions as Types Philip Wadler • How to
Replace Failure by a List of Successes Philip Wadler • µKanren Jason Hemann, Daniel Friedman • Quine Generation via Relational Interpreters William Byrd, Eric Holk, Daniel Friedman
References • The Reasoned Schemer Daniel Friedman, William Byrd, Oleg
Kiselyov • Clause and Effect William Clocksin • The Annotated Turing Charles Petzold • Code Charles Petzold
None
None
Questions? • minikanren.org • github.com/clojure/core.logic • github.com/igorw/reasoned-php • @igorwhiletrue