Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 4 years ago

Max Alekseyev gravatar image

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution.

From this consideration, it should be easy to construct a particular F.

click to hide/show revision 2
No.2 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution.

From this consideration, it should be easy to construct a particular F.

click to hide/show revision 3
No.3 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution.

From this consideration, it should be it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    C1 = A1 & B1
    C2 = A2 & B2

    A1s = A1 - C1
    A2s = A2 - C2

    B1s = B1 - C1
    B2s = B2 - C2

    assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    return list( zip(C1,C1,[num]*len(C1)) ) + list( zip(C2,C2,[num]*len(C2)) ) + list( zip(A1s,B1s,[num]*len(A1s)) ) + list( zip(A2s,B2s,[num]*len(A2s)) )

def construct_F( L1, LL1, L2, LL2 ):
    N = { n for _,n in L1+L2 }
    return sum( (construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N), [] )

Running construct_F( L1, LL1, L2, LL2 ) on your first example returns:

 [((4, 3, 2, 1), (2, 2, 2, 1), 2),
 ((2, 3, 2, 1), (2, 3, 2, 1), 3),
 ((3, 2, 2, 1), (3, 2, 2, 1), 3),
 ((3, 3, 2, 1), (3, 3, 2, 1), 3),
 ((2, 2, 2, 1), (4, 3, 2, 1), 4)]

This is not exactly in the format you want, but reformatting should be easy.

click to hide/show revision 4
No.4 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    C1 = A1 & B1
    C2 = A2 & B2

    A1s = A1 - C1
    A2s = A2 - C2

    B1s = B1 - C1
    B2s = B2 - C2

    assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    return list( zip(C1,C1,[num]*len(C1)) ) + list( zip(C2,C2,[num]*len(C2)) ) + list( zip(A1s,B1s,[num]*len(A1s)) ) + list( zip(A2s,B2s,[num]*len(A2s)) )

def construct_F( L1, LL1, L2, LL2 ):
    N = { n for _,n in L1+L2 }
    return sum( (construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N), [] )

Running construct_F( L1, LL1, L2, LL2 ) on from your first example returns:

 [((4, 3, 2, 1), (2, 2, 2, 1), 2),
 ((2, 3, 2, 1), (2, 3, 2, 1), 3),
 ((3, 2, 2, 1), (3, 2, 2, 1), 3),
 ((3, 3, 2, 1), (3, 3, 2, 1), 3),
 ((2, 2, 2, 1), (4, 3, 2, 1), 4)]

This is not exactly in the format you want, but reformatting should be easy.

click to hide/show revision 5
No.5 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution.involution. In particular, we can take F to be the identity on C1C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    C1 = A1 & B1
    C2 = A2 & B2

    A1s = A1 - C1
    A2s = A2 - C2

    B1s = B1 - C1
    B2s = B2 - C2

    assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    C = C1 + C2

    return list( zip(C1,C1,[num]*len(C1)) ) + list( zip(C2,C2,[num]*len(C2)) zip(C,C,[num]*len(C)) ) + list( zip(A1s,B1s,[num]*len(A1s)) ) + list( zip(A2s,B2s,[num]*len(A2s)) )

def construct_F( L1, LL1, L2, LL2 ):
    N = { n for _,n in L1+L2 }
    return sum( (construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N), [] )

Running construct_F( L1, LL1, L2, LL2 ) from your first example returns:

 [((4, 3, 2, 1), (2, 2, 2, 1), 2),
 ((2, 3, 2, 1), (2, 3, 2, 1), 3),
 ((3, 2, 2, 1), (3, 2, 2, 1), 3),
 ((3, 3, 2, 1), (3, 3, 2, 1), 3),
 ((2, 2, 2, 1), (4, 3, 2, 1), 4)]

This is not exactly in the format you want, but reformatting should be easy.

click to hide/show revision 6
No.6 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. In particular, we can take F to be the identity on C1C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    C1 = A1 & B1
    C2 = A2 & B2

    A1s = A1 - C1
    A2s = A2 - C2

    B1s = B1 - C1
    B2s = B2 - C2

    assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    C = C1 + | C2

    return list( zip(C,C,[num]*len(C)) ) + list( zip(A1s,B1s,[num]*len(A1s)) ) + list( zip(A2s,B2s,[num]*len(A2s)) )

