5 #include <boost/optional.hpp> 30 template <
typename Context,
typename Tapes,
typename Enable =
void>
34 template <
typename Context>
68 template <
typename... LabelSets,
typename WeightSet,
72 std::enable_if_t<(0 < sizeof...(Tapes))>>
80 template <std::size_t... I>
84 template <
typename S,
typename L>
88 template <
typename LabelSet>
89 struct tape_set<seq<>, LabelSet>
94 template <
size_t... I,
typename LabelSet>
95 struct tape_set<seq<I...>, LabelSet>
139 template <
size_t... WeightTapes,
size_t... KeptTapes>
158 static typename labelset_t::value_t
164 template <
size_t... I>
165 static typename labelset_t::value_t
168 return typename labelset_t::value_t{std::get<I>(l)...};
172 static typename weight_tapes_t::value_t
178 template <
size_t... I>
179 static typename weight_tapes_t::value_t
182 return typename weight_tapes_t::value_t{std::get<I>(l)...};
187 template <
typename Ctx,
size_t... Tapes>
190 template <
Automaton Aut,
size_t... Tapes>
193 Tapes...>::context_t>;
196 template <
typename LabelSet,
typename WeightSet,
size_t... Tapes>
213 template <
Automaton Aut,
size_t... Tapes>
217 using auto_in_t = Aut;
221 auto ctx_out = lifter::value(a->context(),
ids);
224 const auto& rs_in = *ctx_out.weightset();
228 auto_out_t
res = make_shared_ptr<auto_out_t>(ctx_out);
231 auto map = std::map<state_in_t, state_out_t>{};
232 map[a->pre()] = res->pre();
233 map[a->post()] = res->post();
234 for (
auto s: a->states())
235 map[s] = res->new_state();
238 if (a->src_of(t) == a->pre())
239 res->add_initial(map[a->dst_of(t)],
240 rs_in.lweight(a->weight_of(t), rs_in.one()));
241 else if (a->dst_of(t) == a->post())
242 res->add_final(map[a->src_of(t)],
243 rs_in.lweight(a->weight_of(t), rs_in.one()));
246 (map[a->src_of(t)], map[a->dst_of(t)],
247 lifter::kept_label(a->label_of(t)),
248 rs_in.lweight(a->weight_of(t),
249 rs_in.atom(lifter::weight_label(a->label_of(t)))));
258 template <
Automaton Aut,
typename Ids,
typename... Tapes>
263 const auto& a = aut->
as<Aut>();
275 template <
typename ExpSet>
280 template <
typename Context>
283 boost::optional<vcsn::rat::identities>
ids = {})
286 return {
lift_context(rs.context()),
ids.get_value_or(rs.identities())};
291 template <
typename ExpSet>
293 lift(
const ExpSet& rs,
const typename ExpSet::value_t& e)
296 return lrs.lweight(e, lrs.one());
305 template <
typename ExpSet>
309 const auto& e = exp->as<ExpSet>();
310 const auto& es = e.valueset();
std::shared_ptr< detail::mutable_automaton_impl< Context > > mutable_automaton
static context_t value_(const in_context_t &ctx, vcsn::rat::identities ids, seq< WeightTapes... >, seq< KeptTapes... >)
Implementation of labels are ones: there is a single instance of label.
auto all_transitions(const Aut &aut)
All the transition indexes between all states (including pre and post).
std::shared_ptr< const node< Context > > expression
typename in_labelset_t::template valueset_t< I > tape_labelset_t
static oneset::value_t kept_label(const in_label_t &)
Label in the output.
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
typename in_labelset_t::value_t in_label_t
detail::lifted_expressionset_t< ExpSet >::value_t lift(const ExpSet &rs, const typename ExpSet::value_t &e)
Move all the labels to the weights.
expression lift_expression(const expression &exp)
Bridge (lift).
static weight_tapes_t::value_t weight_label(const in_label_t &l)
Weight in the output.
typename index_sequence_difference< typename S1::type, typename S2::type >::type sequence_difference
An expressionset can implement several different sets of identities on expressions.
static labelset_t::value_t kept_label(const in_label_t &l)
Label in the output.
label_t_of< in_context_t > in_label_t
Provide a variadic mul on top of a binary mul(), and one().
detail::lifted_automaton_t< Aut, Tapes... > lift(const Aut &a, vcsn::rat::identities ids={})
Lift some tapes of the transducer.
static context_t value(const in_context_t &ctx, vcsn::rat::identities ids)
Conversion.
Build the static sequence of size_t [0, N[.
static context_t value(const in_context_t &ctx, vcsn::rat::identities ids)
Lift a context.
A simple placeholder for integral constants.
std::string type(const automaton &a)
The implementation type of a.
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
expressionset< typename lifter_t< context_t_of< ExpSet > >::context_t > lifted_expressionset_t
typename tape_set< kept_index_t, in_labelset_t >::type labelset_t
Labelset of tapes to be kept.
sequence_difference< index_t, seq< Tapes... > > kept_index_t
Complement the list of indexes of tapes to be lifted, to get the list of tapes to be kept...
lifted_expressionset_t< expressionset< Context > > lift_expressionset(const expressionset< Context > &rs, boost::optional< vcsn::rat::identities > ids={})
lift(expressionset) -> expressionset
automaton lift_automaton(const automaton &aut, identities ids, integral_constant)
Bridge.
auto & as()
Extract wrapped typed automaton.
typename detail::make_index_sequence< in_labelset_t::size()>::type index_t
Index of all input tapes.
Helper structure for a lift of several tapes.
value_impl< detail::expression_tag > expression
const labelset_ptr & labelset() const
static weight_tapes_t::value_t weight_label_(const in_label_t &l, seq< I... >)
static identities ids(const driver &d)
Get the identities of the driver.
Context in_context_t
Input context.
mutable_automaton< typename lifter_t< context_t_of< Aut >, Tapes... >::context_t > lifted_automaton_t
const weightset_ptr & weightset() const
auto map(const std::tuple< Ts... > &ts, Fun f) -> decltype(map_tuple_(f, ts, make_index_sequence< sizeof...(Ts)>()))
Map a function on a tuple, return tuple of the results.
typename tape_set< weight_index_t, in_labelset_t >::type weight_tapes_t
Labelset of tapes to be lifted.
static labelset_t::value_t kept_label_(const in_label_t &l, seq< I... >)
static in_label_t weight_label(const in_label_t &l)
Weight in the output.
lifter_t< context< LabelSet, WeightSet >, Tapes... >::context_t lift_context(const context< LabelSet, WeightSet > &ctx)
lift(ctx) -> ctx