The algorithm
Let s and s0 be sorts (i.e. ”heads” of the rules), θ a new sort name. θ is a shorthand writing forrsgV(V, s, s0). Letϕbe an injective mapping.
1. If rsgV(V, s, s0) has been called before,θ is already defined.
2. If sis of the form s=s1|...|sn,
defineθ=rsgV(V, s1, s0)|...|rsgV(V, sn, s0).
3. If sis of the form s0=s01|...|s0n,
defineθ=rsgV(V, s, s01)|...|rsgV(V, s, s0n).
4. If sis of the form s=f(s1, ..., sn) ands0=f(s01, ..., s0n), defineθ=f(rsgV(V, s1, s01), ..., rsgV(V, s1, s0n)).
5. If s=f(s1, ..., sn) andf0(s01, ..., s0m), defineθ=
(t,t0)∈ϕ−1(V)∩(L(s)×L(s0))ϕ(t, t0).
Hints
• For your algorithm, use the following regular tree grammars (which are the tree grammars for 0 and 1, where some laws about addition and mul- tiplication are known, do not worry about the background knowledge, it is of no importance here):
s0= 0|s0+s0|s0∗st|st∗s0
s1=succ(s0)|s0+s1|s1+s0|s1∗s1
st= 0|succ(st)|st+st|st∗st
• Constants (which is only 0 in our case) are treated in cases 4 and 5, as they are viewed as nullary functions, ifs = 0 and s0 = 0, use rule 4, if only one of them is 0, use rule 5.
• ϕis supposed to be a function assigning values to an input-pair of numbers.
You can use the notationsv00, v01, v10, v11, where vij is shorthand for a mapping (i, j)→ϕ(i, j) that evaluates toiins0 and toj in s1.
• If I did confuse you completely with the last two points, use the following rule in your algorithm:
If you run acrosss= 0, s0 =succ(0), use θ=v01, fors=succ(0), s0 = 0, use θ = v10 etc. This is not entirely correct but should work in our example.
• If the whole story keeps on confusing you all the time, we will try to clear up some things on tuesday.
1