00001 #include <fstream>
00002 #include <iostream>
00003 #include "algebras.H"
00004 #include "homfinder.H"
00005 #include "cmdline.H"
00006 using namespace std;
00007
00017 int main(int argc, char** argv)
00018 {
00020
00022
00023
00024
00025
00026 CommandLine::init(argc, argv);
00027 string name= CommandLine::parameters[0];
00028 string source= name + ".W";
00029 string target= name + ".cohomology.mod2";
00030
00031 UnstableAlgebra A;
00032 GradedAlgebra<F_2> B;
00033
00034 ifstream my_source(source.c_str());
00035 if(my_source.fail()){
00036 cout << "could not read file" << source << endl;
00037 return 10;
00038 }
00039 else
00040 my_source >> A;
00041 my_source.close();
00042
00043 ifstream my_target(target.c_str());
00044 if(my_target.fail()){
00045 cout << "could not read file" << target << endl;
00046 return 10;
00047 }
00048 else
00049 my_target >> B;
00050 my_target.close();
00051
00052
00053
00054 HomFinder myfinder(&A, &B);
00055
00056
00057
00058 myfinder.very_verbose= myfinder.verbose= true;
00059
00060 if(CommandLine::has_tag("-quiet"))
00061 myfinder.very_verbose= false;
00062 if(CommandLine::has_tag("-silent"))
00063 myfinder.very_verbose= myfinder.verbose= false;
00064
00065
00066 A.find_grobner_basis();
00067 A.find_redundancies();
00068 B.find_grobner_basis();
00069
00070 if(myfinder.very_verbose)
00071 cout << "Here's the formal ring of SW classes: "
00072 << endl << "(with a minimal set of relations"
00073 << " extracted from a reduced Grobner basis)"
00074 << endl << A << endl
00075 << "and here is the cohomology: " << endl
00076 << "(with a Grobner basis)" << endl
00077 << B << endl;
00078
00080
00082
00083
00084
00085
00086
00087 myfinder.init();
00088
00090
00092
00093 if(myfinder.verbose)
00094 cout << endl << "*** Step 2:" << endl;
00095
00096
00097
00098
00099 string sol_file= name + ".solutions";
00100 ifstream my_in(sol_file.c_str());
00101
00102 if(my_in.fail()){
00103
00104 myfinder.start();
00105 ofstream my_out(sol_file.c_str());
00106 myfinder.write_solutions_to(my_out);
00107 }
00108 else{
00109 if(myfinder.verbose)
00110 cout << "found solution file " << sol_file
00111 << endl;
00112 myfinder.read_solutions_from(my_in);
00113 }
00114
00115 if(myfinder.verbose)
00116 cout << "Total: "
00117 << myfinder.solution_count
00118 << " possibilities after Steps 1 & 2"
00119 << endl;
00120
00122
00124
00125 if(CommandLine::has_tag("-brute")){
00126
00127 if(myfinder.verbose)
00128 cout << endl << "*** Step 3 (exhaustive version) & Test 1" << endl;
00129
00130
00131 myfinder.define_polynomial_variables_brutally();
00132
00133 }
00134 else{
00135
00136 if(myfinder.verbose)
00137 cout << endl << "*** Step 3 & Test 1" << endl;
00138
00139
00140 myfinder.define_polynomial_variables();
00141 }
00142
00144
00146 if(CommandLine::has_tag("-brute")){
00147
00148 if(myfinder.verbose)
00149 cout << endl << "*** Test 2 skipped, just computing all kernels"
00150 << endl;
00151
00152 myfinder.compute_all_kernels();
00153 }
00154 else{
00155
00156 if(myfinder.verbose)
00157 cout << endl << "*** Test 2" << endl;
00158
00159 if( !myfinder.polynomial_test() ){
00160 cout << "Test 2 failed, giving up!" << endl;
00161 return 2;
00162 }
00163 else
00164 if(myfinder.verbose)
00165 cout << "Passed !" << endl;
00166 }
00167
00169
00171
00172
00173 list< AffineHomomorphism<F_2> > backup= myfinder.solutions;
00174
00175 if(myfinder.verbose)
00176 cout << endl << "*** We count the equivalence classes so far:" << endl;
00177
00178 myfinder.identify();
00179
00180 if(myfinder.verbose)
00181 cout << myfinder.solution_count << " classes" << endl;
00182
00184
00186
00187
00188 if( myfinder.solution_count > 1){
00189
00190 if(myfinder.verbose)
00191 cout << "*** Test 3" << endl;
00192
00193 myfinder.test_steenrod();
00194
00195 if(myfinder.verbose)
00196 cout << "Done, " << myfinder.solution_count
00197 << " classes kept" << endl;
00198 }
00199
00201
00203
00204 if( myfinder.solution_count > 1){
00205
00206 if(myfinder.verbose)
00207 cout << "*** Test 4" << endl;
00208
00209 string res_name= name + ".W.res.elemab";
00210 ifstream res_file(res_name.c_str());
00211
00212 myfinder.restrict_to_elemab( res_file );
00213
00214 if(myfinder.verbose)
00215 cout << "Done, " << myfinder.solution_count
00216 << " classes kept" << endl;
00217 }
00218
00220
00222
00223 if( myfinder.solution_count > 1){
00224 cout << endl << myfinder.solution_count
00225 << " equivalence classes, giving up!"
00226 << endl;
00227 return 1;
00228 }
00229
00230
00231
00232
00233
00234 AffineHomomorphism<F_2> f= *myfinder.solutions.begin();
00235 myfinder.get_equivalence_class(backup, f);
00236
00237 long new_vars;
00238 new_vars= myfinder.extend_all();
00239
00240 if( new_vars > 0 ) {
00241
00242 if(myfinder.verbose)
00243 cout << endl << "*** There are variables which are not SW classes, "
00244 << endl << "we check if the extended homomorphisms are equivalent"
00245 << endl;
00246
00247 myfinder.identify();
00248
00249 if( myfinder.solution_count > 1){
00250 cout << endl << myfinder.solution_count
00251 << " equivalence classes, giving up!"
00252 << endl;
00253 return 3;
00254 }
00255 }
00256
00257
00258
00259
00260
00262
00264 if(myfinder.verbose)
00265 cout << endl << "*** Done ! solution completely determined !"
00266 << endl;
00267
00268
00269 AbstractHomomorphism<F_2> reduc;
00270 list< Polynomial<F_2> >::iterator gen;
00271
00272 f= *myfinder.solutions.begin();
00273
00274 if(myfinder.verbose)
00275 cout << f << endl;
00276
00277 for(gen= f.kernel.generators.begin();
00278 gen != f.kernel.generators.end();
00279 gen++)
00280 A.add_relation(*gen);
00281
00282 A.split_and_sort_relations();
00283
00284
00285 if(new_vars == 0){
00286 reduc= A.saturate_and_reduce();
00287 if(myfinder.verbose)
00288 A.display();
00289 }
00290 else{
00291 reduc= A.find_redundancies();
00292 A.write_trivial_steenrod_operations();
00293
00294 if(myfinder.verbose)
00295 cout << A << endl;
00296
00297 }
00298
00299 string output_name= name + ".final";
00300 ofstream output(output_name.c_str());
00301
00302 output << A;
00303 output << reduc;
00304 output << f;
00305
00306 return 0;
00307 }
00308
00309
00310
00311
00312
00313
00314