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
130
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
62
Beyond the Rails Way
mario_chavez
1
110
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
82
Other Decks in Programming
See All in Programming
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
3
1.2k
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
170
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
210
CSC307 Lecture 12
javiergs
PRO
0
470
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
140
AIに任せる範囲を安全に広げるためにやっていること
fukucheee
0
120
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
990
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.7k
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
110
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
410
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
7.8k
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
210
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Chasing Engaging Ingredients in Design
codingconduct
0
130
The Language of Interfaces
destraynor
162
26k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
280
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
130
Context Engineering - Making Every Token Count
addyosmani
9
740
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
Paper Plane
katiecoart
PRO
0
47k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
780
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