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
93
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
47
Beyond the Rails Way
mario_chavez
1
76
Elm, una mejor manera de hacer frontend
mario_chavez
0
200
Rediscovering ActiveRecord
mario_chavez
2
310
Intro to Elixir
mario_chavez
0
140
From Ruby to Elixir: Developing Web Applications
mario_chavez
0
370
Pitch para Startups
mario_chavez
1
110
Understanding KPIs
mario_chavez
1
70
El nuevo comercio electrónico
mario_chavez
0
54
Other Decks in Programming
See All in Programming
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
240
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
11
1.9k
Open source software: how to live long and go far
gaelvaroquaux
0
630
GitHub Actions × RAGでコードレビューの検証の結果
sho_000
0
250
Spring gRPC について / About Spring gRPC
mackey0225
0
220
2024年のWebフロントエンドのふりかえりと2025年
sakito
1
240
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
190
Writing documentation can be fun with plugin system
okuramasafumi
0
120
Pulsar2 を雰囲気で使ってみよう
anoken
0
230
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
670
ISUCON14公式反省会LT: 社内ISUCONの話
astj
PRO
0
190
ファインディLT_ポケモン対戦の定量的分析
fufufukakaka
0
490
Featured
See All Featured
Statistics for Hackers
jakevdp
797
220k
Being A Developer After 40
akosma
89
590k
Building Applications with DynamoDB
mza
93
6.2k
Git: the NoSQL Database
bkeepers
PRO
427
64k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
9
430
Facilitating Awesome Meetings
lara
51
6.2k
Speed Design
sergeychernyshev
26
790
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
240
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