TTPAttack.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 #ifndef _TTPAttack_H_
00016 #define _TTPAttack_H_
00017 
00018 #include "Word.h"
00019 #include "AEProtocol.h"
00020 #include "ThLeftNormalForm.h"
00021 #include <vector>
00022 
00023 using namespace std;
00024 
00025 class TTPTuple;
00026 typedef pair< int , TTPTuple > NODE;
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 class TTPLBA
00036 {
00037 public:
00038         TTPLBA(){}      
00039 
00040         bool  reduce( int N , const BSets& bs, const TTPTuple& theTuple , const vector< Word >& gens, int sec, ostream& out, TTPTuple& red_T, const Word& z );
00041         bool simpleLBA( int N , const BSets& bs, const TTPTuple& theTuple, const Word& z, TTPTuple* ret_T = NULL );
00042         
00043 private:                                                                                                
00044  
00045         void addNewElt( const TTPTuple& T , const set< NODE >& checkedElements , set< NODE >& uncheckedElements );
00046         void tryNode( int N , NODE cur , const vector<Word>& gens , const set<NODE>& checkedElements ,  set<NODE>& uncheckedElements, int& min_weight );
00047         
00048         TTPTuple savTuple;
00049 };
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00059 class TTPAttack {
00060 public:
00061 
00063 
00066   TTPAttack( int n, BSets bs) : N( n ), BS( bs )  {}
00067 
00068 enum TTP_Result { 
00069   TTP_FAILED, 
00070 
00071   TTP_NOTSURE,
00072   TTP_SUCCESSFULL
00073 };
00074  
00075 
00077 
00080  bool run( const TTPTuple& d );
00081  
00082  
00083  
00084  
00085  private:
00086 
00087  inline void printStats(const ThLeftNormalForm& nf, ostream& out ){
00088    out << "inf : " << nf.getPower() << " sup : " << nf.getDecomposition().size() << flush;
00089  }
00090  
00091  
00092  ThLeftNormalForm cycleDecycle(const ThLeftNormalForm& nf );
00093 
00094  bool simpleLBA( int NWL, int NWR, const vector<ThLeftNormalForm>& theTuple, const Word& z );
00095  bool LBA( int NWL, int NWR, const vector<ThLeftNormalForm>& theTuple, const Word& z );
00096  bool oneOfSSSReps( int N1, int N2, const vector<ThLeftNormalForm>& theTuple );
00097  void reduceDeltaLBA( vector<ThLeftNormalForm>& theTuple );
00098 
00099 
00100  int N;
00101  BSets BS;
00102 };
00103 
00104 #endif