Awali
Another Weighted Automata library
awali
common
docstring
ratexp.hh
Go to the documentation of this file.
1
// This file is part of Awali.
2
// Copyright 2016-2023 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
18
/*****************************************************************************
19
See template-docfile.hh for documentation and how characters are preprocessed
20
******************************************************************************/
21
22
#ifndef AWALI_COMMON_DOCSTRING_RATEXP_HH
23
#define AWALI_COMMON_DOCSTRING_RATEXP_HH
24
25
#include <
awali/common/docstring/entry.hh
>
26
27
namespace
awali
{
namespace
docstring {
28
29
static
entry_t
ratexp
= {
30
/* Name: */
"ratexp"
,
31
/* Description: */
"Writing rational expressions in text format"
,
32
/* Title: */
"Writing of Rational Expressions"
,
33
/* Content: */
34
R
"---doxytoken---(
35
A priori, any character may appear in the alphabet list, and no error or
36
warning will be sent. However, the use of characters `(`, `)`, `+`, `.`, or `*`
37
will result into weird output, or abort.
38
39
### Symbols for constant
40
41
Besides the letters of the alphabet, expressions are written with the symbols
42
`\z` for the constant zero (denoting the empty language, or the zero series)
43
and `\e` for the constant one (denoting the empty word).
44
Caveat: the empty string is not accepted for denoting the empty word, that is,
45
for instance, `cora cat ''` results in an error and the correct writing is
46
`cora cat '\e'`.
47
48
### Trivial identities
49
50
All expressions are necessarily reduced modulo the 'trivial identities':
51
52
0+E = E+0 = E 0.E = E.0 = E 1.E = E.1 = E
53
54
The elements of the weight semiring are written between < >. All expressions
55
are then reduced modulo the 'weighted trivial identities':
56
57
<0>E = E<0> = 0 <1>E = E<1> = E <h>(<k>E<l>)<m> = <hk>E<lm>
58
59
and, if `x` is a letter, `<h>x<k> = <hk>x` .
60
61
(Note that the writing `<h><k>E` is not syntactically correct.)
62
63
If the letters are integers, the product has to be marked with a dot
64
(in order to distinguish from integers that are written by a sequence of
65
digits).
66
67
### Parenthezing and operator precedence
68
69
A sequence of operators `+` or `.` is implicitely parenthezised from left
70
to right and the corresponding parentheses are kept implicit in an output
71
in text format. And the operator `.` is kept implicit if the letters are
72
characters (that is, of type `char`). That is, `((a+b)+c)` is written `a+b+c`
73
and `(a+(b+c))` `a+(b+c)`, `(a.(b.c))` is written `a(bc)` etc.
74
75
The operators are ordered by precedence:
76
77
+ < . < * < <k>
78
79
where the last operation is the external multiplication by a coefficient k in
80
the weight semiring. This implies for instance, and contrarily to the usual
81
reading, that the expression `ab*` denotes the language
82
`{a, ab, abb, abbb,...}` and that `<2>a*` denotes the series
83
`\e + <2>a + <4>aa + ...` The parentheses that are made useless by the
84
precedence ordering are suppressed in the output.
85
)---doxytoken---"
86
};
87
88
89
}}
//End of namespaces awali::docstring and awali
90
91
92
#endif
93
94
// Once Jacques said:
95
// > Automata are elementary (this text is not a block of code)
96
97
// std::string rat_exp_doc {
98
// R"---(
99
// Option -W chooses weight in the weight semiring list: B (default).
100
// Option -L chooses type of letters:
101
// char (-Lchar, default) or int (-Lint) or a 2-tape transducer (-Ltdc).
102
//
103
// In contrast with all other commands which define a new object (automaton
104
// or expression), if the type of letters is 'char' the default alphabet is
105
// not {a,b} but is defined by the letters that appears in <exp>, the expression
106
// that is input.
107
//
108
// Otherwise, that is if the alphabet is defined by -A option, or in case of
109
// letters of type 'int' (by -A<n> for the alphabet from 0 to n-1, default {0,1})
110
// or of tranducers (by -A<list> and -B<list> for the first and second tape
111
// respectively, default ab on both tapes) the command will abort if an unknown
112
// latter is input in <exp>.
113
//
114
// A priori, any character may appear in the alphabet list, and no error or warning
115
// will be sent. However, the use of characters '(', ')', '+', '.', or '*' will
116
// result into weird output, or abort.
117
//
118
// Besides the letters of the alphabet, expressions are written with the symbols
119
// '\z' for the constant zero (denoting the empty language, or the zero series)
120
// and '\e' for the constant one (denoting the empty word).
121
// Caveat: the empty string is not accepted for denoting the empty word, that is,
122
// "cora catE ''" results in an error and the correct writing is "cora catE '\e'".
123
//
124
// All expressions are necessarily reduced modulo the 'trivial identities':
125
//
126
// 0+E = E+0 = E 0.E = E.0 = E 1.E = E.1 = E
127
//
128
// The elements of the weight semiring are written between < >. All expressions
129
// are then reduced modulo the 'weighted trivial identities':
130
//
131
// <0>E = E<0> = 0 <1>E = E<1> = E <h>(<k>E<l>)<m> = <hk>E<lm>
132
//
133
// and, if x is a letter, <h>x<k> = <hk>x .
134
//
135
// (Note that the writing '<h><k>E' is not syntactically correct.)
136
//
137
// If the letters are integers, the product has to be marked with a dot
138
// (in order to distinguish from integers that are written b a sequence of digits).
139
//
140
// A sequence of operators '+' or '.' is implicitely parenthezised from left
141
// to right and the corresponding parentheses are kept implicit in an output
142
// in text format. And the operator '.' is kept implicit if the letters are
143
// 'char'. That is, '((a+b)+c)' is written 'a+b+c' and '(a+(b+c))' 'a+(b+c)',
144
// '(a.(b.c))' is written 'a(bc)' etc.
145
//
146
// The operators are ordered by precedence:
147
//
148
// + < . < * < '<k>'
149
//
150
// where the last operation is the external multiplication by a coefficient k
151
// in the weight semiring. This implies for instance, and contrarily to the usual
152
// reading, that the expression 'ab*' denotes the language {a, ab, abb, abbb,...}
153
// and that '<2>a*' denotes the series '\e + <2>a + <4>aa + ...'.
154
// The parentheses that are made useless by the precedence ordering are suppressed
155
// in the output.
156
// )---"
157
// };
158
159
160
161
162
entry.hh
awali::docstring::ratexp
static entry_t ratexp
Definition:
ratexp.hh:29
awali::docstring::entry_t
Definition:
entry.hh:24
awali
Main namespace of Awali.
Definition:
ato.hh:22
Generated on Fri May 12 2023 09:48:28 for Awali by
1.9.1