Commit e2a0b61d authored by Guillaume Leroi's avatar Guillaume Leroi
Browse files

Add vcsn-tdc.

	* taf-kit/src/tdc_commands.cc: New.
	* taf-kit/src/edition_commands.hxx: .
	* taf-kit/src/getters.hxx: .
	* taf-kit/src/commands_macros.hh: .
	* taf-kit/src/common_commands.hh: .
	* taf-kit/src/Makefile.am: .
	* taf-kit/src/getters.hh: .
	* include/vaucanson/contexts/fmp_transducer_functions.thh: .
	* include/vaucanson/algorithms/evaluation_fmp.hxx: .
	* include/vaucanson/algorithms/normalized_composition.hh: .
	* include/vaucanson/algorithms/normalized_composition.hxx: .
	* include/vaucanson/algorithms/composition_cover.hh: New.
	* include/vaucanson/algorithms/composition_cover.hxx: New.
parent e10e9afb
2006-07-22 Guillaume Leroi <guillaume.leroi@lrde.epita.fr>
Add vcsn-tdc.
* taf-kit/src/tdc_commands.cc: New.
* taf-kit/src/edition_commands.hxx: .
* taf-kit/src/getters.hxx: .
* taf-kit/src/commands_macros.hh: .
* taf-kit/src/common_commands.hh: .
* taf-kit/src/Makefile.am: .
* taf-kit/src/getters.hh: .
* include/vaucanson/contexts/fmp_transducer_functions.thh: .
* include/vaucanson/algorithms/evaluation_fmp.hxx: .
* include/vaucanson/algorithms/normalized_composition.hh: .
* include/vaucanson/algorithms/normalized_composition.hxx: .
* include/vaucanson/algorithms/composition_cover.hh: New.
* include/vaucanson/algorithms/composition_cover.hxx: New.
2006-07-22 Michal Cadilhac <michael.cadilhac@lrde.epita.fr>
Remove `fsm' demo.
......
// composition_cover.hh: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_ALGORITHMS_COMPOSITION_COVER_HH
# define VCSN_ALGORITHMS_COMPOSITION_COVER_HH
# include <vaucanson/automata/concept/automata_base.hh>
/** @addtogroup algorithms *//** @{ */
/**
* @file composition_cover.hh
* @author Guillaume Leroi
*
* @brief Composition for normalized and sub-normalized transducers
* seen as automata over a free monoid product.
*
* @see composition_cover()
* @see composition_co_cover()
*/
/** @} */
namespace vcsn {
/** @addtogroup algorithms *//** @{ */
template <typename S, typename T>
Element<S, T>
composition_cover (const Element<S, T>& fmp);
template <typename S, typename T>
void
composition_cover (const Element<S, T>& fmp,
Element<S, T>& ret);
template <typename S, typename T>
Element<S, T>
composition_co_cover (const Element<S, T>& fmp);
template <typename S, typename T>
void
composition_co_cover (const Element<S, T>& fmp,
Element<S, T>& ret);
/** @} */
}
#ifndef VCSN_USE_INTERFACE_ONLY
# include <vaucanson/algorithms/composition_cover.hxx>
#endif // ! VCSN_USE_INTERFACE_ONLY
#endif // ! VCSN_ALGORITHMS_COMPOSITION_COVER_HH
// composition_cover.hxx: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_ALGORITHMS_COMPOSITION_COVER_HXX
# define VCSN_ALGORITHMS_COMPOSITION_COVER_HXX
/**
* @file composition_cover.hxx
* @author Guillaume Leroi
* @date Sat Jul 22 18:03:02 2006
*
* @brief Composition (co-)cover algorithms for normalized and sub-normalized
* transducers seen as automaton over a free monoid.
*
*
*/
# include <vaucanson/algorithms/internal/outsplitting.hh>
# include <vaucanson/algorithms/composition_cover.hh>
# include <vaucanson/algebra/concept/freemonoid_product.hh>
# include <vaucanson/automata/concept/automata.hh>
namespace vcsn {
template <typename S, typename M1, typename M2, typename Auto_t>
void
do_composition_cover (const AutomataBase<S>&,
const algebra::FreeMonoidProduct<M1, M2>&,
const Auto_t& fmp,
Auto_t& ret)
{
AUTOMATON_TYPES(Auto_t);
ret = splitting::outsplitting (fmp);
}
template <typename S, typename M1, typename M2, typename Auto_t>
void
do_composition_co_cover (const AutomataBase<S>&,
const algebra::FreeMonoidProduct<M1, M2>&,
const Auto_t& fmp,
Auto_t& ret)
{
AUTOMATON_TYPES(Auto_t);
ret = splitting::insplitting (fmp);
}
/// Facade for composition cover
template <typename S, typename T>
Element<S, T>
composition_cover (const Element<S, T>& fmp)
{
typedef Element<S, T> auto_t;
AUTOMATON_TYPES(auto_t);
auto_t ret (fmp.structure());
do_composition_cover (fmp.structure(),
fmp.structure().series().monoid(),
fmp,
ret);
return ret;
}
template <typename S, typename T>
void
composition_cover (const Element<S, T>& fmp,
Element<S, T>& ret)
{
typedef Element<S, T> auto_t;
AUTOMATON_TYPES(auto_t);
for_all_states (s, ret)
ret.del_states (*s);
do_composition_cover (fmp.structure(),
fmp.structure().series().monoid(),
fmp,
ret);
}
/// Facade for composition co-cover
template <typename S, typename T>
Element<S, T>
composition_co_cover (const Element<S, T>& fmp)
{
typedef Element<S, T> auto_t;
AUTOMATON_TYPES(auto_t);
automaton_t ret(fmp.structure());
do_composition_co_cover (fmp.structure(),
fmp.structure().series().monoid(),
fmp,
ret);
return ret;
}
template <typename S, typename T>
void
composition_co_cover (const Element<S, T>& fmp,
Element<S, T>& ret)
{
typedef Element<S, T> auto_t;
AUTOMATON_TYPES(auto_t);
for_all_states (s, ret)
ret.del_states (*s);
do_composition_cover (fmp.structure(),
fmp.structure().series().monoid(),
fmp,
ret);
}
}
#endif // ! VCSN_ALGORITHMS_COMPOSITION_COVER_HXX
......@@ -37,8 +37,8 @@ namespace vcsn
{
trans_t id_aut(trans.structure());
identity(aut, id_aut);
trans_t res_composition = normalized_composition(sub_normalize(id_aut),
sub_normalize(trans));
trans_t res_composition = compose(sub_normalize(id_aut),
sub_normalize(trans));
image(res_composition, res);
}
......@@ -55,7 +55,6 @@ namespace vcsn
aut.structure(), aut.structure().series().monoid(),
res.structure(), res.structure().series().monoid(),
trans, aut, res);
}
} // End of namespace vcsn.
......
......@@ -28,8 +28,8 @@
*
* @author Sarah O'Connor <sarah.o-connor@lrde.epita.fr>
*
* @see b_composition()
* @see normalized_composition()
* @see compose()
* @see u_compose()
*/
/** @} */
......@@ -65,7 +65,7 @@ namespace vcsn {
*
*/
template <typename S, typename T>
void
Element<S, T>
compose(const Element<S, T>& lhs,
const Element<S, T>& rhs);
......@@ -95,7 +95,7 @@ namespace vcsn {
*
*/
template <typename S, typename T>
void
Element<S, T>
u_compose(const Element<S, T>& lhs,
const Element<S, T>& rhs);
......
......@@ -53,8 +53,7 @@ namespace vcsn {
// FIXME: Document.
template <typename S, typename M1, typename M2, typename lhs_t,
typename rhs_t, typename res_t>
template <typename res_t>
inline
void
add_transition(res_t& output,
......@@ -101,7 +100,7 @@ namespace vcsn {
res_t& output,
std::set<hstate_t>& lhs_states,
std::set<hstate_t>& rhs_states,
std::map< hstate_t, std::pair<hstate_t, hstate_t> >& m)
composition_traits::map_of_states_t& m)
{
AUTOMATON_TYPES(res_t);
AUTOMATON_TYPES_(lhs_t, lhs_);
......@@ -260,7 +259,7 @@ namespace vcsn {
// If the outgoing transition is of type (*, 1).
if (left_supp_elt.value().second == lhs_second_identity.value())
{
series_set_elt_t prod_series (series);
typename res_t::series_set_elt_t prod_series (series);
const monoid_elt_value_t word(left_supp_elt.value().first,
rhs_second_identity.value());
prod_series.assoc(monoid_elt_t(monoid, word),
......@@ -268,7 +267,7 @@ namespace vcsn {
add_transition (output, visited, to_process,
lhs_states, rhs_states,
m,
m, current_state,
lhs.dst_of(*l), rhs_s, prod_series);
}
else
......@@ -291,8 +290,8 @@ namespace vcsn {
if (left_supp_elt.value().second ==
right_supp_elt.value().first)
{
series_set_elt_t prod_series (series);
const monoid_elt_value_t word
typename res_t::series_set_elt_t prod_series (series);
const monoid_elt_value_t word
(left_supp_elt.value().first,
right_supp_elt.value().second);
const semiring_elt_t p =
......@@ -303,7 +302,7 @@ namespace vcsn {
add_transition (output, visited, to_process,
lhs_states, rhs_states,
m,
m, current_state,
lhs.dst_of(*l), rhs.dst_of(*r), prod_series);
}
}
......@@ -315,12 +314,12 @@ namespace vcsn {
{
const rhs_series_set_elt_t right_series = rhs.series_of(*r);
rhs_support_t right_supp = right_series.supp();
const rhs_monoid_elt_t right_supp_elt (rhs_monoid, *right_supp);
const rhs_monoid_elt_t right_supp_elt (rhs_monoid, *(right_supp.begin()));
if (right_supp_elt.value().first ==
rhs_first_identity.value())
{
series_set_elt_t prod_series (series);
typename res_t::series_set_elt_t prod_series (series);
const monoid_elt_value_t word
(lhs_first_identity.value(),
right_supp_elt.value().second);
......@@ -329,16 +328,14 @@ namespace vcsn {
add_transition (output, visited, to_process,
lhs_states, rhs_states,
m,
m, current_state,
lhs_s, rhs.dst_of(*r), prod_series);
}
}
}
}
/// compose with multiplicities
template <typename S, typename M1, typename M2, typename coeff_t, typename lhs_t,
typename rhs_t, typename res_t>
......@@ -435,7 +432,7 @@ namespace vcsn {
template <typename S, typename T>
void
Element<S, T>
compose(const Element<S, T>& lhs,
const Element<S, T>& rhs)
{
......@@ -488,7 +485,7 @@ namespace vcsn {
}
template <typename S, typename T>
void
Element<S, T>
u_compose(const Element<S, T>& lhs,
const Element<S, T>& rhs)
{
......
......@@ -31,6 +31,7 @@
# include <vaucanson/algorithms/evaluation_fmp.hh>
# include <vaucanson/algorithms/projections_fmp.hh>
# include <vaucanson/algorithms/internal/outsplitting.hh>
# include <vaucanson/algorithms/composition_cover.hh>
# include <vaucanson/algorithms/transpose.hh>
# include <vaucanson/algorithms/fmp_to_realtime.hh>
#endif // ! VCSN_WITHOUT_ALGORITHM_INCLUDES
......
......@@ -17,7 +17,7 @@ include $(top_srcdir)/src/vaucanson.mk
AM_CPPFLAGS += $(CXXFLAGS_OPTIMIZE)
AM_LDFLAGS = $(TERMLIBS)
Progs = vcsn-b vcsn-z
Progs = vcsn-b vcsn-z vcsn-tdc
if VCSN_TAF_KIT
bin_PROGRAMS = $(Progs)
......@@ -31,7 +31,7 @@ COMMON_SOURCES = commands.hh \
common.hh \
edition_commands.hh \
edition_commands.hxx \
library_commands.hh \
library_commands.hh \
getters.hh \
getters.hxx \
interface.cc \
......@@ -48,6 +48,10 @@ vcsn_z_CPPFLAGS = $(AM_CPPFLAGS) \
-DCONTEXT_HEADER="<vaucanson/z_automaton.hh>" \
-DCONTEXT_NAMESPACE="vcsn::z_automaton"
vcsn_tdc_CPPFLAGS = $(AM_CPPFLAGS) \
-DCONTEXT_HEADER="<vaucanson/fmp_transducer.hh>" \
-DCONTEXT_NAMESPACE="vcsn::fmp_transducer" \
-DWITH_TWO_ALPHABETS
vcsn_b_SOURCES = $(COMMON_SOURCES) \
ratexp_commands.hh b_commands.cc
......@@ -55,6 +59,9 @@ vcsn_b_SOURCES = $(COMMON_SOURCES) \
vcsn_z_SOURCES = $(COMMON_SOURCES) \
ratexp_commands.hh z_commands.cc
vcsn_tdc_SOURCES = $(COMMON_SOURCES) \
tdc_commands.cc
## ------ ##
## argp. ##
## ------ ##
......
......@@ -112,6 +112,7 @@
# define AutAut "aut1 aut2", 2
# define AutInt "aut n", 2
# define AutWord "aut word", 2
# define AutExp "aut exp", 2
# define File "file", 1
# define Nil "", 0
......
......@@ -50,7 +50,7 @@ using vcsn::xml::XML;
/*---------------------------------------.
| Command definition (RatExp excluded). |
`---------------------------------------*/
#ifndef WITH_TWO_ALPHABETS
DEFINE_IS_PROPERTY_COMMAND (ambiguous);
DEFINE_IS_PROPERTY_COMMAND (normalized);
......@@ -59,12 +59,6 @@ DEFINE_IS_PROPERTY_COMMAND (realtime);
DEFINE_IS_PROPERTY_COMMAND (standard);
DEFINE_ONE_ARG_COMMAND (ARG_KIND (aut)
ALGO (trim));
DEFINE_ONE_ARG_COMMAND (ARG_KIND (aut)
ALGO (transpose));
DEFINE_ONE_ARG_COMMAND (ARG_KIND (aut)
ALGO (realtime));
......@@ -81,11 +75,6 @@ DEFINE_ONE_ARG_COMMAND_TWO_ALGOS (NAME (quotient)
ARG_KIND (aut)
ALGOS (quotient, realtime));
DEFINE_ONE_ARG_COMMAND_TWO_ALGOS (NAME (closure)
ARG_KIND (aut)
ALGOS (accessible, closure));
DEFINE_TWO_ARGS_COMMAND (ARG_KIND (aut)
ALGO (sum));
......@@ -95,6 +84,38 @@ DEFINE_TWO_ARGS_COMMAND (ARG_KIND (aut)
DEFINE_TWO_ARGS_COMMAND (ARG_KIND (aut)
ALGO (concatenate));
DEFINE_COMMAND (NAME (eval)
CODE (/* Empty */)
OUTPUT (
eval (realtime (get_aut (args.args[1])),
std::string (args.args[2])))
RETURNVALUE (0));
DEFINE_COMMAND (NAME (power)
CODE (int n = atoi (args.args[2]);
automaton_t a = get_aut (args.args[1]);
automaton_t p (a);
for (int i = 1; i < n; ++i)
p = product (p, a))
OUTPUT (automaton_saver (p, string_out (), XML ()))
RETURNVALUE (0));
DEFINE_COMMAND (NAME (standardize)
CODE (automaton_t a = get_aut (args.args[1]);
standardize (a))
OUTPUT (automaton_saver (a, string_out (), XML ()))
RETURNVALUE (0));
#endif
DEFINE_ONE_ARG_COMMAND (ARG_KIND (aut)
ALGO (trim));
DEFINE_ONE_ARG_COMMAND (ARG_KIND (aut)
ALGO (transpose));
DEFINE_ONE_ARG_COMMAND_TWO_ALGOS (NAME (closure)
ARG_KIND (aut)
ALGOS (accessible, closure));
DEFINE_COMMAND (NAME (are_isomorphic)
CODE (bool b = are_isomorphic (get_aut (args.args[1]),
......@@ -105,14 +126,6 @@ DEFINE_COMMAND (NAME (are_isomorphic)
: "Automata are not isomorphic\n"))
RETURNVALUE (b ? 0 : 1));
DEFINE_COMMAND (NAME (eval)
CODE (/* Empty */)
OUTPUT (
eval (realtime (get_aut (args.args[1])),
std::string (args.args[2]))
<< std::endl)
RETURNVALUE (0));
DEFINE_COMMAND (NAME (is_empty)
CODE (
int states = trim (get_aut (args.args[1])).states ().size ())
......@@ -120,15 +133,6 @@ DEFINE_COMMAND (NAME (is_empty)
(states ? "Entry is not empty\n" : "Entry is empty\n"))
RETURNVALUE (states == 0 ? 0 : 1));
DEFINE_COMMAND (NAME (power)
CODE (int n = atoi (args.args[2]);
automaton_t a = get_aut (args.args[1]);
automaton_t p (a);
for (int i = 1; i < n; ++i)
p = product (p, a))
OUTPUT (automaton_saver (p, string_out (), XML ()))
RETURNVALUE (0));
DEFINE_COMMAND (NAME (info)
CODE (automaton_t a = get_aut (args.args[1]))
OUTPUT (
......@@ -138,12 +142,6 @@ DEFINE_COMMAND (NAME (info)
<< "Final states: " << a.final ().size () << std::endl)
RETURNVALUE (0));
DEFINE_COMMAND (NAME (standardize)
CODE (automaton_t a = get_aut (args.args[1]);
standardize (a))
OUTPUT (automaton_saver (a, string_out (), XML ()))
RETURNVALUE (0));
DEFINE_COMMAND (NAME (identity)
CODE (automaton_t a = get_aut (args.args[1]))
OUTPUT (automaton_saver (a, string_out (), XML ()))
......
// edition_commands.hxx: this file is part of the Vaucanson project.
// edit_commands.hxx: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
......@@ -14,8 +14,8 @@
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef EDIT_AUTOMATON_HXX
# define EDIT_AUTOMATON_HXX
#ifndef EDITION_COMMANDS_HXX
# define EDITION_COMMANDS_HXX
/**
* @file edition_commands.hxx
......@@ -66,7 +66,7 @@ extern void tputs (...);
| Functions that interact with the user to let her edit an |
| automaton |
`---------------------------------------------------------*/
#ifndef WITH_TWO_ALPHABETS
namespace edition_commands
{
using namespace CONTEXT_NAMESPACE;
......@@ -371,7 +371,11 @@ static int edit_automaton_command (const arguments_t& args)
using namespace vcsn::io;
using namespace vcsn::xml;
automaton_t a = make_automaton (get_alphabet ("dummy"));
# ifndef WITH_TWO_ALPHABETS
automaton_t a = make_automaton (alphabet_t ());
# else
automaton_t a = make_automaton (first_alphabet_t (), second_alphabet_t ());
# endif // !WITH_TWO_ALPHABETS
std::fstream input (args.args[1]);
......@@ -408,7 +412,12 @@ static int define_automaton_command (const arguments_t& args)
return -1;
}
# ifndef WITH_TWO_ALPHABETS
automaton_t a = make_automaton (get_alphabet (args.alphabet));
# else
automaton_t a = make_automaton (get_first_alphabet (args.alphabet),
get_second_alphabet (args.alphabet2));
# endif // !WITH_TWO_ALPHABETS
edition_commands::main_loop (a);
output << automaton_saver (a, string_out (), XML ()) << std::endl;
......@@ -416,5 +425,6 @@ static int define_automaton_command (const arguments_t& args)
return 0;
}
#endif // ! WITH_TWO_ALPHABETS
#endif // ! EDIT_AUTOMATON_HXX
#endif // ! EDITION_COMMANDS_HXX
......@@ -35,12 +35,20 @@
using namespace CONTEXT_NAMESPACE;
using namespace vcsn;
# ifndef WITH_TWO_ALPHABETS
static alphab