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
83
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
45
Beyond the Rails Way
mario_chavez
1
67
Elm, una mejor manera de hacer frontend
mario_chavez
0
170
Rediscovering ActiveRecord
mario_chavez
2
300
Intro to Elixir
mario_chavez
0
120
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
310
Pitch para Startups
mario_chavez
1
83
Understanding KPIs
mario_chavez
1
58
El nuevo comercio electrónico
mario_chavez
0
45
Other Decks in Programming
See All in Programming
Domain-Driven Transformation
hschwentner
2
1.5k
CREってこういうこと? 体験入社 - 提案資料 - / what-is-cre-trial-employment
shinden
1
520
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
560
Tailwind CSSを本気でカスタマイズする方法
fsubal
14
5.5k
dbtのドメイン分割による データ基盤の改善とDigdagとの連携
sakama
0
440
SIMD Parallel Programming with the Vector API
josepaumard
0
230
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
380
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
170
DMMプラットフォームがTiDB Cloudを採用した背景
pospome
9
4.2k
新宿ダンジョンを可視化してみた
satoshi7190
3
390
Netty Chicago Java User Group 2024-04-17
sullis
0
200
AppRouter Panel Talk
yosuke_furukawa
PRO
1
460
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
14
1k
Web development in the modern age
philhawksworth
203
10k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
275
13k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
Side Projects
sachag
451
41k
Designing for humans not robots
tammielis
247
25k
Practical Orchestrator
shlominoach
183
9.7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
221
21k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
For a Future-Friendly Web
brad_frost
172
9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
20
1.8k
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