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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
- 2.
The implementation of our hierarchy of tactics can be found online at https://github.com/FranckS/RingIdris/Provers.
- 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.
This notion of set is a way to talk about the carrier type and an equivalence relation, sometimes called Setoid.
- 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.
It only holds for “pure” algebraic structures, i.e., in the absence of additional axioms.
- 7.
Note that we have to be careful and not simplify it to \((-a) + (-b)\) as it would assume that \(+\) is commutative.
- 8.
References
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)
Brady, E.: Constructing correct circuits: verification of functional aspects of hardware specifications with dependent types. In: Trends in Functional Programming (TFP 2007) (2007)
Brady, E.: Idris, a general-purpose dependently typed programming language: design and implementation. J. Funct. Program. 23, 552–593 (2013)
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
Chlipala, A.: Certified Programming with Dependent Types - A Pragmatic Introduction to the Coq Proof Assistant. MIT Press, Cambridge (2013)
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)
Delahaye, D.: A proof dedicated meta-language. Electr. Notes Theor. Comput. Sci. 70(2), 96–109 (2002)
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
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)
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
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
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)
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)
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)
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
Malecha, G., Chlipala, A., Braibant, T.: Compositional computational reflection. In: 5th International Conference on Interactive Theorem Proving, ITP 2014, pp. 374–389 (2014)
Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Chalmers University of Technology (2007)
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)
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
Corresponding author
Editor information
Editors and Affiliations
Rights 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)