Skip to main content

Automatically Proving Equivalence by Type-Safe Reflection

  • Conference paper
  • First Online:
Intelligent Computer Mathematics (CICM 2017)

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

Included in the following conference series:

Abstract

One difficulty with reasoning and programming with dependent types is that proof obligations arise naturally once programs become even moderately sized. For example, implementing an adder for binary numbers indexed over their natural number equivalents naturally leads to proof obligations for equalities of expressions over natural numbers. The need for these equality proofs comes, in intensional type theories, from the fact that the propositional equality enables us to prove as equal terms that are not judgementally equal, which means that the typechecker can’t always obtain equalities by reduction. As far as possible, we would like to solve such proof obligations automatically. In this paper, we show one way to automate these proofs by reflection in the dependently typed programming language Idris. We show how defining reflected terms indexed by the original Idris expression allows us to construct and manipulate proofs. We build a hierarchy of tactics for proving equivalences in semi-groups, monoids, commutative monoids, groups, commutative groups, semi-rings and rings. We also show how each tactic reuses those from simpler structures, thus avoiding duplication of code and proofs.

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.

    http://wiki.portal.chalmers.se/agda%5C?n=Libraries.UsingTheRingSolver.

  2. 2.

    The implementation of our hierarchy of tactics can be found online at https://github.com/FranckS/RingIdris/Provers.

  3. 3.

    This Type would be a Prop in systems, like Coq, that make a distinction between the world of computations and the world of logical statements.

  4. 4.

    This notion of set is a way to talk about the carrier type and an equivalence relation, sometimes called Setoid.

  5. 5.

    refl is not to be confused with Refl, the constructor of \(=\), but when \((\simeq )\) is instantiated with the equality \(=\), refl is implemented by Refl. Therefore, refl of the interface Set is a generalisation of Refl.

  6. 6.

    It only holds for “pure” algebraic structures, i.e., in the absence of additional axioms.

  7. 7.

    Note that we have to be careful and not simplify it to \((-a) + (-b)\) as it would assume that \(+\) is commutative.

  8. 8.

    http://wiki.portal.chalmers.se/agda/pmwiki.php?n=ReferenceManual.Reflection.

References

  1. Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development - Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. An EATCS Series. Springer, Heidelberg (2004)

    Book  MATH  Google Scholar 

  2. Brady, E.: Constructing correct circuits: verification of functional aspects of hardware specifications with dependent types. In: Trends in Functional Programming (TFP 2007) (2007)

    Google Scholar 

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

    Article  MathSciNet  MATH  Google Scholar 

  4. Carette, J., O’Connor, R.: Theory presentation combinators. In: Jeuring, J., Campbell, J.A., Carette, J., Reis, G., Sojka, P., Wenzel, M., Sorge, V. (eds.) CICM 2012. LNCS, vol. 7362, pp. 202–215. Springer, Heidelberg (2012). doi:10.1007/978-3-642-31374-5_14

    Chapter  Google Scholar 

  5. Chlipala, A.: Certified Programming with Dependent Types - A Pragmatic Introduction to the Coq Proof Assistant. MIT Press, Cambridge (2013)

    MATH  Google Scholar 

  6. Crégut, P.: Une procédure de décision reflexive pour un fragment de l’arithmétique de Presburger. In: Journées Francophones des Langages Applicatifs (2004)

    Google Scholar 

  7. Delahaye, D.: A proof dedicated meta-language. Electr. Notes Theor. Comput. Sci. 70(2), 96–109 (2002)

    Article  MATH  Google Scholar 

  8. Delahaye, D., Doligez, D., Gilbert, F., Halmagrand, P., Hermant, O.: Zenon Modulo: when achilles outruns the tortoise using deduction modulo. In: McMillan, K., Middeldorp, A., Voronkov, A. (eds.) LPAR 2013. LNCS, vol. 8312, pp. 274–290. Springer, Heidelberg (2013). doi:10.1007/978-3-642-45221-5_20

    Chapter  Google Scholar 

  9. Delahaye, D., Mayero, M.: Field, une procédure de décision pour les nombres réels en Coq. In: Castéran, P. (ed.) Journées francophones des langages applicatifs (JFLA’01), pp. 33–48. Collection Didactique, INRIA (2001)

    Google Scholar 

  10. Dowek, G., Hardin, T., Kirchner, C.: Theorem proving modulo. J. Autom. Reasoning 31(1), 33–72 (2003). http://dx.doi.org/10.1023/A:1027357912519

  11. Farmer, W.M.: The formalization of syntax-based mathematical algorithms using quotation and evaluation. In: Carette, J., Aspinall, D., Lange, C., Sojka, P., Windsteiger, W. (eds.) CICM 2013. LNCS, vol. 7961, pp. 35–50. Springer, Heidelberg (2013). doi:10.1007/978-3-642-39320-4_3

    Chapter  Google Scholar 

  12. Gregoire, B., Mahboubi, A.: Proving equalities in a commutative ring done right in Coq. In: Theorem Proving in Higher Order Logics (TPHOLS 2005), pp. 98–113 (2005)

    Google Scholar 

  13. Howard, W.: The formulae-as-types notion of construction. In: Seldin, J., Hindley, J. (eds.) To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus, and Formalism. Academic Press, London (1980)

    Google Scholar 

  14. Kokke, P., Swierstra, W.: Auto in Agda – programming proof search using reflection. In: 12th International Conference on Mathematics of Program Construction, MPC 2015, pp. 276–301 (2015)

    Google Scholar 

  15. Lindblad, F., Benke, M.: A tool for automated theorem proving in Agda. In: Filliâtre, J.-C., Paulin-Mohring, C., Werner, B. (eds.) TYPES 2004. LNCS, vol. 3839, pp. 154–169. Springer, Heidelberg (2006). doi:10.1007/11617990_10

    Chapter  Google Scholar 

  16. Malecha, G., Chlipala, A., Braibant, T.: Compositional computational reflection. In: 5th International Conference on Interactive Theorem Proving, ITP 2014, pp. 374–389 (2014)

    Google Scholar 

  17. Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Chalmers University of Technology (2007)

    Google Scholar 

  18. Ziliani, B., Dreyer, D., Krishnaswami, N.R., Nanevski, A., Vafeiadis, V.: Mtac: a monad for typed tactic programming in Coq. In: ACM SIGPLAN International Conference on Functional Programming, ICFP 2013, pp. 87–100 (2013)

    Google Scholar 

Download references

Acknowledgements

We thank the anonymous reviewers and Jacques Carette for their insightful comments on an earlier draft. We are also grateful for the support of the Scottish Informatics and Computer Science Alliance (SICSA) and EPSRC grant EP/N024222/1.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Edwin Brady .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Slama, F., Brady, E. (2017). Automatically Proving Equivalence by Type-Safe Reflection. In: Geuvers, H., England, M., Hasan, O., Rabe, F., Teschke, O. (eds) Intelligent Computer Mathematics. CICM 2017. Lecture Notes in Computer Science(), vol 10383. Springer, Cham. https://doi.org/10.1007/978-3-319-62075-6_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-62075-6_4

  • Published:

  • Publisher Name: Springer, Cham

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

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

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics