[Late night YY] Some superficial understandings and hustles about linear bases

Mosquitoes have a lot of brain holes in the middle of the night. Think about the linear basis of flipping (touching) reading (fish) in a computer science class.

Aside from the legality of vector space linear space operation rules, the combination of the minimum generating set and the maximal linear independent set BLABLA,

A linear basis is the smallest set that can generate any XOR combination in the original array

The violent test is as follows, very OK (the typesetting indentation is terrible due to the constant switching of IDE)
https://paste.ubuntu.com/p/c4HZcTYXYh/

The framework is as follows, it can be said that the design is very delicate

void cal(){
    rep(i,1,n){
        rrep(j,30,0){
            if(a[i]>>j&1){
                if(b[j]) a[i]^=b[j]; 
                else{
                    b[j]=a[i];
                    rrep(k,j-1,0) if(b[k]&&(b[j]>>k&1))b[j]^=b[k];
                    rep(k,j+1,30) if(b[k]>>j&1) b[k]^=b[j];
                    break;
                }
            }
        }
    }
}

For \(b[j]\) , if \(b[j]=1\) , it means that there is at least one number in the original array, and its highest bit is 1, so it will be maintained at least as an upper-triangular matrix in the end

rrep(k,j-1,0) if(b[k]&&(b[j]>>k&1))b[j]^=b[k];

This paragraph is to maintain the simplest form of \(b[j]\) (or to maintain linear independence), if the lower position \(b[k]=1\) , and \(b[j]\ ) The \(k\) bit is also 1, which can prove that \(b[j]\) is not necessarily the simplest form, and at least the \(k\) bit of \(b[j]\) will be set to 0, and even Other same bits will also be set to 0, and before this \(b[k]\) and \(b[k-1...0]\) are linearly independent, so XOR will not lose the optimal solution, so \(b[j]\) is also linearly independent of \(b[k...0]\ ) at this time

That's why

if(b[j]) a[i]^=b[j];

For each \(a[i]\) in this paragraph , the first thing you need is to remove the bits that already exist in the base, and each \(b[]\) is linearly independent, so it will definitely not appear in the front A part of the \(k\) bits that are not \(b[j]\) are XORed to 0 and the \(k\) bits of the next \(b[j']\) are XORed back to 1

then next

rep(k,j+1,30) if(b[k]>>j&1) b[k]^=b[j];

Since they are all linearly irrelevant, of course, the existence of the high order must be XORed linearly.

PS. It can be directly understood as first use the downward to eliminate yourself, and then use yourself to eliminate the upward

Then through two phenomena:
1. For \(b[j]\) , if \(b[j]=1\) , it means that there is at least one number in the original array, and its highest bit is 1
2. \(b The maintenance of []\) is linearly independent.
It can be concluded from YY that
for a certain bit \(i\) in the linear basis, there is one and only one \(b[j]\) that is 1 in this bit

On this basis, the XOR can be performed asdo whatever you wantoperate

Q: Is the base uniquely determined, that is, whether the generated bases are the same for arrays composed of the same elements but in different orders? If it is uniquely determined,So what are the properties it has
Although there is no brute force test and high-end proof, it is intuitive to think that the basis is the same, because the basis is not directly related to the order of the number itself. As for the order of addition of bits, it should be unique in order to maintain linear independence.nature emmm don't know

//The brute force test is established through the conjecture, and the proof goes to tm

With a very superficial understanding, then the next thing is relevant.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325141174&siteId=291194637