/*****************************************************
  Test code for Witt decompositions
  
  October 2011 Don Taylor
  
  $Id: test_WittDecomp 65660 2022-04-06 13:52:49Z don $
  
******************************************************/

// Conjugacy of complements to the radical
print "\nCharacteristic 7";
print "Symplectic";
F<t> := GF(7,2);
J := Matrix(F,4,4,[0,0,0,1, 0,0,0,0, 0,0,0,0, -1,0,0,0]);
V := RSpace(F,4,J);
R := sub< V | V.2, V.3 >;
U1 := sub< V | V.1, V.4 >;
U2 := sub< V | V.1+3*V.4, V.1 >;
f := hom< V -> V | V.1+3*V.4, V.2, V.3, 2*V.1 >;
assert R eq Radical(V);
assert IsIsometry(f);
assert f(U1) eq U2;
M := MaximalTotallyIsotropicSubspace(V);
assert Dimension(M) eq WittIndex(V);
wd:= WittDecomposition(V);
// [Dimension(X) : X in wd ];

print "Orthogonal";
F<t> := GF(49);
B := Matrix(6,6,[F| 
    0,1, 0,0, 0,0,
    0,0, 0,0, 0,0,
    0,0, 0,0, 0,0,
    0,0, 0,0, 0,0,
    0,0, 0,0, 0,1,
    0,0, 0,0, 0,0]);
V := QuadraticSpace(B);
R := sub< V | V.3, V.4 >;
U1 := sub< V | V.1, V.2, V.5, V.6 >;
U2 := sub< V | V.1+t*V.4, V.2, V.4+V.5, V.6>;
f := hom< V -> V | V.1+t*V.4, V.2, V.3, V.4, V.4+V.5,V.6 >;
assert R eq Radical(V);
assert IsIsometry(f);
assert f(U1) eq U2;
M := MaximalTotallyIsotropicSubspace(V);
assert Dimension(M) eq WittIndex(V);
wd:= WittDecomposition(V);
// [Dimension(X) : X in wd ];

print "Unitary";
sigma := hom< F -> F | x :-> x^7 >;
J := Matrix(F,4,4,[0,0,0,1, 0,0,0,0, 0,0,0,0, 1,0,0,0]);
V := UnitarySpace(J,sigma);
R := sub< V | V.2, V.3 >;
U1 := sub< V | V.1, V.4 >;
U2 := sub< V | V.1+t^2*V.4, V.1 >;
f := hom< V -> V | V.1+t^4*V.4, V.2, V.3, t^20*V.1 >;
assert R eq Radical(V);
assert IsIsometry(f);
assert f(U1) eq U2;
M := MaximalTotallyIsotropicSubspace(V);
assert Dimension(M) eq WittIndex(V);
wd:= WittDecomposition(V);
// [Dimension(X) : X in wd ];

J := Matrix(F,5,5,[0,0,0,1,0, 0,0,0,0,0, 0,0,0,0,0, 1,0,0,0,0, 0,0,0,0,1]);
V := UnitarySpace(J,sigma);
R := sub< V | V.2, V.3 >;
U1 := sub< V | V.1, V.4 >;
U2 := sub< V | V.1+t^2*V.4, V.1 >;
f := hom< V -> V | V.1+t^4*V.4, V.2, V.3, t^20*V.1, V.5>;
assert R eq Radical(V);
assert IsIsometry(f);
assert f(U1) eq U2;
M := MaximalTotallyIsotropicSubspace(V);
assert Dimension(M) eq WittIndex(V);
wd:= WittDecomposition(V);
// [Dimension(X) : X in wd ];

print "Characteristic 2";
F<t> := GF(16);
B := Matrix(7,7,[F| 
    1, 0,0, 0,0, 0,0,
    0, 1,1, 0,0, 0,0,
    0, 0,t^3, 0,0, 0,0,
    0, 0,0, 0,1, 0,0,
    0, 0,0, 0,0, 0,0,
    0, 0,0, 0,0, 0,1,
    0, 0,0, 0,0, 0,0]);
V := QuadraticSpace(B);
wd:= WittDecomposition(V);
assert [Dimension(X) : X in wd ] eq [0,3,3,1];
M := MaximalTotallyIsotropicSubspace(V);
assert Dimension(M) eq WittIndex(V) + 1;
S := MaximalTotallySingularSubspace(V);
assert Dimension(S) eq WittIndex(V);

J := Matrix(4,4,[F|
    t^6, t^6, t^6,  t^12,
    0,   1,   t^6,  t^6, 
    0,   0,   t^14, t^4, 
    0,   0,   0,    t^11 ]);
V := QuadraticSpace(J);
M := MaximalTotallyIsotropicSubspace(V);
wd:= WittDecomposition(V);
assert [Dimension(X) : X in wd ] eq [1,1,1,1];
assert Dimension(M) eq WittIndex(V) + 1;
S := MaximalTotallySingularSubspace(V);
assert Dimension(S) eq WittIndex(V);

