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
Logic Programming
Search
Mario Alberto Chávez
October 14, 2014
Programming
130
0
Share
Logic Programming
A quick exploration on Logic Programming... with Ruby and Ruby-Prolog
Mario Alberto Chávez
October 14, 2014
More Decks by Mario Alberto Chávez
See All by Mario Alberto Chávez
Ruby Internals V3
mario_chavez
0
68
Beyond the Rails Way
mario_chavez
1
130
Elm, una mejor manera de hacer frontend
mario_chavez
0
250
Rediscovering ActiveRecord
mario_chavez
2
350
Intro to Elixir
mario_chavez
0
170
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
430
Pitch para Startups
mario_chavez
1
150
Understanding KPIs
mario_chavez
1
120
El nuevo comercio electrónico
mario_chavez
0
87
Other Decks in Programming
See All in Programming
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
110
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
110
3Dシーンの圧縮
fadis
1
580
プロパティの順序で型推論が壊れる!? TypeScript6.0の修正からContext-Sensitivityの仕組みを追う
bicstone
2
1.3k
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
430
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
0
140
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
160
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
140
TAKTでAI駆動開発の品質を設計する
j5ik2o
2
130
Swiftのレキシカルスコープ管理
kntkymt
0
210
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
460
Featured
See All Featured
Paper Plane (Part 1)
katiecoart
PRO
0
8.2k
Exploring anti-patterns in Rails
aemeredith
3
380
WENDY [Excerpt]
tessaabrams
11
38k
Designing for Performance
lara
611
70k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
930
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
The Invisible Side of Design
smashingmag
302
52k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
380
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
240
Transcript
Logic Programming With Ruby Mario Chavez : @mario_chavez
We do love Ruby
Ruby has a story of borrowing features from other languages
Logic Programming with Prolog
Logic Programming • We do not express what a program
should do • We do express data and queries in a specific format
Main Blocks • Facts, assertions about our domain • Rules,
express inferences about our facts • Queries, questions to be answered
Ruby-Prolog https://github.com/preston/ruby-prolog
likes['wallace', 'cheese'].fact ! likes['grommit', 'cheese'].fact! likes['wendolene', 'sheep'].fact! friend[:X, :Y] <<=
[noteq[:X,:Y], likes[:X, :Z], likes[:Y, :Z]] query(friend['wallace', 'grommit']) rp = RubyProlog::Core.new! rp.instance_eval do! end
class Family < RubyProlog::Core! def initialize! super! facts! rules! end!
! def siblings(person)! query sibling[:X, person]! end! ! def parents(child)! query parent[:X, child]! end! ! def children(parent)! query parent[parent, :Y]! end! ! private! def facts! mother["Trude", "Sally"].fact! father["Tom", "Sally"].fact! father["Tom", "Erica"].fact! father["Mike", "Tom"].fact! end! ! def rules! sibling[:X,:Y] <<= [ parent[:Z,:X], parent[:Z,:Y], noteq[:X,:Y] ]! parent[:X,:Y] <<= father[:X,:Y]! parent[:X,:Y] <<= mother[:X,:Y]! end! end! ! s = Family.new! s.siblings 'Sally'!
Not as complete as Prolog But good enough to explore
a different way to solve problems
Be curious
Explore other languages
Gracias Mario Chavez : @mario_chavez