Skip to main content

AlCons : Deductive Synthesis of Sorting Algorithms in Theorema

  • Conference paper
  • First Online:
Theoretical Aspects of Computing – ICTAC 2021 (ICTAC 2021)

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.

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 64.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 84.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.

    This ensures the correctness of algorithms and it is dual to algorithm verification, where the algorithms are first created and then checked.

  2. 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. 3.

    https://www.wolfram.com/mathematica.

  4. 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. 5.

    However some fine tuning of the implementation has been necessary, since trees have a more complex structure.

  6. 6.

    Every element of the inductive domain is a ground instance of exactly one term from the cover set.

  7. 7.

    Meta–variables designate terms (witnesses for existential goals) which are unknown at the current stage of the proof.

  8. 8.

    We presented a more detailed survey of the synthesis methods in [11].

  9. 9.

    https://isabelle.in.tum.de/library/HOL/HOL-Library/Sorting_Algorithms.html.

  10. 10.

    Note that this introduces certain exceptions to antisymmetry and transitivity when the empty composite object is involved.

  11. 11.

    In our context, a pattern is a term possibly containing variables, whose ground instantiations define an injective function into the domain.

  12. 12.

    This is just a matter of efficiency, the goal could contain anything as long as the currently synthesized function is not involved.

  13. 13.

    The rule generates proof alternatives for different groupings of the multiset terms.

  14. 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. 15.

    By local convention, here \(x, x', y, y'\) represent any kind of objects.

  16. 16.

    Note that these kind of new assumptions are global: they can be used on any branch of the current proof.

  17. 17.

    https://www.risc.jku.at/research/theorema/software/.

  18. 18.

    https://www.risc.jku.at/people/tjebelea/AlCons.html.

References

  1. Barstow, D.R.: Remarks on “A synthesis of several sorting algorithms’’ by John Darlington. Acta Inf. 13, 225–227 (1980)

    Article  MathSciNet  Google Scholar 

  2. Blizard, W.D.: Multiset theory. Notre Dame J. Formal Log. 30(1), 36–66 (1989). https://doi.org/10.1305/ndjfl/1093634995

    Article  MathSciNet  MATH  Google Scholar 

  3. Buchberger, B.: Theory exploration with Theorema. Analele Univ. Din Timisoara Ser. Mat.-Inf. XXXVIII(2), 9–32 (2000)

    MathSciNet  MATH  Google Scholar 

  4. Buchberger, B.: Algorithm invention and verification by lazy thinking. Analele Univ. din Timisoara Ser. Mat. - Inf. XLI, 41–70 (2003)

    MathSciNet  MATH  Google Scholar 

  5. Buchberger, B., Craciun, A.: Algorithm synthesis by lazy thinking: Using problem schemes. In: Proceedings of SYNASC 2004, pp. 90–106 (2004)

    Google Scholar 

  6. Buchberger, B., et al.: The Theorema project: A progress report. In: Calculemus 2000, pp. 98–113. A.K. Peters, Natick (2000)

    Google Scholar 

  7. 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

    Article  MathSciNet  MATH  Google Scholar 

  8. Bundy, A., Basin, D., Hutter, D., Ireland, A.: Rippling: Meta-level Guidance for Mathematical Reasoning. Cambridge University Press, Cambridge (2005)

    Book  Google Scholar 

  9. 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

    Article  Google Scholar 

  10. Darlington, J.: A synthesis of several sorting algorithms. Acta Inf. 11, 1–30 (1978)

    Article  MathSciNet  Google Scholar 

  11. 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

    Article  MathSciNet  MATH  Google Scholar 

  12. 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

    Chapter  Google Scholar 

  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

  14. 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

  15. 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

  16. 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

  17. 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

    Article  MathSciNet  MATH  Google Scholar 

  18. 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

  19. Dromey, R.G.: Derivation of sorting algorithms from a specification. Comput. J. 30(6), 512–518 (1987)

    Article  Google Scholar 

  20. 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

    Chapter  Google Scholar 

  21. 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)

    Google Scholar 

  22. 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

  23. Knuth, D.E.: The Art of Computer Programming, Volume 2: Seminumerical Algorithms. 3 edn. Addison-Wesley (1998). https://doi.org/10.1137/1012065

  24. 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

    Chapter  MATH  Google Scholar 

  25. 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

    Article  MathSciNet  MATH  Google Scholar 

  26. Lau, K.K.: Top-down synthesis of sorting algorithms. Comput. J. 35, A001–A007 (1992)

    Google Scholar 

  27. 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

    Article  MATH  Google Scholar 

  28. Manna, Z., Waldinger, R.: The Logical Basis for Computer Programming, vol. 1: Deductive Reasoning. Addison-Wesley (1985). https://doi.org/10.2307/2275898

  29. 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

    Article  Google Scholar 

  30. 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

  31. Radoaca, A.: Properties of multisets compared to sets. In: SYNASC 2015, pp. 187–188 (2015). https://doi.org/10.1109/SYNASC.2015.37

  32. 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

    Article  Google Scholar 

  33. 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

    Article  MATH  Google Scholar 

  34. Stratulat, S.: A general framework to build contextual cover set induction provers. J. Symb. Comput. 32, 403–445 (2001)

    Article  MathSciNet  Google Scholar 

  35. 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

    Article  MATH  Google Scholar 

  36. 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

    Chapter  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Isabela Drămnesc .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics