Abstract
“Smart” devices have become ubiquitous in modern households and industry. Especially in home-automation, robotics, and sensing tasks, rule-based approaches seem ideal to describe the behavior of the interactive systems. But managing input data and state is hard. With little choice of programming language, most code targeted at microcontrollers is written in imperative C or assembler.
Microlog is a deductive database language with a strong logic foundation based on Datalog extended with a representation of time and calls to external functions that may be used to control sensors and actors.
In this paper we describe a method to precalculate sets of Datalog facts that may be derivable for a point in time. Values that will be known only at runtime are represented as parameters of those “states”. During “state transition”, a small number of conditions on parameters and input values must be checked. By representing a possibly quite large number of facts as a single state number and a few parameter values, memory and computing time are saved. If no parameters are needed, the result of this compilation is basically a finite state machine.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
We actually allow users to define a whole statement block as a special predicate. This allows combining interface functions that always need to be called together, defining multiple return arguments, or just doing arithmetic. To avoid confusion, we only refer to function calls from here on out.
- 2.
At the time of writing, PlatformIO.org hosts over 7.000 libraries for embedded devices. More than half are available for Arduino.
References
Agatolio, F., Moro, M.: A workshop to promote Arduino-based robots as wide spectrum learning support tools. In: Merdan, M., Lepuschitz, W., Koppensteiner, G., Balogh, R. (eds.) Robotics in Education. AISC, vol. 457, pp. 113–125. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-42975-5_11
Alvaro, P., Marczak, W.R., Conway, N., Hellerstein, J.M., Maier, D., Sears, R.: Dedalus: Datalog in Time and Space. In: de Moor, O., Gottlob, G., Furche, T., Sellers, A. (eds.) Datalog 2.0 2010. LNCS, vol. 6702, pp. 262–281. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-24206-9_16
Brass, S., Dix, J.: A general approach to bottom-up computation of disjunctive semantics. In: Dix, J., Pereira, L.M., Przymusinski, T.C. (eds.) NMELP 1994. Lecture Notes in Computer Science, vol. 927, pp. 127–155. Springer, Heidelberg (1995). https://doi.org/10.1007/BFb0030663
Brass, S., Goldberg, C.: Proving the safety of SQL queries. In: Cai, K.Y., Ohnishi, A., Lau, M. (eds.) Proceedings of the 5th International Conference on Quality Software (QSIC 2005), pp. 197–204. IEEE Computer Society (2005)
Calimeri, F., Ianni, G.: External sources of computation for answer set solvers. In: Baral, C., Greco, G., Leone, N., Terracina, G. (eds.) LPNMR 2005. LNCS (LNAI), vol. 3662, pp. 105–118. Springer, Heidelberg (2005). https://doi.org/10.1007/11546207_9
Engels, C., Behrend, A., Brass, S.: A rule-based approach to analyzing database schema objects with datalog. In: Fioravanti, F., Gallagher, J.P. (eds.) LOPSTR 2017. LNCS, vol. 10855, pp. 20–36. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-94460-9_2
Fink, M., Germano, S., Ianni, G., Redl, C., Schüller, P.: ActHEX: implementing HEX programs with action atoms. In: Cabalar, P., Son, T.C. (eds.) LPNMR 2013. LNCS (LNAI), vol. 8148, pp. 317–322. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-40564-8_31
Guo, S., Sun, W., Weiss, M.A.: Solving satisfiability and implication problems in database systems. ACM Trans. Database Syst. 21, 270–293 (1996)
Kowalski, R., Sadri, F.: Reactive computing as model generation. New Gener. Comput. 33(1), 33–67 (2015). https://doi.org/10.1007/s00354-015-0103-z
Lausen, G., Ludäscher, B., May, W.: On active deductive databases: the statelog approach. In: Freitag, B., Decker, H., Kifer, M., Voronkov, A. (eds.) Transactions and Change in Logic Databases, pp. 69–106. Springer, Berlin Heidelberg, Berlin, Heidelberg (1998)
Mueller, E.T.: Commonsense Reasoning: An Event Calculus Based Approach, 2nd edn. Morgan Kaufmann Publishers Inc., San Francisco (2014)
Russell, I., Rosiene, C.P., Gold, A.: A CS course for non-majors based on the Arduino platform. In: Proceedings of the 51st ACM Technical Symposium on Computer Science Education. SIGCSE 2020, p. 1309. Association for Computing Machinery, New York (2020). https://doi.org/10.1145/3328778.3372595
Schwarz, S., Wenzel, M.: ev3dev-prolog - prolog API for LEGO EV3. In: Draude, C., Lange, M., Sick, B. (eds.) INFORMATIK 2019: 50 Jahre Gesellschaft für Informatik - Informatik für Gesellschaft (Workshop-Beiträge), 23–26 September 2019, Kassel, Deutschland. LNI, vol. P-295, pp. 385–398. GI (2019). https://doi.org/10.18420/inf2019_ws41
Wenzel, M., Brass, S.: Declarative programming for microcontrollers - datalog on Arduino. In: Hofstedt, P., Abreu, S., John, U., Kuchen, H., Seipel, D. (eds.) INAP/WLP/WFLP -2019. LNCS (LNAI), vol. 12057, pp. 119–138. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-46714-2_9
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Wenzel, M., Brass, S. (2021). Translation of Interactive Datalog Programs for Microcontrollers to Finite State Machines. In: Fernández, M. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2020. Lecture Notes in Computer Science(), vol 12561. Springer, Cham. https://doi.org/10.1007/978-3-030-68446-4_11
Download citation
DOI: https://doi.org/10.1007/978-3-030-68446-4_11
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-68445-7
Online ISBN: 978-3-030-68446-4
eBook Packages: Computer ScienceComputer Science (R0)