def construct_F( L1, LL1, L2, LL2 ):
    N = { n for _,n in L1+L2 }
    return sum( (construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N), [] )

Running construct_F( L1, LL1, L2, LL2 ) from your first example returns:

 [((4, 3, 2, 1), (2, 2, 2, 1), 2),
 ((2, 3, 2, 1), (2, 3, 2, 1), 3),
 ((3, 2, 2, 1), (3, 2, 2, 1), 3),
 ((3, 3, 2, 1), (3, 3, 2, 1), 3),
 ((2, 2, 2, 1), (4, 3, 2, 1), 4)]

This is not exactly in the format you want, but reformatting should be easy.

click to hide/show revision 7
No.7 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. In particular, we can take F to be the identity on C1C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    C1 = A1 & B1
    C2 = A2 & B2

    A1s = A1 - C1
    A2s = A2 - C2

    B1s = B1 - C1
    B2s = B2 - C2

    assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    C = C1 | C2

    return list( zip(C,C,[num]*len(C)) ) + list( zip(A1s,B1s,[num]*len(A1s)) ) + list( zip(A2s,B2s,[num]*len(A2s)) )

def construct_F( L1, LL1, L2, LL2 ):
    N = { n for _,n in L1+L2 }
    return sum( (construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N), [] )

Running construct_F( L1, LL1, L2, LL2 ) on the sets from your first example returns:

 [((4, 3, 2, 1), (2, 2, 2, 1), 2),
 ((2, 3, 2, 1), (2, 3, 2, 1), 3),
 ((3, 2, 2, 1), (3, 2, 2, 1), 3),
 ((3, 3, 2, 1), (3, 3, 2, 1), 3),
 ((2, 2, 2, 1), (4, 3, 2, 1), 4)]

This is not exactly in the format you want, but reformatting should be easy.

click to hide/show revision 8
No.8 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. In particular, we can take F to be the identity on C1C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    C1 = A1 & B1
    C2 = A2 & B2

    A1s = A1 - C1
    A2s = A2 - C2

    B1s = B1 - C1
    B2s = B2 - C2

    assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    C = C1 | C2

    return list( zip(C,C,[num]*len(C)) ) + list( zip(A1s,B1s,[num]*len(A1s)) ) + list( zip(A2s,B2s,[num]*len(A2s)) )

def construct_F( L1, LL1, L2, LL2 ):
    N = { n for _,n in L1+L2 }
    return sum( (construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N), [] )

Running construct_F( L1, LL1, L2, LL2 ) on the sets lists from your first example returns:

 [((4, 3, 2, 1), (2, 2, 2, 1), 2),
 ((2, 3, 2, 1), (2, 3, 2, 1), 3),
 ((3, 2, 2, 1), (3, 2, 2, 1), 3),
 ((3, 3, 2, 1), (3, 3, 2, 1), 3),
 ((2, 2, 2, 1), (4, 3, 2, 1), 4)]

This is not exactly in the format you want, but reformatting should be easy.

click to hide/show revision 9
No.9 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. involution. In particular, we can take F to be the identity on C1C2.

UPDATE. Since we are given that \left.F\right_{A_1\cup B_1} = G, we only need to define F on A2B2. In particular, we can take F to be the identity on C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    C1 #C1 = A1 & B1
    C2 = A2 & B2

    A1s #A1s = A1 - C1
    A2s = A2 - C2

    B1s #B1s = B1 - C1
    B2s = B2 - C2

    assert #assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    C = C1 | C2
# conversion for output
    A2l = [[list(q),num] for q in A2s]
    B2l = [[list(q),num] for q in B2s]
    C2l = [[list(q),num] for q in C2]

    return list( zip(C,C,[num]*len(C)) ) [list(t) for t in zip(C2l,C2l)] + list( zip(A1s,B1s,[num]*len(A1s)) ) + list( zip(A2s,B2s,[num]*len(A2s)) )
 [list(t) for t in zip(A2l,B2l)]

