We view a program in terms of the natural AST corresponding to the CFG of
Section 4.1. In the AST, an application of one of the four
basic operations is written as a function application node with the
operation to be applied in the *name* attribute and a *depth*
attribute that is 0. The children of the node are expression(s) for each
of the arguments.

The following 3 rules can be used to eliminate all sequence comprehension constructs from the AST:

**Rule 1****Rule 2**- Provided
*e*is an_{2}**Id**or**Num**, and , **Rule 3**- [Note: this is typeset differently in the PostScript version
of this paper.]

The resultant AST can be written out in as Fortran 90 with the depth
attribute supplied as an extra argument to the basic functions (`add`,
`length`, `range`, `dist`). Given an appropriate implementation of
these basic four functions, the resultant program specifies fully parallel
execution of each sequence comprehension construct, regardless of the
degree of nesting and sequence sizes.

For example, using these rules, the program from Section 4.2 would be transformed as follows (using as a shorthand for ):

A = range(depth=0, 3) B = add(depth=1, A, A) C = dist(depth=1, A, length(depth=1, range(depth=1, A)))

Note that functions with operate on scalar arguments, whereas functions with operate on vector arguments.

The rules shown for this example are terminating and confluent. When the source language is more expressive and optimization becomes an issue, the rules used are not necessarily terminating, hence additional sequencing rules must be added to control rule application [10].

In the following sections, we shall show how KHEPERA can be used to implement translations, such as the one specified above, in an efficient manner.