Group Theory: When is the sum of two permutations a permutation?

I have to work with encrypted data, a problem arises as follows:
Suppose we have $ sigma_1, sigma_2 in S_X $, $ | X | = 2k + 1 $. What conditions is $ sigma_1 (X) + sigma_2 (X) = sigma (X) $. For example, considering the symmetric group. $ S_5 $, with $ sigma_1 = (1 $ 5) (2 $ 3) $ Y $ sigma_2 = (1 3 2 4) $ so $ sigma_1 + sigma_2 = sigma = (1 3 4 5) in S_5 $. Additionally, if there is a method to generate a given permutation $ sigma_i & # 39; s $ without using the operator $ circ $ in a group $ S_n $ or not.

Thanks in advance.

permutations: decomposition of a symmetric function into elementary symmetric polynomials.

It is stated that any symmetric function can be expressed in terms of the elementary symmetric polynomials. I'm trying to do that for the next generation function:

begin {equation}
prod_ {1 leq i <j leq k} (x_ {i} + x_ {j}).
end {equation}

It seems that I can not find a way to do this in general. However, I can see some kind of pattern, which involves monomial symmetric functions, which are

begin {equation}
m {1,2}} = x_1 x_2 ^ 2 + x_1 ^ 2 x_2,
end {equation}

and similarly for any $ k $. The values ​​subscribed in $ m $ it can be any whole

I have shown that this can be done for cases. $ k = 1,2 $ in which cases do we get

begin {equation}
prod_ {1 leq i <j leq 2} (x_ {i} + x_ {j}) = (x_1 + x_2) = frac {m _ {(1,2)}} { sigma_2 ^ {( two )}},
end {equation}

begin {equation}
prod_ {1 leq i <j leq 3} (x_ {i} + x_ {j}) = frac {m _ {(1,2,3)}} { sigma_3 ^ {(3)}} + 2 sigma_3 ^ {(3)},
end {equation}

and to $ k + 4 $ I get something in the form of
begin {equation}
prod_ {1 leq i <j leq 4} (x_ {i} + x_ {j}) = frac {m _ {(1,2,3,4)}} { sigma_4 ^ {(4) }} + ?,
end {equation}

that I can not solve, at least not easily, although I will do the tedious calculation. (Is there any way to employ monomial symmetric functions in mathematics in any way?)

Main question, is there already a known decomposition of this generating function? If so, what is it? If not, how should I do to make one? Or at least be able to determine it for values ​​up to $ k = 6 $.

performance – Python program to print all the permutations of a string in lexicographical order using the recursion

A task at school required that he print all the permutations of a string in lexicographic or dictionary order.

Here is my solution to the task –

of factorial math of import

def print_permutations_lexicographic_order (s):

