SlideShare a Scribd company logo
2
No if’s, no loops, just the plain mathematical definition !
Most read
3
Logic programming
(Prolog, SQL)
Functional
(Lisp, ..)
Imperative / OO
(C, Smalltalk)
Most read
13
Sample 3 Familiar tuple
notation
Memoized
 Faster
 Avoid infinite loop
Most read
Logic Programming in Python
Pierre Carbonnelle
FOSDEM 2014
No if’s, no loops, just the plain mathematical definition !
Logic programming
(Prolog, SQL)
Functional
(Lisp, ..)
Imperative / OO
(C, Smalltalk)
Logic programming
(Prolog, SQL)
Functional
(Lisp, ..)
Imperative / OO
(C, Smalltalk)
Python
Python + pyDatalog
Why Logic Programming in Python ?
Be productive
Be Readable
Use AI
Easy to learn
Batteries included
Query 11 SQL databases
The anatomy of a prolog program
Fact
Clause
Query
The anatomy of a pyDatalog program
The anatomy of a pyDatalog program
Sample 1
Could be
written in SQL
too !
Sample 1
 Loop
 Calculation
 Test
 Input/output polymorphism !
Shorter
programs !
Sample 1
Batteries
included
 Would need an equation solver
Sample 2
• f[X]=2*X is equivalent to (f[X]==Y) <= (Y==2*x)
• Functions return only 1 value per key (aka dict())
• Functions can appear in expressions
• Resolution starts with the latest clause, and stops on first answer
• Support for aggregate functions : sum, min, max, …
Sample 3 Familiar tuple
notation
Memoized
 Faster
 Avoid infinite loop
Sample 4
Prefixed function
to query
Python classes
or SQL databases
Other pyDatalog features
• Runs on PyPy, Python 2, Python 3
• Accepts predicate definition written in Python
• For I/O, performance, …
• Thread-safe
• For use in multi-threaded web framework
• Multi-model : Switch from one Logic model (= set of clauses)
to another
Applications
Core technology Benefit Applications
The SLG resolution algorithm
determines the sequence of steps
to resolve a query.
Spreadsheet-programming : faster
iterations, fewer bugs, more
readable.
Rule-based expert systems for
pricing, tax calculation, access
right, robot control, intelligent
agent.
Input/output polymorphism. Maximise code reuse : shorter
program, simpler database query
language.
Cross-database queries, data
integration.
Intermediate results are memoized. Avoid re-calculation. Avoid infinite
loop.
Recursive algorithm on tree or
graph structures, natural language
processing, code analysis
Roadmap : Equation solver
Roadmap : Transactions
• Assert facts within transactions, with possible roll-back
• Use logic clauses to validate data operations
• Use logic clauses to define triggers (condition => action)
• Memoize results across queries within the same transaction
• Translate Datalog queries into SQL for server-side processing
Feedback, Help welcome !!
Roadmap : Performance
• Rewrite critical sections in C
• Exploit multi-threading in resolution engine
Feedback, Help welcome !!
Why Logic Programming in Python ?
Easy to learn
Batteries included
Query 11 SQL databases
Be productive
Be Readable
Use AI

More Related Content

What's hot (20)

Planning
Planning Planning
Planning
Amar Jukuntla
 
ID3 ALGORITHM
ID3 ALGORITHMID3 ALGORITHM
ID3 ALGORITHM
HARDIK SINGH
 
Knowledge Engineering in FOL.
Knowledge Engineering in FOL.Knowledge Engineering in FOL.
Knowledge Engineering in FOL.
Megha Sharma
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language Processing
rohitnayak
 
First order predicate logic (fopl)
First order predicate logic (fopl)First order predicate logic (fopl)
First order predicate logic (fopl)
chauhankapil
 
Natural Language Processing (NLP) - Introduction
Natural Language Processing (NLP) - IntroductionNatural Language Processing (NLP) - Introduction
Natural Language Processing (NLP) - Introduction
Aritra Mukherjee
 
Machine Learning: Generative and Discriminative Models
Machine Learning: Generative and Discriminative ModelsMachine Learning: Generative and Discriminative Models
Machine Learning: Generative and Discriminative Models
butest
 
Backpropagation algo
Backpropagation  algoBackpropagation  algo
Backpropagation algo
noT yeT woRkiNg !! iM stiLl stUdYinG !!
 
Natural language processing (NLP) introduction
Natural language processing (NLP) introductionNatural language processing (NLP) introduction
Natural language processing (NLP) introduction
Robert Lujo
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of python
paradisetechsoftsolutions
 
