00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_ALGORITHMS_EQUIVALENT_HXX
00018 # define VCSN_ALGORITHMS_EQUIVALENT_HXX
00019
00020 # include <vaucanson/algorithms/equivalent.hh>
00021 # include <vaucanson/algorithms/determinize.hh>
00022 # include <vaucanson/algorithms/is_deterministic.hh>
00023 # include <vaucanson/algorithms/complement.hh>
00024 # include <vaucanson/algorithms/complete.hh>
00025 # include <vaucanson/algorithms/trim.hh>
00026 # include <vaucanson/algorithms/product.hh>
00027
00028 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
00029 # include <vaucanson/misc/usual_macros.hh>
00030
00031
00032 namespace vcsn
00033 {
00034
00035 template<typename SA, typename A,
00036 typename SB, typename B>
00037 bool
00038 do_are_equivalent(const AutomataBase<SA>&, const A& a,
00039 const AutomataBase<SB>&, const B& b)
00040 {
00041 A pos_a(a);
00042 B pos_b(b);
00043
00044 if (not is_realtime(pos_a))
00045 realtime_here(pos_a);
00046 if (not is_realtime(pos_b))
00047 realtime_here(pos_b);
00048
00049
00050
00051
00052
00053 A neg_a(pos_a);
00054 if (not is_deterministic(neg_a))
00055 neg_a = determinize(neg_a);
00056 else if (not is_complete(neg_a))
00057 complete_here(neg_a);
00058 complement_here(neg_a);
00059 if (trim(product(neg_a, pos_b)).states().size() != 0)
00060 return false;
00061
00062
00063 A neg_b(pos_b);
00064 if (not is_deterministic(neg_b))
00065 neg_b = determinize(neg_b);
00066 else if(not is_complete(neg_b))
00067 complete_here(neg_b);
00068 complement_here(neg_b);
00069 return (trim(product(pos_a, neg_b)).states().size() == 0);
00070 }
00071
00072
00073 template<typename S, typename A, typename B>
00074 bool
00075 are_equivalent(const Element<S, A>& a, const Element<S, B>& b)
00076 {
00077 return do_are_equivalent(a.structure(), a,
00078 b.structure(), b);
00079 }
00080
00081 }
00082
00083 #endif // ! VCSN_ALGORITHMS_EQUIVALENT_HXX