-
Notifications
You must be signed in to change notification settings - Fork 6
/
luks.h
98 lines (82 loc) · 2.83 KB
/
luks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once
#include <deque>
#include <vector>
#include <string>
#include "fhl.h"
#include "group.h"
#include "action.h"
#include "coset.h"
using std::string;
string stringAction( const Permutation& sigma, const string& x );
Iso StringIsomorphism( Group G, string x, string y );
Iso StringIsomorphismNonAutomorphism( Group G, string x, string y );
Iso StringIsomorphismTransitive( Group G, string x, string y );
Iso StringIsomorphismCameronGroup( RestrictedNaturalSetAction A, Group H, string x, string y );
template<typename T>
string stringRestrict( const string& x, const T& Delta ) {
string y;
y.reserve( Delta.size() );
for( int i : Delta )
y.push_back( x[i] );
return y;
}
template<typename T>
Iso ShiftIdentity( Coset C, string x, string y, T f );
template<typename T>
Iso WeakReduction( Group G, Group H, string x, string y, T f );
template<typename T>
Iso ChainRule( Group G, string x, string y, std::vector<std::vector<int>> orbits, T f );
// applies the shift identity to the result of f
template<typename T>
Iso ShiftIdentity( Coset C, string x, string y, T f ) {
return C.representative() * f( C.subgroup(), x, stringAction( C.representative().inverse(), y ) );
}
// applies weak reduction from G to H
template<typename T>
Iso WeakReduction( Group G, Group H, string x, string y, T f ) {
#ifdef DEBUG
std::cout << "WeakReduction( " << G->generators() << "," << H->generators() << "," << x << "," << y << "):" << std::endl;
#endif
IsoJoiner J;
for( Coset C : G->allCosets( H ) )
J.join( ShiftIdentity( C, x, y, f ) );
return Iso( J );
}
// applies the chain rule to the orbits
template<typename T>
Iso ChainRule( Group G, string x, string y, std::vector<std::vector<int>> orbits, T f ) {
#ifdef DEBUG
std::cout << "StringIsomorphismChainRule( " << G->generators() << "," << x << "," << y << "," << orbits << "):" << std::endl;
#endif
auto mu = G->one();
Group F = G;
for( const auto& Delta : orbits ) {
// get generators
auto perm = F->generators();
std::deque<int> almostDelta( Delta.begin(), Delta.end() );
// project onto orbit
for( auto& sigma : perm )
sigma = sigma.project( Delta );
Group H( new Subgroup( Group( new SymmetricGroup( Delta.size() ) ), perm ) );
// apply procedure to orbit
Iso I = f( H, stringRestrict( x, Delta ), stringRestrict( y, Delta ) );
// invert projection
if( I.isEmpty() )
return Empty();
PullbackStructure P( F, perm, F->generators() );
auto tau = P( I.coset().representative() );
auto perm2 = I.coset().subgroup()->generators();
std::deque<Permutation> perm3;
for( auto& sigma : perm2 )
perm3.push_back( P( sigma ) );
RestrictedNaturalAction A( F, almostDelta );
Group J = A.kernel();
// update F, y and mu
F = J->join( std::move( perm3 ) );
y = stringAction( tau.inverse(), y );
mu = mu * tau;
}
// return result
Coset R( G, F, mu, false );
return R;
}