Machine Learning and Data Mining
Machine Learning and Data MiningMachine Learning and Data Mining
Machine Learning and Data Mining
Tilani Gunawardena PhD(UNIBAS), BSc(Pera), FHEA(UK), CEng, MIESL
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
Soujanya V
 
Natural language processing: feature extraction
Natural language processing: feature extractionNatural language processing: feature extraction
Natural language processing: feature extraction
Gabriel Hamilton
 
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Simplilearn
 
Python ppt
Python pptPython ppt
Python ppt
Mohita Pandey
 
04 Multi-layer Feedforward Networks
04 Multi-layer Feedforward Networks04 Multi-layer Feedforward Networks
04 Multi-layer Feedforward Networks
Tamer Ahmed Farrag, PhD
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
Jyotsna Suryadevara
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
Amin Omi
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
Kandarp Tiwari
 
Knowledge Engineering in FOL.
Knowledge Engineering in FOL.Knowledge Engineering in FOL.
Knowledge Engineering in FOL.
Megha Sharma
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language Processing
rohitnayak
 
First order predicate logic (fopl)
First order predicate logic (fopl)First order predicate logic (fopl)
First order predicate logic (fopl)
chauhankapil
 
Natural Language Processing (NLP) - Introduction
Natural Language Processing (NLP) - IntroductionNatural Language Processing (NLP) - Introduction
Natural Language Processing (NLP) - Introduction
Aritra Mukherjee
 
Machine Learning: Generative and Discriminative Models
Machine Learning: Generative and Discriminative ModelsMachine Learning: Generative and Discriminative Models
Machine Learning: Generative and Discriminative Models
butest
 
Natural language processing (NLP) introduction
Natural language processing (NLP) introductionNatural language processing (NLP) introduction
Natural language processing (NLP) introduction
Robert Lujo
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of python
paradisetechsoftsolutions
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
Soujanya V
 
Natural language processing: feature extraction
Natural language processing: feature extractionNatural language processing: feature extraction
Natural language processing: feature extraction
Gabriel Hamilton
 
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Simplilearn
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
Jyotsna Suryadevara
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
Amin Omi
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
Kandarp Tiwari
 

Viewers also liked (20)

Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)
Nitesh Singh
 
Logic Programming and ILP
Logic Programming and ILPLogic Programming and ILP
Logic Programming and ILP
Pierre de Lacaze
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
Yasir Khan
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : Basics
Mitul Desai
 
Le langage Prolog
Le langage PrologLe langage Prolog
Le langage Prolog
Bruno Delb
 
Construire un moteur d'inférence
Construire un moteur d'inférenceConstruire un moteur d'inférence
Construire un moteur d'inférence
Jean Rohmer
 
Logic Programming and Prolog
Logic Programming and PrologLogic Programming and Prolog
Logic Programming and Prolog
Sadegh Dorri N.
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AI
Vishal Singh
 
Functional programming ideas in python
Functional programming ideas in pythonFunctional programming ideas in python
Functional programming ideas in python
Manish Tomar
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
kwatch
 
Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...
Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...
Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...
Jean Rohmer
 
Prolog programming
Prolog programmingProlog programming
Prolog programming
Harry Potter
 
20 examples on Domain-Specific Modeling Languages
20 examples on Domain-Specific Modeling Languages20 examples on Domain-Specific Modeling Languages
20 examples on Domain-Specific Modeling Languages
Juha-Pekka Tolvanen
 
اجابات البرولوج
اجابات البرولوجاجابات البرولوج
اجابات البرولوج
Ammar Khalid
 
Presentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional ProgrammingPresentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional Programming
Filip De Sutter
 
Intelligence Artificielle : Introduction à l'intelligence artificielle
Intelligence Artificielle : Introduction à l'intelligence artificielleIntelligence Artificielle : Introduction à l'intelligence artificielle
Intelligence Artificielle : Introduction à l'intelligence artificielle
ECAM Brussels Engineering School
 
Forward Backward Chaining
Forward Backward ChainingForward Backward Chaining
Forward Backward Chaining
QAU ISLAMABAD,PAKISTAN
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
REHMAT ULLAH
 
Introduction on Prolog - Programming in Logic
Introduction on Prolog - Programming in LogicIntroduction on Prolog - Programming in Logic
Introduction on Prolog - Programming in Logic
Vishal Tandel
 
Introduction to Prolog
Introduction to PrologIntroduction to Prolog
Introduction to Prolog
Chamath Sajeewa
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)
Nitesh Singh
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
Yasir Khan
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : Basics
Mitul Desai
 
