# Problem 5; 26-May-2000

## XML: Foundations, Techniques, Applications; Summer 2000

### Harold Boley; DFKI, Univ. Kaiserslautern

Recall the (first-order) functions (over numbers) double, foo, and cube from Problem 3.

The (higher-order) function compose can be defined as compose(F,G)(x) := F(G(x)) or compose[F,G](X) :& F(G(X)). Its parameters F and G are themselves functions; its argument x or X can be anything. The RFML markup of compose is

```<ft>
<pattop>
<struc>
<con>compose</con>
<var>f</var>
<var>g</var>
</struc>
<var>x</var>
</pattop>
<callop>
<var>f</var>
<callop>
<var>g</var>
<var>x</var>
</callop>
</callop>
</ft>
```

Another (higher-order) function, sumfun, is defined as sumfun(F,G)(x) := F(x) + G(x) or sumfun[F,G](X) :& +(F(X),G(X)).

a) Describe in English the meaning of compose. Test it in the Relfun system and report the values of the calls compose[double,cube](3), compose[double,compose[cube,foo]](2), and compose[compose[double,cube],foo](2). Can you prove compose[F,compose[G,H]] = compose[compose[F,G],H] as a law? Give (as many parts as possible of) the MathML markup of compose.

b) Describe in English the meaning of sumfun. Test it in the Relfun system and report the value of the call sumfun[cube,double](3). Can you prove sumfun[F,G] = sumfun[G,F] as a law? Mark up sumfun in RFML and (as far as possible) in MathML.