$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
52
Beyond the Rails Way
mario_chavez
1
98
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
98
El nuevo comercio electrónico
mario_chavez
0
73
Other Decks in Programming
See All in Programming
関数の挙動書き換える
takatofukui
4
750
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.2k
AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming
kishida
13
5.5k
Level up your Gemini CLI - D&D Style!
palladius
1
140
Phronetic Team with AI - Agile Japan 2025 closing
hiranabe
2
700
「文字列→日付」の落とし穴 〜Ruby Date.parseの意外な挙動〜
sg4k0
0
320
Atomics APIを知る / Understanding Atomics API
ssssota
1
230
Why Kotlin? 電子カルテを Kotlin で開発する理由 / Why Kotlin? at Henry
agatan
1
310
最新のDirectX12で使えるレイトレ周りの機能追加について
projectasura
0
310
WebRTC と Rust と8K 60fps
tnoho
2
1k
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
280
競馬で学ぶ機械学習の基本と実践 / Machine Learning with Horse Racing
shoheimitani
14
14k
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
2.9k
4 Signs Your Business is Dying
shpigford
186
22k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Balancing Empowerment & Direction
lara
5
770
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
11
950
Done Done
chrislema
186
16k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
59
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Documentation Writing (for coders)
carmenintech
76
5.1k
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