Awali
Another Weighted Automata library
context_description.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef DYN_CONTEXT_DESCRIPTION_HH
18 #define DYN_CONTEXT_DESCRIPTION_HH
19 
20 #include <iostream>
21 #include <sstream>
22 #include <stdexcept>
23 #include <vector>
24 #include <string>
25 #include <memory>
26 #include <algorithm>
28 
29 //Definitions and factories for
30 // -labelset_description
31 // -weightset_description
32 // -context_description
34 
35 //Weightset descriptions are handled by object corresponding to
36 //each semiring
38 //The simples case (B, Q, Z-max-plus, etc...) are basic_weightset
40 //The other cases may have specific type
43 
44 namespace awali {
45  namespace dyn {
46  namespace context {
47  //To be register in abstract_weighset, each semiring requires
48  //the instanciation of a static object
49 
50  inline
51  const std::vector<abstract_weightset*>& instances() {
52  static basic_weightset _b_description("B","b",{}, // In spite of {}, B has
53  "Boolean semiring"); // promotion to every weightset
54  static basic_weightset _n_description("N","n",{"N-oo","Z","Q","R","C"},
55  "Natural integer semiring, ie non-negative integers");
56  static basic_weightset _z_description("Z","z",{"Q","R","C"},
57  "Ring of the integers -- a principal ideal domain indeed");
58  static basic_weightset _q_description("Q","q",{"R","C"},
59  "Field of the rational numbers");
60  static basic_weightset _r_description("R","r",{"C"},
61  "Field of the real numbers");
62  static basic_weightset _c_description("C","c",{},
63  "Field of the complex numbers");
64  static basic_weightset _f2_description("F2","f2",{},
65  "Field with 2 elements, 0 and 1 -- isomorphic with Z/2Z");
66  static basic_weightset _noo_description("N-oo","noo",{},
67  "Semiring of the natural integers completed with "
68  "an infinite element (hence starable)");
69  static basic_weightset _zmin_description("Z-min-plus","zmin",{},
70  "Semiring of the integers equipped with min (for addition) "
71  "and + (for multiplication)");
72  static basic_weightset _zmax_description("Z-max-plus","zmax",{},
73  "Semiring of the integers equipped with max (for addition) "
74  "and + (for multiplication)");
75  static basic_weightset _rmaxp_description("R-max-prod","pmax",{},
76  "Semiring of the real numbers equipped with max "
77  "(for addition) and . (for multiplication)");
78  static basic_weightset _maxminp_description("Fuzzy","maxmin",{},
79  "Semiring of the integers equipped with max (for addition) "
80  "and min (for multiplication) -- locally finite");
81  static cyclic_weightset _cyclic_description("Z/<int>Z", "Cyclic semiring Z/<int>Z");
82  static bounded_weightset _bounded_description("N<int>", "Quotient of N by the congruence generated by <int> = <int>+1");
83  static std::vector<abstract_weightset*> v{
84  &_b_description,
85  &_n_description,
86  &_z_description,
87  &_q_description,
88  &_r_description,
89  &_c_description,
90  &_f2_description,
91  &_noo_description,
92  &_zmin_description,
93  &_zmax_description,
94  &_rmaxp_description,
95  &_maxminp_description,
96  &_cyclic_description,
97  &_bounded_description};
98  return v;
99  }
100 
102 
103  labelset_description letterset(std::string const& s);
104 
106 
108 
109  labelset_description wordset(std::string const& s);
110 
112 
113  labelset_description ltupleset(std::vector<labelset_description> lss);
114 
115  weightset_description weightset(const std::string &k);
116 
117  weightset_description wtupleset(std::vector<weightset_description> wss);
118 
120 
123 
125 
127 
129 
131 
133 
134  std::string tostring(labelset_description ls, bool dynamic);
135 
136  std::string tostring(context_description ct, bool dynamic);
137 
138  std::string tostring(weightset_description ws, bool dynamic);
139 
140  std::string tostring(context_description ct, bool dynamic);
141 
142  std::vector<std::string> all_weightset_public_static_names();
143 
145 
146  std::vector<std::string> all_weightset_public_descriptions();
147 
149 
151  }
152  }
153 } //end of namespaces awali::dyn::context, awali::dyn, and awali
154 
155 #endif
Definition: node.hh:367
weightset_description ratweight(context_description cd)
labelset_description nullableset(labelset_description ls1)
std::shared_ptr< weightset_description_impl > weightset_description
Definition: description_types.hh:33
labelset_description ltupleset(std::vector< labelset_description > lss)
weightset_description parse_weightset(json::object_t const *jp)
std::vector< std::string > all_weightset_public_static_names()
context_description parse_context(json::object_t const *jp)
weightset_description weightset(const std::string &k)
std::vector< std::string > all_weightset_public_descriptions()
labelset_description parse_labelset(json::object_t const *jp)
std::shared_ptr< labelset_description_impl > labelset_description
Definition: description_types.hh:32
labelset_description intletterset(int a, int b)
bool is_promotable(weightset_description src, weightset_description dest)
labelset_description letterset(std::string const &s)
labelset_description wordset(std::string const &s)
labelset_description oneset()
std::vector< std::string > const & weightset_promotion_public_static_names(weightset_description ws)
std::string tostring(labelset_description ls, bool dynamic)
const std::vector< abstract_weightset * > & instances()
Definition: context_description.hh:51
weightset_description wtupleset(std::vector< weightset_description > wss)
context_description c_desc(labelset_description ls, weightset_description ws)
std::shared_ptr< context_description_impl > context_description
Definition: description_types.hh:31
std::string all_weightset_public_static_names_as_string()
Main namespace of Awali.
Definition: ato.hh:22
Definition: basic_weightset.hh:30
Definition: bounded_weightset.hh:26
Definition: cyclic_weightset.hh:26