We can create a random function as a substitution table (over arbitrary Cartesian power `d`

of a finite object `K`

, also doing some coersing):

```
import random
from sage.combinat.cartesian_product import CartesianProduct_iters
def get_random_function(K,d):
E = [tuple(e) for e in CartesianProduct_iters(*([K]*d))]
print(E)
D = dict( zip(E,random.choices(E,k=len(E))) )
def rf(x):
return D[tuple(K(e) for e in x)]
return rf
```

Now, we get get two particular random function `my_func1`

and `my_func2`

, and evaluate them on all elements of $GF(2)^4$:

```
my_func1 = get_random_function(GF(2),4)
print([my1_func(x) for x in CartesianProduct_iters(*([GF(2)]*4))])
my_func2 = get_random_function(GF(2),4)
print([my_func2(x) for x in CartesianProduct_iters(*([GF(2)]*4))])
```

Answer to the second question is straightforward:

```
def f(x):
y = (x[0]+x[1], x[2], x[3], x[0])
return (GF(2)(e) for e in y)
print( f( (1,1,1,1) ) )
```

What do you mean by random? You want it uniformly among all possible functions?

Yes, it is taken uniformly among all possible functions.