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
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
370
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
330
miniKanren (clojure berlin)
igorw
1
340
Other Decks in Programming
See All in Programming
継続モナドとリアクティブプログラミング
yukikurage
3
700
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
630
5分で問診!Composer セキュリティ健康診断
codmoninc
0
910
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
160
What's New in Android 2026
veronikapj
0
250
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.1k
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
1
220
Go 1.27 における memory allocation の高速化
andpad
0
110
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.6k
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
160
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.7k
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
140
Featured
See All Featured
Speed Design
sergeychernyshev
33
2k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
250
Done Done
chrislema
186
16k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
210
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Mind Mapping
helmedeiros
PRO
1
300
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
360
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
200
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
270
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