# In Boolean function truth tables in n variables, the table is arranged x_{n-1}, x_{n-2},...,x_1,x_0. How can I change so the order is x_0, x_1,... instead?

In Boolean function truth tables in n variables, the table is arranged x_{n-1}, x_{n-2},...,x_1,x_0. How can I change so the order is x_0, x_1,... instead?

Could you please provide some code showing the situation ?

I enter "from sage . crypto . boolean_function import BooleanFunction" in Sage. Suppose we have the list L={(0,0,0), (0,0,1),...,(1,1,1)} of the 8 binary 3-tuples in lex order and we label them by (x2,x1,x0), which is what Sage does. Then inputs "B=BooleanFunction([1,1,0,0,1,0,1,1])" and "P=B.algebraic_normal_form()" give output " P = x0

x1x2 + x0x2 + x1x2 + x1 + 1". But if we label the entries in L with (x0,x1,x2) (which I want to do and which Mathematica does) then the algebraic normal form for truth table B is "P1 = x0x1x2 + x0x1 + x0x2 + x1 + 1" (that is, we are reversing the order in which x2,x1,x0 are read). My question is how can I get Sage to label tables like L in this way?This is not my forte but it seems this labeling is a convention of Sage. Changing it would entail changing the implementation of

`BooleanFunction`

. Do you really want to change`B`

and/or`P`

? It is much easier to e.g. define`P1 = P.subs(dict(zip(P.parent().gens(), reversed(P.parent().gens()))))`

.Thank you, that is a very nice and simpler solution to the problem.