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
0
110
Logic Programming
A quick exploration on Logic Programming... with Ruby and Ruby-Prolog
Mario Alberto Chávez
October 14, 2014
Tweet
Share
More Decks by Mario Alberto Chávez
See All by Mario Alberto Chávez
Ruby Internals V3
mario_chavez
0
49
Beyond the Rails Way
mario_chavez
1
90
Elm, una mejor manera de hacer frontend
mario_chavez
0
220
Rediscovering ActiveRecord
mario_chavez
2
330
Intro to Elixir
mario_chavez
0
150
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
410
Pitch para Startups
mario_chavez
1
120
Understanding KPIs
mario_chavez
1
88
El nuevo comercio electrónico
mario_chavez
0
66
Other Decks in Programming
See All in Programming
LLMOpsのパフォーマンスを支える技術と現場で実践した改善
po3rin
8
990
ソフトウェアテスト徹底指南書の紹介
goyoki
1
120
STUNMESH-go: Wireguard NAT穿隧工具的源起與介紹
tjjh89017
0
390
AIレビュアーをスケールさせるには / Scaling AI Reviewers
technuma
2
230
速いWebフレームワークを作る
yusukebe
2
260
フロントエンドのmonorepo化と責務分離のリアーキテクト
kajitack
2
150
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
110
Trem on Rails - Prompt Engineering com Ruby
elainenaomi
1
100
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
370
OSS開発者という働き方
andpad
5
1.5k
あのころの iPod を どうにか再生させたい
orumin
2
2.5k
tool ディレクティブを導入してみた感想
sgash708
1
160
Featured
See All Featured
Bash Introduction
62gerente
614
210k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
The Cost Of JavaScript in 2023
addyosmani
53
8.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.5k
Fireside Chat
paigeccino
39
3.6k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
500
Producing Creativity
orderedlist
PRO
347
40k
Into the Great Unknown - MozCon
thekraken
40
2k
A designer walks into a library…
pauljervisheath
207
24k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
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