$30 off During Our Annual Pro Sale. View Details »
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
120
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
53
Beyond the Rails Way
mario_chavez
1
99
Elm, una mejor manera de hacer frontend
mario_chavez
0
230
Rediscovering ActiveRecord
mario_chavez
2
330
Intro to Elixir
mario_chavez
0
160
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
410
Pitch para Startups
mario_chavez
1
130
Understanding KPIs
mario_chavez
1
99
El nuevo comercio electrónico
mario_chavez
0
74
Other Decks in Programming
See All in Programming
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
700
Microservices rules: What good looks like
cer
PRO
0
1.2k
モデル駆動設計をやってみようワークショップ開催報告(Modeling Forum2025) / model driven design workshop report
haru860
0
260
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
210
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
6
2.1k
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
140
FluorTracer / RayTracingCamp11
kugimasa
0
230
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
420
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
790
ゲームの物理 剛体編
fadis
0
330
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
1
220
ID管理機能開発の裏側 高速にSaaS連携を実現したチームのAI活用編
atzzcokek
0
220
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
A designer walks into a library…
pauljervisheath
210
24k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
970
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
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