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
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
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
360
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
960
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.7k
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
300
act1-costs.pdf
sumedhbala
0
230
1B+ /day規模のログを管理する技術
broadleaf
0
140
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.2k
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
260
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
110
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
140
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
170
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
410
Producing Creativity
orderedlist
PRO
348
40k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
How GitHub (no longer) Works
holman
316
150k
Building an army of robots
kneath
306
46k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
400
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
Unsuck your backbone
ammeep
672
58k
Visualization
eitanlees
152
17k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
220
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