ARITHMETIC COMPUTATIONS AND THE NON SAFETY OF UNIVERSAL POLYMORPHISM
DOI:
https://doi.org/10.32689/maup.it.2025.3.18Keywords:
universal polymorphism, RAISE Specification Language, axiomatics, function of a real argumentAbstract
The article examines an algebraic approach to software design and testing.The purpose of the study is to develop, in C#, two classes – integers and real numbers – that are in an inheritance relationship.In this setting, the overridden division operation in the ring of integers and the field of real numbers must lead to errors in thecalculations of polymorphic functions, regardless of which class is the base and which is the derived one. These classes are intended to demonstrate the occurrence of non-obvious errors during computations in a polymorphic implementation of the simplex method. In this work, the developed classes were used to produce an explicit error as the result of executing a very simple polymorphic function. All of this demonstrates the danger of universal polymorphism in arithmetic computations. Research methods. The study employs the basic principles of the RAISE formal development method and Bertrand Meyer’s Design by Contract methodology, which make it possible to apply formal logic to the classes under development.The scientific novelty of this study lies in the fact that, for functions of a real variable, formal indicators were tested thatmake it possible to predict the occurrence of failures in operational software. First, this confirms the usefulness of applying theconsidered formal methods of software design. Second, even for the simplest data types, the study demonstrates the dangers ofuniversal polymorphism used in C# for arithmetic computations. Similar examples of the risks associated with polymorphismcan certainly be obtained in cases of inheritance between real and complex numbers.Conclusions. Algebraic design and testing are based on mathematical principles, which makes it possible to: avoid ambiguityand vagueness in the description of functionality; ensure precision and unambiguity in formulating program requirements;detect and eliminate errors already at the development stage.
References
Наслідування – C# | Microsoft Corporation. Microsoft Learn [Текст] (рос.). URL: https://learn.microsoft.com/ru-ru/dotnet/csharp/fundamentals/tutorials/inheritance (дата звернення: 07.07.2025).
Поліморфізм – C# | Microsoft Corporation. Microsoft Learn [Текст]. URL: https://learn.microsoft.com/ru-ru/dotnet/csharp/fundamentals/object-oriented/polymorphism (дата звернення: 07.07.2025).
Піскунов О. Г. Модульне тестування програмного забезпечення: робоча програма. 2024. URL: https://drive.google.com/file/d/1RBR3ORllP-XjA5idzDBxm-kHyjPr_X5d/view.
Піскунов О. Г. Про відмінності між поняттями типу і класу. Вісник Київського університету. Комп’ютерні науки. 2015. № 3. С. 106–114. URL: https://www.researchgate.net/publication/344177979.
Піскунов О. Г., Мічуда А. М. Перевизначення додавання: небезпечне наслідування у групі цілих чисел. 2023. URL: https://www.researchgate.net/publication/366867037.
Піскунов О. Г., Рудик В. І., Петренко І. А. Арифметика Пеано: від специфікації до класу. 2022. URL: https://www.researchgate.net/publication/365979331.
Піскунов О. Г., Тупко Н. П., Петренко І. А. Алгебраїчне проєктування програмного забезпечення. Інформаційні технології та суспільство. 2024. № 5 (11). С. 50–59.
Cardelli L., Abadi M. A theory of objects. Springer, 1996. 396 p. URL: ttps://drive.google.com/open?id=1mShdblP3LnooSSfk8Osh_SAtIc54Jczu.
Cardelli L., Wegner P. On understanding types, data abstraction, and polymorphism. ACM Computing Surveys (CSUR). 1985. Vol. 17, No. 4. P. 471–523.
ECMA International. ECMA-334: C# Language Specification, 7th Edition. Technical Report ECMA-334. December 2023.
Haxthausen A. Lecture Notes on The RAISE Development Method. 1999. URL: http://www2.imm.dtu.dk/courses/02263/E20/Files/methodnotes99.pdf.
IEEE Standard for Floating-Point Arithmetic. – NY : IEEE Computer Society, 2019. 83 p. URL: https://en.wikipedia.org/wiki/IEEE_754.
Liskov B., Wing J. A behavioral notion of subtyping. ACM Transactions on Programming Languages and Systems (TOPLAS). 1994. Vol. 16, No. 6. P. 1811–1841.
Martin R.C. The Liskov Substitution Principle [Електронний ресурс] // C++ Report. March 1996. URL: https://objectmentor.com/resources/articles/lsp.pdf.
Meyer B. Object-oriented Software Construction. – 2-nd edition. Santa Barbara : ISE Inc, USA, 2000. 1284 p.
Stepanov A. A., Rose D. E. From Mathematics to Generic Programming. Upper Saddle River, NJ : Addison-Wesley/ Pearson, 2014.
The RAISE Language Group. The RAISE Specification Language. UNU/IIST, Prentice Hall Europe, Denmark, 1992. URL: https://raisetools.github.io/material/documentation/raise-language.pdf.






