Commit 1988f13a authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Merge branch 'exp/pair-to-fmp' into next

Conflicts:
	ChangeLog
parents 09fc0560 fa0869d6
2009-06-05 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Add the pair-to-fmp command to TAF-Kit.
* taf-kit/src/Makefile.am (vcsn_char_fmp_b_LDADD,
vcsn_char_fmp_z_LDADD, vcsn_int_fmp_b_LDADD,
vcsn_int_fmp_z_LDADD): Add the corresponding pair automaton
library.
* taf-kit/src/fmp_commands.cc (pair_to_fmp): New command.
* taf-kit/src/getters.hxx (get_pair_aut): New function.
* taf-kit/src/pipe_getters.hh, taf-kit/src/pipe_getters.hxx
(pair_automaton_getter): New class.
* taf-kit/tests/vcsn-char-fmp-b.test,
taf-kit/tests/vcsn-int-fmp-z.test: Add more tests for ltl-to-pair
and pair-to-fmp.
2009-06-05 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Make pair_to_fmp() available in FMP contexts.
* include/vaucanson/contexts/fmp_transducer_functions.thh:
include pair_to_fmp.hh.
2009-06-05 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Make mute_ltl_to_pair<S,T>::make_automaton available.
* include/vaucanson/algorithms/ltl_to_pair.hxx (make_automaton):
Move the code...
* include/vaucanson/algorithms/ltl_to_pair.hh (make_automaton):
... here, so it is available even if VCSN_USE_INTERFACE_ONLY
is defined.
2009-06-05 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Introduce contexts for char-char-z and int-int-z automata.
* include/vaucanson/automata/generic_contexts/char_char_z_automaton.hh,
include/vaucanson/automata/generic_contexts/char_char_z_automaton_structures.hh,
include/vaucanson/automata/generic_contexts/int_int_z_automaton.hh,
include/vaucanson/automata/generic_contexts/int_int_z_automaton_structures.hh:
New files.
* include/Makefile.am (nobase_include_HEADERS): Add them.
* lib/generate_libvcsn.rb: Adjust to build int-int-z and
char-char-z contexts.
* lib/Makefile.am: Include the new libraries' makefiles.
2009-03-23 Alexandre Duret-Lutz <adl@lrde.epita.fr>
 
