# Question:Why does `applyrule` fail to apply rules?

## Question:Why does `applyrule` fail to apply rules?

Maple 2023

I would like to simulate the evolution of the so-called B, C, K, W system and SKI combinator calculus in Maple.
The rewrite rules of them are simple:

S(x)(y)(z)＝x(z)(y(z))
K(x)(y)＝x, and
I(x)＝x. (Note that since I is protected, I shall use cI hereafter.)

However, if I try to evaluate the following example given in the Wikipedia article,

Maple will only return an unchanged result:

```restart;
applyrule([cS(x::anything)(y::anything)(z::anything) = x(z)(y(z)),
cK(x::anything)(y::anything) = x, cI(x::anything) = x],
cS(cK(cS(cI)))(cS(cK(cK))(cI))(x)(y)); # Unable to reduce???
=
cS(cK(cS(cI)))(cS(cK(cK))(cI))(x)(y)

```

I believe that this is not an outlier.

```> rls := [cS(x::anything)(y::anything)(z::anything) = x(z)(y(z)), cK(x::anything)(y::anything) = x]:
> map2(applyrule, rls, [cS(cS(cS)(cS))(cS)(cS(cS))(cK), cS(cS(cS))(cS)(cS)(cS)(cS(cS)(cK(cK)))]);
[cS(cS(cS)(cS))(cS)(cS(cS))(cK), cS(cS(cS))(cS)(cS)(cS)(cS(cS)(cK(cK)))]

>```

So why can't `applyrule` apply rules as desired? Meanwhile, how to automatically and thoroughly (like `:-eval['recurse']` or `MmaTranslator:-Mma:-ReplaceRepeated`) apply those transformation rules to

1. cS(cK(cS(cI)))(cS(cK(cK))(cI))(x)(y)
2. cS(cS(cS)(cS))(cS)(cS(cS))(cK), and
3. cS(cS(cS))(cS)(cS)(cS)(cS(cS)(cK(cK)))

I have read something like How to apply a recursive rule in an expression? - MaplePrimes, but they are not the same issue.

﻿