Abstract
We describe the principles and the implementation of AlCons (Algorithm Constructor), a system for the automatic proof–based synthesis of sorting algorithms on lists and on binary trees, in the frame of the Theorema system. The core of the system is a dedicated prover based on specific inference rules and strategies for constructive proofs over the domains of lists and of binary trees, aimed at the automatic synthesis of sorting algorithms and their auxiliary functions from logical specifications. The specific distinctive feature of our approach is the use of multisets for expressing the fact that two lists (trees) have the same elements. This allows a more natural expression of the properties related to sorting, compared to the classical approach using the permutation relation (a list is a permutation of another). Moreover, the use of multisets leads to special inference rules and strategies which make the proofs more efficient, as for instance: expand/compress multiset terms and solve meta-variables using multiset equalities. Additionally we use a Noetherian induction strategy based on the relation induced by the strict inclusion of multisets, which facilitates the synthesis of arbitrary recursion structures, without having to indicate the recursion schemes in advance. The necessary auxiliary algorithms (like, e.g., for insertion and merging) are generated by the same principles from the synthesis conjectures that are automatically produced during the main proof, using a “cascading” method, which in fact contributes to the automation of theory exploration. The prover is implemented in the frame of the Theorema system and works in natural style, while the generated algorithms can be immediately tested in the same system.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
This ensures the correctness of algorithms and it is dual to algorithm verification, where the algorithms are first created and then checked.
- 2.
Theory exploration is the generation of interesting statements following from a certain set of axioms and/or for the purpose of developing certain proofs or algorithms.
- 3.
- 4.
In other approaches one uses the permutation notion, which must be expressed by specific algorithmic definitions, and whose properties are more difficult to infer.
- 5.
However some fine tuning of the implementation has been necessary, since trees have a more complex structure.
- 6.
Every element of the inductive domain is a ground instance of exactly one term from the cover set.
- 7.
Meta–variables designate terms (witnesses for existential goals) which are unknown at the current stage of the proof.
- 8.
We presented a more detailed survey of the synthesis methods in [11].
- 9.
- 10.
Note that this introduces certain exceptions to antisymmetry and transitivity when the empty composite object is involved.
- 11.
In our context, a pattern is a term possibly containing variables, whose ground instantiations define an injective function into the domain.
- 12.
This is just a matter of efficiency, the goal could contain anything as long as the currently synthesized function is not involved.
- 13.
The rule generates proof alternatives for different groupings of the multiset terms.
- 14.
Terms containing universally quantified variables, such that for every element of the domain there exists exactly one term in the set which instantiates to that element.
- 15.
By local convention, here \(x, x', y, y'\) represent any kind of objects.
- 16.
Note that these kind of new assumptions are global: they can be used on any branch of the current proof.
- 17.
- 18.
References
Barstow, D.R.: Remarks on “A synthesis of several sorting algorithms’’ by John Darlington. Acta Inf. 13, 225–227 (1980)
Blizard, W.D.: Multiset theory. Notre Dame J. Formal Log. 30(1), 36–66 (1989). https://doi.org/10.1305/ndjfl/1093634995
Buchberger, B.: Theory exploration with Theorema. Analele Univ. Din Timisoara Ser. Mat.-Inf. XXXVIII(2), 9–32 (2000)
Buchberger, B.: Algorithm invention and verification by lazy thinking. Analele Univ. din Timisoara Ser. Mat. - Inf. XLI, 41–70 (2003)
Buchberger, B., Craciun, A.: Algorithm synthesis by lazy thinking: Using problem schemes. In: Proceedings of SYNASC 2004, pp. 90–106 (2004)
Buchberger, B., et al.: The Theorema project: A progress report. In: Calculemus 2000, pp. 98–113. A.K. Peters, Natick (2000)
Buchberger, B., Jebelean, T., Kutsia, T., Maletzky, A., Windsteiger, W.: Theorema 2.0: Computer-assisted natural-style mathematics. J. Formal. Reason. 9(1), 149–185 (2016). https://doi.org/10.6092/issn.1972-5787/4568
Bundy, A., Basin, D., Hutter, D., Ireland, A.: Rippling: Meta-level Guidance for Mathematical Reasoning. Cambridge University Press, Cambridge (2005)
Bundy, A., Dixon, L., Gow, J., Fleuriot, J.: Constructing induction rules for deductive synthesis proofs. Electron. Notes Theor. Comput. Sci. 153, 3–21 (2006). https://doi.org/10.1016/j.entcs.2005.08.003
Darlington, J.: A synthesis of several sorting algorithms. Acta Inf. 11, 1–30 (1978)
Dramnesc, I., Jebelean, T.: Synthesis of list algorithms by mechanical proving. J. Symb. Comput. 68, 61–92 (2015). https://doi.org/10.1016/j.jsc.2014.09.030
Drămnesc, I., Jebelean, T.: Automatic synthesis of merging and inserting algorithms on binary trees using multisets in Theorema. In: Slamanig, D., Tsigaridas, E., Zafeirakopoulos, Z. (eds.) MACIS 2019. LNCS, vol. 11989, pp. 153–168. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-43120-4_13
Dramnesc, I., Jebelean, T.: Proof-based synthesis of sorting algorithms using multisets in Theorema. In: FROM 2019, pp. 76–91. EPTCS 303 (2019). https://doi.org/10.4204/EPTCS.303.6
Dramnesc, I., Jebelean, T.: Deductive synthesis of bubble-sort using multisets. In: SAMI 2020, pp. 165–172. IEEE (2020). https://doi.org/10.1109/SAMI48414.2020.9108725
Dramnesc, I., Jebelean, T.: Deductive synthesis of min-max-sort using multisets. In: SACI 2020, pp. 165–172. IEEE (2020). https://doi.org/10.1109/SACI49304.2020.9118814
Dramnesc, I., Jebelean, T.: Synthesis of sorting algorithms using multisets in Theorema. J. Log. Algebraic Methods Programm. 119(100635) (2020). https://doi.org/10.1016/j.jlamp.2020.100635
Dramnesc, I., Jebelean, T., Stratulat, S.: Mechanical synthesis of sorting algorithms for binary trees by logic and combinatorial techniques. J. Symb. Comput. 90, 3–41 (2019). https://doi.org/10.1016/j.jsc.2018.04.002
Dramnesc, I., Jebelean, T.: Synthesis of merging algorithms on binary trees using multisets in Theorema. In: SACI 2021, pp. 497–502. IEEE (2021). https://doi.org/10.1109/SACI51354.2021.9465619
Dromey, R.G.: Derivation of sorting algorithms from a specification. Comput. J. 30(6), 512–518 (1987)
Eguchi, S., Kobayashi, N., Tsukada, T.: Automated synthesis of functional programs with auxiliary functions. In: Ryu, S. (ed.) APLAS 2018. LNCS, vol. 11275, pp. 223–241. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-02768-1_13
Howard, B.T.: Another iteration on “A synthesis of several sorting algorithms” Technical report KSU CIS 94–8. Kansas State University, Department of Computing and Information Sciences (1994)
Itzhaky, S., Peleg, H., Polikarpova, N., Rowe, R.N.S., Sergey, I.: Cyclic program synthesis. In: PLDI 2021, pp. 944–959. ACM (2021). https://doi.org/10.1145/3453483.3454087
Knuth, D.E.: The Art of Computer Programming, Volume 2: Seminumerical Algorithms. 3 edn. Addison-Wesley (1998). https://doi.org/10.1137/1012065
Korukhova, Y.: Automatic deductive synthesis of lisp programs in the system ALISA. In: Fisher, M., van der Hoek, W., Konev, B., Lisitsa, A. (eds.) JELIA 2006. LNCS (LNAI), vol. 4160, pp. 242–252. Springer, Heidelberg (2006). https://doi.org/10.1007/11853886_21
Korukhova, Y.: An approach to automatic deductive synthesis of functional programs. Ann. Math. Artif. Intell. 50(3–4), 255–271 (2007). https://doi.org/10.1007/s10472-007-9079-9
Lau, K.K.: Top-down synthesis of sorting algorithms. Comput. J. 35, A001–A007 (1992)
Manna, Z., Waldinger, R.: A deductive approach to program synthesis. ACM Trans. Programm. Lang. Syst. 2(1), 90–121 (1980). https://doi.org/10.1145/357084.357090
Manna, Z., Waldinger, R.: The Logical Basis for Computer Programming, vol. 1: Deductive Reasoning. Addison-Wesley (1985). https://doi.org/10.2307/2275898
Manna, Z., Waldinger, R.: Fundamentals of deductive program synthesis. IEEE Trans. Softw. Eng. 18(8), 674–704 (1992). https://doi.org/10.1109/32.153379
Polikarpova, N., Kuraj, I., Solar-Lezama, A.: Program synthesis from polymorphic refinement types. In: PLDI 2016, pp. 522–538 (2016). https://doi.org/10.1145/2908080.2908093
Radoaca, A.: Properties of multisets compared to sets. In: SYNASC 2015, pp. 187–188 (2015). https://doi.org/10.1109/SYNASC.2015.37
Smith, D.R.: KIDS: a semiautomatic program development system. IEEE Trans. Softw. Eng. 16(9), 1024–1043 (1990). https://doi.org/10.1109/32.578788
Srivastava, S., Gulwani, S., Foster, J.S.: From program verification to program synthesis. SIGPLAN Not. 45(1), 313–326 (2010). https://doi.org/10.1145/1707801.1706337
Stratulat, S.: A general framework to build contextual cover set induction provers. J. Symb. Comput. 32, 403–445 (2001)
Traugott, J.: Deductive synthesis of sorting programs. J. Symb. Comput. 7(6), 533–572 (1989). https://doi.org/10.1016/S0747-7171(89)80040-9
Windsteiger, W.: Theorema 2.0: A system for mathematical theory exploration. In: Hong, H., Yap, C. (eds.) ICMS 2014. LNCS, vol. 8592, pp. 49–52. Springer, Heidelberg (2014). https://doi.org/10.1007/978-3-662-44199-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
Drămnesc, I., Jebelean, T. (2021). AlCons : Deductive Synthesis of Sorting Algorithms in Theorema . In: Cerone, A., Ölveczky, P.C. (eds) Theoretical Aspects of Computing – ICTAC 2021. ICTAC 2021. Lecture Notes in Computer Science(), vol 12819. Springer, Cham. https://doi.org/10.1007/978-3-030-85315-0_18
Download citation
DOI: https://doi.org/10.1007/978-3-030-85315-0_18
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-85314-3
Online ISBN: 978-3-030-85315-0
eBook Packages: Computer ScienceComputer Science (R0)