Talk @ ICNSC 2017, Calabria, Italy, 16 May 2017
Abstract: The widespread diffusion of low-cost computing devices, such as Arduino boards and Raspberry Pi, along with improvements of Cloud computing platforms, are paving the way towards a whole new set of opportunities for Internet of Things (IoT) applications and services. Varying degrees of intelligence are often required for supporting adaptation and self-management—yet, they should be provided in a light-weight, easy to use and customise, highly-interoperable way. Accordingly, in this paper we explore the idea of Logic Programming as a Service (LPaaS) as a novel and promising re-interpretation of distributed logic programming in the IoT era. After introducing the reference context and motivating scenarios of LPaaS as a key enabling technology for intelligent IoT, we define the LPaaS general system architecture. Then, we present a prototype implementation built on top of the tuProlog system, which provides the required interoperability and customisation. We showcase the LPaaS potential through a case study designed as a simplification of the motivating scenarios.
Logic Programming as a Service (LPaaS): Intelligence for the IoT
1. Logic Programming as a Service (LPaaS):
Intelligence for the IoT
Roberta Calegari1 Enrico Denti1 Stefano Mariani2
Andrea Omicini1
{roberta.calegari, enrico.denti, andrea.omicini}@unibo.it
stefano.mariani@unimore.it
1Dipartimento di Informatica, Scienza e Ingegneria—Universit`a di Bologna
2Dipartimento di Scienze e Metodi dell’Ingegneria, Universit`a di Modena e Reggio Emilia
Talk @ 14th IEEE International Conference on
Networking, Sensing and Control (ICNSC 2017)
Calabria, 16 May 2017
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 1 / 32
2. Outline
1 Scope & Goals
2 Logic Programming as a Service
Vision & Architecture
Service Description
Interface & API
3 LPaaS as a Web Service in tuProlog
Architecture & Technology
tuProlog in a nutshell
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 2 / 32
3. Scope & Goals
Next in Line. . .
1 Scope & Goals
2 Logic Programming as a Service
3 LPaaS as a Web Service in tuProlog
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 3 / 32
4. Scope & Goals
Context
New opportunities for IoT apps and services [Zambonelli, 2015]
Devices and people collaborate as a superorganism: situation-aware dense
ecosystem where infrastructures should
be customisable
be self-managing
govern interaction
encapsulate intelligence
distributed situated intelligence
spread light-weight, context-aware, effective intelligence chunks where
and when needed
locally satisfy the specific reasoning needs of the application at hand
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 4 / 32
5. Scope & Goals
Motivations
IoT scenarios
mobility/pervasive/cloud (eco)systems
infrastructure, platforms, and software as a service
enabling people to benefit from ubiquitous information access
exploiting contextual knowledge
Logic-based languages
multiple, distributed Prolog engines
intelligence providers
technology integrators
Logic Programming as a Service (LPaaS)
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 5 / 32
6. Logic Programming as a Service
Next in Line. . .
1 Scope & Goals
2 Logic Programming as a Service
3 LPaaS as a Web Service in tuProlog
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 6 / 32
7. Logic Programming as a Service Vision & Architecture
Focus on. . .
1 Scope & Goals
2 Logic Programming as a Service
Vision & Architecture
Service Description
Interface & API
3 LPaaS as a Web Service in tuProlog
Architecture & Technology
tuProlog in a nutshell
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 7 / 32
8. Logic Programming as a Service Vision & Architecture
LPaaS Vision I
Evolution of LP in parallel, concurrent, and distributed scenarios
re-interpreting the notion of distribution of LP in today’s context
service perspective → further underlines the role of situatedness
LP as a situated service
Key features
encapsulation
statelessness
locality
situatedness: space, time, context
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 8 / 32
9. Logic Programming as a Service Vision & Architecture
LPaaS Vision II
preservation, with
re-contextualisation, of the SLD
resolution process
stateless client-server interaction
time-sensitive computation
space-sensitive computation
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 9 / 32
10. Logic Programming as a Service Vision & Architecture
LPaaS Architecture
Logic Programming as a Service (LPaaS)
provides an abstract view of an LP inference engine in terms of service
promotes interoperability, encapsulation, and situatedness
promotes context-awareness
Each LP server node exposes its services concurrently to multiple clients,
via interfaces: Configurator Interface and Client Interface
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 10 / 32
11. Logic Programming as a Service Service Description
Focus on. . .
1 Scope & Goals
2 Logic Programming as a Service
Vision & Architecture
Service Description
Interface & API
3 LPaaS as a Web Service in tuProlog
Architecture & Technology
tuProlog in a nutshell
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 11 / 32
12. Logic Programming as a Service Service Description
Service Description
Logic resolution process provided as a service
The LPaaS service
implements SLD resolution [Robinson, 1965]
encapsulates the logic theory / Knowledge Base (KB)
is configured with the set of goals that the client can ask to be proven
Service initialised at deployment-time → dynamic re-configuration (when
needed) only by the Configurator
Main features of the LP service
stateful vs. stateless interaction dynamic vs. static KB
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 12 / 32
13. Logic Programming as a Service Interface & API
Focus on. . .
1 Scope & Goals
2 Logic Programming as a Service
Vision & Architecture
Service Description
Interface & API
3 LPaaS as a Web Service in tuProlog
Architecture & Technology
tuProlog in a nutshell
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 13 / 32
14. Logic Programming as a Service Interface & API
LPaaS Configurator Interface
LPaaS methods
observational methods to provide configuration and contextual
information about the service
usage methods to query the service for triggering computations and
reasoning, and for asking solutions
setConfiguration(+ConfigurationList)
getConfiguration(-ConfigurationList)
resetConfiguration()
setTheory(+Theory)
getTheory(-Theory)
setGoals(+GoalList)
getGoals(-GoalList)
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 14 / 32
17. LPaaS as a Web Service in tuProlog
Next in Line. . .
1 Scope & Goals
2 Logic Programming as a Service
3 LPaaS as a Web Service in tuProlog
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 17 / 32
18. LPaaS as a Web Service in tuProlog Architecture & Technology
Focus on. . .
1 Scope & Goals
2 Logic Programming as a Service
Vision & Architecture
Service Description
Interface & API
3 LPaaS as a Web Service in tuProlog
Architecture & Technology
tuProlog in a nutshell
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 18 / 32
19. LPaaS as a Web Service in tuProlog Architecture & Technology
Architecture
The LPaaS RESTful WS Architecture [Fielding and Taylor, 2002]
reused and adapted patterns commonly used for the REST
architectural style
introduced a novel architecture supporting embedding Prolog engines
into Web Services
client applications interacting via HTTP requests and JSON objects
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 19 / 32
20. LPaaS as a Web Service in tuProlog Architecture & Technology
Technology
Exploiting a plurality of common technologies
Business Logic realised on the J2EE framework [J2EE, 2017], exploiting
EJB [EJB, 2017]
database interaction implemented on top of JPA
[Java Persistence API, 2017]
service interfaces exploit the EJB architecture—also accessible as
RESTful WS → JAX-RS Java Standard (Jersey) [Jersey, 2017]
security based on jose.4.j [jose.4.j, 2017]
application deployment → Payara Application Server [Payara, 2017]
Prolog engine implemented on top of the tuProlog system
[Denti et al., 2001]
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 20 / 32
21. LPaaS as a Web Service in tuProlog tuProlog in a nutshell
Focus on. . .
1 Scope & Goals
2 Logic Programming as a Service
Vision & Architecture
Service Description
Interface & API
3 LPaaS as a Web Service in tuProlog
Architecture & Technology
tuProlog in a nutshell
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 21 / 32
22. LPaaS as a Web Service in tuProlog tuProlog in a nutshell
tuProlog engine
open-source, light-weight
minimal and easily deployable
dynamically configurable
inter-operable
multi-paradigm and multi-language
multi-platform (Java, .NET, Android, iOS)
Minimality
tuProlog core contains only the Prolog engine essentials → other feature
implemented via libraries
Interoperability
tuProlog also supports JSON serialisation natively, ensuring the
interoperability required by a WS
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 22 / 32
23. The Smart Bathroom: Case Study
Next in Line. . .
1 Scope & Goals
2 Logic Programming as a Service
3 LPaaS as a Web Service in tuProlog
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 23 / 32
24. The Smart Bathroom: Case Study
The Smart Bathroom Case Study I
Testbed Scenario: monitor physiological functions
deduce symptoms and diseases
sensors collect data and undertake reasoning on tuProlog-LPaaS
solutions available through a dedicated tuProlog Android app
Three tuProlog-enabled LPaaS services processing data by
toilet sensors analysing biological products, like temperature, volume
or glucose sensors (Toilet Server)
nano sensors integrated into the toothbrush (Toothbrush Server)
ultrasonic bathtubs, pressure sensing toilet seats and other devices to
monitor people’s cardiovascular health (Personal Server).
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 24 / 32
25. The Smart Bathroom: Case Study
The Smart Bathroom Case Study II
Collected data may trigger different alerts: urgent ones, such as presence
of streptococcus infection, positive diabetes tests, etc. and normal ones
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 25 / 32
26. The Smart Bathroom: Case Study
Prototype Screenshots
KB extraction of LPaaS Personal Server and LPaaS Toothbrush Server
The system is built on the following network:
toilet server: on Raspberry Pi 3 (Ubuntu Mate
Arm)
toothbrush server: on Lubuntu laptop
personal server: on Windows 10 laptop
client: tablet Lenovo A10 (Android 5.0.1)
client: desktop application on Windows 10
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 26 / 32
27. Conclusion & Further Work
Next in Line. . .
1 Scope & Goals
2 Logic Programming as a Service
3 LPaaS as a Web Service in tuProlog
4 The Smart Bathroom: Case Study
5 Conclusion & Further Work
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 27 / 32
28. Conclusion & Further Work
Conclusion
pervasive and situated IoT scenarios requie a range of diverse degrees
of intelligence to support adaptation and self-management
LPaaS aims at fitting such a challenging context by providing
standard interface
both stateful and stateless services
either static or dynamic knowledge bases
fully configurable and customisable
first working implementation designed on the top of tuProlog
→ modular, multi-platform, and multi-language logic engine
→ situated logic engines
→ tuProlog as a service based on the usual SOA infrastructure
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 28 / 32
29. Conclusion & Further Work
Further Work
further tests in pervasive deployment scenarios are required, mainly in
the IoT landscape—e.g., testing directly LPaaS tuProlog over
Bluetooth Low Energy connections
space-awareness and situatedness need to be further investigated, for
instance by exploring the idea to opportunistically federate LP engines
by need as a form of dynamic service composition
architecting a specialised logic-based middleware
integrating LPaaS with Labelled LP [Calegari et al., 2016] for
domain-specific logic-based computation
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 29 / 32
30. References
References I
Calegari, R., Denti, E., Dovier, A., and Omicini, A. (2016).
Labelled variables in logic programming: Foundations.
In Fiorentini, C. and Momigliano, A., editors, CILC 2016 – Italian Conference on
Computational Logic, volume 1645 of CEUR Workshop Proceedings, pages 5–20, Milano,
Italy. CEUR-WS.
Proceedings of the 31st Italian Conference on Computational Logic.
Denti, E., Omicini, A., and Ricci, A. (2001).
tuProlog: A light-weight Prolog for Internet applications and infrastructures.
In Ramakrishnan, I., editor, Practical Aspects of Declarative Languages, volume 1990 of
LNCS, pages 184–198. Springer.
3rd International Symposium (PADL 2001), Las Vegas, NV, USA, 11–12 March 2001.
Proceedings.
EJB (2017).
Home Page.
Fielding, R. T. and Taylor, R. N. (2002).
Principled design of the modern Web architecture.
ACM Transactions on Internet Technology, 2(2):115–150.
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 30 / 32
31. References
References II
J2EE (2017).
Home Page.
Java Persistence API (2017).
Home Page.
Jersey (2017).
Home Page.
jose.4.j (2017).
Home Page.
Payara (2017).
Home Page.
Robinson, J. A. (1965).
A machine-oriented logic based on the resolution principle.
Journal of the ACM, 12(1):23–41.
Zambonelli, F. (2015).
Engineering self-organizing urban superorganisms.
Engineering Applications of Artificial Intelligence, 41(C):325–332.
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 31 / 32
32. Logic Programming as a Service (LPaaS):
Intelligence for the IoT
Roberta Calegari1 Enrico Denti1 Stefano Mariani2
Andrea Omicini1
{roberta.calegari, enrico.denti, andrea.omicini}@unibo.it
stefano.mariani@unimore.it
1Dipartimento di Informatica, Scienza e Ingegneria—Universit`a di Bologna
2Dipartimento di Scienze e Metodi dell’Ingegneria, Universit`a di Modena e Reggio Emilia
Talk @ 14th IEEE International Conference on
Networking, Sensing and Control (ICNSC 2017)
Calabria, 16 May 2017
Calegari, Denti, Mariani, Omicini LPaaS ICNSC 2017 32 / 32