def construct_F( L1, LL1, L2, LL2 LL2, G ):
    N = { n for _,n in L1+L2 }
    return sum( (construct_F_fixed_num( [construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N), [] N], G )

Running construct_F( L1, LL1, L2, LL2 LL2, G ) on the lists from your first example returns:

 [((4, [[[[2, 2, 2, 1], 4], [[4, 3, 2, 1), (2, 2, 2, 1), 2),
 ((2, 1], 4]],
 [[[3, 2, 2, 1], 3], [[2, 3, 2, 1), (2, 1], 3]],
 [[[2, 3, 2, 1), 3),
 ((3, 2, 2, 1), (3, 2, 2, 1), 3),
 ((3, 1], 3], [[3, 2, 2, 1], 3]],
 [[[4, 3, 2, 1), (3, 1], 2], [[2, 2, 2, 1], 2]],
 [[[3, 3, 2, 1), 3),
 ((2, 2, 2, 1), (4, 1], 3], [[3, 3, 2, 1), 4)]
1], 3]]]

This


As for the number of different involutions F, it equals |A2|!ι(|C2|), where ι() is not exactly in the format you want, but reformatting should be easy.

the involution number given by OEIS A000085. The factor |A2|! accounts for bijections between on A2 and B2, while ι(|C2|) accounts for involutions on C2.

click to hide/show revision 10
No.10 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. In particular, we can take F to be the identity on C1C2.

UPDATE. Since we are given that \left.F\right_{A_1\cup B_1} = G, we only need to define F on A2B2. In particular, we can take F to be the identity on C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    #C1 = A1 & B1
    C2 = A2 & B2

    #A1s = A1 - C1
    A2s = A2 - C2

    #B1s = B1 - C1
    B2s = B2 - C2

    #assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    # conversion for output
    A2l = [[list(q),num] for q in A2s]
    B2l = [[list(q),num] for q in B2s]
    C2l = [[list(q),num] for q in C2]

    return [list(t) for t in zip(C2l,C2l)] +  [list(t) for t in zip(A2l,B2l)]

def construct_F( L1, LL1, L2, LL2, G ):
    N = { n for _,n in L1+L2 }
    return sum( [construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N], G )

Running construct_F( L1, LL1, L2, LL2, G ) on the lists from your first example returns:

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

As for the number of different involutions F, it equals |A2|!ι(|C2|), where ι() is the involution number given by OEIS A000085. The factor |A2|! accounts for bijections between on A2 and B2, while ι(|C2|) accounts for involutions on C2.

click to hide/show revision 11
No.11 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. In particular, we can take F to be the identity on C1C2.

UPDATE. Since we are given that $\left.F\right_{A_1\cup $\left.F\right|_{A_1\cup B_1} = G,weonlyneedtodefineFonA_2\cup B_2.Inparticular,wecantakeFtobetheidentityonC_2$.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    #C1 = A1 & B1
    C2 = A2 & B2

    #A1s = A1 - C1
    A2s = A2 - C2

    #B1s = B1 - C1
    B2s = B2 - C2

    #assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    # conversion for output
    A2l = [[list(q),num] for q in A2s]
    B2l = [[list(q),num] for q in B2s]
    C2l = [[list(q),num] for q in C2]

    return [list(t) for t in zip(C2l,C2l)] +  [list(t) for t in zip(A2l,B2l)]

def construct_F( L1, LL1, L2, LL2, G ):
    N = { n for _,n in L1+L2 }
    return sum( [construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N], G )

Running construct_F( L1, LL1, L2, LL2, G ) on the lists from your first example returns:

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

As for the number of different involutions F, it equals |A2|!ι(|C2|), where ι() is the involution number given by OEIS A000085. The factor |A2|! accounts for bijections between on A2 and B2, while ι(|C2|) accounts for involutions on C2.

click to hide/show revision 12
No.12 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. In particular, we can take F to be the identity on C1C2.

UPDATE. Since we are given that F|A1B1=G, we only need to define F on A2B2. In particular, we can take F to be the identity on C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    #C1 = A1 & B1
    C2 = A2 & B2

    #A1s = A1 - C1
    A2s = A2 - C2

    #B1s = B1 - C1
    B2s = B2 - C2

    #assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    # conversion for output
    A2l = [[list(q),num] for q in A2s]
    B2l = [[list(q),num] for q in B2s]
    C2l = [[list(q),num] for q in C2]

    return [list(t) for t in zip(C2l,C2l)] +  [list(t) for t in zip(A2l,B2l)]

def construct_F( L1, LL1, L2, LL2, G ):
    N = { n for _,n in L1+L2 }
    return sum( [construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N], G )

Running construct_F( L1, LL1, L2, LL2, G ) on the lists from your first example returns:

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

As for the number of different involutions F, it equals $$|A_2|!\cdot $$|A_2^\star|!\cdot \iota(|C_2|),$$ where $\iota(\cdot)$ is the involution number given by OEIS A000085. The factor |A2|! |A2|! accounts for bijections between on A2 and B2, while ι(|C2|) accounts for involutions on C2.

click to hide/show revision 13
No.13 Revision

Since F must preserve the number, it's worth to decompose the problem into smaller subproblems, where the number is fixed. E.g., in the first example, you'd have 3 subproblems with number being 2, 3, and 4, respectively.

Let's consider such a subproblem, where the number is fixed.

Let A be a set of elements from L1, and A1 be the set of elements from LL1. Denote A2:=AA1, so that A=A1A2.

Similarly, let B be the set of elements from L2, and B1 be the set of elements from LL2. Denote B2:=BB1, so that B=B1B2.

For existence of F, it is necessary that A1B2=A2B1=.

Let C1:=A1B1 and C2:=A2B2. Then define A1:=A1C1, A2:=A2C2, B1:=B1C1, B2:=B2C2.

From the definition it follows that the sets A1,A2,B1,B2,C1,C2 are pairwise disjoint. Furthermore, A=A1A2C1C2, B=B1B2C1C2. The properties of F imply that F(A1)=B1, F(B1)=A1, F(A2)=B2, F(B2)=A2, F(C1)=C1, and F(C2)=C2. Other than that F can be an arbitrary involution. In particular, we can take F to be the identity on C1C2.

UPDATE. Since we are given that F|A1B1=G, we only need to define F on $A_2\cup B_2$. B_2 = A_2^\star \sqcup B_2^\star \sqcup C_2$. In particular, we can take F to be the identity on C2.

From this consideration, it's easy to construct a particular F.


Here us a sample code:

def construct_F_fixed_num( L1, LL1, L2, LL2, num ):
    A = { tuple(q) for q,n in L1 if n==num }
    A1 = { tuple(q) for q,n in LL1 if n==num }
    A2 = A - A1

    B = { tuple(q) for q,n in L2 if n==num }
    B1 = { tuple(q) for q,n in LL2 if n==num }
    B2 = B - B1

    assert len(A1 & B2) == 0
    assert len(A2 & B1) == 0

    #C1 = A1 & B1
    C2 = A2 & B2

    #A1s = A1 - C1
    A2s = A2 - C2

    #B1s = B1 - C1
    B2s = B2 - C2

    #assert len(A1s) == len(B1s)
    assert len(A2s) == len(B2s)

    # conversion for output
    A2l = [[list(q),num] for q in A2s]
    B2l = [[list(q),num] for q in B2s]
    C2l = [[list(q),num] for q in C2]

    return [list(t) for t in zip(C2l,C2l)] +  [list(t) for t in zip(A2l,B2l)]

def construct_F( L1, LL1, L2, LL2, G ):
    N = { n for _,n in L1+L2 }
    return sum( [construct_F_fixed_num( L1, LL1, L2, LL2, n ) for n in N], G )

Running construct_F( L1, LL1, L2, LL2, G ) on the lists from your first example returns:

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

As for the number of different involutions F, it equals |A2|!ι(|C2|), where ι() is the involution number given by OEIS A000085. The factor |A2|! accounts for bijections between on A2 and B2, while ι(|C2|) accounts for involutions on C2.