seq = list (s)
for _ in range (factorial (len (seq))):
print (& # 39; & # 39; join (seq))
nxt = get_next_permutation (seq)
# if seq is the highest permutation
if nxt is none:
# then reverse it
seq.reverse ()
plus:
seq = nxt

def get_next_permutation (seq):
""
Next return greater lexicographical permutation. Return none if you can not.

This will return the next greater permutation of sequences in lexicographical order. If seq is the highest permutation, this will return None.

seq is a list.
""
if len (seq) == 0:
return none

nxt = get_next_permutation (seq[1:])

# whether[1:] is the highest permutation
if nxt is none:
# reverse seq[1:], so that it[1:] now it is in ascending order
I know that[1:] = inverted (seq[1:])

# find q such that seq[q] it is the smallest element in the sequence[1:] such that
# I know that[q] > seq[0]
        q = 1
while q < len(seq) and seq[0] > I know that[q]:
q + = 1

# If you can not find q, then seq is the highest permutation
if q == len (seq):
return none

# swap seq[0] and seq[q]
        I know that[0], I know that[q] = seq[q], I know that[0]

        return seq
plus:
he came back[Iknowthat[Iknowthat[seq[seq[0]]+ nxt


s = entry (& # 39; Enter the string: & # 39;)
print_permutations_lexicographic_order (s))

Here are some examples of inputs / outputs:

Enter the string: cow
>>> cow
cwo
ocw
owc
wco
woc

Enter the chain: dogs
>>> dogs
dosg
dsgo
dsog
gdos
gdso
hen house
gosd
gsdo
gsod
odgs
odsg
ogds
ogsd
osdg
osgd
sdgo
dog
sgdo
sgod
sodg
sogd
ogds
ogsd

So, I would like to know if I could make my program shorter and more efficient.

Any help would be greatly appreciated.

co.combinatorics – Circular permutations (bracelets) with similar things (reflections are equivalent) using the enumeration of polia

The circular permutations of N objects of n1 are identical of one type, n2 are identical of another type and so on, so that n1 + n2 + n3 + ….. = N?
There is a similar question but it does not address the case in which the reflections are under the same equivalent class.$$ frac {1} {N} sum_ {d | N} phi (d) p_d ^ {N / d} $$ This is when the reflections are not the same. How does the equation change under this new restriction?

Note: I could not comment on that question because of my low reputation, so I asked this question.

Unique data: algorithm for permutations of a string of characters, without duplicate orders

I have seen many good questions about similar problems, but not exactly what I am looking for.

Dice: a non-unique set of symbols (or characters)

(1, 1, 2, 3)

Expected: an exit similar to this one (the order is not important, only the elements cast)

1123
1132
1213
1231
1312
1321
2113
2131
2311
3112
3121
3211

I know I could channel the permutation output into another algorithm similar to uniq Bash command but I'm going to use this in big chains and I want the "singularity" to be done on the fly, not after the fact.

I imagine that the easiest way to do something like this is to use a hash in the permutation algorithm, the key being the permutations, but is there a smarter way to do it? Am I missing a great trick here?

Edit: For better examples, I have provided two more

# given a set (1,1,1,2,3)
[1, 1, 1, 2, 3]
[1, 1, 1, 3, 2]
[1, 1, 2, 1, 3]
[1, 1, 2, 3, 1]
[1, 1, 3, 1, 2]
[1, 1, 3, 2, 1]
[1, 2, 1, 1, 3]
[1, 2, 1, 3, 1]
[1, 2, 3, 1, 1]
[1, 3, 1, 1, 2]
[1, 3, 1, 2, 1]
[1, 3, 2, 1, 1]
[2, 1, 1, 1, 3]
[2, 1, 1, 3, 1]
[2, 1, 3, 1, 1]
[2, 3, 1, 1, 1]
[3, 1, 1, 1, 2]
[3, 1, 1, 2, 1]
[3, 1, 2, 1, 1]
[3, 2, 1, 1, 1]







# given a set (1, 1, 2, 2, 3)
[1, 1, 2, 2, 3]
[1, 1, 2, 3, 2]
[1, 1, 3, 2, 2]
[1, 2, 1, 2, 3]
[1, 2, 1, 3, 2]
[1, 2, 2, 1, 3]
[1, 2, 2, 3, 1]
[1, 2, 3, 1, 2]
[1, 2, 3, 2, 1]
[1, 3, 1, 2, 2]
[1, 3, 2, 1, 2]
[1, 3, 2, 2, 1]
[2, 1, 1, 2, 3]
[2, 1, 1, 3, 2]
[2, 1, 2, 1, 3]
[2, 1, 2, 3, 1]
[2, 1, 3, 1, 2]
[2, 1, 3, 2, 1]
[2, 2, 1, 1, 3]
[2, 2, 1, 3, 1]
[2, 2, 3, 1, 1]
[2, 3, 1, 1, 2]
[2, 3, 1, 2, 1]
[2, 3, 2, 1, 1]
[3, 1, 1, 2, 2]
[3, 1, 2, 1, 2]
[3, 1, 2, 2, 1]
[3, 2, 1, 1, 2]
[3, 2, 1, 2, 1]
[3, 2, 2, 1, 1]

Mathematical optimization – NMaximize with a variable that varies over the permutations

I have an optimization problem where there $ n $ activities and
I want to find an optimal schedule of those activities.

The schedule is specified as $ S = ( mathbf {t}, p) $ where:

  • $ mathbf {t} = left (t_ {1}, dots, t_ {n} right) $ specifies the assigned times
    to activities
  • $ p $ It is the order of the activities, so it is a member of the set.
    of permutations on $ n $ elements.

The restriction is mainly that there is a finite total time, so $ sum {} _ {i = 0} ^ {n} t_ {i} = T $. There is also the restriction that, for all $ i $, $ t_ {i}> 0 $.

The objective function, to be maximized, is $ F ( mathbf {t}, p) $; to keep the question short I will mention the way to $ F $, if relevant, after the question.

The question is how to put this optimization problem in Mathematica. There would be dozens of variables, so I can not thoroughly analyze all the permutations, but some local / heuristic search algorithm would probably do a good job; I do not need the global maximum.

My main problem is with $ p $, that is, put in the order of the activities. Without the order, I can put it in Mathematica with NMaximize in the following way:

NMaximize[
  { 
     u1[t1]+ u2[t2]+ u3[t3],
{t1 + t2 + t3 == 365, t1> 0, t2> 0, t3> 0}
}, {t1, t2, t3}
]

I just showed an example with 3 variables for brevity, but I can also do something similar with dozens of variables and it seems to work well.

Extra idea: Maybe another way to model it is by specifying $ 2n $ variables, a start time and an end time for each activity and, in some way, produce all the restrictions that two activities must not overlap. This would leave the possibility of "dead time" without activity, but that should be fine.

Information on how to $ F $ (if relevant)

$$
F ( mathbf {t}, p) = sum limits_ {i = 0} ^ {n} left (u_ {i} left (t_ {i} right) -p_ {i} left (s_ {i} right) right)
$$

where:

  • $ u_ {i} $ is a utility / benefit of putting $ t_ {i} $ time in activity $ i $; I will specify it for each activity and it would be a monotonously increasing but not linear function in general.
  • $ s_ {i} $ It is the start time of the activity. $ i $, which is equal to the sum
    of the $ t_ {i} $ for the activities that precede it (according to the
    order specified by $ p $). So, $ s_ {i} $ It depends on both $ p $ Y $ mathbf {t} $.
  • $ p_ {i} $ is a penalty function that gives a decrease in profit / benefit because the activity is delayed by $ s_ {i} $ hour.

algorithms – list of lexicographic permutations

/ * lists all the permutations of the first n positive integers * /

/ * In lexicographical order. * /

typedef int Bool;

int a[N + 1], n;

void step_in (void);

void next_permutation (const int left_index, const int right_index);

void print_permutation (void);

void get_n (void);

void initialize_a (void);

principal()

{

get_n ();

initialize_a ();

He passed();

returns 0;

}

/ ************************************************ * *********

  • step_in: this recursive function manipulates the *

  • values ​​of left_index, right_index and *

  • address. These variables control the *

  • General flow of the algorithm, determinant *.

  • if a permutation must be calculated or *

  • printed and if the function should be *

  • stepped out *

********************************************** * ********

void step_in (void)

{

static enumeration {LEFT, RIGHT} direction = RIGHT;

static left_index = 0;

int right_index; / * successive calls from step_in hide * /

/ * previous values ​​of right_index * /

for (;;) {

yes (address == RIGHT) {

++ left_index;

right_index = n;

if (left_index == n – 1) {

print_permutation ();

next_permutation (left_index, right_index);

print_permutation ();

direction = LEFT;

break;

}

else if (left_index <n – 1)

He passed();

else {

/ * special cases where n equals 0 or 1 are treated here * /

print_permutation ();

break;

}

}

else {

–left_index;

if (left_index <right_index) {

next_permutation (left_index, right_index);

–right_index;

address = RIGHT;

He passed();

}

plus

break;

}

}

}

/ ************************************************ * *********

  • next_permutation: swap the elements of the matrix to *

  • between them to get a new one *

  • Permutation of these elements. *

********************************************** * ********

void next_permutation (const int left_index, const int right_index)

{

int i;

int temp[N + 1];

int top = left_index;

temperature[top] = a[right_index];

++ above;

for (i = n; i> right_index; top ++, i–)

temperature[top] = a[i];

temperature[top] = a[left_index];

++ above;

for (i = right_index – 1; i> left_index; top ++, i–)

temperature[top] = a[i];

for (i = left_index; i <= n; i ++)

a[i] = temp[i];

}

/ ************************************************ * *********

  • print_permutation: print the current permutation. *

********************************************** * ********

void print_permutation (void)

{

int i;

printf (" n (");

yes (n> 0) {

printf ("% 2d", a1);

for (i = 2; i <= n; i ++)

printf (",% 2d", a[i]);

}

printf (") n n");

}

/ ************************************************ * *********

  • get_n: prompts the user for the permutation length n. Read all *

  • Characters entered by the user to the new line *

  • character. Repeat if there is invalid data or a *

  • The illegal permutation length is entered. *

********************************************** * ********

void get_n (void)

{

Bool invalid_int_val;

char next_char;

for (;;) {

invalid_int_val = FALSE;

printf (" n");

printf ("Enter n:");

scanf ("% d", & n);

for(;;) {

if ((next_char = getchar ()) == & # 39; n & # 39;)

break;

else if (next_char! = & # 39; & # 39; && next_char! = & # 39; t & # 39;) {

invalid_int_val = TRUE;

for (; getchar ()! = & # 39; n & # 39 ;;)

;

break;

}

}

yes (invalid_int_val || n < 0 || n > N) {

printf (" n");

printf ("The number n must be an integer between% d and% d.
again. n ", 0, N);

}

plus

break;

}

}

/ ************************************************ * *********

  • initialize_a: initialize the array a. *

********************************************** * ********

void initialize_a (void)

{

int i;

for (i = 1; i <= n; i ++)

a[i] = i;

}

Creation of a list of permutations given a condition with the GAP system

Please, I am new to the GAP system and I am trying to prove the following simplified form of code where I try to test a given condition in a set of permutations and then add to the list M of the permutations that satisfy the given equation. The objective is to calculate the appropriate values ​​of the variables a and b.

> S: =[1,2,3];; T: =[1,2,3];; M: =[];;
> for a in S do for b in T
> do if b <> a and (1, a) * (b, 3) = (1,2,3) then
> Add (M, [[1, a], [b,3]]); fi overdose; overdose;
> M;

Here is the error message that I received

Syntax error :: = expected
SUBWAY;
^

Please, if I can get this fixed code or an alternative way to achieve a similar goal. Below is my expected result:

[[[1,2],[1,3]],

The[[[1,3],[2,3]]].

permutations – Is "$ forall x in L, sigma ( neg x) = neg sigma (x) $" given that $ sigma (F) equiv F $ for a formula CNF $ F $ built in a $ L $ set of literals?

No. Suppose $ F $ is the formula

$$ (x_1 lor x_2) land ( neg x_1 lor x_2) land (x_1 lor neg x_2) land ( neg x_1 lor neg x_2) land (x_1 lor neg x_1) land (x_2 lor neg x_2), $$

and consider the permutation $ sigma $ such that $ sigma (x_1) = x_2 $, $ sigma (x_2) = neg x_1 $, $ sigma ( neg x_1) = x_1 $Y $ sigma ( neg x_2) = neg x_2 $.

So $ sigma (F) equiv F $, but $ sigma ( neg x_1) ne neg sigma (x_1) $.

c # – The best way of performance permutations

enter the description of the image here

This has been my white whale for a while, the idea is to convert all the symbols to the goal symbol using everyone tHE PIECES.

I did an algorithm like 5 years ago (now it's lost) and I reached level 48 but I got stuck here and fell. After watching The Imitation Game and seeing how Turin solves the enigma using a Heil Hitler to reduce the search for space, I decided to give it a second chance.

I try to solve row by row. First you have to see how many laps you need each row and then find a set of pieces with enough squares to flip all the symbols or a multiple of the symbol cycle (in this case 3)

In the original version, when I found a set, I try to put the pieces in each column to see if it can resolve the row if that happens, and then go to the next row. Now I do not try to solve it, but I directly try to go to the next row with fewer pieces. I'm not sure which is the best approach.

With these 18 pieces, 6.5E25 combinations to place them on the board (consider that the machine engimates has 15E18). But if you try to solve only the flips in the first row, you have 2 ^ 18 = 262k combinations of sets, of which only 84k has the correct number of flips. That is the greatest cunning I could find.

My hope is that there is some algorithm that allows me to further reduce the search space or some optimization that I can use to improve search speed.

Shape

[Serializable()]



Public class Form: ICloneable
{
public int Height {get; set; }
public int Width {get; set; } // I will use Width to test by column later
int public[] Changes {get; set; } // How many flips
Long public identification {obtain; set; }
public int RowPosition {get; set; } // In which row am I using the piece?
public int MaxRow {get; set; } // What is the last row where it can fit

Public form (double id, int[] piece, int height)
{
Changes = piece;
Height = height;
Id = (long) id;
RowPosition = -1;
MaxRow = 8 - height;
}

Public Object Clone ()
{
returns this.MemberwiseClone ();
}
}

Solution

[Serializable()]



Public class solution: ICloneable
{
private reading only[] Game = new int[8] {3, 8, 6, 7, 7, 8, 9, 7};
Public list Pieces {get; set; }
Long public identification {obtain; set; }

Public solution ()
{
Pieces = new list();
}

// Returns a deep clone of a type T object.
public object DeepClone ()
{
using (MemoryStream memory_stream = new MemoryStream ())
{
// Serialize the object in the memory stream.
BinaryFormatter formatter = new BinaryFormatter ();
formatter.Serialize (memory_stream, this);

// Rewind the sequence and use it to create a new object.
memory_stream.Position = 0;
return (Solution) formatter.Deserialize (memory_stream);
}
}

public bool TestRowFlips (int row)
{
In t[] Changes = new int[8] {0, 0, 0, 0, 0, 0, 0, 0};

foreach (Form p in pieces)
{
for (int i = 0; i < p.Height; i++)
            {
                Changes[ i + p.RowPosition ] += p.Changes[i];
            }
        }

        if ((Changes[row] - Game[row]) % 3 == 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public bool ExistPiece(long id)
    {
        return Pieces.Any(x => x.Id == id);
}
}

Recursive

recursive class
{
Private list Pieces {get; set; }

Public vacuum configuration ()
{
Pieces = new list
        {
New form (Math.Pow (2, 0), new int[5] {2, 1, 2, 0, 0}, 3),
New form (Math.Pow (2, 1), new int[5] {2, 1, 0, 0, 0}, 2),
New form (Math.Pow (2, 2), new int[5] {2, 2, 2, 0, 0}, 3),

New form (Math.Pow (2, 3), new int[5] {3, 1, 3, 0, 0}, 3),
New form (Math.Pow (2, 4), new int[5] {4, 3, 3, 3, 0}, 4),
New form (Math.Pow (2, 5), new int[5] {3, 0, 0, 0, 0}, 1),

New form (Math.Pow (2, 6), new int.[5] {3, 1, 3, 0, 0}, 3),
New form (Math.Pow (2, 7), new int.[5] {3, 4, 1, 2, 2}, 5),
New form (Math.Pow (2, 8), new int[5] {1, 0, 0, 0, 0}, 1),

New form (Math.Pow (2, 9), new int[5] {2, 2, 2, 0, 0}, 3),
New form (Math.Pow (2, 10), new int.[5] {2, 3, 4, 0, 0}, 3),
New form (Math.Pow (2, 11), new int.[5] {1, 3, 1, 3, 2}, 5),

New form (Math.Pow (2, 12), new int.[5] {1, 2, 2, 0, 0}, 3),
New form (Math.Pow (2, 13), new int.[5] {2, 4, 1, 1, 0}, 4),
New form (Math.Pow (2, 14), new int.[5] {1, 2, 1, 0, 0}, 3),

New form (Math.Pow (2, 15), new int[5] {1, 1, 3, 0, 0}, 3),
New form (Math.Pow (2, 16), new int.[5] {3, 2, 3, 1, 0}, 4),
New form (Math.Pow (2, 17), new int.[5] {1, 3, 2, 2, 0}, 4)
};
// try to solve the first row
for (long PieceSet = 0; PieceSet < Math.Pow(2, 18); PieceSet++)
        {
            Solution solution = new Solution();
            foreach (Shape piece in Pieces)
            {
                if ((piece.Id & PieceSet) > 0)
{
Form p = (Form) piece.Clone ();
p.RowPosition = 0;
solution.Piezas.Add (p);
}
}

if (solution.TestRowFlips (0))
{
solution.Id = PieceSet;
Solve_Row (solution, 1);
}
}
}

public bool Solve_Row (Solution solution, int rowToSolve)
{
// Check the unused parts to see if they are too large to be used in any other row.
if (Pieces.Any (x => (x.Id & solution.Id) == 0 && x.MaxRow <rowToSolve))
{
false return;
}

for (long pieceSet = 0; pieceSet < Math.Pow(2, 18); pieceSet++)
        {          
            if ((pieceSet & solution.Id) == 0)
            {
                Solution newSolution = (Solution)solution.DeepClone();

                foreach (Shape piece in Pieces.Where(x => (x.Id & pieceSet)> 0)
.To list())
{
Form p = (Form) piece.Clone ();
p.RowPosition = rowToSolve;
newSolution.Pieces.Add (p);
}

newSolution.Id = newSolution.Id | pieceSet;

if (newSolution.Id == Pieces.Sum (x => x.Id))
{
Debug.Print ("Found a Solution");
true returns
}

if (newSolution.TestRowFlips (rowToSolve))
{
Solve_Row (newSolution, rowToSolve + 1);
}
}
}
false return;
}


}