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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
59
Beyond the Rails Way
mario_chavez
1
100
Elm, una mejor manera de hacer frontend
mario_chavez
0
240
Rediscovering ActiveRecord
mario_chavez
2
340
Intro to Elixir
mario_chavez
0
170
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
420
Pitch para Startups
mario_chavez
1
140
Understanding KPIs
mario_chavez
1
110
El nuevo comercio electrónico
mario_chavez
0
79
Other Decks in Programming
See All in Programming
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
250
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6k
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
110
AgentCoreとHuman in the Loop
har1101
5
220
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
4
310
CSC307 Lecture 03
javiergs
PRO
1
490
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2k
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
170
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
450
CSC307 Lecture 08
javiergs
PRO
0
670
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
Vibe codingでおすすめの言語と開発手法
uyuki234
0
220
Featured
See All Featured
A better future with KSS
kneath
240
18k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
A designer walks into a library…
pauljervisheath
210
24k
Balancing Empowerment & Direction
lara
5
880
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Color Theory Basics | Prateek | Gurzu
gurzu
0
190
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
96
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
The SEO identity crisis: Don't let AI make you average
varn
0
64
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