Le langage Prolog
Le langage PrologLe langage Prolog
Le langage Prolog
Bruno Delb
 
Construire un moteur d'inférence
Construire un moteur d'inférenceConstruire un moteur d'inférence
Construire un moteur d'inférence
Jean Rohmer
 
Logic Programming and Prolog
Logic Programming and PrologLogic Programming and Prolog
Logic Programming and Prolog
Sadegh Dorri N.
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AI
Vishal Singh
 
Functional programming ideas in python
Functional programming ideas in pythonFunctional programming ideas in python
Functional programming ideas in python
Manish Tomar
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
kwatch
 
Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...
Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...
Intelligence Artificielle: résolution de problèmes en Prolog ou Prolog pour l...
Jean Rohmer
 
Prolog programming
Prolog programmingProlog programming
Prolog programming
Harry Potter
 
20 examples on Domain-Specific Modeling Languages
20 examples on Domain-Specific Modeling Languages20 examples on Domain-Specific Modeling Languages
20 examples on Domain-Specific Modeling Languages
Juha-Pekka Tolvanen
 
اجابات البرولوج
اجابات البرولوجاجابات البرولوج
اجابات البرولوج
Ammar Khalid
 
Presentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional ProgrammingPresentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional Programming
Filip De Sutter
 
Intelligence Artificielle : Introduction à l'intelligence artificielle
Intelligence Artificielle : Introduction à l'intelligence artificielleIntelligence Artificielle : Introduction à l'intelligence artificielle
Intelligence Artificielle : Introduction à l'intelligence artificielle
ECAM Brussels Engineering School
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
REHMAT ULLAH
 
Introduction on Prolog - Programming in Logic
Introduction on Prolog - Programming in LogicIntroduction on Prolog - Programming in Logic
Introduction on Prolog - Programming in Logic
Vishal Tandel
 
Ad

Similar to Logic programming in python (20)

Logical Programming Paradigm for programming Languages.
Logical Programming Paradigm for programming Languages.Logical Programming Paradigm for programming Languages.
Logical Programming Paradigm for programming Languages.
SwatiAtulJoshi
 
app4.pptx
app4.pptxapp4.pptx
app4.pptx
sg4795
 
Logical programming languages and functional programming languages
Logical programming languages and functional programming languagesLogical programming languages and functional programming languages
Logical programming languages and functional programming languages
nahianzarif
 
practical file 11.pdf
practical file 11.pdfpractical file 11.pdf
practical file 11.pdf
PanditKavyaKaushik
 
Introduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptxIntroduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptx
MMCOE, Karvenagar, Pune
 
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
RuchitaMaaran
 
Python Course At Sparse Matrix Solutions
Python Course At Sparse Matrix SolutionsPython Course At Sparse Matrix Solutions
Python Course At Sparse Matrix Solutions
ESPARSE MATRIX SOUTIONS PRIVATE LIMITED
 
Python ppt
Python pptPython ppt
Python ppt
Rachit Bhargava
 
Pl/Python
Pl/PythonPl/Python
Pl/Python
Command Prompt., Inc
 
CPSC 125 Ch 1 Sec 5
CPSC 125 Ch 1 Sec 5CPSC 125 Ch 1 Sec 5
CPSC 125 Ch 1 Sec 5
David Wood
 
An Introduction to Computer Science with Java, Python an.docx
An Introduction to  Computer Science  with Java, Python an.docxAn Introduction to  Computer Science  with Java, Python an.docx
An Introduction to Computer Science with Java, Python an.docx
daniahendric
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
Syed Farjad Zia Zaidi
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
ParrotAI
 
ICS1019.pdf
ICS1019.pdfICS1019.pdf
ICS1019.pdf
Matt Montebello
 
Python-content-1.pdf
Python-content-1.pdfPython-content-1.pdf
Python-content-1.pdf
panimalarhemdochemla
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introduction
wahab khan
 
Do we need a logic of quantum computation?
Do we need a logic of quantum computation?Do we need a logic of quantum computation?
Do we need a logic of quantum computation?
Matthew Leifer
 
Deductive databases
Deductive databasesDeductive databases
Deductive databases
Dabbal Singh Mahara
 
Python Programming Basics
Python Programming BasicsPython Programming Basics
Python Programming Basics
RichardAlexanderPhilip
 
UNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHONUNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
Nandakumar P
 
