17 #ifndef AWALI_ALGOS_LIFT_HH
18 # define AWALI_ALGOS_LIFT_HH
29 namespace awali {
namespace sttc {
38 template <
typename ValueSet>
41 using type =
typename ValueSet::context_t;
44 template <
typename Context>
50 template <
typename ValueSet>
53 template <
typename Context>
57 template <
typename Aut>
61 template <
typename RatExpSet>
66 template <
typename LabelSet,
typename WeightSet>
77 template <
typename Context>
78 lifted_ratexpset_t<ratexpset<Context>>
90 template <
typename Aut>
92 internal::lifted_automaton_t<Aut>
93 lift(
const Aut& a,
bool keep_history=
true)
95 using auto_in_t =
typename Aut::element_type;
100 rs_in_t rs_in{
get_rat_context(a->context()), rs_in_t::identities_t::trivial};
104 auto_out_t res = make_shared_ptr<auto_out_t>(ctx_out);
105 std::map<state_t, state_t>
map;
106 map[a->pre()] = res->pre();
107 map[a->post()] = res->post();
108 for (
auto s: a->states())
109 map[s] = res->add_state();
111 for (
auto t: a->all_transitions())
112 if (a->src_of(t) == a->pre())
113 res->add_initial(
map[a->dst_of(t)],
114 rs_in.lmul(a->weight_of(t), rs_in.one()));
115 else if (a->dst_of(t) == a->post())
116 res->add_final(
map[a->src_of(t)],
117 rs_in.lmul(a->weight_of(t), rs_in.one()));
118 else if (a->context().labelset()->is_one(a->label_of(t)))
121 (
map[a->src_of(t)],
map[a->dst_of(t)],
123 rs_in.lmul(a->weight_of(t), rs_in.one()));
127 (
map[a->src_of(t)],
map[a->dst_of(t)],
129 rs_in.lmul(a->weight_of(t), rs_in.atom(a->label_of(t))));
131 auto history = std::make_shared<single_history<Aut>>(a);
133 history->add_state(p.second,p.first);
134 res->set_history(history);
145 template <
typename Exp>
150 template <
typename RatExpSet>
153 lift(
const RatExpSet& rs,
const typename RatExpSet::ratexp_t& e)
156 return lrs.lmul(e, lrs.one());
carries the algebraic settings of automata
Definition: context.hh:40
Implementation of labels are ones: there is a single instance of label.
Definition: oneset.hh:38
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.
Definition: tuple.hh:134
mutable_automaton< lifted_context_t< context_t_of< Aut > >> lifted_automaton_t
Definition: lift.hh:59
typename ValueSet::context_t type
Definition: lift.hh:41
lifted_context_t< context< LabelSet, WeightSet > > lift_context(const context< LabelSet, WeightSet > &ctx)
Definition: lift.hh:68
Context type
Definition: lift.hh:47
typename context_of< ValueSet >::type context_of_t
Definition: lift.hh:51
lifted_ratexpset_t< ratexpset< Context > > lift_ratexpset(const ratexpset< Context > &rs)
Definition: lift.hh:79
typename lifted_context_t< context_t_of< Exp > >::ratexp_t lifted_ratexp_t
Definition: lift.hh:147
@ trivial
Trivial identities only.
auto get_rat_context(const Context &ctx) -> context< typename labelset_trait< typename Context::labelset_t >::ratlabelset_t, typename Context::weightset_t >
Definition: traits.hh:238
typename internal::context_t_of_impl< internal::base_t< ValueSet > >::type context_t_of
Helper to retrieve the type of the context of a value set.
Definition: traits.hh:66
internal::lifted_automaton_t< Aut > lift(const Aut &a, bool keep_history=true)
Definition: lift.hh:93
std::shared_ptr< internal::mutable_automaton_impl< Context > > mutable_automaton
Definition: mutable_automaton.hh:45
Main namespace of Awali.
Definition: ato.hh:22
Provide a variadic mul on top of a binary mul(), and one().
Definition: weightset.hh:38