Remove Vaucanswig.
......
......@@ -481,11 +481,15 @@ vaucanson/automata/generic_contexts/int_z_min_plus_automaton_structures.hh \
vaucanson/automata/generic_contexts/int_z_fmp_transducer.hh \
vaucanson/automata/generic_contexts/int_z_fmp_transducer_structures.hh \
vaucanson/automata/generic_contexts/char_char_boolean_automaton.hh \
vaucanson/automata/generic_contexts/char_char_z_automaton.hh \
vaucanson/automata/generic_contexts/char_int_boolean_automaton.hh \
vaucanson/automata/generic_contexts/int_int_boolean_automaton.hh \
vaucanson/automata/generic_contexts/int_int_z_automaton.hh \
vaucanson/automata/generic_contexts/char_char_boolean_automaton_structures.hh \
vaucanson/automata/generic_contexts/char_char_z_automaton_structures.hh \
vaucanson/automata/generic_contexts/char_int_boolean_automaton_structures.hh \
vaucanson/automata/generic_contexts/int_int_boolean_automaton_structures.hh \
vaucanson/automata/generic_contexts/int_int_z_automaton_structures.hh \
vaucanson/automata/implementation/automaton_view.hh \
vaucanson/automata/implementation/automaton_view.hxx \
vaucanson/automata/implementation/bmig/bmig_functors.hh \
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2008 The Vaucanson Group.
// Copyright (C) 2008, 2009 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
......@@ -128,8 +128,14 @@ namespace vcsn
typedef Element<ret_set_t, ret_impl_t> ret;
// Automaton "makers".
static ret
make_automaton(const ret_alphabet_t&);
static inline ret
make_automaton(const ret_alphabet_t& A)
{
semiring_t semiring;
ret_monoid_t freemonoid(A);
typename ret::series_set_t series(semiring, freemonoid);
return ret(Automata<typename ret::series_set_t, typename ret::kind_t>(series));
}
static ret
make_automaton(const automaton_t&);
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2008 The Vaucanson Group.
// Copyright (C) 2008, 2009 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
......@@ -44,18 +44,6 @@ namespace vcsn
return E;
}
template <typename S, typename T>
inline typename MUTE_TRAITS::ret
MUTE_TRAITS::
make_automaton(const typename MUTE_TRAITS::ret_alphabet_t& A)
{
semiring_t semiring;
ret_monoid_t freemonoid(A);
typename ret::series_set_t series(semiring, freemonoid);
return ret(Automata<typename ret::series_set_t, typename ret::kind_t>(series));
}
template <typename S, typename T>
inline typename MUTE_TRAITS::ret
MUTE_TRAITS::
......
// char_char_z_automaton.hh: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 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.
//
/*
* CPP guard should not be inserted here as
* VCSN_GRAPH_IMPL could be changed.
*/
# include GRAPH_CONTEXT_HEADER_(char_char_z_automaton_structures.hh)
# define VCSN_CONTEXT_NAMESPACE namespace char_char_z_automaton
# include <vaucanson/contexts/automaton_functions.thh>
# undef VCSN_CONTEXT_NAMESPACE
// char_char_boolean_z_structures.hh: this file is part of the
// Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 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.
//
/*
* CPP guard should not be inserted here as
* VCSN_GRAPH_IMPL could be changed.
*/
# define VCSN_CONTEXT_NAMESPACE namespace char_char_z_automaton
# include <vaucanson/contexts/char_char_letter.thh>
# include <vaucanson/contexts/dynamic_alphabet.thh>
# include <vaucanson/contexts/free_monoid.thh>
# include <vaucanson/contexts/z_semiring.thh>
# include <vaucanson/contexts/generic_series.thh>
# include <vaucanson/contexts/generic_automaton_impl.thh>
# include <vaucanson/contexts/automaton.thh>
namespace vcsn
{
namespace VCSN_GRAPH_IMPL
{
VCSN_CONTEXT_NAMESPACE
{
AUTOMATON_FREEMONOID_TYPES_EXACT(automaton_t);
AUTOMATON_PROJECTION_TYPES();
}
}
}
# include <vaucanson/contexts/automaton_maker.thh>
# undef VCSN_CONTEXT_NAMESPACE
// int_int_z_automaton.hh: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 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.
//
/*
* CPP guard should not be inserted here as
* VCSN_GRAPH_IMPL could be changed.
*/
# include GRAPH_CONTEXT_HEADER_(int_int_z_automaton_structures.hh)
# define VCSN_CONTEXT_NAMESPACE namespace int_int_z_automaton
# include <vaucanson/contexts/automaton_functions.thh>
# undef VCSN_CONTEXT_NAMESPACE
// int_int_z_automaton_structures.hh: this file is part of the
// Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 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.
//
/*
* CPP guard should not be inserted here as
* VCSN_GRAPH_IMPL could be changed.
*/
# define VCSN_CONTEXT_NAMESPACE namespace int_int_z_automaton
# include <vaucanson/contexts/int_int_letter.thh>
# include <vaucanson/contexts/dynamic_alphabet.thh>
# include <vaucanson/contexts/free_monoid.thh>
# include <vaucanson/contexts/z_semiring.thh>
# include <vaucanson/contexts/generic_series.thh>
# include <vaucanson/contexts/generic_automaton_impl.thh>
# include <vaucanson/contexts/automaton.thh>
/* Specializations */
# include <vaucanson/algebra/implementation/monoid/free_monoid_int.hh>
namespace vcsn
{
namespace VCSN_GRAPH_IMPL
{
VCSN_CONTEXT_NAMESPACE
{
AUTOMATON_FREEMONOID_TYPES_EXACT(automaton_t);
AUTOMATON_PROJECTION_TYPES();
}
}
}
# include <vaucanson/contexts/automaton_maker.thh>
# undef VCSN_CONTEXT_NAMESPACE
......@@ -3,7 +3,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2005, 2006, 2008 The Vaucanson Group.
// Copyright (C) 2005, 2006, 2008, 2009 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
......@@ -36,6 +36,7 @@
#include <vaucanson/algorithms/is_ltl.hh>
#include <vaucanson/algorithms/ltl_to_pair.hh>
#include <vaucanson/algorithms/normalized_composition.hh>
#include <vaucanson/algorithms/pair_to_fmp.hh>
#include <vaucanson/algorithms/projection.hh>
#include <vaucanson/algorithms/sub_normalize.hh>
#include <vaucanson/algorithms/transpose.hh>
......@@ -33,8 +33,10 @@ include vcsn-z-tdc/libvcsn-z-tdc.mk
include vcsn-int-fmp-tdc/libvcsn-int-fmp-tdc.mk
include vcsn-int-z-fmp-tdc/libvcsn-int-z-fmp-tdc.mk
include vcsn-char-char-b/libvcsn-char-char-b.mk
include vcsn-char-char-z/libvcsn-char-char-z.mk
include vcsn-char-int-b/libvcsn-char-int-b.mk
include vcsn-int-int-b/libvcsn-int-int-b.mk
include vcsn-int-int-z/libvcsn-int-int-z.mk
maintainer-clean-local:
rm -rf $(top_builddir)/lib/vcsn-b \
......@@ -51,8 +53,10 @@ maintainer-clean-local:
$(top_builddir)/lib/vcsn-int-fmp-tdc \
$(top_builddir)/lib/vcsn-tdc \
$(top_builddir)/lib/vcsn-char-char-b \
$(top_builddir)/lib/vcsn-char-char-z \
$(top_builddir)/lib/vcsn-char-int-b \
$(top_builddir)/lib/vcsn-int-int-b
$(top_builddir)/lib/vcsn-int-int-b \
$(top_builddir)/lib/vcsn-int-int-z
rm -rf $(top_srcdir)/lib/vcsn-b \
$(top_srcdir)/lib/vcsn-int-b \
$(top_srcdir)/lib/vcsn-r \
......@@ -67,5 +71,7 @@ maintainer-clean-local:
$(top_srcdir)/lib/vcsn-int-fmp-tdc \
$(top_srcdir)/lib/vcsn-tdc \
$(top_srcdir)/lib/vcsn-char-char-b \
$(top_srcdir)/lib/vcsn-char-char-z \
$(top_srcdir)/lib/vcsn-char-int-b \
$(top_srcdir)/lib/vcsn-int-int-b \
$(top_srcdir)/lib/vcsn-int-int-b
......@@ -2,7 +2,7 @@
# generate_libvcsn.rb: this file is part of the Vaucanson project.
#
# Vaucanson, a generic library for finite state machines.
# Copyright (C) 2007, 2008 The Vaucanson Group.
# Copyright (C) 2007, 2008, 2009 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
......@@ -30,8 +30,10 @@ vcsn = Hash[
"vcsn-int-z-fmp-tdc" => "int_z_fmp_transducer",
"vcsn-z-tdc" => "z_transducer",
"vcsn-char-char-b" => "char_char_boolean_automaton",
"vcsn-char-char-z" => "char_char_z_automaton",
"vcsn-char-int-b" => "char_int_boolean_automaton",
"vcsn-int-int-b" => "int_int_boolean_automaton",
"vcsn-int-int-z" => "int_int_z_automaton",
]
# Creating directories in lib/
......@@ -51,8 +53,9 @@ def create?(type, file)
( "vcsn-b" == type or "vcsn-r" == type or "vcsn-z" == type or
"vcsn-int-b" == type or "vcsn-int-z" == type or
"vcsn-z-max" == type or "vcsn-z-min" == type or
"vcsn-char-char-b" == type or "vcsn-char-int-b" == type or
"vcsn-int-int-b" == type
"vcsn-char-char-b" == type or "vcsn-char-char-z" == type or
"vcsn-char-int-b" == type or "vcsn-int-int-b" == type or
"vcsn-int-int-z" == type
) and
file !~ /realtime_decl.hh/ and
file !~ /extension.hh/ and # transducer
......@@ -76,8 +79,11 @@ def create?(type, file)
)
) and
( # Pair letters only filters.
not ( "vcsn-char-char-b" == type or "vcsn-char-int-b" == type or
"vcsn-int-int-b" == type
not ( "vcsn-char-char-b" == type or
"vcsn-char-char-z" == type or
"vcsn-char-int-b" == type or
"vcsn-int-int-b" == type or
"vcsn-int-int-z" == type
) or
(
file !~ /berry_sethi.hh/ # algorithm not generic with letter_t
......@@ -147,7 +153,7 @@ def create?(type, file)
file !~ /\/projection.hh/ and # FMP transducer (identity)
file !~ /composition_cover.hh/ # FMP transducer
)
)
)
)
)
end
......
......@@ -81,7 +81,8 @@ vcsn_char_fmp_b_CPPFLAGS = $(AM_CPPFLAGS) \
-DRW_CONTEXT=boolean_transducer -DVCSN_USE_LIB
vcsn_char_fmp_b_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-fmp-tdc.la \
$(top_builddir)/lib/libvcsn-b.la
$(top_builddir)/lib/libvcsn-b.la \
$(top_builddir)/lib/libvcsn-char-char-b.la
vcsn_char_fmp_z_SOURCES = $(COMMON_SOURCES) \
fmp_commands.cc
......@@ -93,7 +94,8 @@ vcsn_char_fmp_z_CPPFLAGS = $(AM_CPPFLAGS) \
-DWITH_WEIGHTS
vcsn_char_fmp_z_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-z-fmp-tdc.la \
$(top_builddir)/lib/libvcsn-z.la
$(top_builddir)/lib/libvcsn-z.la \
$(top_builddir)/lib/libvcsn-char-char-z.la
vcsn_int_b_SOURCES = $(COMMON_SOURCES) \
ratexp_commands.hh \
......@@ -121,7 +123,8 @@ vcsn_int_fmp_b_CPPFLAGS = $(AM_CPPFLAGS) -DCONTEXT=int_fmp_transducer \
-DRW_CONTEXT=int_boolean_transducer -DVCSN_USE_LIB
vcsn_int_fmp_b_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-int-b.la \
$(top_builddir)/lib/libvcsn-int-fmp-tdc.la
$(top_builddir)/lib/libvcsn-int-fmp-tdc.la \
$(top_builddir)/lib/libvcsn-int-int-b.la
vcsn_int_fmp_z_SOURCES = $(COMMON_SOURCES) \
fmp_commands.cc
......@@ -133,7 +136,8 @@ vcsn_int_fmp_z_CPPFLAGS = $(AM_CPPFLAGS) -DCONTEXT=int_z_fmp_transducer \
-DVCSN_USE_LIB
vcsn_int_fmp_z_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-int-z.la \
$(top_builddir)/lib/libvcsn-int-z-fmp-tdc.la
$(top_builddir)/lib/libvcsn-int-z-fmp-tdc.la \
$(top_builddir)/lib/libvcsn-int-int-z.la
vcsn_char_char_b_SOURCES = $(COMMON_SOURCES) \
ratexp_commands.hh \
......
......@@ -82,6 +82,14 @@ DEFINE_COMMAND(NAME(ltl_to_pair)
KEEP(dst)
RETURNVALUE(0));
DEFINE_COMMAND(NAME(pair_to_fmp)
CODE(
vcsn::mute_ltl_to_pair_t::ret src = get_pair_aut(args, 1);
automaton_t dst = pair_to_fmp(src);
set_writing_data(dst, args))
KEEP(dst)
RETURNVALUE(0));
DEFINE_COMMAND (NAME(evaluation)
CODE(automaton_t src = get_aut(args, 1))
OUTPUT(
......@@ -214,7 +222,9 @@ const command_t command_map[] =
"Evaluate the language described by the\n\t"
IOAUT_NAME " automaton `aut2' on the transducer `aut1'."),
COMMAND_ENTRY(ltl_to_pair, Aut,
"Give an automaton defined over a pair letter alphabet same as `aut'."),
"Convert `Aut' into an automaton defined over a pair letter alphabet."),
COMMAND_ENTRY(pair_to_fmp, Aut,
"Convert an automata `Aut' using pair letters into an FMP."),
COMMAND_ENTRY(image, Aut,
"Give an automaton that accepts all output produced by `aut'."),
COMMAND_ENTRY(transpose, Aut,
......
......@@ -332,6 +332,66 @@ static IOAUT_CONTEXT::automaton_t get_boolean_aut(const arguments_t& args, const
exit(1);
}
}
static
mute_ltl_to_pair<automaton_t::set_t, automaton_t::value_t>::ret
get_pair_aut(const arguments_t& args, const int& n)
{
const std::string& s = args.args[n];
if (s == "-")
{
mute_ltl_to_pair<automaton_t::set_t, automaton_t::value_t>::ret a =
boost::apply_visitor(pair_automaton_getter
(global_result.name, global_result.input_aut_type),
global_result.output);
// We don't set the writing data before return because the
// pair automaton will be passed to pair_to_fmp and we will
// force the writing data on the resulting fmp.
return a;
}
std::istream* is (s == "-" ? &std::cin : new std::ifstream (s.c_str()));
if (not is->fail())
{
using namespace vcsn::tools;
using namespace vcsn::xml;
mute_ltl_to_pair<automaton_t::set_t, automaton_t::value_t>::ret a =
mute_ltl_to_pair<automaton_t::set_t, automaton_t::value_t>::
make_automaton(mute_ltl_to_pair<automaton_t::set_t,
automaton_t::value_t>::ret_alphabet_t());
switch (global_result.input_aut_type)
{
case INPUT_TYPE_XML:
*is >> automaton_loader(a, string_out (), XML ());
break;
case INPUT_TYPE_FSM:
fsm_load(*is, a);
break;
default:
std::cerr << "FATAL: Could not load automaton." << std::endl;
exit(1);
}
if (s != "-")
delete is;
// We don't set the writing data before return because the
// pair automaton will be passed to pair_to_fmp and we will
// force the writing data on the resulting fmp.
return a;
}
else
{
std::cerr << "FATAL: Could not load automaton." << std::endl;
exit(1);
}
}
#endif // !WITH_TWO_ALPHABETS
// Set the representations provided on the command line.
......
......@@ -94,6 +94,31 @@ public:
std::string command;
input_format_t f;
};
class pair_automaton_getter
: public boost::static_visitor<mute_ltl_to_pair<automaton_t::set_t,
automaton_t::value_t>::ret>
{
public:
typedef mute_ltl_to_pair<automaton_t::set_t, automaton_t::value_t> trait;
typedef trait::ret pair_t;
pair_automaton_getter (std::string& command, input_format_t);
pair_t
operator() (pair_t& a) const;
pair_t
operator() (std::string& str) const;
pair_t operator() (command_output_status& i) const;
template<typename T>
pair_t operator() (T&) const;
std::string command;
input_format_t f;
};
# endif // !WITH_TWO_ALPHABETS
#endif /* !PIPE_GETTERS_HH */
......@@ -296,6 +296,85 @@ boolean_automaton_getter::operator() (T&) const
<< std::endl;
exit (1);
}
pair_automaton_getter::pair_automaton_getter (std::string& cmd,
input_format_t fmt)
: command (cmd),
f (fmt)
{
}
pair_automaton_getter::pair_t
pair_automaton_getter::operator() (pair_automaton_getter::pair_t& a) const
{
return a;
}
pair_automaton_getter::pair_t
pair_automaton_getter::operator() (std::string& str) const
{
std::istringstream is (str);
// Representations will be build by the automaton loader.
pair_automaton_getter::pair_t a =
pair_automaton_getter::trait::make_automaton(trait::ret_alphabet_t());
switch (f)
{
case INPUT_TYPE_XML:
is >> automaton_loader(a, string_out (), XML ());
break;
case INPUT_TYPE_FSM:
fsm_load(is, a);
break;
default:
std::cerr << "FATAL: Could not load automaton." << std::endl;
exit(1);
}
return a;
}
pair_automaton_getter::pair_t
pair_automaton_getter::operator() (command_output_status& i) const
{
if (i != PIPE_GET_FROM_STDIN)
{
std::cerr << command
<< ": Incorrect input type"
<< std::endl;
exit (1);
}
// Representations will be build by the automaton loader.
pair_automaton_getter::pair_t a =
pair_automaton_getter::trait::make_automaton(trait::ret_alphabet_t());
switch (f)
{
case INPUT_TYPE_XML:
std::cin >> automaton_loader(a, string_out (), XML ());
break;
case INPUT_TYPE_FSM:
fsm_load(std::cin, a);
break;