Skip to main content

Formalising Executable Specifications of Low-Level Systems

  • Conference paper
  • First Online:
Verified Software. Theories, Tools, and Experiments (VSTTE 2018)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 11294))

  • 571 Accesses

Abstract

Formal models of low-level applications rely often on the distinction between executable layer and underlying hardware abstraction. This is also the case for the model of Pip, a separation kernel formalised and verified in Coq using a shallow embedding. DEC is a deeply embedded imperative typed language with primitive recursion and specified in terms of small-step semantics, which we developed in Coq as a reified counterpart of the shallow embedding used for Pip. In this paper, we introduce DEC and its semantics, we present its interpreter based on the type soundness proof and extracted to Haskell, we introduce a Hoare logic to reason about DEC code, and we use this logic to verify properties of Pip as a case study, comparing the new proofs with those based on the shallow embedding. Notably DEC can import shallow specifications as external functions, thus allowing for reuse of the abstract hardware model (DEC can be found at https://github.com/2xs/dec.git [1]).

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Details in 2xs/dec/src/langspec/LangSpec.v [14].

  2. 2.

    Specification and proofs in 2xs/dec/src/DEC1 [1].

References

  1. Torrini, P., Nowak, D., Cherif, M.S., Jomaa, N.: The repository of DEC (2018). https://github.com/2xs/dec.git

  2. Gu, R., et al.: CertiKOS: an extensible architecture for building certified concurrent OS kernels. In: OSDI, pp. 653–669 (2016)

    Google Scholar 

  3. Klein, G., et al.: seL4: formal verification of an OS kernel. In: Proceedings of the ACM SIGOPS 22nd Symposium on Operating Systems Principles, pp. 207–220 (2009)

    Google Scholar 

  4. Jomaa, N., Torrini, P., Nowak, D., Grimaud, G., Hym, S.: Proof-oriented design of a separation kernel with minimal trusted computing base. In: Proceedings of AVOCS 2018, 16 p. (2018). http://www.cristal.univ-lille.fr/~nowakd/pipdesign.pdf

  5. Bertot, Y., Casteran, P.: Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-662-07964-5

    Book  MATH  Google Scholar 

  6. Nipkow, T., Wenzel, M., Paulson, L.C.: Isabelle/HOL: A Proof Assistant for Higher-Order Logic. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45949-9

    Book  MATH  Google Scholar 

  7. Bergougnoux, Q., Grimaud, G., Iguchi-Cartigny, J.: Porting the Pip proto-kernel’s model to multi-core environments. In: IEEE-DASC 2018, 8 p. (2018)

    Google Scholar 

  8. Yaker, M., et al.: Ensuring IoT security with an architecture based on a separation kernel. In: FiCloud 2018, 8 p. (2018)

    Google Scholar 

  9. Bergougnoux, Q., et al.: The repository of Pip (2018). http://pip.univ-lille1.fr

  10. Zhao, Y., Sanan, D., Zhang, F., Liu, Y.: High-assurance separation kernels: a survey on formal methods. arXiv preprint arXiv:1701.01535 (2017)

  11. Dam, M., Guanciale, R., Khakpour, N., Nemati, H., Schwarz, O.: Formal verification of information flow security for a simple ARM-based separation kernel. In: Proceedings of the 2013 ACM SIGSAC Conference on Computer & Communications Security, CCS 2013, pp. 223–234. ACM (2013)

    Google Scholar 

  12. Hym, S., Oudjail, V.: The repository of Digger (2017). https://github.com/2xs/digger

  13. Blazy, S., Leroy, X.: Mechanized semantics for the Clight subset of the C language. J. Autom. Reason. 43, 263–288 (2009)

    Google Scholar 

  14. Torrini, P., Nowak, D.: DEC 1.0 specification (2018). https://github.com/2xs/dec.git

  15. Felleisen, M., Hieb, R.: The revised report on the syntactic theories of sequential control and state. Theor. Comput. Sci. 103(2), 235–271 (1992)

    Article  MathSciNet  Google Scholar 

  16. Moggi, E.: Notions of computation and monads. Inf. Comput. 93, 55–92 (1991)

    Google Scholar 

  17. Churchill, M., Mosses, P.D., Sculthorpe, N., Torrini, P.: Reusable components of semantic specifications. In: Chiba, S., Tanter, É., Ernst, E., Hirschfeld, R. (eds.) Transactions on Aspect-Oriented Software Development XII. LNCS, vol. 8989, pp. 132–179. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-46734-3_4

    Chapter  Google Scholar 

  18. Plotkin, G.D.: A structural approach to operational semantics. J. Log. Algebr. Program. 60–61, 17–139 (2004)

    MathSciNet  MATH  Google Scholar 

  19. Leroy, X.: Using Coq’s evaluation mechanisms in anger (2015). http://gallium.inria.fr/blog/coq-eval/

  20. Cock, D., Klein, G., Sewell, T.: Secure microkernels, state monads and scalable refinement. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 167–182. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-71067-7_16

    Chapter  Google Scholar 

  21. Swierstra, W.: A Hoare logic for the state monad. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 440–451. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-03359-9_30

    Chapter  Google Scholar 

  22. Wadler, P.: Comprehending monads. Math. Struct. Comput. Sci. 2, 461–493 (1992)

    Google Scholar 

  23. Cherif, M.S.: Project report - modelling and verifying the Pip protokernel in a deep embedding of C (2017). https://github.com/2xs/dec.git

  24. Gibbons, J., Wu, N.: Folding domain-specific languages: deep and shallow embeddings (functional pearl). In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP, vol. 49 (2014)

    Google Scholar 

  25. Svenningsson, J., Axelsson, E.: Combining deep and shallow embedding of domain-specific languages. Comput. Lang. Syst. Struct. 44, 143–165 (2015)

    MATH  Google Scholar 

  26. Jovanovic, V., Shaikhha, A., Stucki, S., Nikolaev, V., Koch, C., Odersky, M.: Yin-yang: concealing the deep embedding of DSLs. In: Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences. GPCE 2014, pp. 73–82. ACM (2014)

    Google Scholar 

  27. Carette, J., Kiselyov, O., Shan, C.: Finally tagless, partially evaluated: tagless staged interpreters for simpler typed languages. J. Funct. Program. 19, 509–543 (2009)

    Article  MathSciNet  Google Scholar 

  28. Wildmoser, M., Nipkow, T.: Certifying machine code safety: shallow versus deep embedding. In: Slind, K., Bunker, A., Gopalakrishnan, G. (eds.) TPHOLs 2004. LNCS, vol. 3223, pp. 305–320. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-30142-4_22

    Chapter  Google Scholar 

  29. O’Connor, L., et al.: Refinement through restraint: bringing down the cost of verification. In: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, pp. 89–102. ACM (2016)

    Google Scholar 

  30. Delaware, B., Pit-Claudel, C., Gross, J., Chlipala, A.: Fiat: deductive synthesis of abstract data types in a proof assistant. In: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, pp. 689–700 (2015)

    Google Scholar 

  31. Chlipala, A.: The Bedrock structured programming system: combining generative metaprogramming and Hoare logic in an extensible program verifier. In: Morrisett, G., Uustalu, T. (eds.) ACM SIGPLAN International Conference on Functional Programming, ICFP 2013, Boston, MA, USA, 25–27 September 2013, pp. 391–402. ACM (2013). https://doi.org/10.1145/2500365.2500592

  32. Vijayaraghavan, M., Chlipala, A., Arvind, Dave, N.: Modular deductive verification of multiprocessor hardware designs. In: Kroening, D., Păsăreanu, C. (eds.) CAV 2015. LNCS, vol. 9207, pp. 109–127. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-319-21668-3_7

  33. Gu, R., et al.: Deep specifications and certified abstraction layers. In: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, pp. 595–608. ACM (2015)

    Google Scholar 

Download references

Acknowledgments

We wish to thank all the other members of the Pip Development Team, especially Gilles Grimaud and Samuel Hym, Vlad Rusu and the anonymous reviewers for feedback and discussion. This work has been funded by the European Celtic-Plus Project ODSI C2014/2-12.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Paolo Torrini .

Editor information

Editors and Affiliations

A Appendix: Denotational Semantics

A Appendix: Denotational Semantics

We can define a denotational semantics of IL relying on a monadic translation similar to the one in [16] based on a state monad M with fixed state type W. The semantics is defined by a translation of IL to the monadic metalanguage (4–7), for types (\(\varTheta _{t}\)), expressions (\(\varTheta _{e}\)), expression lists (\(\varTheta _{es}\)) and functions (\(\varTheta _{f}\)), using the auxiliary definitions here also included (1–3).

$$\begin{aligned} \begin{array}{lll} \mathsf {condM} &{} : \ M \ \mathsf {Bool} \rightarrow M \ t_1 \rightarrow M \ t_1 \rightarrow M \ t_1 \ := \\ &{} \lambda x_0 \ x_1 \ x_2. \ \mathsf {bind} \ x_0 \\ &{} (\lambda v_0. \ \mathsf {bind} \ x_1 \ (\lambda v_1. \ \mathsf {bind} \ x_2 \ (\lambda v_2. \ \mathsf {if\_then\_else} \ v_0 \ v_1 \ v_2))) \end{array} \end{aligned}$$
(1)
$$\begin{aligned} \begin{array}{lll} \mathsf {mapM} &{} : \ (\forall t. \ \mathsf {Exp} \ t \rightarrow M \ t) \rightarrow \mathsf {Exps} \ ts \ \rightarrow M \ \ ts \ := \\ &{} \lambda f \ es. \ \mathsf {match} \ es \ \mathsf {with} \ [] \ \Rightarrow \ [] \\ &{} \qquad \qquad \qquad \quad | \ e \,\,{:}{:}\,\, es' \Rightarrow \mathsf {bind} \ (f \ e) \ (\lambda x. \ (\mathsf {bind} \ (\mathsf {mapM} \ f \ es') \\ &{} \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \quad (\lambda xs. \ \mathsf {ret} \ (x \,\,{:}{:}\,\, xs )))) \end{array} \end{aligned}$$
(2)
$$\begin{aligned} \begin{array}{lll} \mathsf {iterateM} &{} ({ ts}: \mathsf {Typs}) \ (t : \mathsf {Typ}) \ (e_0 : \ { ts}\rightarrow M \ t) \\ &{} (e_1: \ ({ ts}\rightarrow M \ t) \rightarrow ({ ts}\rightarrow M \ t)) \\ &{} (n: \mathsf {Nat}) \ (xs: \ { ts}) : M \ t \ := \mathsf {match} \ n \ \mathsf {with} \\ &{} \quad 0 \ \Rightarrow \ e_0 \ xs \quad | \ S \ n' \ \Rightarrow \ e_1 \ (\mathsf {iterateM} \ { ts}\ t \ e_0 \ e_1 \ n') \ xs \end{array} \end{aligned}$$
(3)
$$\begin{aligned} \begin{array}{lll} \varTheta _{t} \ (\mathsf {Exp} \ t) \ &{} := \ M \ t \\ \varTheta _{t} \ (\mathsf {Exps} \ { ts}) \ &{} := \ M \ { ts}\\ \varTheta _{t} \ (\mathsf {Fun} \ t \ { ts}) \ &{} := \ { ts}\rightarrow M \ t \\ \varTheta _{t} \ (\mathsf {Act} \ t \ { ts}) \ &{} := \ { ts}\rightarrow M \ t \end{array} \end{aligned}$$
(4)
$$\begin{aligned} \begin{array}{lll} \varTheta _e \ : \ \forall t. \ \mathsf {Exp} \ t \rightarrow M \ t \\ \varTheta _e \ (\mathsf {val} \ x) &{} = \ \mathsf {ret} \ x \\ \varTheta _e \ (\mathsf {binds} \ e_1 \ (\lambda x: t. \ e_2)) &{} = \ \mathsf {bind} \ (\varTheta _e \ e_1) \ (\lambda x: t. \ \varTheta _e \ e_2) \\ \varTheta _e \ (\mathsf {cond} \ e_1 \ e_2 \ e_3) &{} = \ \mathsf {condM} \ (\varTheta _{e} \ e_1) \ (\varTheta _{e} \ e_2) \ (\varTheta _{e} \ e_3) \\ \varTheta _e \ (\mathsf {call} \ { fc}\ { es}) &{} = \ \mathsf {bind} \ (\varTheta _{es} \ { es}) \ (\varTheta _{f} \ { fc}) \\ \varTheta _e \ (\mathsf {xcall} \ a \ { es}) &{} = \ \mathsf {bind} \ (\varTheta _{es} \ { es}) \ a \end{array} \end{aligned}$$
(5)
$$\begin{aligned} \begin{array}{lll} \varTheta _{es} \ : &{} \mathsf {Exps} \ { ts}\rightarrow M \ { ts}\\ \varTheta _{es} \ es &{} = \ \mathsf {mapM} \ \varTheta _e \ es \end{array} \end{aligned}$$
(6)
$$\begin{aligned} \begin{array}{lll} \varTheta _{f} &{} : \ \mathsf {Fun} \ t \ { ts}\rightarrow { ts}\rightarrow M \ t \\ \varTheta _{f} &{} (\mathsf {fun} \ (\lambda \ x: \ { ts}. \ e_0) \ (\lambda \ (r: \ { ts}\rightarrow \mathsf {Exp} \ t) \ (x: \ { ts}). \ e_1) \ \ n) \ = \\ &{} \quad \mathsf {iterateM} \ { ts}\ t \ (\lambda \ x: \ { ts}. \ \varTheta _e \ e_0) \\ &{} \qquad \qquad \qquad \ (\lambda \ (r: \ { ts}\rightarrow M \ t) \ (x: \ { ts}). \ \varTheta _e \ e_1)) \ \ n \end{array} \end{aligned}$$
(7)

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Torrini, P., Nowak, D., Jomaa, N., Cherif, M.S. (2018). Formalising Executable Specifications of Low-Level Systems. In: Piskac, R., Rümmer, P. (eds) Verified Software. Theories, Tools, and Experiments. VSTTE 2018. Lecture Notes in Computer Science(), vol 11294. Springer, Cham. https://doi.org/10.1007/978-3-030-03592-1_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-03592-1_9

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-03591-4

  • Online ISBN: 978-3-030-03592-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics