17 #ifndef AWALI_CTX_CONTEXT_HH
18 # define AWALI_CTX_CONTEXT_HH
24 #include <awali/common/json/node.cc>
31 namespace awali {
namespace sttc {
38 template <
typename LabelSet,
typename WeightSet>
47 using kind_t =
typename labelset_t::kind_t;
58 using label_t =
typename labelset_t::value_t;
60 using weight_t =
typename weightset_t::value_t;
63 using ratexp_t = std::shared_ptr<const node_t>;
82 :
context(std::make_shared<const labelset_t>(ls),
83 std::make_shared<const weightset_t>(ws))
101 template <
typename LabelSet2 = labelset_t>
102 context(
const std::initializer_list<typename LabelSet2::letter_t>& gs,
108 template <
typename LabelSet2 = labelset_t>
130 return (labelset_t::sname()
131 +
"_" + weightset_t::sname());
143 auto ls = labelset_t::make(is);
145 auto ws = weightset_t::make(is);
172 template<
unsigned version = version::fsm_json>
176 obj->
push_back(
"labels", ls_->template to_json<version>());
177 obj->
push_back(
"weights", ws_->template to_json<version>());
181 static constexpr
bool
184 return labelset_t::has_one();
205 template <
typename... ValueSets>
215 template <
typename... ValueSets>
225 template <
typename ValueSet>
233 template <
typename ValueSet1,
typename ValueSet2,
234 typename ValueSet3,
typename... VSs>
236 join(
const ValueSet1& vs1,
const ValueSet2& vs2,
const ValueSet3& vs3,
238 -> decltype(
join(
join(vs1, vs2), vs3, vs...))
240 return join(
join(vs1, vs2), vs3, vs...);
245 template <
typename ValueSet>
253 template <
typename ValueSet1,
typename ValueSet2,
typename ValueSet3,
256 meet(
const ValueSet1& vs1,
const ValueSet2& vs2,
const ValueSet3& vs3,
258 -> decltype(
meet(
meet(vs1, vs2), vs3, vs...))
260 return meet(
meet(vs1, vs2), vs3, vs...);
269 template <
typename LhsLabelSet,
typename LhsWeightSet,
270 typename RhsLabelSet,
typename RhsWeightSet>
277 auto ls =
join(*a.labelset(), *
b.labelset());
278 auto ws =
join(*a.weightset(), *
b.weightset());
288 template <
typename LhsLabelSet,
typename LhsWeightSet,
289 typename RhsLabelSet,
typename RhsWeightSet>
296 auto ls =
meet(*a.labelset(), *
b.labelset());
297 auto ws =
join(*a.weightset(), *
b.weightset());
object_t * push_back(std::string key, node_t *node)
The Boolean semring.
Definition: b.hh:38
carries the algebraic settings of automata
Definition: context.hh:40
std::string vname(bool full=true) const
Definition: context.hh:134
LabelSet labelset_t
Definition: context.hh:42
const weightset_ptr & weightset() const
Definition: context.hh:154
typename labelset_t::kind_t kind_t
Definition: context.hh:47
static std::string sname()
The name of this context, built from its parameters.
Definition: context.hh:128
@ is_law
Definition: context.hh:55
@ is_lao
Definition: context.hh:52
@ is_lat
Definition: context.hh:54
@ is_lal
Definition: context.hh:50
@ is_lar
Definition: context.hh:53
@ is_lan
Definition: context.hh:51
context(const labelset_ptr &ls, const weightset_ptr &ws)
Definition: context.hh:73
json::node_t * to_json() const
Definition: context.hh:174
static constexpr bool has_one()
Definition: context.hh:182
typename labelset_t::value_t label_t
Type of transition labels, and type of RatExp atoms.
Definition: context.hh:58
std::shared_ptr< const weightset_t > weightset_ptr
Definition: context.hh:45
context()
Build a context whose labelset constructor takes no argument.
Definition: context.hh:109
static context make(std::istream &is)
Build from the description in is.
Definition: context.hh:141
std::shared_ptr< const labelset_t > labelset_ptr
Definition: context.hh:44
context(const std::initializer_list< typename LabelSet2::letter_t > &gs, const weightset_t &ws={})
Build a context.
Definition: context.hh:102
WeightSet weightset_t
Definition: context.hh:43
typename weightset_t::value_t weight_t
Type of weights.
Definition: context.hh:60
std::shared_ptr< const node_t > ratexp_t
Definition: context.hh:63
const labelset_ptr & labelset() const
Definition: context.hh:149
context(const context &that)
Definition: context.hh:67
context(const labelset_t &ls, const weightset_t &ws={})
Build a context.
Definition: context.hh:81
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: context.hh:160
Definition: visitor.hh:30
The abstract parameterized, root for all rational expression types.
Definition: ratexp.hh:74
static constexpr TOP< void > value
Definition: priority.hh:93
void eat(std::istream &is, char c)
Check lookahead character and advance.
Definition: stream.hh:62
decltype(join(std::declval< ValueSets >()...)) join_t
Computation of the join of some value sets.
Definition: context.hh:206
auto join(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< join_t< Ctx1, Ctx2 >>
The union of two ratexpsets.
Definition: ratexpset.hh:448
auto meet(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< meet_t< Ctx1, Ctx2 >>
The meet of two ratexpsets.
Definition: ratexpset.hh:437
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
decltype(meet(std::declval< ValueSets >()...)) meet_t
Computation of the meet of some value sets.
Definition: context.hh:216
static const std::string full
Completely version of Awali as a std::string.
Definition: version.hh:40
Main namespace of Awali.
Definition: ato.hh:22