Literature.
[1] J. Komara. Specification and Verification of Programs. Online.
[2] Ján Kľuka. Úvod do deklaratívneho programovania. Online.
[3] Ján Komara. Recursive Functions. Online.
[CL] Syntax. Identifier conventions:
Variable identifier. A string of lower case letters possibly followed by one or two digits as indices. Examples: , , , .
Function identifier. An alpha-numeric string starting with a capital letter and containing lower case letters, digits, and underline symbols '_'. Examples: , , , .
Square function. The following component contains the explicit definition of the function which returns the square of the number .
Cube function. Write an explicit definition of the function which returns the cube of the number .
Hint. Use the Ins/Del button on the right to insert a new component.
Sum of two squares. Give an explicit definition of the binary function which returns the sum of the squares and .
Minimum of two numbers. The binary function returns the smaller of its two arguments:
The following component contains its explicit clausal definition. Note that the definition uses dichotomy discrimination.
[CL] Remark. Here is an example of syntactically incorrect definition of the same function:
This is because the first application of the minimum function is syntactically different from the second . They should be identical as it is in the previous definition.
Maximum of two numbers. Define the binary function which returns the larger of its two arguments:
Minimum of three numbers. The ternary function returns the smallest of its three arguments:
The following component contains its explicit clausal definition. Note that the definition uses two nested dichotomy discriminations.
Median of three numbers. Define the ternary function which returns the median of its three arguments: