/*

Checks the formulas for j1 and j2.

*/

load 'witt2_fun.m';
load 'fctWitt.m';
load 'witt_gen.m';

// //////////////////////////////////////

// choose char. and coef

p:=5; n:=20; F<g>:=GF(p^n); P<j0>:=RationalFunctionField(F);


// coef.
a0:=Random(F);
b0:=Random(F);
// FF<a0,b0>:=RationalFunctionField(GF(p),2);

// //////////////////////////////////////////////


// load formulas for j's to test
load 'load_js.m';


// compute can. lift
a1, b1, _, _, a2, b2 := lift(a0,b0);

a:=[a0,a1,a2];
b:=[b0,b1,b2];

/*
// compute the j-invariant

// pre-compute to make repeated WittToInt faster
primr:=GenPrimRoots(p,3);

// convert integers to Witt vec.
w4:=IntToWitt(4,p,3 : primr:=primr);
w27:=IntToWitt(27,p,3 : primr:=primr);
w1728:=IntToWitt(1728,p,3 : primr:=primr);

acub:=WittProd2(WittProd2(a,a),a);
bsqr:=WittProd2(b,b);

num:=WittProd2(w4,acub);
den:=WittSum2(num,WittProd2(w27,bsqr));

num:=WittProd2(w1728,num);
den:=WittInv(den);

// finally the j-inv. of the can. lift.
J:=WittProd2(num,den);
*/

// compute the j-invariant
load 'wittj.m';
J:=wittj(a,b);

// values from the formulas
J1:=Evaluate(j1,J[1]);
J2:=Evaluate(j2,J[1]);


// check
if J1 ne J[2] then
    print "J1 wrong";
end if;

if J2 ne J[3] then
    print "J2 wrong";
end if;

if (J1 eq J[2]) and (J2 eq J[3]) then
    print "OK";
end if;
