Skip to main content

Theories as Types

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNAI,volume 10900))

Abstract

Theories are an essential structuring principle that enable modularity, encapsulation, and reuse in formal libraries and programs (called classes there). Similar effects can be achieved by dependent record types. While the former form a separate language layer, the latter are a normal part of the type theory. This overlap in functionality can render different systems non-interoperable and lead to duplication of work.

We present a type-theoretic calculus and implementation of a variant of record types that for a wide class of formal languages naturally corresponds to theories. Moreover, we can now elegantly obtain a contravariant functor that reflects the theory level into the object level: for each theory we obtain the type of its models and for every theory morphism a function between the corresponding types. In particular this allows shallow – and thus structure-preserving – encodings of mathematical knowledge and program specifications while allowing the use of object-level features on models, e.g. equality and quantification.

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

Buying options

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

Learn about institutional subscriptions

Notes

  1. 1.

    This is sometimes called horizontal subtyping. In that case, the straightforward covariance rule for record types is called vertical subtyping.

  2. 2.

    Note that it does not matter how the fields of the record are split into \(\varDelta _1\) and \(\varDelta _2\) as long as \(\varDelta _1\) contains all fields that the declaration of x depends on.

  3. 3.

    It is possible and important in practice to also define \(\varDelta \oplus E\) when the types/definitions in d and e are provably equal. We omit that here for simplicity.

  4. 4.

    Note that because \(P\cap P'\) depends on the syntactic structure of P and \(P'\), it only approximates the least upper bound of \(\mathtt {Mod}\left( P\right) \) and \(\mathtt {Mod}\left( P'\right) \) and is not stable under, e.g., flattening of P and \(P'\). But it can still be very useful in certain situations.

  5. 5.

    The computation of \(\max P\) may look like it requires flattening. But it is easy to compute and cache its value for every named theory.

  6. 6.

    In practice, these substitutions are easy to implement without flattening r because we can cache for every theory which theories it includes and which names it declares.

References

  1. Brady, E.: Idris, a general-purpose dependently typed programming language: design and implementation. J. Funct. Program. 23(5), 552–593 (2013)

    Article  MathSciNet  Google Scholar 

  2. Constable, R., et al.: Implementing Mathematics with the Nuprl Development System. Prentice-Hall, Upper Saddle River (1986)

    Google Scholar 

  3. Dehaye, P.-O., et al.: Interoperability in the OpenDreamKit project: the math-in-the-middle approach. In: Kohlhase, M., Johansson, M., Miller, B., de Moura, L., Tompa, F. (eds.) CICM 2016. LNCS (LNAI), vol. 9791, pp. 117–131. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-42547-4_9. https://github.com/OpenDreamKit/OpenDreamKit/blob/master/WP6/CICM2016/published.pdf

    Chapter  Google Scholar 

  4. Farmer, W., Guttman, J., Thayer, F.: Little theories. In: Kapur, D. (ed.) Conference on Automated Deduction, pp. 467–581 (1992)

    Chapter  Google Scholar 

  5. Goguen, J., Winkler, T., Meseguer, J., Futatsugi, K., Jouannaud, J.: Introducing OBJ. In: Goguen, J., Coleman, D., Gallimore, R. (eds.) Applications of Algebraic Specification Using OBJ. Cambridge (1993)

    Google Scholar 

  6. Hardin, T., et al.: The FoCaLiZe Essential (2012). http://focalize.inria.fr/

  7. Harrison, J.: HOL light: a tutorial introduction. In: Srivas, M., Camilleri, A. (eds.) FMCAD 1996. LNCS, vol. 1166, pp. 265–269. Springer, Heidelberg (1996). https://doi.org/10.1007/BFb0031814

    Chapter  Google Scholar 

  8. Kohlhase, M., Koprucki, T., Müller, D., Tabelow, K.: Mathematical models as research data via flexiformal theory graphs. In: Geuvers, H., England, M., Hasan, O., Rabe, F., Teschke, O. (eds.) CICM 2017. LNCS (LNAI), vol. 10383, pp. 224–238. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-62075-6_16

    Chapter  Google Scholar 

  9. MathHub MMT/LFX Git Repository. http://gl.mathhub.info/MMT/LFX. Accessed 15 May 2015

  10. Luo, Z.: Manifest fields and module mechanisms in intensional type theory. In: Berardi, S., Damiani, F., de’Liguoro, U. (eds.) TYPES 2008. LNCS, vol. 5497, pp. 237–255. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02444-3_15

    Chapter  Google Scholar 

  11. Mathematical Components. http://www.msr-inria.fr/projects/mathematical-components-2/

  12. MitM/SMGLoM. https://gl.mathhub.info/MitM/smglom. Accessed 01 Feb 2018

  13. Müller, D., Rabe, F., Kohlhase, M.: Theories as Types. http://kwarc.info/kohlhase/submit/tatreport.pdf

  14. Owre, S., Rushby, J.M., Shankar, N.: PVS: a prototype verification system. In: Kapur, D. (ed.) CADE 1992. LNCS, vol. 607, pp. 748–752. Springer, Heidelberg (1992). https://doi.org/10.1007/3-540-55602-8_217

    Chapter  Google Scholar 

  15. Rabe, F.: How to identify, translate, and combine logics? J. Log. Comput. (2014). https://doi.org/10.1093/logcom/exu079

  16. Rabe, F.: A modular type reconstruction algorithm. ACM Trans. Comput. Log. (2017). Accepted pending minor revision: https://kwarc.info/people/frabe/Research/rabe_recon_17.pdf

  17. Rabe, F., Kohlhase, M.: A scalable module system. Inf. Comput. 230(1), 1–54 (2013)

    Article  MathSciNet  Google Scholar 

  18. Spitters, B., van der Weegen, E.: Type classes for mathematics in type theory. CoRR abs/1102.1323 (2011). arXiv:1102.1323

    Article  MathSciNet  Google Scholar 

  19. Trybulec, A., Blair, H.: Computer assisted reasoning with MIZAR. In: Joshi, A. (ed.) Proceedings of the 9th International Joint Conference on Artificial Intelligence, pp. 26–28. Morgan Kaufmann (1985)

    Google Scholar 

  20. Wenzel, M.: The Isabelle/Isar Reference Manual, 3 December 2009. http://isabelle.in.tum.de/documentation.html

  21. Coq Development Team: The Coq Proof Assistant: Reference Manual. Technical report, INRIA (2015)

    Google Scholar 

Download references

Acknowledgements

The work reported here has been kicked off by discussions with Jacques Carette and William Farmer who have experimented with theory internalizations into record types in the scope of their MathScheme system. We acknowledge financial support from the OpenDreamKit Horizon 2020 European Research Infrastructures project (#676541).

Author information

Authors and Affiliations

Authors

Corresponding authors

Correspondence to Dennis Müller , Florian Rabe or Michael Kohlhase .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer International Publishing AG, part of Springer Nature

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Müller, D., Rabe, F., Kohlhase, M. (2018). Theories as Types. In: Galmiche, D., Schulz, S., Sebastiani, R. (eds) Automated Reasoning. IJCAR 2018. Lecture Notes in Computer Science(), vol 10900. Springer, Cham. https://doi.org/10.1007/978-3-319-94205-6_38

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-94205-6_38

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-94204-9

  • Online ISBN: 978-3-319-94205-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics