ϵ">]>
Literature.
[1] J. Komara. Specification and Verification of Programs. Downloadable lecture notes available through the web page of the course.
[2] J. Komara and P. J. Voda. Metamathematics of Computer Programming. 2001.
Exercise. Your task is to use CL as a simple calculator for the evaluation of arithmetic expressions in the form of so-called queries. The window Query which appears at the end is designed for the input of queries. The result of a given query will be displayed in the window Results.
Examples of simple queries:
Addition. Query: . CL-syntax is: . Result: true for .
Modified subtraction. Query: . CL-syntax is: . Result: true for .
Multiplication. Query: . CL-syntax is: . Result: true for .
Integer (Euclidean) division. Query: . CL-syntax is: . Result: true for .
Remainder after integer division. Query: . CL-syntax is: . Result: true for .
Further apply these queries:
The last two examples illustrate the following properties of arithmetic operators:
Exercise. It is possible to evaluate also compound queries (conjunctions of simple queries). For instance
CL-syntax is:
Result: true for , , and .
Examples of syntactically incorrect queries (when reading the queries from left to right):
. The variable has not been assigned a value.
. The variable has not been assigned a value.
. The variable has not been assigned a value.
Exercise. Your next task is to use CL for the evaluation of arithmetic comparison relations.
Examples of simple queries:
Query: . CL-syntax: . Result: true.
Query: . CL-syntax: . Result: false.
Query: . CL-syntax: . Result: true.
Query: . CL-syntax: . Result: false.
Query: . CL-syntax: . Result: false.
Query: . CL-syntax: . Result: true.
Example of a compound query:
Query: . Result: true.
Examples of syntactically incorrect queries:
. The variable has not been assigned a value.
. The variable has not been assigned a value.
[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 next component contains the explicit definition of the function which yields the square of the number .
Cube function. Write an explicit definition of the function which yields the cube of the number .
Hint. Use the Ins/Del button.
Sum of two squares. Write an explicit definition of the binary function which yields the sum of the squares and .