Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

We can 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_func 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):
  return (x[0]+x[1], x[2], x[3], x[0])
print( f( (1,1,1,1) ) )

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_func 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):
  return (x[0]+x[1], x[2], x[3], x[0])
print( f( (1,1,1,1) ) )

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_funcmy_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):
  return (x[0]+x[1], x[2], x[3], x[0])
print( f( (1,1,1,1) ) )

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):
  return  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) ) )