Logical Programming Paradigm for programming Languages.
Logical Programming Paradigm for programming Languages.Logical Programming Paradigm for programming Languages.
Logical Programming Paradigm for programming Languages.
SwatiAtulJoshi
 
app4.pptx
app4.pptxapp4.pptx
app4.pptx
sg4795
 
Logical programming languages and functional programming languages
Logical programming languages and functional programming languagesLogical programming languages and functional programming languages
Logical programming languages and functional programming languages
nahianzarif
 
Introduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptxIntroduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptx
MMCOE, Karvenagar, Pune
 
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
RuchitaMaaran
 
CPSC 125 Ch 1 Sec 5
CPSC 125 Ch 1 Sec 5CPSC 125 Ch 1 Sec 5
CPSC 125 Ch 1 Sec 5
David Wood
 
An Introduction to Computer Science with Java, Python an.docx
An Introduction to  Computer Science  with Java, Python an.docxAn Introduction to  Computer Science  with Java, Python an.docx
An Introduction to Computer Science with Java, Python an.docx
daniahendric
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
Syed Farjad Zia Zaidi
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
ParrotAI
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introduction
wahab khan
 
Do we need a logic of quantum computation?
Do we need a logic of quantum computation?Do we need a logic of quantum computation?
Do we need a logic of quantum computation?
Matthew Leifer
 
UNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHONUNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT - 2 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
Nandakumar P
 
Ad

Recently uploaded (20)

wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025
Orangescrum
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right WayMigrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
Insurance Tech Services
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Software Testing & it’s types (DevOps)
Software  Testing & it’s  types (DevOps)Software  Testing & it’s  types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025
Orangescrum
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
Insurance Tech Services
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Software Testing & it’s types (DevOps)
Software  Testing & it’s  types (DevOps)Software  Testing & it’s  types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 

Logic programming in python

  • 1. Logic Programming in Python Pierre Carbonnelle FOSDEM 2014
  • 2. No if’s, no loops, just the plain mathematical definition !
  • 3. Logic programming (Prolog, SQL) Functional (Lisp, ..) Imperative / OO (C, Smalltalk)
  • 4. Logic programming (Prolog, SQL) Functional (Lisp, ..) Imperative / OO (C, Smalltalk) Python Python + pyDatalog
  • 5. Why Logic Programming in Python ? Be productive Be Readable Use AI Easy to learn Batteries included Query 11 SQL databases
  • 6. The anatomy of a prolog program Fact Clause Query
  • 7. The anatomy of a pyDatalog program
  • 8. The anatomy of a pyDatalog program
  • 10. Sample 1  Loop  Calculation  Test  Input/output polymorphism ! Shorter programs !
  • 11. Sample 1 Batteries included  Would need an equation solver
  • 12. Sample 2 • f[X]=2*X is equivalent to (f[X]==Y) <= (Y==2*x) • Functions return only 1 value per key (aka dict()) • Functions can appear in expressions • Resolution starts with the latest clause, and stops on first answer • Support for aggregate functions : sum, min, max, …
  • 13. Sample 3 Familiar tuple notation Memoized  Faster  Avoid infinite loop
  • 14. Sample 4 Prefixed function to query Python classes or SQL databases
  • 15. Other pyDatalog features • Runs on PyPy, Python 2, Python 3 • Accepts predicate definition written in Python • For I/O, performance, … • Thread-safe • For use in multi-threaded web framework • Multi-model : Switch from one Logic model (= set of clauses) to another
  • 16. Applications Core technology Benefit Applications The SLG resolution algorithm determines the sequence of steps to resolve a query. Spreadsheet-programming : faster iterations, fewer bugs, more readable. Rule-based expert systems for pricing, tax calculation, access right, robot control, intelligent agent. Input/output polymorphism. Maximise code reuse : shorter program, simpler database query language. Cross-database queries, data integration. Intermediate results are memoized. Avoid re-calculation. Avoid infinite loop. Recursive algorithm on tree or graph structures, natural language processing, code analysis
  • 18. Roadmap : Transactions • Assert facts within transactions, with possible roll-back • Use logic clauses to validate data operations • Use logic clauses to define triggers (condition => action) • Memoize results across queries within the same transaction • Translate Datalog queries into SQL for server-side processing Feedback, Help welcome !!
  • 19. Roadmap : Performance • Rewrite critical sections in C • Exploit multi-threading in resolution engine Feedback, Help welcome !!
  • 20. Why Logic Programming in Python ? Easy to learn Batteries included Query 11 SQL databases Be productive Be Readable Use AI