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
Reasoned PHP (bephpug)
Search
Igor Wiedler
August 06, 2014
Programming
810
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Reasoned PHP (bephpug)
Igor Wiedler
August 06, 2014
Transcript
47 slides
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
More Decks by Igor Wiedler
See All by Igor Wiedler
Redis Bedtime Stories
igorw
1
410
Wide Event Analytics (LISA19)
igorw
4
970
a day in the life of a request
igorw
0
190
production: an owner's manual
igorw
0
210
The Power of 2
igorw
0
370
LISP 1.5 Programmer's Manual: A Dramatic Reading
igorw
0
520
The Moral Character of Software
igorw
1
340
interdisciplinary computing (domcode)
igorw
0
340
miniKanren (clojure berlin)
igorw
1
360
Other Decks in Programming
See All in Programming
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
240
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
390
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
200
Skills Are the New npm [AAIF Bengaluru, Nov 2026]
shivamsaraswat
0
120
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
110
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
110
テストだけで見つかる? Rubyでつくるメソッド発掘器
izawa
0
160
AI Augmentation Techniques with Liberty
ivargrimstad
1
560
RaspberryPi 5で軽くはじめるk3sとtailscaleを用いたホームサーバー構築 (1)
nasum
0
440
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
15
12k
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
230
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
150
Featured
See All Featured
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
530
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.7k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
540
Marketing to machines
jonoalderson
1
6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.7k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
The Art of Programming - Codeland 2020
erikaheidi
57
15k
What's in a price? How to price your products and services
michaelherold
247
13k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
370
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Done Done
chrislema
187
17k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
3k