Benoît Barbot

Aiswarya Cyriac

Automatic verification has nowadays become a central domain of investigation in computer science. Over 25 years, a rich theory has been developed leading to numerous tools, both in academics and industry, allowing the verification of Boolean properties -those that can be either true or false. Current needs evolve to a finer analysis, a more quantitative one. Extension of verification techniques to quantitative domains has begun 15 years ago with probabilistic systems. However, many other quantitative properties are of interest, such as the lifespan of an equipment, energy consumption of an application, the reliability of a program, or the number of results matching a database query. Expressing these properties requires new specification languages, as well as algorithms checking these properties over a given structure. This thesis aims at investigating several formalisms, equipped with weights, able to specify such properties: denotational ones -like regular expressions, first-order logic with transitive closure, or temporal logics -or more operational ones, like navigating automata, possibly extended with pebbles.

A first objective of this thesis is to study expressiveness results comparing these formalisms. In particular, we give efficient translations from denotational formalisms to the operational one. These objects, and the associated results, are presented in a unified framework of graph structures. This permits to handle finite words and trees, nested words, pictures or Mazurkiewicz traces, as special cases. Therefore, possible applications are the verification of quantitative properties of traces of programs (possibly recursive, or concurrent), querying of XML documents (modeling databases for example), or natural language processing.

Second, we tackle some of the algorithmic questions that naturally arise in this context, like evaluation, satisfiability and model checking. In particular, we study some decidability and complexity results of these problems depending on the underlying semiring and the structures under consideration (words, trees...).

Finally, we consider some interesting restrictions of the previous formalisms. Some permit to extend the class of semirings on which we may specify quantitative properties. Another is dedicated to the special case of probabilistic specifications: in particular, we study syntactic fragments of our generic specification formalisms generating only probabilistic behaviors.

iii J'ai eu la chance d'être dirigé par Paul Gastin et Benedikt Bollig durant mes trois années de doctorat. Ils ont toujours pris le temps de m'écouter et su trouver les mots justes pour me guider. Je les ai tout d'abord connus comme mes professeurs, que ce soit en première année de mon cursus à l'École Normale Supérieure de Cachan, ou lors de mon M2 au Master Parisien de Recherche en Informatique. Leurs talents pédagogiques à ces occasions -comme d'ailleurs tout au long de ces trois ans -couplés à leur grande générosité ont permis de construire une atmosphère stimulante bien que bon enfant, propice à la recherche que nous avons menée ensemble. Pour leur patience et leur savoir, leurs interrogations et leurs réponses, leurs encouragements et leur soutien inconditionnel, je voudrais les remercier chaleureusement.

Je remercie également les rapporteurs de ce manuscrit, Manfred Droste et Sylvain Lombardy, ainsi que les autres membres du jury, Olivier Carton, Jean-Marc Talbot et Jacques Sakarovitch, pour leurs commentaires, et le temps qu'ils m'ont consacré.

Durant mon stage de Master 2, j'ai également été co-encadré par Marc Zeitoun, avec qui j'ai pu continuer à travailler durant les trois dernières années. Un grand merci pour son soutien et son écoute pendant le stage, ainsi que pendant le doctorat.

Durant ces trois années, j'ai eu la chance de faire partie du Laboratoire Spécification et Vérification de l

Résumé

La vérification automatique est aujourd'hui devenue un domaine central de recherche en informatique. Depuis plus de 25 ans, une riche théorie a été développée menant à de nombreux outils, à la fois académiques et industriels, permettant la vérification de propriétés booléennes -celles qui peuvent être soit vraies soit fausses. Les besoins actuels évoluent vers une analyse plus fine, c'est-à-dire plus quantitative. L'extension des techniques de vérification aux domaines quantitatifs a débuté depuis 15 ans avec les systèmes probabilistes. Cependant, de nombreuses autres propriétés quantitatives existent, telles que la durée de vie d'un équipement, la consommation énergétique d'une application, la fiabilité d'un programme, ou le nombre de résultats d'une requête dans une base de données. Exprimer ces propriétés requiert de nouveaux langages de spécification, ainsi que des algorithmes vérifiant ces propriétés sur une structure donnée. Cette thèse a pour objectif l'étude de plusieurs formalismes permettant de spécifier de telles propriétés, qu'ils soient dénotationnels -expressions régulières, logiques monadiques ou logiques temporelles -ou davantage opérationnels, comme des automates pondérés, éventuellement étendus avec des jetons.

Un premier objectif de ce manuscript est l'étude de résultats d'expressivité comparant ces formalismes. En particulier, on donne des traductions efficaces des formalismes dénotationnels vers celui opérationnel. Ces objets, ainsi que les résultats associés, sont présentés dans un cadre unifié de structures de graphes. Ils peuvent, entre autres, s'appliquer aux mots et arbres finis, aux mots emboîtés (nested words), aux images ou aux traces de Mazurkiewicz. Par conséquent, la vérification de propriétés quantitatives de traces de programmes (potentiellement récursifs, ou concurrents), les requêtes sur des documents XML (modélisant par exemple des bases de données), ou le traitement des langues naturelles sont des applications possibles.

On s'intéresse ensuite aux questions algorithmiques que soulèvent naturellement ces résultats, tels que l'évaluation, la satisfaction et le model checking. En particulier, on étudie la décidabilité et la complexité de certains de ces problèmes, en fonction du semi-anneau sous-jacent et des structures considérées (mots, arbres...).

Finalement, on considère des restrictions intéressantes des formalismes précédents. Certaines permettent d'étendre l'ensemble des semi-anneau sur lesquels on peut spécifier des propriétés quantitatives. Une autre est dédiée à l'étude du cas spécial de spécifications probabilistes : on étudie en particulier des fragments syntaxiques de nos formalismes génériques de spécification générant uniquement des comportements probabilistes. v

Introduction 1.1 From Boolean to Quantitative Verification

Automatic verification is nowadays a central domain of research in computer science. Software supports systems in many critical applications: embedded and communication systems, Internet and e-commerce, health, finance, transport, energy, etc. Due to the economic and human cost of an error, it is important to develop tools to ensure a high degree of confidence in these applications. Formal methods provide an appropriate framework for achieving this goal: the development of the theory for over 25 years now provides many tools to verify properties of such systems, especially when the expected response is Boolean, namely whenever the property is either satisfied or is not.

The process of verification with formal methods usually follows a classical pattern in three steps. 1. Modeling. The system to be verified must be modeled in a formal way. Such a model can be finite or infinite depending on the modeling and can have a more or less rich structure: words, trees, or more complex graphs (such as Kripke structures). It could also be the case that the model generates such structures (e.g., a finite state automaton generating finite words), and that we want to check some properties of all the generated structures. 2. Specification. The property that the system should verify must be formally specified, i.e., written in a predetermined language. Regular expressions, temporal logics and first-order or monadic second-order logic are well-known high-level specification languages of properties over finite or infinite words. They can be generalized to deal with richer structures like trees for example. More specifically, properties of trees or graphs may be specified using some propositional dynamic logics or XPath and their extensions. Notice that we may also use some automata to specify properties. 3. Algorithms. The typical question consists in model checking the system against the specification, i.e., verify whether or not the model verifies the property (see [START_REF] Clarke | Model Checking[END_REF] for a general overview of model checking). This may be seen as an evaluation of the property over a given structure. Another typical question, usually called satisfiability problem (or emptiness problem), consists in checking whether the specified property admits at least one structure verifying it. The golden tool for answering these problems is to translate the high-level specification languages into a low-level one, namely automata, which are a powerful, yet tractable fragment of Turing machines (see [START_REF] Vardi | An Automata-Theoretic Approach to Automatic Program Verification[END_REF] for the first application of automata techniques to verification).

Current verification needs are evolving towards a more detailed analysis, i.e., a quantitative one. The extension of the verification to quantitative fields began in the specific context of probabilistic systems, i.e., systems that may use randomization. In this mature field, theoretical methods are already transferred into usable tools like PRISM [START_REF] Kwiatkowska | PRISM 4.0: Verification of Probabilistic Real-time Systems[END_REF]. Nevertheless, it is still an active area of research, see, e.g., [START_REF] Gimbert | Probabilistic Automata on Finite Words: Decidable and Undecidable Problems[END_REF][START_REF] Fijalkow | Deciding the Value 1 Problem for Probabilistic Leaktight Automata[END_REF] with new (un)decidability results about probabilistic automata.

However, there are many other interesting quantitative properties outside the scope of probabilistic systems. Specifically, we may want to assess costs required to complete a task, the lifetime of a device, the energy requirements of an application, the reliability of a program, or the number of responses selected by a query in a database.

In this manuscript, the quantities only come from the specifications. In particular, we will consider the same models as in the Boolean setting, i.e., without any weights. This differs from other extensions like real-time verification (see, e.g., [START_REF] Alur | A Theory of Timed Automata[END_REF] introducing timed automata), where models can be seen as time words (every position of the word is associated to a time stamp being a positive real number), probabilistic verification (see, e.g., [START_REF] Baier | Principles of Model Checking[END_REF]) where models are Markov chains or Markov decision processes, or verification of systems dealing with unbounded data (see, e.g., [START_REF] Kaminski | Finite-Memory Automata[END_REF] introducing finite-memory automata), where models are data words (every position of the word has both a label from a finite alphabet and a data from an infinite domain).

Henceforth, we consider a model, and a quantitative specification, and the model checking problem becomes a model evaluation problem, i.e., the computation of the quantity associated with the model by the specification. The classical model checking problem can then be seen as a special case where the computed quantity is indeed a Boolean value. However, the quantitative framework permits to address many more properties.

Counting Problems.

A first common problem is to go from the verification of a property over a model to the computation of the total number of witnesses of this property in the model. As an example, a model could be an XML document representing a database, and a quantitative specification could ask the number of elements of the database selected by a given query: the quantity is in that case a natural number. Another interesting example could consist of a picture (a finite two-dimensional grid with a finite alphabet encoding the pixel colors) in which we may count the number of patterns of interest, e.g., counting the number of monochromatic squares in a picture.

Cost Optimization. Another interesting application lies in the optimization field. For example, considering a routing graph, we may ask for the length of the smallest path from a vertex to another. In terms of energy, considering a model being the execution trace of a sensor -with some actions requiring energy and some others representing an energy refillwe may ask for the minimal amount of energy needed at the beginning in order to perform the whole trace.

Probabilities.

Even though our aim is to verify more general quantitative properties than just probabilities, we still can consider the probabilistic setting as a special case of our framework. For example, considering a graph as a finite arena, we may want to compute the probability that a uniform random walk goes from one point to another. Probabilities may also model reliability: e.g., it would be interesting to compute the reliability of a system, namely the probability that it never fails or runs out of energy.

Transducers.

In the formal language community, quantities may be languages. Henceforth, a quantitative specification can map a given word to a language of words, the automaton view of it being commonly called transducers. Generalized to trees for example, this is the basis of some XML tree transducers, a fundamental tool for the database and natural language processing communities.

High-Level Specification Languages

Examples of high-level specification languages are regular expressions, or various kinds of logics, like monadic second order logic, first order logic, temporal logics or propositional dynamic logics. Whereas regular expressions are widely used for pattern matching in different areas, and lexical analysis in particular, temporal and propositional dynamic logics are broadly used in the formal verification field, and first or second order logic have a more theoretical interest. We give three examples below of extensions of classical specification languages to the quantitative framework: weighted regular expressions, probabilistic linear temporal logic and weighted monadic second order logic. In the three cases, the motto is always the same: Maintaining a very similar syntax but evaluating a specification over a richer weight structure permits to specify some quantitative properties easily.

Weighted Regular Expressions

Over finite words, Kleene first introduced in [START_REF] Stephen | Representation of Events in Nerve Nets and Finite Automata[END_REF] the theoretical bases for the study of regular languages, namely those being definable by a regular expression such as a ⋆ ba ⋆ or (a + b) ⋆ ca ⋆ + a ⋆ (bc) ⋆ . Schützenberger extended in [START_REF] Schützenberger | On the Definition of a Family of Automata[END_REF] these bases to the quantitative setting considering some regular formal power series, i.e., regular functions mapping each word to a weight (that we may seen as a generalization of the previous case if the weight is a Boolean value). Keeping the same syntax as usual regular expressions -simply introducing some constant weight additionally -we may represent easily those regular formal power series. For example, if we want to map every word w over an alphabet A to the number of occurrences of a pattern p in it, we may simply consider the weighted regular expression A ⋆ pA ⋆ : if evaluated in the Boolean setting, it simply checks the occurrence of p as a factor of w, but evaluated over the set of natural numbers, it will output the number of such occurrences.

Probabilistic Linear Temporal Logic

For temporal logics, we may easily extend Linear Temporal Logic (LTL) with a probabilistic version. Usually, an LTL formula is constructed from atomic formulae from the finite alphabet A, namely a for every letter a ∈ A, on top of which we may apply temporal operators X (next), F (finally) and G (globally) being unary and U (until) being binary -if ϕ and ψ are formulae, X ϕ, F ϕ, G ϕ and ϕ U ψ are formulae too -and Boolean connectives -if ϕ and ψ are formulae ¬ϕ, ϕ ∨ ψ and ϕ ∧ ψ are formulae too. The semantics is defined with respect to a word w = a 0 a 1 . . . a n-1 ∈ A ⋆ and a position i of this word (0 ≤ i ≤ n -1). We define w, i |= ϕ by induction over the formula ϕ: w, i |= a if a i = a w, i |= X ϕ if i < n -1 and w, i + 1 |= ϕ w, i |= F ϕ if there exists j ≥ i such that w, j |= ϕ w, i |= G ϕ if for all j ≥ i w, j |= ϕ w, i |= ϕ U ψ if there exists j ≥ i such that w, j |= ψ and for all i ≤ ℓ < j w, ℓ |= ϕ w, i |= ¬ϕ if not w, i |= ϕ w, i |= ϕ ∨ ψ if w, i |= ϕ or w, i |= ψ w, i |= ϕ ∧ ψ if w, i |= ϕ and w, i |= ψ For example, with the formula ϕ = F(a ∧ X b), a word w ∈ A ⋆ verifies w, 0 |= ϕ if, and only if, w contains ab as a factor. We may search for a probabilistic version of this logic. Notice that, contrary to most of other works in this field (see, e.g., [START_REF] Baier | Principles of Model Checking[END_REF] for an overview of model checking), we still consider non-probabilistic models, here words. However, we enrich the specification, i.e., LTL formulae with some constant weights, here probabilities p between 0 and 1. More precisely, we replace atomic formulae a and ¬a by pa and p(¬a) with p a probability and a a letter of the alphabet. Now, each formula ϕ maps a pair (w, i) of word and position of this word to a probability, denoted by [[ϕ]](w, i), namely the probability that (w, i) verifies ϕ (the probabilities coming from the formula itself and not from the model). Rather than probability, one may consider this as a way to model a system receiving information from unreliable sensors. Naming a, b, c, ... the messages that may be received from the different sensors, the quantitative specification verifies a property of a given trace of execution of the system, associating to each message two different probabilities: the true-positive probability, i.e., the probability p that a message a appearing in the trace (checked by the LTL formula a) has really been sent by the sensor, and the true-negative probability, i.e., the probability p ′ that a message not appearing in the trace (checked by the LTL formula ¬a) has really not been sent by the sensor. Such a situation is modeled by the formula pa ∨ p ′ (¬a). In particular, this permits to consider false-positive events (with probability 1p), namely when a message seems to be received but has not really been sent, or false-negative events (with probability 1p ′ ), namely when a message is lost.

The semantics is defined inductively over the formulae: during the definition, we maintain as an invariant the fact that the sum of the semantics of a formula and its negation is always 1. Henceforth, we let

[[¬ϕ]](w, i) = 1 -[[ϕ]](w, i) .
For the other Boolean connectives, we may simply define the semantics of the conjunction as a product (considering that the verification of each property is independant from the rest):

[[ϕ ∧ ψ]](w, i) = [[ϕ]](w, i) × [[ψ]](w, i) ,
and adapt from the de Morgan law ϕ ∨ ψ = ¬(¬ϕ ∧ ¬ψ), the semantics for the disjunction:

[[ϕ∨ψ]](w, i) = [[ϕ]]

(w, i)+[[ψ]](w, i)-[[ϕ]](w, i)×[[ψ]](w, i) = [[ϕ]](w, i)+[[¬ϕ]](w, i)×[[ψ]](w, i) .

For atomic formulae and operator X, we simply let

[[pa]](w, i) = p if a i = a 0 otherwise, [[X ϕ]](w, i) = [[ϕ]](w, i + 1) if i < n -1 0 otherwise,
In classical LTL, a formula F ϕ may be developped in the equivalent formula ϕ ∨ X(F ϕ): intuitively, it says that ϕ finally holds either when ϕ holds right now, or when F ϕ holds in the next position. In the probabilistic setting, we may translate this statement (considering the previous semantics for the disjunction and the negation) in

[[F ϕ]](w, i) = [[ϕ]](w, i) + [[F ϕ]](w, i + 1) -[[ϕ]](w, i) × [[F ϕ]](w, i + 1) = [[ϕ]](w, i) + [[¬ϕ]](w, i) × [[F ϕ]](w, i + 1) .
This equation can be applied iteratively to obtain the semantics of formula F ϕ:

[[F ϕ]](w, i) = j≥i i≤ℓ<j [[¬ϕ]](w, ℓ) × [[ϕ]](w, j) .
We set the semantics of other temporal operators similarly, letting

[[G ϕ]](w, i) = j≥i [[ϕ]](w, j) [[ϕ U ψ]](w, i) = j≥i i≤ℓ<j [[¬ψ]](w, ℓ) × [[ϕ]](w, ℓ) × [[ψ]](w, j) .
For example, consider the word abba. The formula ϕ = ( 2 3 a ∨ 2 3 (¬a)) U 3 4 a, that we can abusively write 2 3 U 3 4 a since the left term is always interpreted as the constant probability 2 3 , interprets on this word as

[[ϕ]](abba, 0) = 3 4 + 0 + 0 + 1 4 × 2 3 × 1 × 2 3 × 1 × 2 3 × 3 4 .
The intuition is that the left term of the Until operator models a discounting factor, modeling the fact that a sooner witness is preferable. However, in order to keep a probabilistic interpretation of the result, the first witness a, apart from counting to three fourth of the result, also decreases the power of the second witness with an initial factor 1 4 = 1-3 4 . Notice also that the right term of the Until operator does not give a true-negative probability, that we may interpret as a probability 0, which results in the two zeros in the semantics.

The Finally operator can then be seen as a special Until operation without discount: indeed, as for the classical LTL, we have the following semantical equivalence F ϕ = ⊤ U ϕ where ⊤ is an atomic formula always evaluating to 1 (that we can write 1a ∨ 1(¬a) for example). Then, formula ϕ = F( 23 a) interprets over the word abb as [[ϕ]](abb, 0) = 2 3 + 0 + 0 as well as over the word bba:

[[ϕ]](bba, 0) = 0 + 0 + 1 × 1 × 2 3
No discount factor is taken into account in the Finally operator.

Weighted Monadic Second Order Logic

Apart from the previous probabilistic example, we may notice that this semantics has been defined by the dual use of sums and products of probabilities. The same duality is used to define the semantics of weighted regular expressions (one may find a formal definition in [START_REF] Sakarovitch | Elements of Automata Theory[END_REF], or later in Chapter 3). Indeed, in many works about quantitative specification, such a duality is common: the weight structure is equipped with an algebraic structure of semiring. It permits to treat in a unified and elegant way many quantitative settings, as for example, real numbers with the usual addition and multiplication (used for counting or probabilities), natural numbers equipped with a minimum operation and the addition (used for optimization) or languages of words with the union and the concatenation (used in transducers for example).

Recently, Droste and Gastin introduced in [DG07] a weighted monadic second order logic over words. They also defined a fragment of this latter which captures exactly the regular formal power series. The main idea is again to keep a similar syntax to the classical monadic second order logic -simply adding constant weights as atomic formulae -but to give a quantitative semantics to every formula. This is done using semirings, by interpreting (as for probabilistic LTL) disjunctions as sums, conjunctions as products and by extension, existential and universal quantifications as addition and multiplication over positions or sets of positions of the word.

However, Droste and Gastin showed that, in order for the series denoted by a formula to remain regular, it is necessary to restrict the use of universal quantification, leading to the first logical characterization of regular formal power series.

Notice that, apart from words, regular expressions and various logics have been intensively extended to more complex models like ranked trees, nested words, pictures, or infinite models. In particular, the logic defined in [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF] has been further studied over many models: ranked and unranked trees [START_REF] Droste | Weighted Tree Automata and Weighted Logics[END_REF][START_REF] Droste | Weighted Logics for Unranked Tree Automata[END_REF], infinite words [START_REF] Droste | Weighted Automata and Weighted Logics with Discounting[END_REF][START_REF] Droste | Describing Average-and Longtime-Behavior by Weighted MSO Logics[END_REF], infinite trees [START_REF] Rahonis | Weighted Müller Tree Automata and Weighted Logics[END_REF], nested words [START_REF] Mathissen | Weighted Logics for Nested Words and Algebraic Formal Power Series[END_REF][START_REF] Droste | Weighted Nested Word Automata and Logics Over Strong Bimonoids[END_REF], or pictures [START_REF] Fichtner | Weighted Picture Automata and Weighted Logics[END_REF].

The first aim of this manuscript is to describe and study more general and expressive high-level specification formalisms of quantitative properties. Rather than only considering words, or trees, we study a general framework of graphs, having as special cases all previously mentioned finite models.

The Success Story of Automata

It is usually difficult to directly reason about, or verify, high-level specifications. It is wellknown, for instance, that the best method to parse a regular expression is to use automata (see, e.g., [START_REF] Aho | The Theory of Parsing, Translation, and Compiling[END_REF] or [START_REF] Fischer | A Play on Regular Expressions: Functional Pearl[END_REF] with an original and recent presentation in both the classical and the weighted settings). Also, checking a model against a logical specification is usually achieved efficiently by first translating the specification into an equivalent automaton, as introduced initially in [START_REF] Vardi | An Automata-Theoretic Approach to Automatic Program Verification[END_REF].

In the classical setting, Kleene proves in [START_REF] Stephen | Representation of Events in Nerve Nets and Finite Automata[END_REF] the equivalence between languages definable with regular expressions -namely the regular languages -and those recognized by finite-state automata. A further equivalence between monadic second order logic and finite-state automata, usually known as the Büchi-Elgot-Trakhtenbrot theorem, follows from [START_REF] Büchi | Weak Second-Order Arithmetic and Finite Automata[END_REF][START_REF] Elgot | Decision Problems of Finite Automata Design and Related Arithmetics[END_REF][START_REF] Trakhtenbrot | Finite Automata and Logic of Monadic Predicates[END_REF].

In the weighted setting, Schützenberger also introduced weighted automata in [START_REF] Schützenberger | On the Definition of a Family of Automata[END_REF], a quantitative extension of finite-state automata (see [START_REF] Droste | Handbook of Weighted Automata[END_REF][START_REF] Berstel | Noncommutative Rational Series With Applications[END_REF][START_REF] Sakarovitch | Elements of Automata Theory[END_REF] for recent books about extension of automata theory to the weighted setting among others). The computation result of a weighted automaton on a word is not a Boolean value distinguishing accepted behaviors from those rejected. Instead, a computation over a word produces a weight in a semiring. The weight of a word is the sum of the weights of the different possible computations over the word, each calculated as the product of the weight of the visited transitions. In [START_REF] Schützenberger | On the Definition of a Family of Automata[END_REF], Schützenberger already presented an extension of Kleene theorem, i.e., an equivalence between regular formal power series (that are definable by weighted regular expressions for example), and formal power series recognized by weighted automata. This seminal result is still a central object of research, either to make efficient translations from weighted regular expressions to weighted automata [START_REF] Caron | From Glushkov WFAs to Rational Expressions[END_REF][START_REF] Allauzen | A Unified Construction of the Glushkov, Follow, and Antimirov Automata[END_REF] and implement them [START_REF] Fischer | A Play on Regular Expressions: Functional Pearl[END_REF], or to extend it to other structures, like infinite words for example [START_REF] Droste | Regular Expressions on Average and in the Long Run[END_REF].

Surprisingly, the logical equivalence generalizing the result of the Boolean case only appeared recently, in terms of the logic introduced in [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF]. As previously mentioned, this is not the full weighted monadic second order logic, but rather a restricted fragment of it. In particular, this fragment does not contain entirely the weighted first order logic, by lack of power of weighted automata. The previously mentioned articles introducing similar fragments over richer models, like trees or infinite models, also prove an equivalence between the logic and weighted automata over the subsequent models. For example, in [START_REF] Droste | A Kleene Theorem for Weighted Tree Automata[END_REF], authors prove the equivalence between a fragment of weighted monadic second order logic over finite ranked trees, and a weighted extension of tree automata.

A second aim of this manuscript is to introduce a more general class of weighted automata, at least able to compute all the formal power series definable by weighted first order formulae.

Rather than considering branching automata (like bottom-up tree automata [CLDG + 08] or graph automata [START_REF] Thomas | On Logics, Tilings, and Automata[END_REF]), we focus on navigating automata. Over words for instance, these automata may be seen as a weighted generalization of two-way automata (first introduced by Rabin and Scott in [START_REF] Michael | Finite Automata and Their Decision Problems[END_REF]). An advantage of these navigating automata is their possible direct generalization to any class of graphs. These automata are still not general enough to recognize all formal power series defined by weighted first order formulae. However, following ideas of [START_REF] Engelfriet | Tree-Walking Pebble Automata. Jewels are forever, contributions to Theoretical[END_REF], it is possible to add pebbles to navigating automata in order to recognize more behaviors: those pebbles permit to mark temporarily the model with some tokens. Tree-walking automata, and pebble tree-walking automata, have been extensively studied recently [START_REF] Bojańczyk | Expressive Power of Pebble Automata[END_REF][START_REF] Samuelides | Complexity of Pebble Tree-Walking Automata[END_REF][START_REF] Bojańczyk | Tree-Walking Automata[END_REF]. Such automata models have attracted increasing interest, particularly in the context of queries manipulating XML documents and XPath (XML Path Language) queries [START_REF] Balder Ten | Transitive Closure Logic, and Nested Tree Walking Automata, and Xpath[END_REF]. In [START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF], considering ranked trees (and also general classes of graphs), authors prove, in the Boolean setting, that pebble navigating automata are expressively equivalent to the first order logic enriched with a transitive closure operator.

One of the main contributions of this manuscript is to define weighted pebble navigating automata, and to introduce a weighted transitive closure operator, to prove some equivalence results between formal power series recognized by such automata and formulae of weighted first order logic with a weighted transitive closure operator.

A weighted extension of tree-walking automata has been introduced and studied in [START_REF] Fülöp | Weighted Tree-Walking Automata[END_REF]. However, the authors only consider a non-looping version of these automata, and do not consider the extension with pebbles.

It has to be noticed that some other results of equivalence between quantitative generalizations of automata and quantitative logics have also been obtained by other authors, with different purposes. Quantitive properties of infinite words have been considered in [START_REF] Colcombet | The Theory of Stabilisation Monoids and Regular Cost Functions[END_REF], for example, by the mean of regular cost functions. These may be defined in terms of Bor S-automata, and have equivalent logical and algebraic characterizations. More recently, [ADD + 13] investigates tree transducers as a way to define quantitative functions over finite words: the model, called cost register automata, defines some regular functions, also with an equivalent logical formalism based on monadic second order logic.

Algorithms

Translating high-level specification formalisms into automata is interesting because this enables efficient algorithms, e.g., with respect to model checking (or evaluation) and emptiness checking. For example, some classical automata-based techniques to verify systems have been extended in [CCH + 05] to the weighted setting: authors use bound functions in order to transfer classical methods and results. Algorithms over weighted automata (determinization, minimization, etc.) have also been extensively studied since the 60s, see [START_REF] Mohri | Weighted Automata Algorithms[END_REF] for an overview. For example, the minimization of a weighted automaton (over finite words) over a field can be done in polynomial time (as already shown in the seminal paper of Schützenberger [START_REF] Schützenberger | On the Definition of a Family of Automata[END_REF]): as an interesting implication for the Boolean setting, this implies that the equivalence of unambiguous finite-state automata can be performed in polynomial time, and not only in polynomial space as it is the case for general non-deterministic finite-state automata. All these efficient algorithms have already permitted to apply the techniques to several areas such as natural language processing [START_REF] Knight | Applications of Weighted Automata in Natural Language Processing[END_REF] and language recognition, or the compression of digital images (see [START_REF] Droste | Handbook of Weighted Automata[END_REF] Part IV]).

In this manuscript, we will consider the evaluation and emptiness problems of our newly introduced class of pebble weighted automata. In particular, we give a precise complexity for the evaluation of pebble weighted automaton, in terms of the size of the model (usually huge), and the automaton (usually more reasonable).

CHAPTER 1. INTRODUCTION

Notice that other authors design algorithms for weighted automata, in other contexts. For example, in [START_REF] Chatterjee | Quantitative Languages[END_REF], authors study quantitative languages of infinite words: rather than using a semiring, they consider more complex product operations in order to model discounting or averaging. This has been further studied with alternating automata in [START_REF] Chatterjee | Alternating Weighted Automata[END_REF], and also [START_REF] Almagor | Max and Sum Semantics for Alternating Weighted Automata[END_REF] over finite words. They also consider some mean-payoff expressions using automata as atomic expressions in [CDE + 10], in order to specify more complex quantitative properties.

Outline

This manuscript aims at studying different formalisms describing quantitative properties of graph structures. We start in Chapter 2 by introducing the graphs we study, and the weight domains we use.

We introduce hybrid weighted expressions in Chapter 3, namely a generalization of weighted regular expressions over general classes of graphs. They may also use some variables in order to generate more behaviors. As usual, we give a denotational (and inductive) semantics of these expressions. As a preliminary for subsequent proofs, we also give a more algebraic semantics of them, in terms of marked graphs.

Chapter 4 is devoted to the introduction of our class of pebble weighted automata. We start by the special case of weighted navigating automata (without pebbles) and prove, in this case as well as in the more general one, a Kleene-Schützenberger theorem stating the equivalence with weighted expressions and hybrid weighted expressions respectively. The translations from expressions to automata are done carefully in order to generate small automata.

In Chapter 5, we explain how to evaluate a pebble weighted automaton over a given model. After giving a very general evaluation algorithm, we consider some special cases (words, trees and nested words) and give more efficient algorithms.

Logical specifications are studied in Chapter 6. We first recall monadic second order logics over graphs, permitting to prove some decidability results for the emptiness of a pebble weighted automaton. Afterwards, we introduce our class of weighted first order logic with transitive closure. The main result of this chapter is to prove the expressive equivalence between this logic and pebble weighted automata. The translation from logics to automata is made efficiently (as for hybrid weighted expressions), in particular by a careful use of the pebbles: this translation requires to consider searchable classes of graphs, i.e., graphs in which a walking automaton can enumerate every vertex faithfully. Conversely, the translation from automata to logic -with a more theoretical interest of completeness and robustness of the class of automata -is also shown: it requires to consider the new concept of zonable classes of graphs, namely graphs that we can partition into zones expressible into the logic. Finally, hybrid navigational logics are considered at the end of this chapter: they generalize the classical propositional dynamic logic and temporal logics to capture the power of pebble weighted automata.

Chapter 7 focuses on some natural restrictions of the specification languages considered before. In particular, these restrictions permit to extend the set of weights studied, and consider for example the set of positive and negative real numbers (forbidden in the rest of this manuscript for reasons that we present in Chapter 3). The restrictions are of two sorts: one, semantical, restricts the set of runs that automata may follow to non-looping ones, whereas the second, syntactical, directly restricts the possibility of the automata to only one-way runs. We show that both restrictions indeed coincide over finite words. We also prove that the emptiness problem quickly becomes undecidable in this restricted case, in particular because we allow more general semirings.

We consider the probabilistic case as a special case of the weighted setting in Chapter 8. The aim is to design a fragment of hybrid weighted expressions and pebble weighted automata generating only probabilistic behaviors of graphs. After presenting the restrictions, 1. 5

. OUTLINE

we again prove a Kleene-Schützenberger theorem relating these two formalisms. As a special case, this permits to give a set of regular expressions (with probabilities) that define exactly the behaviors recognized by Rabin probabilistic automata [START_REF] Michael | Probabilistic Automata[END_REF]. If we forget about the probabilities, this also gives an insight of some deterministic restrictions of the model of automata we study in this manuscript.

Finally, we present in Chapter 9 an implementation of the algorithm of evaluation of a hybrid weighted expression in the case of words.

CHAPTER 2 Preliminaries

Graph

. . 20

General Notations

|E| the cardinality of a finite set E P(E) the powerset of a set E We will use the same notation (x i ) i∈I for families and sequences of elements. The main difference lies in the index set I: it is considered as an ordered set in the case of a sequence, but families are not ordered.

The domain of a partial mapping f : A ⇀ B is the set of elements a ∈ A for which image f (a) is well-defined: it is denoted by dom(f ) in the following. Substitutions (also called valuations in the following) are partial mappings from a (possibly infinite) set Var of variables to a set A. The substitution of domain {x} mapping x to value a ∈ A is denoted by [x → a]. Moreover, if σ is a substitution of domain D, σ[x → a] is the substitution σ ′ of domain D ∪ {x} such that σ ′ (x) = a and σ ′ (y) = σ(y) for every y ∈ D different from x.

Graph Structures

In order to introduce the definitions and results of this manuscript in a unified way for different kinds of structures like words, trees, nested words, etc. we will use graphs in the sequel. Among other works, this unified presentation of our framework has been inspired by [START_REF] Thomas | On Logics, Tilings, and Automata[END_REF][START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF][START_REF] Fichtner | Characterizations of Recognizable Picture Series[END_REF]. Graphs we will consider are graphs of bounded degree with labels on vertices and edges.

We fix a finite alphabet A and another finite set D that will be used for encoding the directiondirections of the graph. This set is always supposed to be symmetrical in the following meaning: there exists a bijective mapping • -1 : D → D such that for every direction d ∈ D, (d -1 ) -1 = d. For example {→, ←} with → -1 = ← and ← -1 = → is a valid set of directions. We extend the mapping • -1 to sets of directions: if • for all d ∈ D, E d ⊆ V × V is a functional irreflexive relation describing the d-edges of the graph, i.e., for all v ∈ V , there exists at most a vertex v ′ ∈ V such that (v, v ′ ) ∈ E d , and then it verifies v ′ = v; • for all d ∈ D, d -1 -edges are the reversed d-edges, i.e.,

D ′ ⊆ D, D ′-1 = {d -1 | d ∈ D ′ }.
E d -1 = {(v, v ′ ) | (v ′ , v) ∈ E d } ;
• λ : V → A is a labeling of vertices with letters of the alphabet. In the following, we denote E = d∈D E d the full set of edges of a graph.

A path in such a graph is a finite non-empty sequence (v k ) 0≤k≤n of vertices of the graph such that successive vertices are linked by an edge, i.e., for every 0 ≤ k ≤ n -1, (v k , v k+1 ) ∈ E. Such a path is said to be a path from v 0 to v n , and its length is n, i.e., the number of edges it contains. Throughout this manuscript, we restrict ourselves to connected graphs, i.e., such that for every pair of vertices, there always exists a path from the first one to the second one. For a subset D ′ of D, we say that a path is a D ′ -path if every edge it contains is labeled by a direction of D ′ : with previous notations, for every 0

≤ k ≤ n -1, (v k , v k+1 ) ∈ d∈D ′ E d . A {d}-path is also called a d-path for conciseness.
Finally, a D ′ -cycle is a non-empty D-path from a vertex to itself.

We may equip every graph G = (V, (E d ) d∈D , λ) with a distance function d : V × V → N with d(v, v ′ ) being the length of the shortest path from v to v ′ . In particular, it verifies the following properties:

• d(v, v ′ ) = 0 if, and only if, v = v ′ , for every vertices v, v ′ ∈ V ; • d(v, v ′ ) = d(v ′ , v) for every vertices v, v ′ ∈ V ; • d(v, v ′′ ) ≤ d(v, v ′ ) + d(v ′ , v ′′ ), for every vertices v, v ′ , v ′′ ∈ V .
Vertices of a graph come with a type. In a graph G, the type of vertex v, denoted type(v), is the set of all possible directions available from v, namely

type(v) = {d ∈ D | ∃v ′ ∈ V (v, v ′ ) ∈ E d } A pointed graph is a tuple G = (V, (E d ) d∈D , λ, v (i) , v (f ) ) with (V, (E d ) d∈D , λ, χ) a graph and v (i) , v (f )
some vertices of V , used as initial and final vertices. The set of pointed graphs with alphabet A and directions D is denoted by G(A, D).

Throughout this manuscript, if not specified, a graph G ∈ G(A, D) will be supposed to have set of vertices denoted V , sets of edges (E d ) d∈D , etc.

a a b b b a a b a b a → → → → → → → → → → ← ← ← ← ← ← ← ← ← ← Figure 2.1: Graph representation of a word

Words

A word is a finite sequence w = a 0 a 1 • • • a n-1 of letters a i ∈ A. The empty word is denoted by ε. The set of words over the alphabet A is denoted by A ⋆ , whereas the set of non-empty words is denoted by A + . The length of the word w is the number n of letters it contains, and is often denoted by |w|. We also denote by |w| a the number of occurrences of letter a in word w. Words may be concatenated: the concatenation of two words w 1 and w 2 , denoted w 1 • w 2 (or shortly w 1 w 2 ), is the word obtained by appending the letters of w 2 after the letters of w 1 .

We model the set of words in our graph framework by considering as set of directions D = {→, ←}, with → -1 = ←. Notice that the set G(A, D) then contains all the words of A + . However, it also contains graphs that do not represent words (e.g., cycles), and hence we only consider the subset of graphs that represents finite words. More precisely, we let Word(A) be the set of pointed graphs ([0 .

. n -1], (E → , E ← ), λ, 0, n -1) with n ≥ 1, such that E → = {(i, i + 1) | i ∈ [0 .. n -2]} and E ← = {(i, i -1) | i ∈ [1 .. n -1]}.
For these graphs, the initial vertex is the first position of the word, whereas the final vertex is the last one. The graph representation of the word aabbbaababa is depicted in Figure 2.1: this word has length n = 11.

Ranked Trees

A ranked alphabet is an alphabet A where each letter a ∈ A comes with an arity denoted by ar(a) ∈ N. A ranked tree is then a finite term labeled by letters of a ranked alphabet. More formally, a ranked tree is a partial mapping 1 t : N ⋆ ⇀ A with domain dom(t) satisfying the following properties

• dom(t) is finite and nonempty;

• dom(t) is prefix closed, i.e., if a sequence is in dom(t), each of its prefixes is also in dom(t);

• for all u ∈ dom(t), if ar(t(u)) = n ≥ 0, then {i ∈ N | ui ∈ dom(t)} = [0 .. n -1].
Notice that in the case n = 0, the interval [0 .. n -1] is empty. Elements of the domain dom(t) are called nodes of the tree. Each node u ∈ dom(t) inherits an arity ar(t(u)) from its labeling. Nodes of arity 0 are called leaves, whereas nodes of non-null arity are called internal nodes. The root of t is the node ε. A node ui ∈ dom(t) is said to be a child of node u, sometimes called the ith child of u, whereas u is the parent of node ui. We denote by |t| the cardinality of the domain dom(t) of t, i.e., its number of nodes.

We may represent these trees in our graph framework by considering the set of directions

D = {↑ i , ↓ i | 0 ≤ i < ar(a), a ∈ A}, with ↑ -1 i = ↓ i .
The set G(A, D) then contains all the ranked trees over alphabet A. Indeed this set of graphs contains also graphs which are not well-formed, e.g., because a vertex admits as type {↓ 2 }, or because the arity of the symbol labeling a vertex is not correct. Hence, we let T ree(A) be the subset of G(A, D) containing only well-formed ranked trees. More formally, T ree(A) is the set of pointed graphs (dom(t), (E d ) d∈D λ, ε, ε) where t is a ranked tree as defined previously, such that λ(u) = t(u) for every vertex u ∈ dom(t), and for every i ∈ [0 .. max a∈A ar(a

) -1], E ↓i = {(u, ui) | u, ui ∈ dom(t)} and E ↑i = {(ui, u) | u, ui ∈ dom(t)}.
Notice that in these graphs, the initial and final vertices are the same, namely the root of the tree. An example of ranked

c c b b c b c a a b a ↓ 0 ↓ 1 ↓ 0 ↓ 1 ↓ 0 ↓ 0 ↓ 0 ↓ 0 ↓ 1 ↓ 0 ↑ 0 ↑ 1 ↑ 0 ↑ 1 ↑ 0 ↑ 0 ↑ 0 ↑ 0 ↑ 1 ↑ 0 Figure 2.2: A ranked tree a a b a a a a b a a b a b b → → → → → → ← ← ← ← ← ← → ← → → → → → → ← ← ← ← ← ←

Nested Words

Nested words are structures particularly useful to denote XML documents or finite executions of recursive programs. Indeed, these structures have in common to contain an underlying linear order over their positions, and additional informations. In well-formed XML documents, an opening tag (e.g., <ul> or <h1> for HTML documents) is linked to its matched closing tag (</ul> and </h1>). In the same way, for recursive programs, positions encoding a call of a program is linked to its matched return. Formally, we will describe the set of nested words over an alphabet A as a subset of the pointed graphs G(A, D) with D = {→, ←, , } with → -1 = ← and -1 = . Whereas → and ← are used, as for words, to denote the successor and predecessor edges in the linear order, directions and encode the links in the nested words (opening/closing tags, call/matching return). We let N est(A) the subset of G(A, D) containing all pointed graphs

([0 .. n -1], (E → , E ← , E , E ), λ, 0, n -1) with n ≥ 1, E → = {(i, i + 1) | i ∈ [0 .. n -2]}, and E ⊂ {(i, j) | i < j} the set of nesting edges verifying for every (i, j), (i ′ , j ′ ) ∈ E that
• nesting edges do not share positions: i = i ′ if, and only if, j = j ′ ;

• nesting edges do not cross: if i < i ′ then either j < i ′ or j > j ′ ). An example of nested word is depicted in Figure 2. 3. Its set of vertices is [0 .. 13], depicted in increasing order, and has as -edges (5,11), (6,8), (12, 13)} .

E = {(1, 3),
On the picture, we have structured vertically the vertices with respect to their call-depth. By definition, the call-depth of a vertex in a nested word is the number of nesting edges jumping over this vertex: more formally, the call-depth of a vertex v is

|{(v 1 , v 2 ) ∈ E | → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ → ← ↓ ↑ ↓ ↑ ↓ ↑ ↓ ↑ Figure 2.4: A picture v 1 < v < v 2 }|.
For example, vertex 4 and 5 have call-depth 0, vertex 9 has call-depth 1 and vertex 7 is the only vertex of call-depth 2.

Grids and Pictures

Finite grids are another interesting example of graphs. As noticed by [START_REF] Blum | Automata on a 2-Dimensional Tape[END_REF], pictures may be seen as finite two-dimensional grids. We may model those by graphs with sets of directions D = {→, ←, ↓, ↑} (with → -1 = ← and ↓ -1 = ↑), labeled by letters in an alphabet A encoding gray levels or colors of the pixels. Let Pict(A) be the subset of G(A, D) containing all pointed graphs ([0

.. n 1 -1] × [0 .. n 2 -1], (E → , E ← , E ↓ , E ↑ ), λ, (0, 0), (n 1 -1, n 2 -1))
with n 1 ≥ 1 being the width of the picture, n 2 ≥ 1 its height, and with edges

E → = {((i, j), (i + 1, j)) | i ∈ [0 .. n 1 -2], j ∈ [0 .. n 2 -1]} E ← = {((i, j), (i -1, j)) | i ∈ [1 .. n 1 -1], j ∈ [0 .. n 2 -1]} E ↓ = {((i, j), (i, j + 1)) | i ∈ [0 .. n 1 -1], j ∈ [0 .. n 2 -2]} E ↑ = {((i, j), (i, j -1)) | i ∈ [0 .. n 1 -1], j ∈ [1 .. n 2 -1]}
An example of picture with pixels either white or black is represented in Figure 2. 4. Its width is 7 and its height is 5. For example, the only black pixel is the vertex indexed (5, 1) of the graph.

Mazurkiewicz Traces

Another domain of application is the study of distributed systems, and, for example, concurrent programs with a static set of processes that may synchronize through rendez-vous. In this setting, Mazurkiewicz traces have been acknowledged to be a very useful and succinct model for sets of communications of such programs.

We now define Mazurkiewicz in terms of their graph representations, following ideas of [START_REF]The Book of Traces[END_REF]. We fix a finite set of n processes, that we index by integers in [1 .. n]. Vertices of the graph represent actions executed by the processes: hence, we fix a finite alphabet A representing internal actions and rendez-vous of the program. More precisely, we suppose fixed a mapping proc : A → P([ 1 .. n]) such that proc(a) = ∅ for every a ∈ A: the set proc(a) is the subset of processes involved in the execution of action a (a is an internal action if, and only if, proc(a) is a singleton). Edges of the graph relate, for each process, the actions in which this process is involved, ordered linearly: hence, for every process p, we label edges by ↓ p and ↑ p to encode the linear order of actions of a process. Let

↓ 1 ↑ 1 ↓ 2 ↑ 2 ↓ 2 ↑ 2 ↓ 2 ↑ 2 ↓ 2 ↑ 2 ↓ 3 ↑ 3 ↓ 3 ↑ 3 ↓ 3 ↑ 3 ↓ 3 ↑ 3 1 2 3 4 Figure 2.5: A Mazurkiewicz trace D = {↓ p , ↑ p | p ∈ [1 .
. n]} be the set of directions. Formally, we denote by MT race proc (A) the subset of G(A, D) containing all pointed graphs G = (V, (E d ) d∈D , λ, v (i) , v (f ) ) verifying the following properties:

• every vertex v ∈ V is labeled by an action a such that proc(a) is compatible with the type of v, i.e., {p ∈ [1 .. n] | ↓ p ∈ type(v) ∨ ↑ p ∈ type(v)} ⊆ proc(a); • for every process p ∈ [1 .
. n], the set of vertices V p labeled by actions involving process p is linearly ordered by the successor relation

E ↓p : if V p = {v ∈ V | p ∈ proc(λ(v))},
there exists a unique maximal ↓ p -path, which visits exactly the vertices of

V p ; • the set of directions D ′ = {↓ p | p ∈ [1 .
. n]} generates a partial order over the vertices:

if there is a

D ′ -path from vertex v to v ′ and from v ′ to v, then v = v ′ ; • v (i)
is the first vertex in the linear order induced by the smallest active process min{p ∈

[1 .. n] | ∃v ∈ V V p = ∅}; • v (f )
is the last vertex in the linear order induced by the largest active process min{p ∈ [1 .

. n] | ∃v ∈ V V p = ∅}. The graph representation of a Mazurkiewicz trace is depicted in Figure 2. 5. It is over alphabet {a, b, c} with set of processes {1, 2, 3, 4} verifying proc(a) = {1, 2}, proc(b) = {3}, proc(c) = {2, 3} and proc(d) = {2, 3, 4}. It contains seven vertices. We have represented the processes from left to right. In this Mazurkiewicz trace, the sequence of actions involving process 2 is acdac, which is the linear order used in the definition. Action b is the unique internal action (for process 3).

Ordered Graphs

Words and nested words have an interesting point in common, namely that these structures are naturally linearly ordered, and that a particular direction in D defines this order. This is an interesting property that we will exploit later. Let us formalize this notion in a more general way. A direction set D is said to be ordered if there exists a partition of D into two sets D → and D ← such that for all d ∈ D, d ∈ D → if, and only if, d -1 ∈ D ← . Directions in D → (respectively, D ← ) are said to be forward directions (respectively, backward directions). In the case of words, direction set {→, ←} may be partitioned as D → = {→} and D ← = {←}, whereas for nested words, the partition is D → = {→, } and D ← = {←, }.

By extension, an (

A, D)-graph G = (V, (E d ) d∈D , λ) is said to be →-ordered (or simply ordered if → is clear from the context) if D is ordered, → ∈ D → , V
comes with a total linear order ≤ generated by → -in the sense that a vertex v ′ is the direct successor of v in the linear order ≤ if, and only if, (v, v ′ ) ∈ E → -and for all edge (v, v ′ ) ∈ E, v < v ′ if, and only if, there exists d ∈ D → such that (v, v ′ ) ∈ E d . E.g., words and nested words are →-ordered graphs with respect to the natural linear order defined over their positions, which is generated by the direction →.

Finally, a pointed graph G = (V, (E d ) d∈D , λ, v (i) , v (f ) ) is said to be an ordered pointed graph if G = (V, (E d ) d∈D , λ) is an ordered graph with ≤ the total linear order on V which has v (i) as minimal element and v (f ) as maximal one. Notice that this enforces that ordered pointed graphs with set of vertices different from a singleton must have distinct initial and final vertices.

Weight Domains

The definitions of algebraic tools used in this manuscript are extracted from several references: [KS85, Kui97, DK09].

Monoids

A monoid is a set M equipped with a binary operation • and a designated element 1 such that:

• • is associative, i.e., m •(m ′ • m ′′ ) = (m • m ′ ) • m ′′ for all elements m, m ′ , m ′′ of M; • 1 is a neutral element of •, i.e., m • 1 = 1 • m = m for all elements m of M.
In the following, we will denote (M, •, 1) such a monoid. We often write mm ′ instead of m • m ′ . The monoid M is said to be commutative if the operation • is commutative, i.e., m • m ′ = m ′ • m for all elements m and m ′ of M. Alternatively, a commutative monoid may be denoted by (M, +, 0).

A submonoid of a monoid (M, •, 1) is a subset M ′ of M containing the neutral element 1 and stable by multiplication: for all

m 1 , m 2 ∈ M ′ , m 1 • m 2 ∈ M ′ . Then, denoting • the restriction of • to elements of M ′ (well-defined by hypothesis), the structure (M ′ , •, 1) is automatically a monoid.
A morphism ϕ of a monoid M into a monoid M ′ is a mapping ϕ : M → M ′ compatible with the neutral elements and operations in M and M ′ , i.e.,

• ϕ(1) = 1;

• ϕ(m 1 • m 2 ) = ϕ(m 1 ) • ϕ(m 2 ) for every elements m 1 , m 2 of M.
The commutative monoid (M, +, 0) is said to be complete if every family (m i ) i∈I of elements of M over an arbitrary indexed set I is summable to some element in M, denoted i∈I m i , and called sum of the family, such that the following conditions are satisfied:

• i∈∅ m i = 0, i∈{j} m i = m j and i∈{j,k} m i = m j + m k ; • if I = j∈J I j is a partition, j∈J i∈Ij s i = i∈I s i .
Intuitively, this means that it is possible to define infinite sums that extend the binary addition and satisfies an infinite version of the associativity axiom.

The monoid (M, +, 0) is said to be continuous if it is a complete monoid and the following conditions are satisfied:

• the relation ≤ M defined over M by m 1 ≤ M m 2 if m 2 = m 1 + m for some m ∈ M, for every m 1 , m 2 ∈ M
, is a partial order, that we call the natural order of the monoid; • the sum i∈I m i is the least upper bound with respect to ≤ M of the finite sums i∈J m i for J finite subsets of I, for every family (m i ) i∈I in M: more precisely, i∈J m i ≤ M i∈I m i for every finite subset J of I, and for all m ∈ M, if i∈J m i ≤ M m for all finite subset J of I, then i∈I m i ≤ M m. Intuitively, this means that every infinite sum can be approximated by finite partial sums. In the literature, such monoids are sometimes called ω-continuous monoids, especially when the focus is on summation of countable families, as it will be the case in this manuscript.

A monoid (M, •, 1) is graded if it is equipped with a gradation, i.e., a morphism ϕ from the monoid M to the monoid N of natural numbers (equipped with addition) such that ϕ(m) > 0 for every element m of M different from 1.

Semirings

A semiring is a set S equipped with two binary operations ⊕ and ⊗ and two designated neutral elements 0 S and 1 S (respectively denoted by 0 and 1 if S is clear from the context) such that:

• (S, ⊕, 0 S ) is a commutative monoid;

• (S, ⊗, 1 S ) is a monoid; • ⊗ distributes over ⊕, i.e., m ⊗ (m ′ ⊕ m ′′ ) = (m ⊗ m ′ ) ⊕ (m ⊗ m ′′ ) and (m ⊕ m ′ ) ⊗ m ′′ = (m ⊗ m ′′ ) ⊕ (m ′ ⊗ m ′′ ) for all elements m, m ′ , m ′′ of M; • 0 S is a zero, i.e., m ⊗ 0 S = 0 S ⊗ m = 0 S for all elements m of M.
If the monoid (S, ⊗, 1 S ) is commutative, the semiring itself is said to be commutative. In the following, we denote by (S, ⊕, ⊗, 0 S , 1 S ) the semirings.

A subsemiring of a semiring (S, ⊕, ⊗, 0 S , 1 S ) is a subset S ′ of S containing the neutral elements 0 S and 1 S , and stable by addition and multiplication: for all m 1 , m 2 ∈ S ′ , m 1 ⊕m 2 ∈ S ′ and m 1 ⊗ m 2 ∈ S ′ . Then, denoting again ⊕ and ⊗ the restriction of these operations to elements of S ′ (well-defined by hypothesis), the structure (S ′ , ⊕, ⊗, 0 S , 1 S ) is automatically a semiring.

A morphism ϕ of a semiring S into a monoid S ′ is a mapping ϕ : S → S ′ compatible with the neutral elements and operations in S and S ′ , i.e.,

• ϕ(0 S ) = 0 S ′ and ϕ(1

S ) = 1 S ′ ; • ϕ(m 1 ⊕ m 2 ) = ϕ(m 1 ) ⊕ ϕ(m 2 ) and ϕ(m 1 ⊗ m 2 ) = ϕ(m 1 ) ⊗ ϕ(m 2 ), for every elements m 1 , m 2 of S.
The semiring (S, ⊕, ⊗, 0 S , 1 S ) is said to be complete if the monoid (S, ⊕, 0 S ) is complete, and if the product distributes over the infinite sums, i.e.,

i∈I s i ⊗ j∈J t j = (i,j)∈I×J (s i ⊗ t j )
for all families (s i ) i∈I and (t j ) j∈J of elements of S. Informally, this means that it is possible to define infinite sums that extend the binary addition and satisfies infinite versions of associativity (see the definition of complete monoids) and distributivity axioms.

In a complete semiring, every element s of S admits a star, denoted s ⋆ , and defined by s ⋆ def = i∈N s i (where s i is defined recursively by s 0 = 1 S and s i+1 = s i ⊗ s). Every element s also admits a quasi-inverse, denoted s + , and defined by s + def = i∈N\{0} s i . These two objects are related by the following proposition, immediate to prove by using the axioms of the definition of complete semirings: Proposition 2.2. Let S be a complete semiring. Then for all s ∈ S,

1. s + = s ⊗ s ⋆ = s ⋆ ⊗ s; 2. s ⋆ = 1 S ⊕ s + .
The semiring (S, ⊕, ⊗, 0 S , 1 S ) is said to be continuous if it is a complete semiring, and if the monoid (S, ⊕, 0 S ) is continuous.

Example 2.3. We will use many examples of semirings in this manuscript:

• the real semiring (R, +, ×, 0, 1), having a subsemirings the rational semiring (Q, +, ×, 0, 1), the integer semiring (Z, +, ×, 0, 1) and the natural semiring (N, +, ×, 0, 1); • the positive real completed semiring (R + ∪ {+∞}, +, ×, 0, 1), from which can be extracted the natural completed semiring (N ∪ {+∞}, +, ×, 0, 1), which are both continuous; • the Boolean semiring ({0, 1}, ∨, ∧, 0, 1), denoted B, which is continuous;

• the tropical semiring (R∪{+∞, -∞}, max, +, -∞, 0), denoted T, and the arctic semiring (R ∪ {+∞, -∞}, min, +, +∞, 0), denoted A, which are continuous;

• ([0, 1], min, max, 1, 0) used in some probabilistic applications, which is continuous;

• the language semiring (P(A ⋆ ), ∪, •, ∅, {ε}) where the concatenation L 1 • L 2 of two languages is defined as

{w 1 • w 2 | w 1 ∈ L 1 , w 2 ∈ L 2 }, which is also continuous.
It is interesting to recall that not every complete semiring is continuous. For example, if we equip the semiring (R + ∪ {+∞}, +, ×, 0, 1) with the infinite summation defined by i∈I s i = +∞ if, and only if, {i | s i = 0} is infinite or if s j = +∞ for some j ∈ I (and the well-defined finite sum otherwise), the semiring is complete but not continuous. Indeed, i∈N 1/2 i = +∞ whereas every finite sum is bounded above by the usual infinite sum

i∈N 1/2 i = lim n→∞ n i=0 1/2 i = 2.
Continuous semirings are interesting since they permit to get more equalities involving stars of elements. We give in the next theorem some of these, whose proofs may be found, e.g., in [Kui97, Theorem 2.4].

Theorem 2. 4. Let S be a continuous semiring. For every s, s ′ ∈ S:

(i) (s ⊗ s ′ ) ⋆ ⊗ s = s ⊗ (s ′ ⊗ s) ⋆ ; 2 (ii) (s ⊕ s ′ ) ⋆ = s ⋆ ⊗ (s ′ ⊗ s ⋆ ) ⋆ = (s ⋆ ⊗ s ′ ) ⋆ ⊗ s ⋆ .
The semiring (S, ⊕, ⊗, 0 S , 1 S ) is said to be positive if the two following conditions are verified:

• S is zerosumfree:

if s 1 ⊕ s 2 = 0 S , then s 1 = s 2 = 0 S , for every s 1 , s 2 ∈ S; • S has no divisors of zero: if s 1 ⊗ s 2 = 0 S , then s 1 = 0 S or s 2 = 0 S , for every s 1 , s 2 ∈ S.
We easily have that Proposition 2.5. [START_REF] Golan | Semirings and their Applications[END_REF]Proposition 22.28] Every complete semiring is zerosumfree.

Proof. Let (S, ⊕, ⊗, 0 S , 1 S ) be a complete semiring. Let s 1 and s 2 be two elements of S such that s 1 ⊕ s 2 = 0 S . By distributivity over infinite sums, we have

i∈N (s 1 ⊕ s 2 ) = i∈N 0 S = i∈N 0 S ⊗ 0 S = 0 S ⊗ i∈N 0 S = 0 S
By partitioning the infinite sum i∈N (s 1 ⊕ s 2 ) in three parts, we obtain

0 S = s 1 ⊕ i∈N\{0} s 1 ⊕ i∈N s 2
Notice that N \ {0} is in bijection with N. Generally, if ϕ : J → I is a bijection, and (s i ) i∈I a family of elements of S, then, by using the partitioning again, we have

i∈I s i = j∈J i∈ϕ(j) s i = j∈J s ϕ(j)
the last equality coming from the first property of complete monoids. Hence, infinite sums are preserved by bijective renaming of families. In our case, we obtain that

0 S = s 1 ⊕ i∈N s 1 ⊕ i∈N s 2
By refactoring the partition, we finally get

0 S = s 1 ⊕ i∈N (s 1 ⊕ s 2 ) = s 1 ⊕ 0 S = s 1 which proves that s 1 = 0 S . Since s 1 ⊕ s 2 = 0 S , we also have s 2 = 0 S .
However, it is not true that every complete (or even continuous) semiring is positive, as it is shown in Remark 2. 6.

Finally, the semiring (S, ⊕, ⊗, 0 S , 1 S ) is said to be idempotent if it is idempotent for the addition: it is sufficient to verify 1 S ⊕ 1 S = 1 S . The tropical and arctic semirings are typical examples of idempotent semirings.

Formal Power Series and Polynomials

In all this section, we fix a semiring (S, ⊕, ⊗, 0, 1).

Let Z be a set. A formal power series f over Z (or series for short) is a map f : Z → S. Alternatively, f can be seen as a formal sum z∈Z f (z)z, so that f (z) is called the coefficient of z in f . The set of series over Z with coefficients in S is denoted by S Z .

The support of a series f ∈ S Z is the set {z ∈ Z | f (z) = 0}, and is denoted supp(f ). A series with a finite support is called a polynomial. The set of polynomials over Z with coefficients in S is denoted by S Z .

We can lift addition and product3 from S to S Z pointwisely by defining for every series f and g:

(f ⊕ g)(z) = f (z) ⊕ g(z) and (f ⊙ g)(z) = f (z) ⊗ g(z)
for all z ∈ Z .

The product of series defined thereby is usually called the Hadamard product of two series. Then (S Z , ⊕, ⊙, 0, 1) is a semiring where 0 (respectively 1) denotes the series mapping every element z ∈ Z to 0 (respectively 1). This semiring is commutative if, and only if, S is a commutative semiring. When (Z, •, 1 Z ) is a monoid, it is possible to define another product for series: the Cauchy product f ⊗ g of two series f and g is then defined by

(f ⊗ g)(z) = z=x • y f (x) ⊗ g(y)
for all z ∈ Z .

This sum may be infinite, but is well-defined when either the monoid is graded or the semiring is complete. The Cauchy product is then associative and admits as neutral element the polynomial 1 Z , whose only non null coefficient is the one of 1 Z which is 1. Hence, (S Z , ⊕, ⊗, 0, 1 Z ) is a semiring when the monoid is graded or the semiring is complete.

When the semiring S is complete, we can also lift infinite sums pointwise to S Z which becomes a complete semiring. Moreover, if S is a continuous semiring, S Z is also continuous, equipped with a natural order defined as the pointwise extension of the natural order of S.

Matrices

In all this section, we fix a semiring (S, ⊕, ⊗, 0, 1).

Let I and J be two non-empty sets. A matrix indexed by I×J is a mapping M : I×J → S: value M (i, j) is often denoted as M i,j , and called (i, j)-coefficient of M . The matrix itself is sometimes denoted by (M i,j ) i∈I,j∈J . The set of all matrices indexed by I × J and with values in S is denoted by S I×J . If I ′ ⊆ I and J ′ ⊆ J, we denote by

M |I ′ ×J ′ the submatrix of M indexed by I ′ × J ′ .
We may define neutral elements and binary operations so that sets of matrices become monoids and semirings. First, denoting by 0 the matrix in S I×J with all coefficients equal to 0, and defining M ⊕M ′ , for every matrices M, M ′ ∈ S I×J , as the matrix with (i, j)-coefficient being M i,j ⊕ M ′ i,j , we obtain that (S I×J , ⊕, 0) is a commutative monoid.

Moreover if J is finite, we may define the product of two matrices M ∈ S I×J and M ′ ∈ S J×K as being the matrix M ′′ ∈ S I×K with (i, k)-coefficient given by j∈J M i,j ⊗M ′ j,k . Denoting by Id ∈ S I×I the square matrix with 1 on the main diagonal, and 0 at other positions, (S I×I , ⊕, ⊗, 0, Id) is a semiring. In case S is a continuous semiring, S I×I is also a continuous semiring, and we denote by M ⋆ the infinite sum n≥0 M n . Remark 2.6. If we consider the continuous semiring (R + ∪ {+∞}, +, ×, 0, 1), the semiring of square matrices with coefficients in this semiring is continuous but not commutative, and not positive, as it contains zero divisors: for example for square matrices of size 2, we have

0 1 0 0 ⊗ 0 1 0 0 = 0
In [START_REF] Horton | Regular Algebra and Finite Machines[END_REF], Conway proved a very useful lemma permitting to compute the star of a matrix with additions, products and stars in the semiring. It can also be seen as a rewriting of McNaughton-Yamada algorithm, or the state elimination method used to construct a regular expression equivalent to a finite-state automaton. We state it here and will use it at several occasions in this manuscript. Proofs can be found in [START_REF] Kuich | Semirings, Automata and Languages[END_REF] or [START_REF] Sakarovitch | Elements of Automata Theory[END_REF]: they are both based on an adaptation of Arden's lemma in the case of continuous semirings.

M ⋆ = (A ⊕ B ⊗ D ⋆ ⊗ C) ⋆ A ⋆ ⊗ B ⊗ (D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ D ⋆ ⊗ C ⊗ (A ⊕ B ⊗ D ⋆ ⊗ C) ⋆ (D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ CHAPTER 3

Hybrid Expressions

Simplicity is the glory of expression.

Walt Whitman Regular expressions are widely used in many programming languages to concisely denote string patterns. They permit to efficiently locate particular words or sequences of characters in a text, a web page or any source of characters. Written with a flexible and handy syntax, they are interpreted by a parser which aims at executing it over the source text.

More theoretically, they are bound to the name of Stephen Cole Kleene who exhibited [START_REF] Stephen | Representation of Events in Nerve Nets and Finite Automata[END_REF] the concept of regular languages: regular expressions are then a way to denote such regular languages easily. His famous eponymous theorem states that this class of languages coincides with the ones recognized by finite state automata: we will come back to this fundamental result in Chapter 4.

Whereas regular expressions are now widely used and studied in order to denote patterns of sequences of characters, i.e., words over a finite alphabet, it is not so long ago that they have been used for extended purposes. Amongst various works, we may cite caterpillar expressions, introduced by [BKW00] -which are regular expressions navigating in unranked trees -and forest expressions, to generate more branching behaviors, exposed in [START_REF] Bojańczyk | Forest Expressions[END_REF] (also exposed in [START_REF] Cyriac | Temporal Logics for Concurrent Recursive Programs[END_REF][START_REF] Bozzelli | Visibly Rational Expressions[END_REF] for nested words).

Another domain of extension consists in introducing quantities in expressions. Whereas weighted regular series have been discovered by Marcel-Paul Schützenberger in [Sch61] -both with weighted automata and the extension of Kleene theorem stating the equivalence of both formalisms -the notion of weighted expression as a way to denote such series has emerged later (see, e.g., [START_REF] Sakarovitch | Elements of Automata Theory[END_REF] for a recent presentation of this large field). It has to be noticed that recent works are still produced in order to investigate further these weighted expressions 23 and several of their extensions. For example, new parsing algorithms of (weighted) regular expressions are still implemented, as we may find in [START_REF] Fischer | A Play on Regular Expressions: Functional Pearl[END_REF] recently. Weighted expressions have also been investigated in the framework of infinite words, with an average semantics, in [START_REF] Droste | Regular Expressions on Average and in the Long Run[END_REF].

Our goal in this chapter is to define and study a new extension of weighted expressions, able to denote a broader class of quantitative properties, yet with a readable formalism inspired by the rich history of regular expressions. An original part of this work is the use of variables to enrich the power of expressions. After giving the syntax and semantics of these new expressions, we will consider some possible restrictions or other denotations, that could permit to express more easily some properties (for example, by hiding the use of variables, which could be seen as a weak point of this formalism, even if it permits to express rich quantitative properties). As a final section, we will give an algebraic view of the semantics of these expressions, that will be of the greatest interest to prove several theorems of next chapters.

Hybrid Weighted Expressions

In this section, we introduce expressions with weights and variables. Like classical regular expressions, their syntax is based on operators + (for alternatives), • (for sequences), and ⋆ (for iteration). Then, + and • are interpreted as sum and Cauchy product in a semiring, respectively.

We first introduce these expressions with some examples, one on words, a second on nested words and a last one over graphs. Example 3.2. We consider a nested word over the alphabet {a, b}. Consider the more complex task of counting the total number of occurrences of the letter b inside a context with a call position labeled with a: more formally we want to sum over all possible call positions labeled with a, the number of occurrences of b that appear strictly in-between this position and the matching return. For the nested word of Figure 2.3, we must count 4 (in particular, position 7 must count for both call positions 5 and 6). In our formalism, we will achieve this task again in semiring (N ∪ {+∞}, +, ×, 0, 1) using expression:

E = → ⋆ • (a?∧ ?) • x! → ⋆ • x? • • (¬x? • ←) + • b? • → ⋆ • → ⋆ .
First, we search for a call position labeled with a using expression → ⋆ • (a?∧ ?): there, we again use the test a? to check the letter without moving, and moreover test whether the current position is a call position using ?. Then, we mark, with x!-, the call position of the interesting context with a variable of name x: this permits us to compute independently the subexpression between parentheses on the nested word (starting from the beginning again) with the previous position marked with variable x. The latter subexpression first searches for the variable with → ⋆ • x?, follows the nesting edge from the call to the corresponding return, and then moves backward inside the context with (¬x? • ←) + to pick non-deterministically a position carrying letter b. . 255] representing the level of gray of the pixel. The same way regular expressions are a way to express word patterns, our expression could be a way to define pictorial patterns. We start with the toy example consisting of finding rectangles in a picture. The pattern will consist of monocolor pixels grouped in a rectangle shape encircled by pixels of highly contrasted colors, like in the Figure 3.1. Supposing that the top left corner of the rectangle is marked with a variable of name x, the expression will follow the rectangle clockwisely, expecting to reach back the position marked with variable x after changing directions 3 times. Moreover, the expression checks at every point that the outside of the rectangle has a grayscale highly contrasted with the (constant) grayscale of the rectangle.

E rectangle = x? • c∈[0 .. 255] (c? • F c ↑ • →) + • F c ↑ • (c? • F c → • ↓) + • F c → • (c? • F c ↓ • ←) + • F c ↓ • (c? • F c ← • ↑) + • F c ← • x?
where the expression F c d tests that the position in direction d has a color sufficiently distinct from the grayscale c:

F c d = c ′ ∈[0 .. c-50] ∪[c+50 .. 255] d • c ′ ? • d -1
Notice that we do not care about the color of the interior of the rectangle, but we could refine our expression to also take it into account. Imagine that our final goal is to count the number of such highly contrasted rectangles in a picture, and then compare this number with the number of another pattern described by an expression E pattern , to compute the maximum of these two cardinalities. A maximum operation is then necessary, which forces us to use semiring (N ∪ {-∞, +∞}, max, +, -∞, 0). Then, counting the number of rectangles cannot be done by using a non-deterministic choice (as if in semiring (N ∪ {+∞}, +, ×, 0, 1)). We rather use a deterministic search of the picture, using the variable x to check whether we found a new rectangle:

G rectangle = ↓ • [0 + 1 • (x!(→ ⋆ • ↓ ⋆ • E rectangle • → ⋆ • ↓ ⋆ ))] • → + • ¬(→?) • ← + • ¬(←?) + • ¬(↓?) • → ⋆
The expression inside the rectangle bracket is the sum between weight 0 and weight 1 multiplied by the check of expression E rectangle over the current rectangle: sum is evaluated as a maximum, and product as an addition, hence this whole expression computes 1 if there is a highly contrasted rectangle with upper left corner at the current position, and 0 otherwise. Inside the x!-operator, starting from the upper left pixel of the picture (as this is the initial vertex we chose in our representation of pictures), we first search (unambiguously) for the position holding variable x, evaluate expression E rectangle , and reach the lower right pixel of the picture (the final vertex) to continue the computation. By the same way, we may obtain a formula G pattern counting the number of occurrences of the other pattern, and finally consider formula G rectangle +G pattern to count the maximum between these two cardinalities, as + is evaluated using the first operation of the semiring, i.e., the max operation in this case.

We turn to the formal syntax of expressions. We let Var = {x, y, . . .} be an infinite set of variables. In all this chapter, we let D be a fixed set of directions. Pebble weighted expressions are built upon simple Boolean tests that we define first. Definition 3.4. We let Test(A, D, Var) (or shortly, Test) be the set of formulae defined by the following grammar:

α ::= ⊤ | init? | final? | a? | d? | x? | ¬α | α ∧ α | α ∨ α (3.1)
where a ∈ A, d ∈ D and x ∈ Var.

Thus, a test is a Boolean combination of atomic checks allowing one to verify whether a given vertex has label a, whether it enables a certain direction d, or whether it carries an occurrence of variable x, respectively. Recall that we defined in Chapter 2 the notion of type τ ∈ P(D) of a vertex of a graph, as a subset of D: in particular, we can check the type of a vertex by using a maximal Boolean combination of directions.

Given a test α of Test, a variable x ∈ Var is free in α if the latter contains the atom x?. More formally, we denote Free(α) the (finite) set of pebble names free in α, which is defined inductively by letting Free(⊤) = Free(init?) = Free(final?) = Free(a?) = Free(d?) = ∅ Free(x?) = {x}

Free(¬α) = Free(α) Free(α 1 ∧ α 2 ) = Free(α 1 ∨ α 2 ) = Free(α 1 ) ∪ Free(α 2 )
with a ∈ A, d ∈ D and x ∈ Var.

We are now ready to define the semantics of tests, in the general case of graphs. Let G = (V, (E d ) d∈D , λ, v (i) , v (f ) ) ∈ G(A, D) be a pointed graph. Let v ∈ V be a position and σ : Var ⇀ V be a valuation. We define inductively the semantics of a test α ∈ Test with free variables Free(α) contained in the domain dom(σ) of the valuation: we denote G, σ, v |= α if α is verified over the given model which is defined in Table 3. 1. Notice that the semantics only depends on the valuation of free variables of the test. Next, we present hybrid weighted expressions over a continuous semiring (S, ⊕, ⊗, 0, 1). Definition 3.5. We let HWE(S, A, D, Var) (or shortly HWE) be the set of hybrid weighted expressions defined by the following grammar:

E ::= s | α | d | E + E | E • E | E + | x!E where s ∈ S, α ∈ Test(A, D, Var), d ∈ D and x ∈ Var.
The set of variables appearing in an expression E of HWE (either in tests or in constructions x!-) is denoted by Var(E). Given an expression E of HWE, a variable x ∈ Var is free in E if it is free in some test used in E, and not bound by an expression x!-. More

(s) = Free(d) = ∅ Free(α) = Free(α) Free(E + ) = Free(E) Free(E 1 + E 1 ) = Free(E 1 ) ∪ Free(E 2 ) Free(x!E) = Free(E) \ {x} Free(E 1 • E 2 ) = Free(E 1 ) ∪ Free(E 2 )
with s ∈ S, α ∈ Test, d ∈ D and x ∈ Var.

We now turn to the semantics of hybrid weighted expressions. A hybrid weighted expression is interpreted over a pointed graph G = (V, (E d ) d∈D , λ, v (i) , v (f ) ) ∈ G(A, D) with a marked initial vertex v, a marked final vertex v ′ and a valuation σ : Var ⇀ V . The atomic expression d ∈ D has its natural interpretation as the binary relation E d and is evaluated 1 or 0 depending on whether or not (v, v ′ ) ∈ E d . On the contrary, expressions s, α, x!E are non-progressing and require v = v ′ . In particular, x!E evaluates E in the graph G, from v (i) to v (f ) , with the current vertex marked with a new occurrence of variable x. Formally, the semantics of a hybrid weighted expression E ∈ HWE with Free(E) ⊆ dom(σ) is the weight in S denoted [[E]](G, σ, v, v ′ ) defined inductively in Table 3. 2. In this table, we denote E n the n-th iteration of expression E defined inductively by E 1 = E and E n+1 = E n • E for n > 0; occasionally, we may denote the expression 1 as E 0 . Notice that the infinite sum used to define the semantics of E + is well-defined as we consider a continuous semiring S. We will see in Chapter 7 a way to remove the continuity condition over the semiring, at the price of restricting the expressions.

Notice that the semantics does only depend on the valuation of free pebble names of the pebble weighted expression. If the assignment σ is not relevant, i.e., if there are no free pebble names in the expression, we may denote [[E]](G, v, v ′ ) the semantics.

By default, v and v ′ are the initial and final vertices of the pointed graph G, i.e., v (i) and v (f ) , so that we use

[[E]](G) (respectively, [[E]](G, σ)) as shortcuts for [[E]](G, v (i) , v (f ) ) (respectively, [[E]](G, σ, v (i) , v (f )
)): in that case, we may see [[-]] as a formal power series in S G(A, D) . Remark 3.6. We get the classical Kleene star as an abbreviation: E ⋆ = 1 + E + . As usual, we may sometimes remove the symbol • used for the concatenation of two expressions and write E 1 E 2 for E 1 • E 2 . In words and nested words for example, it is also convenient to introduce macros for "check-and-move": a def = a? • →. This allows us, for example, to use common syntax such as (ab) + abc, or to write → ⋆ abba← + init?→ ⋆ baab→ ⋆ to identify words having both abba and baab as factors.

We call depth of an expression E in HWE, denoted by depth(E), its maximal number of Table 3.2: Semantics of HWE(S, A, D, Var)

[[s]](G, σ, v, v ′ ) = s if v = v ′ 0 otherwise [[α]](G, σ, v, v ′ ) = 1 if v = v ′ ∧ G, σ, v |= α 0 otherwise [[d]](G, σ, v, v ′ ) = 1 if (v, v ′ ) ∈ E d 0 otherwise [[E 1 • E 2 ]](G, σ, v, v ′ ) = v ′′ ∈V [[E 1 ]](G, σ, v, v ′′ ) ⊗ [[E 2 ]](G, σ, v ′′ , v ′ ) [[E 1 + E 2 ]](G, σ, v, v ′ ) = [[E 1 ]](G, σ, v, v ′ ) ⊕ [[E 2 ]](G, σ, v, v ′ ) [[E + ]](G, σ, v, v ′ ) = n>0 [[E n ]](G, σ, v, v ′ ) [[x!E]](G, σ, v, v ′ ) = [[E]](G, σ[x → v], v (i) , v (f ) ) if v = v ′ 0 otherwise nested x!-operators. It is defined inductively by depth(s) = depth(d) = depth(α) = 0 depth(E + ) = depth(E) depth(E 1 + E 2 ) = depth(E 1 • E 2 ) = max(depth(E 1 ), depth(E 2 )) depth(x!E) = 1 + depth(E)
Example 3.7. Over the semiring (N ∪ {-∞, +∞}, max, +, -∞, 0), consider the hybrid weighted expression (over nested words)

E = 1• ? • → • ¬( ?) + 0 • ¬( ?∨ ?) • → • ¬( ?) + + ? • → • ¬( ?) ⋆ • x? • → ⋆ .
Notice the use of 1 ∈ N which is not the unit of the semiring. Moreover, operations + are resolved by the max operator, whereas concatenation implies the use of addition in N ∪ {-∞, +∞}. For every nested word G ∈ N est(A) (with set of vertices [0 .

. n]), and every vertex v,

[[E]](G, [x → v]
) computes the call-depth of vertex v. Indeed the first Kleene star is unambiguous, meaning that only one path starting from position 0 will lead to x in this iteration; along this path -the shortest one -we only count the number of times we enter inside the context of a call position. Hence, the maximal call-depth of a nested word can be computed with expression

E ′ = → ⋆ • (x!E) • → ⋆ .

Syntactical Subclasses of Hybrid Weighted Expressions

We described in the previous section the full class of hybrid weighted expressions we will use in this manuscript. However, it may be the case that only a subset of the features we presented is sufficient to model the desired quantitative property. In this section, we present some interesting subclasses of HWE.

Weighted Expressions

At the first sight, the variable mechanism of hybrid weighted expressions may seem intricate and far-fetched from the spirit of classical regular (or even weighted) expressions. We will see that this complication is unavoidable in order to express powerful quantitative properties, and yet permits to express them in an elegant and concise way. However, we consider now the subclass of HWE that does not use any variables. Let (S, ⊕, ⊗, 0, 1) be a continuous semiring again.

Definition 3.8. We let WE(S, A, D, Var) (or shortly WE) be the set of weighted expressions defined by the following grammar:

E ::= s | α | d | E + E | E • E | E +
where s ∈ S, α ∈ Test(A, D, Var) and d ∈ D.

Notice that we keep in Test(A, D, Var) the possibility to check the presence of a variable over a vertex, however, we discard the ability to place a new occurrence of a variable with the x!-operator.

As a subclass of HWE, weighted expressions in WE inherits their semantics from those of expressions in HWE. As an illustration that weighted expressions may be useful, even without pebbles, we give another example here.

Example 3.9. Weighted expressions may be very handy in the field of Natural Language Processing (see [START_REF] Knight | Applications of Weighted Automata in Natural Language Processing[END_REF]), in particular for automatic translation, speech recognition or transliteration. All these tasks have in common to split the problem into independent parts, certain directly related to the specific task and others related to the knowledge of the current language. For example, in the translation task from French sentences to English sentences, one splits the problem into first knowing translation of single words and then modeling English sentences (knowledge which is independent from the translation task). The second part, namely to know whether a sequence of words is a good English sentence, is known as language modeling. Often this knowledge is learned from a large corpus of English texts, and stored into a formal model, e.g., a weighted finite state automaton representing the probability distribution P of well-formed English sentences. The translation task is then resolved by first generating several English sentences from the original French one (due to ambiguity of the word-by-word translation task), and then choosing among this set of sentences the ones with highest probability.

One broadly used language model is the n-gram model, where the probability of a word in a sentence depends only on the previous n -1 words: for example in a 1-gram model, only the individual word frequencies are relevant to generate well-formed English sentences, whereas in a 2-gram model, the probability of a word depends on the very same frequency distribution and also the previous word. Typical values of the parameter n are 2 or 3, and the largest value for which a full model of English has been produced is 7 [BPX + 07]. To formally describe these models, and further study them, let us define them using weighted expressions. Let D denote the dictionary of words in the language. Suppose we are given the conditional probability distributions P(w n | w 1 , . . . , w n-1 ) in the n-gram model (with w i ∈ D for all i). The probability of a sentence (w i ) 1≤i≤m ∈ D m can be given by the following weighted regular expression in a 1-gram model and a 3-gram model:

E 1 = u∈D u • P(u) ⋆ E 3 = → • → • u,v,w∈D ← • ← • u • v • w • P(w | u, v)
⋆ Expression E 3 uses the opportunity to move forward and backward to easily recover the context. Notice that expression E 3 is quite readable and intuitive. One could write an equivalent expression only moving forward, but imagine how intricate it would be since positions would have to encode the context, i.e., the last two words.

Actually, expression E 3 is not small since the sum hides the very big set D 3 : for a dictionary of size 1 million, this seems already unpracticable. But in practice, a much smaller expression could be sufficient. First, for many words, the frequency distribution of the word w is a sufficiently good approximation of the conditional probability P(w | u, v). Let us denote D 0 this set of words. For instance, the probability of observing the word the may not really depend on the previous words. Then, let D 1 be the set of words (disjoint from D 0 ) such that only the previous word is necessary to describe the probability. Finally, let D 2 be the rest of the dictionary, i.e., the set of words such that the two previous words are really necessary to describe the probability P(u n | u n-2 , u n-1 ). Now, we may replace expression E 3 by the following expression, whose size is much smaller if D 0 and D 1 contain enough words:

w∈D0 w • P(w) + w∈D1,v∈D ← • v • w • P(w | v) + w∈D2,u,v∈D ← • ← • u • v • w • P(w | u, v) ⋆

Chop Weighted Expressions: An Alternative to Variables

Sometimes variables are unavoidable in order to express naturally some quantitative properties.

Example 3.10 (continued from Example 3.9). We add internationalization to the natural language processing task previously studied, which means that the user has the ability to write/speak alternately in two or more languages, e.g., English and French. All tasks such as automatic translation or speech recognition are now more complex since there is no a priori knowledge of the current language of the speaker. Again, splitting the problem into independent parts, we have to know the probability distributions P L for every involved language L, and, assuming a current language L, we should be able to solve the language processing task with a procedure Task L . Then, before processing the next word, we start a computation which re-reads the current prefix of the text in order to compute using P L the probability that the current language L is still valid. The next word is then processed with the current or the alternate language. In order to compute the probability that the current language is still valid, we may use variables (and intuitively we need): we mark the current position with a variable and read the current prefix of the text with a subexpression modeling the current language. Then we return to the marked position in order to resume the top level computation, in either languages, depending on the probability we computed.

More critically, variables really have some intrinsic expressiveness power: Proposition 3.11. There exists a hybrid weighted expressions E over the semiring (N ∪ {+∞}, +, ×, 0, 1) such that no weighted expression E ′ ∈ WE is equivalent to E, i.e., generates the same semantics over every graph.

Proof. This result is more easily proved by means of automata, and is indeed a corollary of Theorem 4.18 which states the same result for automata, by using translation from automata to expressions and vice versa stated in Theorems 4.9 and 4.31. Stated in the syntax of hybrid weighted expressions, the counter example that is shown to be not recognized by a weighted expression is

E = x! (2 • →) + • → + evaluated over the set of words Word(A).
The expression used as a counter example in this proof indeed uses a variable in an awkward manner. It is only used in order to ensure that we recompute the inner expression as many times as the number of vertices in the graph. This suggests that we may still gain in expressive power by enriching weighted expressions with a restricted version of variables which would permit such an iteration. As an alternative, and following a terminology of We start by defining what is a chop in a graph. Let G = (V, E, λ, χ, v (i) , v (f ) ) be an ordered pointed graph, with ≤ the total linear order on V . Given v ∈ V , the chop decomposition of G associated to v is the pair of ordered pointed graphs (G 1 , G 2 ) such that

G 1 = (V 1 , (E d ∩ (V 1 × V 1 )) d∈D , λ |V1 , v (i) , v) G 2 = (V 2 , (E d ∩ (V 2 × V 2 )) d∈D , λ |V2 , v, v (f ) ) where V 1 = {v ′ ∈ V | v ′ ≤ v} and V 2 = {v ′ ∈ V | v ≤ v ′ }.
We denote again ≤ the total linear order on V 1 and V 2 . Definition 3.12. We let chopWE(S, A, D, Var) (or shortly chopWE) be the set of chop weighted expressions defined by the following grammar:

E ::= s | α | d | E + E | E • E | E † E | E +
where s ∈ S, α ∈ Test(A, D, Var) and d ∈ D.

We define the semantics of such expressions in the same way as for hybrid weighted expressions (in particular, we may use free variables, even though it is not possible to place fresh variables anymore). We only complete Table 3.2 with the semantics of the new chop operator:

[[E 1 † E 2 ]](G, σ, v, v ′ ) = [[E 1 ]](G 1 , σ, v (i) , v) ⊗ [[E 2 ]](G 2 , σ, v, v (f ) ) if v = v ′ 0 otherwise
where (G 1 , G 2 ) denotes the chop decomposition of G associated to v.

For example, over words of Word(A), the hybrid weighted expression in the proof of Proposition 3.11 is equivalent to the chop weighted expression

2 • (2 • →) ⋆ † (2 • →) ⋆ • → +
Without much surprise, variables permit to simulate chop operations over ordered pointed graphs.

Theorem 3. 13. For every E ∈ chopWE, there exists E ′ ∈ HWE with Free(E ′ ) = Free(E) equivalent to E, i.e., such that for all ordered pointed graph G ∈ G(A, D), v, v ′ ∈ V and σ : Var ⇀ V with domain containing Free(E), we have

[[E]](G, σ, v, v ′ ) = [[E ′ ]](G, σ, v, v ′ ) .
Proof. We proceed by induction on the syntax of E ∈ chopWE. Once for all, we fix two variables x and y of Var that do not appear in Free(E). We also denote → the direction in D that generates the total linear order ≤ over V .

In case E is of the form s, α, d,

E 1 + E 2 , E 1 • E 2 or E + 1
, we can directly conclude by induction, as these constructs are allowed in HWE.

The interesting case is when E = E 1 †E 2 . By induction, let E ′ 1 and E ′ 2 be the expressions in HWE equivalent to E 1 and E 2 . We encode the chop vertex (i.e., the vertex where E will be evaluated) with variable x: as E ′ 1 must go from the initial vertex to the chop vertex and E ′ 2 from the chop vertex to the final vertex, we will consider expression

x!(E ′ 1 • x? • E ′ 2 ) .
However, this expression is not equivalent to E in general.

d • y!(→ ⋆ • y? • → ⋆ • x? • → ⋆ )
and, similarly, every move

d with d ∈ D ← , appearing in E ′ 2 by d • y!(→ ⋆ • x? • → ⋆ • y? • → ⋆ ) .
We denote E ′′ 1 and E ′′ 2 the expressions obtained after making these transformations. We let

E ′ = x!(E ′′ 1 • x? • E ′′ 2 ) .
Consider now an ordered pointed graph G, a vertex v ∈ V and a valuation σ : Var ⇀ V .

Denoting by (G 1 , G 2 ) the chop decomposition of G associated to v, we easily show by induction over E 1 and E 2 that

[[E 1 ]](G 1 , σ, v (i) , v) = [[E ′′ 1 ]](G, σ[x → v], v (i) , v) [[E 2 ]](G 2 , σ, v, v (f ) ) = [[E ′′ 2 ]](G, σ[x → v], v, v (f ) )
By definition of the semantics of the chop operator from one side, and the x!-and • operators from the other side, we then obtain:

[[E]](G, σ, v, v) = [[E ′ ]](G, σ, v, v) .
We let as future work the extension of this result to other classes of graphs (not necessarily ordered). An interesting question is the reciprocal of this proposition, i.e., whether the chop operation is strong enough to simulate the pebble features. Notice that this reciprocal has a flavor of separation theorem, in the sense of [START_REF] Hodkinson | Separation -Past, Present, and Future[END_REF][START_REF] Marx | Conditional XPath, the First Order Complete XPath Dialect[END_REF].

Algebraic Semantics of Hybrid Weighted Expressions

In this last section, we propose to redefine the semantics of hybrid weighted expressions in a more algrebraic way. This will be particularly useful when proving Kleene-Schützenberger theorems in Chapter 4. To introduce this algebraic semantics, we first consider the semantics of usual weighted regular expressions over finite words1 , i.e., expressions defined by the grammar

E ::= sa | E + E | E • E | E +
where s ∈ S and a ∈ A. Notice that sa is now considered as a basic expression (and not the sequence of weight s and letter a) in order to define only proper expressions, and hence avoid difficulties in the definition of the semantics of the Kleene iteration. We may hence consider general -not necessarily continuous -semirings S.

The semantics of an expression E is now a mapping from words in A + to S: in particular, no need for valuations or initial and final vertices to define the semantics as we will see. Hence, we consider the semantics of an expression E as a formal power series |E| ∈ S A + over the words of A + . As A ⋆ is a graded monoid, (S A ⋆ , ⊕, ⊗, 0, 1ε) is a semiring, where ⊗ is the Cauchy product of two series. This permits to define trivially the semantics by lifting the operations of the semiring2 :

|sa| = sa |E 1 + E 2 | = |E 1 | ⊕ |E 2 | |E 1 • E 2 | = |E 1 | ⊗ |E 2 |
It only remains to deal with Kleene iteration. Indeed, we may define the Kleene iteration of a series f ∈ S A ⋆ , in case this one is a proper series, i.e., if f (ε) = 0. In fact, the Kleene iteration of a proper formal power series f ∈ S A ⋆ is defined by f + (ε) = 0 and for every word w ∈ A + by

f + (w) = n≥1 w1,w2,...,wn∈A + w=w1w2•••wn f (w 1 ) ⊗ f (w 2 ) ⊗ • • • ⊗ f (w n )
which is well-defined as the inner sum is empty for every n greater than the length of w.

As the semantics |E| of any expression is proper, as a formal power series of S A + , this permits to define the semantics of the Kleene iteration of an expression E by:

|E + | = |E| +
Indeed, this definition of the semantics of a weighted regular expression by series operations is the way used by Schützenberger to define regular formal power series -the weighted equivalent of regular languages -namely the smallest class of series which contains the series sa with s ∈ S and a ∈ A, and which is closed by addition, Cauchy product and Kleene iteration of proper series. Weighted regular expressions are just a way to denote such regular series.

Remark 3.14. In that regular case, it is also possible, as explained in [Sak09, Chapter III.5], to remove the graded condition of the monoid, at the price of ensuring that the semiring is continuous. We do not present this generalization/restriction here in details, but we will indeed follow the same path in our case.

We now apply this elegant and powerful way of defining the semantics of expressions to our hybrid weighted expressions. Considering the navigation feature, and the presence of variables, this will be more complex than for the weighted regular languages. In particular, this requires to find a structure -if possible a monoid, but indeed we will not achieve this final goal -on which we will build formal power series, and the underlying operations. We fix A a finite alphabet and D a finite set of directions. Objects of the structure will be marked graphs. A marked graph is of the form (G, σ, v, v ′ ) where G ∈ G(A, D) is a pointed graph, σ : Var ⇀ V is a valuation with a finite domain, and v, v ′ ∈ V are vertices. These are exactly the structures we use to define the semantics of hybrid weighted expressions. Let MG(A, D, Var) (or shortly MG if the parameters are implicit) be the set of all marked graphs.

We may equip the set of marked graphs with a product operation.

Given (G 1 , σ 1 , v 1 , v ′ 1 ) and (G 2 , σ 2 , v 2 , v ′
2 ) two marked graphs, the product of these marked graphs, denoted by

(G 1 , σ 1 , v 1 , v ′ 1 ) • (G 2 , σ 2 , v 2 , v ′ 2 ), is defined whenever G 1 = G 2 , σ 1 = σ 2 and v ′ 1 = v 2 , by (G 1 , σ 1 , v 1 , v ′ 1 ) • (G 1 , σ 1 , v ′ 1 , v ′ 2 ) = (G 1 , σ 1 , v 1 , v ′ 2 )
The product operation defined that way is a partial binary operation. It admits several partial units: indeed we have

(G 1 , σ 1 , v 1 , v ′ 1 ) • (G 1 , σ 1 , v ′ 1 , v ′ 2 ) = (G 1 , σ 1 , v 1 , v ′ 1 ) if, and only if, v ′ 2 = v ′ 1 A marked graph of the form (G, σ, v, v) is henceforth called a partial unit.
The set of all partial units is denoted by U(A, D, Var) (or shortly U if the parameters are implicit).

We have now defined an algebraic structure over the set of marked graphs, not as neat as a monoid structure, but this will be sufficient. Before coming back to the algebraic definition of the semantics of hybrid weighted expressions, we explore the properties of this new structure, that we call a partial monoid.

Partial Monoids

A partial monoid is a set M equipped with a partial binary operation • and a subset of elements called partial units, and denoted U such that:

• • is partially associative, i.e., m •(m ′ • m ′′ ) is defined if, and only if, (m • m ′ ) • m ′′ is defined, and in that case, m •(m ′ • m ′′ ) = (m • m ′ ) • m ′′ for all elements m, m ′ , m ′′ of M; • every partial unit u ∈ U is a partial neutral element of •, i.e., if m • u (respectively, u • m) is defined then m • u = m (respectively, u • m = m)
for all element m of M; • every element admits a unique left partial unit, and a unique right partial unit, i.e., for all m ∈ M, there is a unique u ∈ U such that m • u is defined, and also, there is a unique u ∈ U such that u • m is defined. Ideally, a monoid is a partial monoid with the binary operation being totally defined and with the set of partial units being the singleton set consisting of the neutral element.

Example 3.15. (MG(A, D, Var), •, U(A, D, Var)) is a partial monoid. Clearly, • is partially associative and every partial unit is a partial neutral element of it. Moreover, for every marked graph (G, σ, v, v ′ ) and every partial unit

(G ′ , σ ′ , v ′′ , v ′′ ), their product (G, σ, v, v ′ ) • (G ′ , σ ′ , v ′′ , v ′′ ) is defined if, and only if, G = G ′ , σ = σ ′ and v ′ = v ′′ ,
which defines uniquely the partial unit. Hence, every element admits a unique left partial unit, and a unique right partial unit.

Consider now a continuous semiring (S, ⊕, ⊗, 0, 1). The set S M of formal power series over the partial monoid M is equipped with an addition operation (this does not require any operation over M indeed), and we may also define partial Cauchy products, basically with the same definition as the Cauchy product when M is a monoid. Formally, the partial Cauchy product f ⊗ g of two series f and g of S M is defined by

(f ⊗ g)(m) = m=m ′ • m ′′ f (m ′ ) ⊗ g(m ′′ )
for all m ∈ M .

The sum now ranges over all pairs (m ′ , m ′′ ) for which the product m ′ • m ′′ is defined and such that m = m ′ • m ′′ . Notice that this sum may be infinite (but is well-defined since the semiring is continuous) but is necessarily non empty because of the existence of the left and right units of m. Interestingly, this Cauchy product permits to equip S M with a structure of semiring, which is indeed continuous.

Proposition 3.16. If (M, •, U ) is a partial monoid, and (S, ⊕, ⊗, 0, 1) a continuous semiring, then (S M , ⊕, ⊗, 0, 1 U ) is a continuous semiring 3 .

Proof. We detail below the different elements proving that (S M , ⊕, ⊗, 0, 1 U ) is a continuous semiring.

• For every set M, (S M , ⊕, 0) is a commutative monoid.

• The novelty is to prove that (S M , ⊗, 1 U ) is a monoid. Indeed, ⊗ is easily shown to be an associative operation, by following the same proof as for monoids. Moreover, 1 U is a neutral element for ⊗. As a matter of fact, we have for every m ∈ M:

(f ⊗ 1 U )(m) = m=m ′ • m ′′ f (m ′ ) ⊗ 1 U (m ′′ ) = m ′ ∈M,m ′′ ∈U m=m ′ • m ′′ f (m ′ ) = m ′′ ∈U m=m • m ′′ f (m) = f (m)
where the last equality follows from the existence and unicity of the right partial unit of m. A symmetric proof may be used to prove that 1 U ⊗ f = f . • ⊗ distributes over ⊕, and 0 is an annihilator by lifting these properties from the semiring S. • Sum of family (f i ) i∈I is given, for every m ∈ M, by

i∈I f i (m) = i∈I f i (m) .
From this pointwise definition of the summation, it is not difficult to lift completeness and continuity from the semiring S to S M . Remark 3.17. The previous proposition permits to conclude that the structure

(S MG(A, D, Var) , ⊕, ⊗, 0, 1 U (A,D,Var) ) is a continuous semiring.
As in every continuous semiring, the Kleene iteration f ⋆ of every series f ∈ S M is well-defined. We may use in the following the notation f + as the partial Cauchy product f ⊗ f ⋆ .

Application to the Semantics of Hybrid Weighted Expressions

We now come back to the main purpose of defining algebraically the semantics of hybrid weighted expressions. To every hybrid weighted expression E ∈ HWE will be associated a series |E| ∈ S MG , inductively on the structure of E.

The semantics of E = s (with s ∈ S) is defined by |s| = s1 U the series which associates s to the partial units and 0 otherwise. Similarly, the semantics of E = α (with α ∈ Test) is defined by

|α| = 1 {(G,σ,v,v)∈U |G,σ,v|=α}
For every direction d ∈ D, we finally define

|d| = 1 {(G,σ,v,v ′ )∈MG|(v,v ′ )∈E d }
These three base cases are not surprising and resemble the previous definition of the semantics. But, indeed, the hardest is done as the inductive cases are trivial, in the sense that they are nothing more than a rewriting of the formulae used for weighted regular expressions:

|E 1 + E 2 | = |E 1 | ⊕ |E 2 | |E 1 • E 2 | = |E 1 | ⊗ |E 2 | |E + | = |E| +
It only remains to deal with the semantics of E = x!E 1 . Indeed, this can be seen as a projection operation over the series, but is inductively defined by the same equation as previously:

|x!E 1 |(G, σ, v, v ′ ) = |E 1 |(G, σ[x → v], v (i) , v (f ) ) if v = v ′ 0 otherwise Proposition 3.18.
For every E ∈ HWE, and for every marked graph

(G, σ, v, v ′ ) ∈ MG with Free(E) ⊆ dom(σ), [[E]](G, σ, v, v ′ ) = |E|(G, σ, v, v ′ ).
Proof. We proceed by induction over E. The equality is trivially verified for expressions s, α, d and x!E.

If E = E 1 + E 2 , we have by induction [[E 1 + E 2 ]](G, σ, v, v ′ ) = [[E 1 ]](G, σ, v, v ′ ) ⊕ [[E 2 ]](G, σ, v, v ′ ) = |E 1 |(G, σ, v, v ′ ) ⊕ |E 2 |(G, σ, v, v ′ ) = |E 1 + E 2 |(G, σ, v, v ′ )
as the addition of series is defined pointwisely.

If E = E 1 • E 2 , we have [[E 1 • E 2 ]](G, σ, v, v ′ ) = v ′′ ∈V [[E 1 ]](G, σ, v, v ′′ ) ⊗ [[E 2 ]](G, σ, v ′′ , v ′ ) = v ′′ ∈V |E 1 |(G, σ, v, v ′′ ) ⊗ |E 2 |(G, σ, v ′′ , v ′ ) = (G,σ,v,v ′ )= (G1,σ1,v1,v ′ 1 )• (G2,σ2,v2,v ′ 2 ) |E 1 |(G 1 , σ 1 , v 1 , v ′ 1 ) ⊗ |E 2 |(G 2 , σ 2 , v 2 , v ′ 2 ) = (|E 1 | ⊗ |E 2 |)(G, σ, v, v ′ ) = |E 1 • E 2 |(G, σ, v, v ′ ) Finally, if E = E + 1 , we have [[E + 1 ]](G, σ, v, v ′ ) = n>0 [[E n 1 ]](G, σ, v, v ′ )
An induction over n shows that

[[E n 1 ]](G, σ, v, v ′ ) = |E 1 | n (G, σ, v, v ′ )
with f n defined for every series f by f 1 = f and f n+1 = f ⊗ f n . By definition of the Kleene iteration of a series, we conclude that

[[E + 1 ]](G, σ, v, v ′ ) = |E 1 | + (G, σ, v, v ′ ) = |E + 1 |(G, σ, v, v ′ ) CHAPTER 4
Navigating Automata

Le petit Poucet les laissait crier, sachant bien par où il reviendrait à la maison, car en marchant il avait laissé tomber le long du chemin les petits cailloux blancs qu'il avait dans ses poches. In this chapter, we explore a more operational view of quantitative specification, in terms of weighted automata. Originally investigated by Marcel-Paul Schützenberger in [START_REF] Schützenberger | On the Definition of a Family of Automata[END_REF] as a way to compute rational series, they have been extended and studied extensively since then. In particular, much has been done to transfer Kleene's result, stating the equivalence of regular expressions and finite-state automata. This result, extended to the weighted case in Schützenberger theorem, is not only of theoretical interest, but is also practically important: in particular, transforming a denotational specification into an automaton must be done as fast as possible. Classical fast algorithms in the Boolean case are based on Glushkov constructions (see [START_REF] Victor | On a Synthesis Algorithm for Abstract Automata[END_REF][START_REF] Victor | The Abstract Theory of Automata[END_REF]), further investigated, e.g., in Berry-Sethi algorithm (see [START_REF] Berry | From Regular Expressions to Deterministic Automata[END_REF]). These algorithms have been extended into the weighted case (see [START_REF] Sakarovitch | Elements of Automata Theory[END_REF]): a unified version of several algorithms is studied in [START_REF] Allauzen | A Unified Construction of the Glushkov, Follow, and Antimirov Automata[END_REF].

Before presenting our framework of weighted automata navigating over graphs, we start by recalling standard definitions of weighted automata (over words). Usually, a weighted automaton over an alphabet A and semiring S is a tuple (Q, λ, µ, ν) with Q a finite set of states, λ ∈ S Q a row vector of initial weights, µ : A → S Q×Q a mapping from letters to matrices of transitions, and ν ∈ S Q a column vector of final weights. For example, over the

defined by Q = {1, 2}, λ = 1 0 , µ(a) = 1 2 0 1 , µ(b) = 1 0 0 1 and ν = 0 2 . It is depicted in Figure 4.1.
Its semantics may be defined using runs, having a certain weight: this is the way we will define the semantics of our automata. However, in this simple example, the semantics may be defined in a more algebraic and direct way. Indeed, notice that the mapping µ may be uniquely extended as a morphism from the free monoid A ⋆ (i.e., the monoid generated by elements of A) to the monoid of square matrices S Q×Q . This is done by letting µ(ε) being the identity matrix, and for every word w, and letter a ∈ A by letting µ(aw) = µ(a) × µ(w) where × denotes here the matrix product. Then, the semantics of a weighted automaton A is the formal power series obtained by associating to every word w ∈ A ⋆ the coefficient

|A|(w) = λ × µ(w) × ν ∈ S .
For example, the weighted automaton A of Figure 4.1 generates the formal power series mapping every word w to the coefficient 2(|w| a + 1). Indeed, as µ(b) is the identity matrix, we have µ(w) = µ(a |w|a ), and an induction shows that

µ(a n ) = 1 2n 0 1
A computation, shown in our setting in Theorem 4.18, shows that weighted automata over the natural semiring may only recognize formal power series f such that f (w) = 2 O(|w|) , bounding immediately their expressive power. Our starting point is then to explore more expressive automata: this will be done by adding navigational features, as well as pebbles.

Whereas the first section investigates the navigational issue, and states a first Kleene-Schützenberger theorem, the second one will add pebble features and prove an extended theorem relating these automata with the expressions defined in the previous chapter. This chapter is an extension of some of the results presented in [2] in the special case of words, and [4] in the special case of nested words.

Weighted Automata over Graphs

Syntax and Semantics over a Continuous Semiring

In this section, we define weighted automata navigating over graphs. We will simply call them weighted automata, even though they are not the same objects as weighted automata we can find in the literature, and that we have described previously. We will see however that they naturally contain weighted automata over words.

Definition 4.1. A weighted automaton over a semiring S is a tuple

A = (Q, A, D, I, ∆, F ) where • Q is a finite set of states; • A is a finite alphabet;
• D is a finite set of directions;

• I ∈ S Q is the vector of initial weights; • ∆ ∈ S Test(A, D, Var) D Q×Q is the weighted transition matrix2 : a transition goes from a state q to a state q ′ performing a test α and an action given by a direction d, and has weight ∆ q,q ′ (d)(α); • F ∈ S Test(A, D, Var) Q is the final vector: each state q is mapped to a polynomial F q of tests. The class of all weighted automata over S is denoted by WA(S) or WA if the semiring is clear from the context, or not relevant.

Example 4.2. We first consider the case of words in this example, i.e., we suppose that D = {←, →}. Let A ′ = ({1, 2}, {a, b}, D, I, ∆, F ) be the weighted automaton in WA(N) (over the semiring (N, +, ×, 0, 1)) defined by

I = 1 0 ∆ = (1a? + 1b?)→ (2a?)→ 0 (1a? + 1b?)→ F = 4a? 2a? + 2b? Automaton A ′ is depicted in Figure 4.2.
Notice that (1a? + 1b?)→ denotes the formal power series f ∈ S Test D with f (←) = 0 and f (→) being the formal power series of S Test having for only non-zero coefficients the one of tests a? and b? which are both equal to 1.

Intuitively, a weighted automaton navigates in a pointed graph, keeping in its finite memory the current state. At every time step, the automaton chooses an available direction of D and follows it, under the condition that some test of Test(A, D, Var) is verified on the current vertex of the graph. Notice that we allow the presence of some tests x? of a variable x: this will become useful in the following of this chapter. Henceforth, to be evaluated, the weighted automaton A also needs a valuation of the free variables Free(A), namely the (finite) set of variables appearing in tests of non-zero coefficients of the polynomials in ∆ and F .

A run collects a sequence of moves from one vertex to another, and the weight of a run is the product (in the semiring S) of the weights of the transitions taken during the run. The non-determinism is resolved by using the sum of the semiring, i.e., a weighted automaton maps every possible pointed graph to the sum of the weights of the accepted runs over this graph, namely those that start in the initial vertex and end in the final one. Now, we formalize this definition of the semantics.

A run will be described as a sequence of configurations of A.

A configuration of A = (Q, A, D, I, ∆, F ) is an element (G, σ, q, v) composed of a pointed graph G ∈ G(A, D), a valuation σ : Var ⇀ V , a state q of Q and a vertex v of V .
Any two configurations with a fixed graph G and a fixed valuation σ give rise to a concrete transition (G, σ, q, v) ❀ (G, σ, q ′ , v ′ ) whenever the pair (v, v ′ ) is an edge in E. Its weight is then defined by

d∈D | (v,v ′ )∈E d α∈Test | G,σ,v|=α ∆ q,q ′ (d)(α) . ( 4.1)
Remark 4.3. Notice that this sum is finite because ∆ q,q ′ (d) is a polynomial for every d ∈ D.

A run of A is a sequence of configurations related successively by concrete transitions. Its weight is the product of transition weights, multiplied from left to right. We are interested in runs that start at some vertex v, in state q, and end in some configuration with vertex v ′ and state q ′ . Therefore, we let [[A q,q ′ ]](G, σ, v, v ′ ) be the sum of the weights of all runs leading from configuration (G, σ, q, v) to configuration (G, σ, q ′ , v ′ ). If we consider a continuous semiring, this a priori infinite sum is well-defined.

Finally, the semantics of weighted automaton A maps every pointed graph G ∈ G(A, D) and valuation σ : Var ⇀ V with domain containing the free variables of A to an element of the continuous semiring S by including the initial and final weights, letting 2). We consider a pointed graph G ∈ Word({a, b}) representing a finite word w ∈ {a, b} + . The weighted automaton A ′ has no free variables so that we can forget about the valuation part in the configurations and in the semantics. A run with non-zero weight in A ′ from a configuration (G, 1, v (i) ) to (G, q, v (f ) ) (with q ∈ {1, 2}) visits first only state 1, and then either stops in state 1, or uses the transition from state 1 to state 2 and then loops in state 2. If it stops in state 1, to accept, and get a non-zero weight, the final test a? must be verified, in which case weight 4 is multiplied. This simulates the behavior of the (classical) weighted automaton A of Figure 4.1 where the transition from state 1 to state 2 -with weight 2 -is taken in the last position of the word, before accepting with weight 2. Otherwise, the run in A ′ takes the transition from state 1 to state 2, simulating the same behavior in A. It finally loops in state 2 before accepting with weight 2 in the final vertex, since 2a? + 2b? is a polynomial which evaluates as the constant polynomial 2. Finally, this shows that [[A ′ ]](G) = |A|(w).

[[A]](G, σ) = q,q ′ ∈Q I q ⊗ [[A q,q ′ ]](G, σ, v (i) , v (f ) ) ⊗ α∈Test | G,σ,v (f ) |=α F q ′ (α) .

As for the hybrid weighted expressions, we may write [[A]](G) and [

[A q,q ′ ]](G, v, v ′ )
Remark 4.5. Notice that the previous example indeed shows that we can translate every (classical) weighted automaton over finite words in our navigating formalism. We must particularly care about the vector of final weights: indeed, the last transition of a (classical) weighted automaton leads from a configuration in the last vertex of a word to the outside of this word. In contrast, it is forbidden in our setting to exit the set of vertices of a graph. Henceforth, we simulate the last transition by the vector of final weights, by using the power of test formulae in Test. For example, in automaton A of Figure 4.1, if a run ends with the looping transition on state 2, it is simulated in A ′ by testing a? + b? (without making the → move which would informally exit the set of vertices) and multiplying by the final weight 2 of state 2.

Remark 4.6. In the sequel, we will continuously use terminologies borrowed from the usual Boolean setting. For example, we may talk about initial state (respectively, final state) for a state having an initial weight (respectively, final polynomial) different from 0. By extension, an accepting run is a run which starts in a configuration (G, σ, q, v (i) ) with q an initial state, and ends in a configuration (G, σ, q ′ , v (f ) ) with q ′ a final state, and having a weight different from 0.

1 0 2 3 0⊤ min(2 a?, 1 b?)↓ 1 (0 ¬(↓ 1 ?))↑ 1 (0 ⊤)↓ 2 (0 ¬(↓ 1 ?))↑ 2 (0 ⊤)↑ 2 (0 ⊤)↑ 1
G ∈ Word({a}).
Once in the final vertex of the graph, the automaton is forced to accept with weight 1, since neither the → transition, nor the ← transition -because of the test ¬final? -can be taken. On the other hand, the test ¬init? in the transition is there to ensure that direction ← is not taken on the first position of the word: notice however, that the semantics of the automaton would not have been different if this test was removed. Indeed, there is a bijection between the accepting runs of A, and the paths in G from the initial vertex to the final vertex, that stop the first time they reach this final vertex. The weight of an accepting run is then p m→ (1p) m← where m → (respectively, m ← ) is the number of → directions (respectively, ← directions) taken along the run: considering the length n of the word, we must have m → = m ← + n -1. Notice that there is an infinite number of accepting runs, which means that the semantics of A involves an infinite sum, making it crucial to consider a complete semiring. This example is further studied in Example 8.4, giving a probabilistic interpretation of the semantics of this automaton.

Example 4.8. We consider now an example over binary trees. Let A = {a, b, c} with a and b being binary letters, and c a nullary letter. Hence, we will consider binary trees where a and b are labels of internal nodes and c the label of the leaves. Let A be the weighted automaton in WA(N ∪ {+∞}) (over the semiring (N ∪ {+∞}, min, +, +∞, 0)) depicted in Figure 4. 4. Over each binary tree G ∈ T ree(A), the automaton A admits a unique accepting run following a depth-first-search of the tree: it visits each leaf exactly once, in state 1, and each internal node three times, the first one in state 1, then in state 2 and the last time in state 3. During the first visit of each internal node, we count 2 if the node is labeled by a and 1 if it is labeled by b. All other transitions count 0, hence, the weight of a run, defined as the sum3 of the weights of the transitions, is precisely 2n a + n b if n a (respectively, n b ) is the number of internal nodes labeled by a (respectively, b). By adding to this automaton three more states (in a separated connected component) related in the same way by simply exchanging the weights 1 and 2 in the self loop, we produce an automaton with exactly two accepting runs over each binary tree: the non-determinism is then resolved by taking a minimum, and the semantics then maps a binary tree to the value min(2n a +n b , n a +2n b ).

A First Kleene-Schützenberger Theorem

We are now ready to state the first result of this manuscript: its aim is to relate a denotational formalism -weighted expressions -with a computational formalism -weighted automata.

From one side, translating weighted expressions into weighted automata may be seen as a prerequisite to efficient parsing of weighted expressions: therefore, we will try to make this translation as efficient as possible. From the other side, this is a theoretical result involving some closure properties of the weighted automata: this shows the robustness of the class of automata we considered.

Theorem 4.9. Let S be a continuous semiring.

For each weighted expression E ∈ WE(S), we can construct a weighted automaton

A E ∈ WA(S) with Free(A E ) = Free(E), equivalent to E, i.e., [[E]](G, σ) = [[A E ]](G, σ)
for every pointed graph G and every valuation σ with domain containing Free(E).

For each weighted automaton A ∈ WA(S), we can construct a weighted expression

E A ∈ WE(S) with Free(E A ) = Free(A), equivalent to A, i.e., [[A]](G, σ) = [[E A ]](G, σ)
for every pointed graph G and every valuation σ with domain containing Free(A).

The rest of this section is devoted to the proof of this theorem. We start by proving the second item, as its proof will help us for the proof of the first one.

From Weighted Automata to Weighted Expressions

This section is devoted to the construction of a weighted expression E A equivalent to a given weighted automaton A. We will show that we can use the classical constructions to transform regular expressions into finite-state automata, e.g., the state elimination method of Brzozowski and McCluskey [START_REF] Brzozowski | Signal Flow Graph Techniques for Sequential Circuit State Diagrams[END_REF], the procedure of McNaughton and Yamada [START_REF] Mcnaughton | Regular Expressions and State Graphs for Automata[END_REF] or the recursive algorithm [START_REF] Horton | Regular Algebra and Finite Machines[END_REF]. We refer to the survey of Sakarovitch [Sak12, Section 6.2] where these methods are presented and compared for (classical) weighted automata over finite words.

In the state elimination method, states are progressively suppressed and transitions are labeled with weighted expressions. Therefore, it is convenient to consider automata allowing weighted expressions in the labels of transitions: we first introduce these generalized weighted automata and then show how to exploit them to translate automata into expressions.

Definition 4.10. A generalized weighted automaton is a tuple

A = (Q, A, D, I, ∆, F ) where • Q is a finite set of states; • A is a finite alphabet; • D is a finite set of directions; • I ∈ S Q is the initial vector; • ∆ ∈ WE(S, A, D) Q×Q is the transition matrix; • F ∈ S Test(A, D, Var) Q is the final vector.
The class of all generalized weighted automata over S is denoted by gWA(S) or gWA if the semiring is clear from the context, or not relevant.

The differences compared with weighted automata in WA reside in the introduction of weighted expressions in the transition matrix. The semantics of such a generalized weighted automaton is given by a variation of the semantics of weighted automata: now, the weight of a concrete transition (G, σ, q, v) ❀ (G, σ, q ′ , v ′ ) is defined by [[∆ q,q ′ ]](G, σ, v, v ′ ) (the semantics of a weighted expression). This permits to update accordingly the definition of [[A q,q ′ ]](G, σ, v, v ′ ). We introduce another step before giving the final semantics as this will be useful in the following: we denote [[A]](G, σ, v, v ′ ) the semantics of the generalized au-tomaton from vertex v to vertex v ′ , which is defined by

[[A]](G, σ, v, v ′ ) = q,q ′ ∈Q I q ⊗ [[A q,q ′ ]](G, σ, v, v ′ ) ⊗ α∈Test | G,σ,v ′ |=α F q ′ (α) . Finally, we let [[A]](G, σ) = [[A]](G, σ, v (i) , v (f )
) be the semantics from the initial to the final vertex of the pointed graph G with valuation σ.

Notice that every weighted automaton can be seen as a generalized weighted automaton.

Proposition 4.11. From a weighted automaton A ∈ WA(S), we can construct an equivalent generalized weighted automaton à ∈ gWA(S) with the same set of free variables.

Proof. Let A = (Q, A, D, I, ∆, F ) be a weighted automaton. We construct an equivalent generalized weighted automaton à = (Q, A, D, I, ∆, F ) by letting for every q, q ′ ∈ Q,

∆q,q ′ = α∈Test,d∈D ∆ q,q ′ (d)(α) • α • d
which is a weighted expression, since this sum is finite (∆ has finite support by definition).

A simple rewriting permits to show that both definitions of the semantics coincide in that case.

We first relate the semantics of a generalized weighted automaton with the star of the semantic matrix [[∆]], whose coefficients are given by [[∆ q,q ′ ]]. For each q, q ′ ∈ Q, the entry ∆ q,q ′ is a weighted expression in WE(S) and its semantics [[∆ q,q ′ ]] may hence be seen as a series over marked graphs of MG(A, D, Var) (that we denote MG in the following). Hence, the semantic matrix verifies

[[∆]] = ([[∆ q,q ′ ]]) (q,q ′ )∈Q 2 ∈ S MG Q×Q .
Recall that S MG is a continuous semiring by Remark 3.17. For each finite set Q, the semiring of matrices S MG Q×Q is also continuous. Hence, given a matrix H in S MG Q×Q , the star matrix

H ⋆ = n≥0 H n ∈ S MG Q×Q is well-defined. Applying this to H = [[∆]
] we can generalize the classical relation between the semantics of a one-way weighted automaton and the star of a matrix of series. Proposition 4.12. Let A = (Q, A, D, I, ∆, F ) be a weighted automaton. For all states q, q ′ ∈ Q, the two series

[[A q,q ′ ]] and ([[∆]] ⋆ ) q,q ′ are equal, i.e., [[A q,q ′ ]](G, σ, v, v ′ ) = ([[∆]] ⋆ ) q,q ′ (G, σ, v, v ′ ) for all marked graph (G, σ, v, v ′ ) ∈ MG.

Proof. We show by induction on

n ≥ 0 that for every marked graph (G, σ, v, v ′ ) ∈ MG, ([[∆]] n ) q,q ′ (G, σ, v, v ′ ) computes the sum of the weights of runs of length n from configuration (G, σ, q, v) to configuration (G, σ, q ′ , v ′ ).
This is true for n = 0, as

1 U (G, σ, v, v ′ ) = 1 if, and only if, v = v ′ .
Then, assuming the property for n -1 ≥ 0, we prove it for n. A run of length n > 0 starts with a transition followed by a run of length n -1. Hence, the sum of the weights of runs of length n from configuration (G, σ, q, v) to configuration (G, σ, q ′ , v ′ ) is computed by

q ′′ ∈Q,v ′′ ∈V [[∆]] q,q ′′ (G, σ, v, v ′′ ) ⊗ ([[∆]] n-1 ) q ′′ ,q ′ (G, σ, v ′′ , v ′ ) .
Indeed, by using the definition of the matrix multiplication induced by the Cauchy product, we have

([[∆]] n ) q,q ′ (G, σ, v, v ′ ) = ([[∆]] ⊗ [[∆]] n-1 ) q,q ′ (G, σ, v, v ′ ) = q ′′ ∈Q [[∆]] q,q ′′ ⊗ ([[∆]] n-1 ) q ′′ ,q ′ (G, σ, v, v ′ ) .
Then, applying the definition of the Cauchy product in the partial semiring over the partial monoids of marked graphs, we obtain

([[∆]] n ) q,q ′ (G, σ, v, v ′ ) = q ′′ ∈Q (G,σ,v,v ′ )= (G1,σ1,v1,v ′ 1 )• (G2,σ2,v2,v ′ 2 ) [[∆]] q,q ′′ (G 1 , σ 1 , v 1 , v ′ 1 ) ⊗ ([[∆]] n-1 ) q ′′ ,q ′ (G 2 , σ 2 , v 2 , v ′ 2 )
which is equal to

q ′′ ∈Q,v ′′ ∈V [[∆]] q,q ′′ (G, σ, v, v ′′ ) ⊗ ([[∆]] n-1 ) q ′′ ,q ′ (G, σ, v ′′ , v ′ ) as (G, σ, v, v ′ ) = (G 1 , σ 1 , v 1 , v ′ 1 ) • (G 2 , σ 2 , v 2 , v ′ 2 ) implies G 1 = G 2 = G, σ 1 = σ 2 = σ, v = v 1 , v ′ = v ′ 2 and v ′ 1 = v 2 .
The same way we introduced the semantic matrix [[∆]] we may also introduce

• the semantic initial row vector [[I]] ∈ S MG Q defined by [[I]] q = G∈G(A,D) σ : Var⇀V I q (G, σ, v (i) , v (i) ) ; • the semantic final column vector [[F ]] ∈ S MG Q defined by [[F ]] q = G∈G(A,D) σ : Var⇀V α∈Test| G,σ,v (f ) |=α F q (α) (G, σ, v (f ) , v (f ) ) .
As a corollary of Proposition 4.12, we obtain that for every pointed graph G and every valuation σ,

[[A]](G, σ) = ([[I]] ⊗ [[∆]] ⋆ ⊗ [[F ]])(G, σ, v (i) , v (f ) ) (4.2)
where ⊗ is interpreted as the matrix multiplication induced by the Cauchy product over S MG . Now, Lemma 2.7 shows that the entries of the star of a matrix H are in the rational closure 4 of the entries of H. Using this fact, we can prove Proposition 4. 13. Let A = (Q, A, D, I, ∆, F ) be a weighted automaton. We can construct a matrix Φ(∆) ∈ WE Q×Q which is equivalent to the automaton, i.e., such that the following matrix equality holds:

[[Φ(∆)]] = [[∆]] ⋆
Moreover, the entries of Φ(∆) are in the rational closure of the entries of ∆.

∆ = E F G H that implies [[∆]] = [[E]] [[F ]] [[G]] [[H]]
with H of size 1, to get

[[∆]] ⋆ = ([[E]] ⊕ [[F ]] ⊗ [[H]] ⋆ ⊗ [[G]]) ⋆ [[E]] ⋆ ⊗ [[F ]] ⊗ ([[H]] ⊕ [[G]] ⊗ [[E]] ⋆ ⊗ [[F ]]) ⋆ [[H]] ⋆ ⊗ [[G]] ⊗ ([[E]] ⊕ [[F ]] ⊗ [[H]] ⋆ ⊗ [[G]]) ⋆ ([[H]] ⊕ [[G]] ⊗ [[E]] ⋆ ⊗ [[F ]]) ⋆
As H is a matrix of size 1, this is a weighted expression, so that H ⋆ is well-defined. To mimick this semantical computation, we then let

Φ(∆) = Φ(E + F • H ⋆ • G) Φ(E) • F • (H + G • Φ(E) • F ) ⋆ H ⋆ • G • Φ(E + F • H ⋆ • G) (H + G • Φ(E) • F ) ⋆
Notice that we apply the operator Φ twice over matrices of size |Q| -1. Moreover, we extend the concatenation of weighted expressions to matrices of weighted expressions in a straightforward way. Finally, notice that

G • Φ(E) • F is a matrix of size 1 so that (H + G • Φ(E) • F ) ⋆ is well-defined. We now prove that [[Φ(∆)]] = [[∆]] ⋆ .
From the algebraic definition of the semantics and Proposition 3.18 of weighted expressions, H and (

H + G • Φ(E) • F ) ⋆ being weighted expressions, we obtain [[H ⋆ ]] = [[H]] ⋆ and [[(H + G • Φ(E) • F ) ⋆ ]] = ([[H]] ⊕ [[G]] ⊗ [[Φ(E)]] ⊗ [[F ]]) ⋆ By induction we get [[Φ(E + F • H ⋆ • G)]] = [[E + F • H ⋆ • G]] ⋆ = ([[E]] ⊕ [[F ]] ⊗ [[H]] ⋆ ⊗ [[G]]) ⋆
which permits to conclude by considering again the algebraic properties implied by Proposition 3.18.

As a corollary, using (4.2) and the fact that [[F ]] may be easily transformed into an equivalent column vector with coefficients in WE(S, A, D), we have proved item 2 of Theorem 4.9.

Example 4.14 (Continued from Example 4.8). We apply the technique presented in this section to find a weighted expression equivalent to the weighted automaton A presented in Figure 4. 4. Throughout this proof, we allow ourself to simplify the weighted expressions produced, e.g., by remarking that, in the semiring (N ∪ {+∞}, min, +, +∞, 0), +∞ • E is always equivalent to +∞, +∞ + E is equivalent to E, and 0 • E is equivalent to E. Also, we remove tests ⊤ which do not change the semantics of weighted expressions.

First, we translate A into a generalized weighted automaton. We obtain the following matrix of weighted expressions

∆ =   (2a? + 1b?)↓ 1 ¬(↓ 1 ?)↑ 1 ¬(↓ 1 ?)↑ 2 ↓ 2 +∞ +∞ +∞ ↑ 1 ↑ 2  
Considering the initial and final vectors, we only need to compute the (1, 3)-coefficient of the matrix Φ( ∆). Considering the block decomposition given in the previous proof, we have Noticing that (+∞) ⋆ = 0, we can compute Φ(E) and obtain

E = (2a? + 1b?)↓ 1 ¬(↓ 1 ?)↑ 1 ↓ 2 +∞ , F = ¬(↓ 1 ?)↑ 2 +∞ , G = +∞ ↑ 1 and H = ↑ 2 A = ι c N J U A = 1 0    0 J 0 N      c U  
Φ(E) 1,1 = (2a? + 1b?)↓ 1 + ¬(↓ 1 ?)↑ 1 ↓ 2 ⋆ Φ(E) 2,1 = ↓ 2 (2a? + 1b?)↓ 1 + ¬(↓ 1 ?)↑ 1 ↓ 2 ⋆
We finally find Φ( ∆) 1,3 by computing the upper coefficient of Φ(E)

• F • (H + G • Φ(E) • F ) ⋆ : Φ( ∆) 1,3 = (2a? + 1b?)↓ 1 + ¬(↓ 1 ?)↑ 1 ↓ 2 ⋆ ¬(↓ 1 ?)↑ 2 ↑ 2 + ↑ 1 ↓ 2 (2a? + 1b?)↓ 1 + ¬(↓ 1 ?)↑ 1 ↓ 2 ⋆ ¬(↓ 1 ?)↑ 2 ⋆
which also gives a weighted expression equivalent to the weighted automaton A.

From Weighted Expressions to Weighted Automata

We now prove item 1 of Theorem 4.9, i.e., how to transform a weighted expression to an equivalent weighted automaton. Efficient translations have been well-studied both in the Boolean and in the weighted (one-way) cases. Glushkov's translation [START_REF] Victor | The Abstract Theory of Automata[END_REF] (or Berry-Sethi [START_REF] Berry | From Regular Expressions to Deterministic Automata[END_REF]) is acknowledged to be among the best ones. The good news is that this construction can be adapted to cope with two-way moves as we will show in this section. The construction is by structural induction on the expression. The induction hypothesis to maintain is slightly strengthened, in order to prove the result, as presented in the following proposition.

Proposition 4.15. For each weighted expression E ∈ WE we can construct a weighted automaton

A E ∈ WA such that [[A E ]] = [[E]], i.e., for all (G, σ, v, v ′ ) ∈ MG we have [[A E ]](G, σ, v, v ′ ) = [[E]](G, σ, v, v ′ ) .
We define the literal-length ℓℓ(E) of a weighted expression as the number of occurrences of directions from D. We construct an automaton A E with 1 + ℓℓ(E) states.

For the rational operations (+, •, ⋆ , and + ), we can still use the classical constructions even though we are working with navigating weighted automata. Nethertheless, for seek of clarity, we repeat the whole proof in the following. We adopt the presentation of standard automata found in [START_REF] Sakarovitch | Automata and Expressions[END_REF]. A standard automaton A = (Q, A, D, I, ∆, F ) has a single initial state ι with (initial) weight 1, all other states have initial weight 0. Moreover, the initial state ι has no ingoing transition. We use both the graphical representation and the matrix representation of an automaton of Figure 4.5, where the entries of the matrices J and N are polynomials in S Test D .

Since terminal weights allow polynomials over Test with the vector F ∈ S Test Q , we will be able to cope with expressions of the form E • ϕ? and E • s without adding unnecessary states. The constant term c and the entries of U are polynomials in S Test . For s ∈ S, α ∈ Test and d ∈ D, we simply write s for s⊤, α for 1α, and d for 1⊤d.

We start with atoms. Compared to the classical (one-way) translation, a slight difference is that we are using tests (α) and directions (d) instead of letters for the atoms. The automata for the atoms are depicted in Figure 4.6 and we can easily see that they are equivalent to the corresponding atoms. The constructions for sum and concatenation are as usual, and are depicted in Figure 4. 7.

A s = ι s A d = ι d 1 A α = ι α
A 1 + A 2 = ι c 1 ⊕ c 2 N 1 J 1 U 1 N 2 J 2 U 2 A 1 • A 2 = ι c 1 c 2 N 1 J 1 U 1 c 2 N 2 c 1 J 2 U 2 U 1 J 2
In the concatenation, we are overloading5 the product notation as follows. The product of two monomials s 1 α 1 and s 2 α 2 from S Test should be understood as (

s 1 ⊗ s 2 )(α 1 ∧ α 2 ) to stay in S Test . Hence c 1 ⊗ c 2 and the entries of U 1 ⊗ c 2 are in S Test . Similarly, in U 1 ⊗ J 2 , the product of a monomial s 1 α 1 ∈ S Test and a monomial s 2 α 2 d ∈ S Test D (with d ∈ D) is defined as (s 1 ⊗ s 2 )(α 1 ∧ α 2 )d.
Hence, the entries of the matrices c 1 ⊗ J 2 and U 1 ⊗ J 2 are in S Test D . The matrix representation is therefore:

A 1 • A 2 = 1 0 0        0 J 1 c 1 ⊗ J 2 0 N 1 U 1 ⊗ J 2 0 0 N 2               c 1 ⊗ c 2 U 1 ⊗ c 2 U 2       
Example 4.16. For instance, the automaton for 2a = 2a?→ is computed as follows:

ι 2⊤ • ι 1a? • ι (1⊤)→ 1⊤ = ι (2a?)→ 1⊤
Similarly, for the expression E = (2a? + b?)→(2b? + 3c?) we compute the concatenation of 3 automata as follows:

ι 2a? + b? • ι (1⊤)→ 1⊤ • ι 2b? + 3c? = ι (2a? + b?)→ 2b? + 3c?
Finally, the star is also computed as usual with the construction depicted in Figure 4.8, where c ′ ∈ S Test is defined to be equivalent to c ⋆ as follows. Since c ∈ S Test and test formulas are closed under Boolean connectives, we find an equivalent expression c = i s i α i with (α i ) i pairwise incompatible test formulae (i = j implies α i ∧ α j unsatisfiable). Then

A ⋆ = ι c ′ N + U c ′ J c ′ J U c ′ A ⋆ = 1 0    0 c ′ ⊗ J 0 N ⊕ U ⊗ c ′ ⊗ J       c ′ U ⊗ c ′    Figure 4.8: Automaton for Kleene star we can easily check that [[c]] ⋆ = [[c ′ ]] with c ′ = i s ⋆ i α i .
The particular case c = 0 = 0⊤ gives c ′ = 1 = 1⊤. Notice that s ⋆ i ∈ S is well-defined since the semiring is complete. As for the concatenation, we can check that the entries of U ⊗ c ′ are in S Test and the entries of U ⊗ c ′ ⊗ J are in S Test D . The strict iteration A + is computed similarly by simply changing the final weight of ι to c ′′ = i s + i α i (note that 0

+ = 0), but keeping the other occurrences of c ′ in c ′ ⊗ J, U ⊗ c ′ ⊗ J and U ⊗ c ′ .
Example 4.17. (Continued from Example 4.16) For instance, for expression

E = → + a?← + b?→ + c?← + d?→ + ,
we can compute the automaton as follows:

A → + = ι (1⊤)→ (1⊤)→ 1⊤ A → + •a? = ι (1⊤)→ (1⊤)→ 1a? A E = ι (1⊤)→ (1⊤)→ (1⊤)← (1a?)← (1⊤)→ (1b?)→ (1⊤)← (1c?)← (1⊤)→ (1d?)→ 1⊤
Let us briefly discuss the complexity of our translation. Clearly, the number of states of the automaton A E is 1 plus the literal-length ℓℓ(E) of expression E. The time complexity is cubic in the length of E, since in the worst case, each step requires to compute a bounded number of multiplications of a matrix and a vector of sizes bounded by ℓℓ(E). As future works, it would be interesting to search for a quadratic algorithm: one possible direction could be to generalize the notion of star normal form introduced in [START_REF] Brüggeman-Klein | Regular Expressions into Finite Automata[END_REF] for word languages or the algorithm presented in [START_REF] Allauzen | A Unified Construction of the Glushkov, Follow, and Antimirov Automata[END_REF] for classical weighted expressions and automata.

To conclude this section, we prove the correctness of the constructions. This correctness is trivial for the atoms. For sum, product and star, the proof is similar to the case of classical (one-way) weighted expressions and automata. Indeed, from (4.2), we know that

[[A]] = [[I]] ⊗ [[∆]] ⋆ ⊗ [[F ]]
: notice that this is an equality between series over marked graphs. Using the special form of standard automata and Lemma 2.7, we have

[[∆]] =    0 [[J]] 0 [[N ]]    [[∆]] ⋆ =    1 [[J]] ⊗ [[N ]] ⋆ 0 [[N ]] ⋆    and we get [[A]] = [[c]] ⊕ [[J]] ⊗ [[N ]] ⋆ ⊗ [[U ]].
For the concatenation, the matrix

N of A = A 1 • A 2 satisfies (applying Lemma 2.7): [[N ]] =    [[N 1 ]] [[U 1 ⊗ J 2 ]] 0 [[N 2 ]]    [[N ]] ⋆ =    [[N 1 ]] ⋆ [[N 1 ]] ⋆ ⊗ [[U 1 ⊗ J 2 ]] ⊗ [[N 2 ]] ⋆ 0 [[N 2 ]] ⋆    .
Hence we obtain

[[A]] = [[c]] ⊕ [[J]] ⊗ [[N ]] ⋆ ⊗ [[U ]] = [[c 1 ⊗ c 2 ]] ⊕ [[J 1 ]] ⊗ [[N 1 ]] ⋆ ⊗ [[U 1 ⊗ c 2 ]] ⊕ [[J 1 ]] ⊗ [[N 1 ]] ⋆ ⊗ [[U 1 ⊗ J 2 ]] ⊗ [[N 2 ]] ⋆ ⊗ [[U 2 ]] ⊕ [[c 1 ⊗ J 2 ]] ⊗ [[N 2 ]] ⋆ ⊗ [[U 2 ]] = ([[c 1 ]] ⊕ [[J 1 ]] ⊗ [[N 1 ]] ⋆ ⊗ [[U 1 ]]) ⊗ ([[c 2 ]] ⊕ [[J 2 ]] ⊗ [[N 2 ]] ⋆ ⊗ [[U 2 ]]) = [[A 1 ]] ⊗ [[A 2 ]]
For the star construction, the correctness is obtained as follows using classical rational identities and

[[c]] ⋆ = [[c ′ ]]: [[A]] ⋆ = ([[c]] ⊕ [[J]] ⊗ [[N ]] ⋆ ⊗ [[U ]]) ⋆ = ([[c]] ⋆ ⊗ [[J]] ⊗ [[N ]] ⋆ ⊗ [[U ]]) ⋆ ⊗ [[c]] ⋆ = ([[c ′ ]] ⊗ [[J]] ⊗ [[N ]] ⋆ ⊗ [[U ]]) ⋆ ⊗ [[c ′ ]] = [[c ′ ]] ⊕ [[c ′ ]] ⊗ [[J]] ⊗ ([[N ]] ⋆ ⊗ [[U ]] ⊗ [[c ′ ]] ⊗ [[J]]) ⋆ ⊗ [[N ]] ⋆ ⊗ [[U ]] ⊗ [[c ′ ]] = [[c ′ ]] ⊕ [[c ′ ]] ⊗ [[J]] ⊗ ([[N ]] ⊕ [[U ]] ⊗ [[c ′ ]] ⊗ [[J]]) ⋆ ⊗ [[U ]] ⊗ [[c ′ ]] = [[c ′ ]] ⊕ [[c ′ ⊗ J]] ⊗ [[N ⊕ U ⊗ c ′ ⊗ J]] ⋆ ⊗ [[U ⊗ c ′ ]] = [[A ⋆ ]]
This closes the proof of Theorem 4.9.

Pebble Weighted Automata

We considered weighted automata navigating over graphs as a way to parse weighted expressions. Could it be possible to translate the full set of hybrid weighted expressions into weighted automata? Consider as an example the hybrid weighted expression

E = x! 2(2→) ⋆ → ⋆ x! 2(2→) ⋆
over the set D = {→, ←} of directions and the continuous semiring (N ∪ {+∞}, +, ×, 0, 1). Over a graph G ∈ Word(A) representing a finite word of length n, it computes the weight [[E]](G) = 2 n 2 . Indeed, the expression successively marks every vertex of G with the variable x, and then computes the subexpression 2(2→) ⋆ over G, that computes 2 n . We now show that such a function cannot be generated by a weighted automaton.

Theorem 4.18. Let D = {→, ←} and A an alphabet. There exists no weighted automaton

A ∈ WA over the semiring (N ∪ {+∞}, +, ×, 0, 1) such that for every graph G ∈ Word(A),

[[A]](G) = 2 |V | 2 .
Proof. We suppose that there exists a weighted automaton A ∈ WA such that for every pointed graph G ∈ Word(A),

[[A]](G) = 2 n 2 if G has n vertices.
In particular, the semantics of every graph representing a word is finite. This implies that every accepting run visits only distinct configurations. Indeed, if there exists an accepting run over G (having n vertices indexed from 0 to n -1), visiting two occurrences of the same configuration, it is of the form (G, q 0 , 0)

❀ * (G, q, i) ❀ + (G, q, i) ❀ * (G, q f , n -1) with I q0 × s 1 × s 2 × s 3 × F q f = 0,
where s 1 is the weight of the subrun from (G, q 0 , 0) to (G, q, i), s 2 the weight of the loop over (G, q, i) and s 3 the weight from (G, q, i) to (G, q f , n -1). Then, we may build a run of weight I q0 × s 1 × s k 2 × s 3 × F q f over the same word, for every k ≥ 0, by iterating the loop over configuration (G, q, i). Notice that s 2 is a positive integer, hence, s 2 ≥ 1. Finally, we obtain

[[A]](G) ≥ ∞ k=0 I q0 × s 1 × s 2 × s 3 × F q f = I q0 × s 1 × ∞ k=0 s 2 × s 3 × F q f = +∞ which violates the fact that [[A]](G) must be finite.
Therefore, we have proved that every accepting run over a graph G must visit at most once every configuration, and hence has a length bounded by |Q| × n. Denoting by M the greatest weight appearing in the description of the automaton A, we obtain that the weight of a run must be bounded by M |Q|×n+2 . Moreover, a run is uniquely defined by the sequence of states it visits and of directions (→ or ←) it follows: hence the number of runs (that do not visit twice a configuration) is bounded by (2|Q|) |Q|×n . In total, we obtain that

[[A]](G) ≤ (2M |Q|) |Q|×n+2 = o(2 n 2 ) Hence, for n large enough, [[A]](G) < 2 n 2 ,
which proves that A cannot recognize the series mentioned above.

As we way to overcome this limitation, we now decribe how to add pebbles to weighted automata: a pebble is a device used to mark temporarily a vertex with a variable. It mimicks in a more operational way the operator x!-of the hybrid weighted expressions. After giving the extended syntax and semantics, we will consider in details what is the difference between pebble weighted automata and hybrid weighted expressions. However, we will still be able to prove some Kleene-Schützenberger theorem relating HWE and layered pebble weighted automata.

Extended Syntax and Semantics

Pebbles have names taken from the infinite set Var of variables introduced in Chapter 3. A = (Q,A,D,I,∆,F ) where

Definition 4.19. A pebble weighted automaton over a semiring S is a tuple

• Q is a finite set of states; • A is a finite alphabet; • D is a finite set of directions; • I ∈ S Q is the vector of initial weights; • ∆ ∈ S Test(A, D, Var)
Actions Q×Q is the weighted transition matrix, where Actions = D ∪ {drop x | x ∈ Var} ∪ {lift} is the set of available actions; • F ∈ S Test(A, D, Var) Q is the final vector: each state q is mapped to a polynomial F q of tests. The class of all pebble weighted automata over S is denoted by PWA(S) or PWA if the semiring is clear from the context, or not relevant.

Note that we add the ability for the weighted automata to drop a pebble of name x with the action drop x and to later lift a pebble with the action lift. Pebbles are recorded in a last-in-first-out fashion, i.e., they are handled by a stack. This is the reason why lift actions are not labeled with the name of the pebble on which they will be applied: this is not a part of the choice of the automaton. In this manuscript, we will only consider stacks of bounded size, i.e., we will limit a priori the number of pebbles possibly dropped during an execution of the automaton.

Moreover, variables are reusable: this means that we have an unbounded supply of pebbles each marked by a pebble name in Var. More than one pebble with name x can be placed during the run, but only the last dropped is visible. However, when the latter will be lifted, the previous occurrence of pebble x will become visible again. Notice that our notion of reusability is slightly different from the notion of invisibility introduced in [START_REF] Engelfriet | XML Transformation by Tree-Walking Transducers with Invisible Pebbles[END_REF], where only the last dropped pebbles are visible, even if several of them have the same pebble name.

Let K ≥ 0 be an integer bound. Configurations are enriched with the stack of pebbles currently dropped: a K-configuration of a pebble weighted automaton A = (Q, A, D, I, ∆, F ) is a tuple (G, σ, q, π, v) composed of a pointed graph G ∈ G(A, D), a valuation σ : Var ⇀ V , a state q of Q, a stack of length at most K containing pairs of variables and vertices, π ∈ (Var × V ) k with k ≤ K (by convention, the top of the stack will be placed on the right of the word π), and a vertex v of V . A configuration is a K-configuration for some K. Reusability of variables means that a pebble name may occur at several places in π, but only its topmost occurrence is visible. Having this in mind, we associate to every stack π and valuation σ, an enriched valuation σ π : Var ⇀ V by σ ε = σ, and

σ π(x,v) = σ π [x → v].
Any two K-configurations with such a fixed graph G and fixed valuation σ give rise to a concrete transition (G, σ, q, π, v) ❀ (G, σ, q ′ , π ′ , v ′ ). Its weight is then defined by

                   d∈D | (v,v ′ )∈E d α∈Test | G,σπ,v|=α ∆ q,q ′ (d)(α) if π = π ′ α∈Test | G,σπ,v|=α ∆ q,q ′ (drop x )(α) if v ′ = v (i) , and π ′ = π(x, v) α∈Test | G,σπ,v|=α ∆ q,q ′ (lift)(α) if v = v (f )
, and π = π ′ (y, v ′ ) for some y ∈ Var Remark 4.20. In this definition, we suppose that the valuation σ π has a domain that contains the free variables in all the tests α that appear. We will come back later on this point.

Notice that the first case, dealing with actions being a direction of D, is a straightforward extension of the semantics of weighted automata given in (4.1): we simply ensure that the stack of pebbles is not changed during such a concrete transition. The second case, dealing with drop transitions, set the next vertex to be the initial vertex v (i) of the graph, enriching the stack of pebbles with the pair (x, v) composed of the name of the dropped pebble and the vertex v where it is dropped. Notice that this transition is enabled only if π ′ has size bounded by K, i.e., if less than K pebbles have been dropped so far. The third case, dealing with lift transitions, assumes that the current vertex is the final vertex v (f ) of the graph, pops the top of the stack (that therefore should be non-empty), and moves to the vertex v ′ where the last dropped pebble was. Remark 4.21. It might seem awkward to enforce the condition on the initial and final vertices in the two last cases of this definition: we will indeed use these conditions to simplify a little some proofs later on. Indeed, another natural choice would have been to let the automaton stay on its current vertex when a pebble is dropped, and assume that it is on the vertex holding the last dropped pebble to let it lift this pebble. In principle, this other choice would have led to an automaton model generating the same behaviors. This is the case if the class of graphs in which automata navigate permit to deterministically move to the initial vertex, to the final vertex or to any vertex marked with a visible pebble: words, ranked trees, nested words and pictures have clearly this property for example. Another possibility could be to relax the property only for one of these two actions. For example, it is possible to let lift transitions happen everywhere in the graph by simply erasing the condition v = v (f ) in the third case. Again, for the previously cited classes of graphs, this would not have changed the behaviors since it is possible to deterministically move to the final vertex and perform only lift transitions on v (f ) . In the following, we henceforth may use the possibility to lift pebbles anywhere without harm. However, notice that in every case, a lift transition must lead the automaton in the vertex where the lifted pebble was: if this is not the case, pebbles are called strong in the literature, whereas our pebbles are called weak, as detailed, e.g., in [START_REF] Bojańczyk | Expressive Power of Pebble Automata[END_REF]. Even though strong pebbles are showed to have the same expressive power as weak pebbles in the Boolean setting (see [START_REF] Bojańczyk | Expressive Power of Pebble Automata[END_REF]), we do not know if this is the case in our weighted setting, hence we leave the investigation of strong pebbles for future work.

A K-run is a sequence of K-configurations related successively by concrete transitions. Its weight is the product of transition weights, multiplied from left to right. A run is a K-run for some K. We are interested in runs that start at some vertex v, in state q with empty stack, and end in some configuration with vertex v ′ , in state q ′ with empty stack. Therefore, we let [[A q,q ′ ]] K (G, σ, v, v ′ ) be the sum of the weights of all K-runs leading from configuration (G, σ, q, ε, v) to configuration (G, σ, q ′ , ε, v ′ ). If we consider a continuous semiring, this a priori infinite sum is again well-defined.

Before defining the semantics of pebble weighted automata, we must first extend the notion of free variables to pebble weighted automata. It is not as simple as in the case of weighted automata, since new pebbles can be dropped making the set of variables currently allocated in the valuation σ π dynamic. Hence, we let Free(A) be the (finite) set of variables that must be in the domain of a valuation σ such that at least one run starting in a configuration (G, σ, q, ε, v) requires this variable to be in the domain of σ π to define the weight of one of its concrete transitions. We also let Var(A) be the whole set of variables appearing in the transition matrix and the final vector of A (either in tests x? or in drop transitions drop x ).

Finally, the semantics of the pebble weighted automaton A maps every pointed graph G and valuation σ with domain containing the free variables of A to an element of the continuous semiring S by including the initial and final weights, letting

[[A]] K (G, σ) = q,q ′ ∈Q I q ⊗ [[A q,q ′ ]] K (G, σ, v (i) , v (f ) ) ⊗ α∈Test | G,σ,v (f ) |=α F q ′ (α) .
Remark 4.22. As we did for weighted automata in Remark 4.6, we may introduce the same notions of initial state, final state and accepting run in pebble weighted automata. In particular, an accepting run starts and ends with an empty stack of pebbles.

Example 4.23. Notice first that every weighted automaton of WA is also a pebble weighted automaton in PWA, and that in this case, the definition of free variables coincide. Moreover, pebbles permit to design automata in a compositional way. For example, consider the weighted automaton of Figure 4.2 mapping each word w represented by a graph G ∈ Word(A) to 2(|w| a + 1). Then, it is really easy to design a pebble weighted automaton mapping the same graph to 2(|w| a + 1) |w| b . The idea is to drop a pebble (of name x in the following) on every vertex of the graph labeled by b, and simply execute the weighted automaton of Figure 4.2 each time a pebble is dropped, lifting the pebble at the end of its computation. The pebble weighted automaton obtained is depicted in Figure 4. 9. Notice that if we allow lift transitions to happen anywhere in the graph as suggested in Remark 4.21, then we should change the label of the transition from state 2 to state 3 to (2 final?)lift. As another example of pebble weighted automaton, consider the formal power series over pictures mapping each picture to the area of the biggest monochromatic rectangle it contains, in semiring (N∪{-∞}, max, +, -∞, 0). We show that we can generate it using a pebble weighted automaton A. We consider A = [0 .

. 255] to be the alphabet of gray levels, and D = {→, ←, ↓, ↑} as set of directions. Automaton A uses two variables x and y in order to mark the upper-left and lower-right corners of a rectangle in the picture. At first, A chooses non-deterministically a position to drop x and then a position to drop y.

The color c of the position hosting pebble x is put in the memory of the automaton. Then, starting from this position, the automaton scans each position of the rectangle checking that it has the gray level c, and computing 1 for each such position: to do so, the automaton can for example drop a pebble of name z on this position, in order to check that (i) it is below and on the right of x, (ii) above and on the left of y, and (iii) finally come back to this position to continue the computation. We denote by A c the sub-automaton having two free variables x and y (and a further variable z which is not free) that checks whether the area limited by positions marked by variables x and y is a monochromatic rectangle of color c, and computing its area. Then automaton A is depicted in Figure 4.10: notice that this is typically a case where lift transitions are not necessarily performed on the final vertex, but as explained in Remark 4.21, this is not a problem in the case of pictures. Each accepting run -a run having a weight different from -∞ in this case -computes the area of a monochromatic rectangle, by summing (again addition is the product of the semiring) 1 for every position inside this rectangle. The non-determinism is resolved by taking the maximum of the weights of all the accepting runs, which proves that A computes the area of Layer 2:

Layer 1:

Layer 0: the biggest monochromatic rectangle. Notice that there are several accepting runs that check the same rectangle -since in the initial state, we allow the automaton to follow any sequence of → and ↓ actions for example -but this is not an issue here as the semiring is idempotent, in the sense that the maximum verifies max(s, s) = s for every s ∈ N ∪ {-∞}.

→ ← ← → → ← → ← → ← → ← → → → ← ← ← lift drop x drop y lift lift drop x drop z lift

Layered Pebble Weighted Automata

The bound K on the length of the stack can be seen as a semantical restriction, and it is natural to transform it into a syntactical restriction. Hence, we consider the natural subclass of pebble weighted automata that store in their state an information about the height of the current stack of pebbles. 4.12 depicts a 1-layered PWA with mapping ℓ given by: ℓ(0) = ℓ(1) = 1 and ℓ(2) = 0.

Definition 4.25. A PWA

A = (Q, A, D, I, ∆, F ) is K-layered if there is a mapping ℓ : Q → [0 .. K] satisfying, for all q, q ′ ∈ Q, • if I q = 0 or F q = 0 then ℓ(q) = K; • if there is α ∈ Test and d ∈ D such that ∆ q,q ′ (d)(α) = 0 then ℓ(q) = ℓ(q ′ ); • if there is α ∈ Test such that ∆ q,q ′ (lift)(α) = 0 then ℓ(q ′ ) = ℓ(q) + 1; • if there is α ∈ Test and x ∈ Var such that ∆ q,q ′ (drop x )(α) = 0 then ℓ(q ′ ) = ℓ(q) -1. A layered PWA is a K-layered PWA for some K.
We naturally obtain the following lemma relating pebble weighted automaton and layered ones.

Lemma 4.26. For every K-layered pebble weighted automaton

A, [[A]] K (G, σ) = [[A]] K ′ (G, σ)
for every K ′ > K, every pointed graph G and every valuation σ.

Proof. We only have to notice that every configuration appearing in an accepting run of A is necessarily a K-configuration. Hence, allowing more configurations do not add any accepting runs.

Hence, for a K-layered pebble weighted automaton, we let

[[A]](G, σ) to be [[A]] K (G, σ).
The next lemma explains why the K-layered restriction is a syntactical equivalent to the semantical restriction over the stack. Lemma 4.27. For every pebble weighted automaton A and for every K ≥ 0, there exists a K-layered pebble weighted automaton A K such that for every pointed graph G and every valuation σ:

[[A]] K (G, σ) = [[A K ]](G, σ).
Proof. We simply extend the state space of A to contain the layer information.

If A = (Q, A, D, I, ∆, F ), we let A K = (Q × [0 .. K], A, D, I ′ , ∆ ′ , F ′ ) with
• I ′ (q,K) = I q and I ′ (q,k) = 0 for every state q ∈ Q, and k < K;

• ∆ ′ (q,k),(q ′ ,k) (d)(α) = ∆ q,q ′ (d)(α) for every k ∈ [0 .. K], α ∈ Test, d ∈ D, and q, q ′ ∈ Q; • ∆ ′ (q,k),(q ′ ,k-1) (drop x )(α) = ∆ q,q ′ (drop x )(α) for every k ∈ [1 .. K], α ∈ Test, x ∈ Var, and q, q ′ ∈ Q; • ∆ ′ (q,k),(q ′ ,k+1) (lift)(α) = ∆ q,q ′ (lift)(α) for every k ∈ [0 .. K -1]
, α ∈ Test, and q, q ′ ∈ Q; • all other transition weight in ∆ ′ is set to 0; • F ′ (q,K) = F q and F ′ (q,k) = 0 for every state q ∈ Q, and k < K. By mapping a state (q, k) to layer ℓ((q, k)) = k, we can verify that

A K is K-layered. Hence, [[A K ]](G, σ) = [[A K ]] K (G, σ)
for every pointed graph G and every valuation σ. Moreover, by forgetting about the second component of states in A K , we can prove that K-runs of A over (G, σ) are in bijection with K-runs of A K over (G, σ), and this bijection preserves the weight of these runs. This shows that [

[A]] K (G, σ) = [[A K ]] K (G, σ), which concludes the proof.
Henceforth, to study its semantics [[-]] K , we can always suppose that a pebble weighted automaton is K-layered.

Another stronger restriction will be useful in the following. It consists of associating every layer of an automaton to a given variable: every drop transition appearing in this layer must then uses this special variable. We call such an automaton strongly layered.

Definition 4.28. A PWA

A = (Q, A, D, I, ∆, F ) is K-strongly layered if it is K-layered (with
mapping ℓ as defined previously) and if there exists a mapping P ℓ : [1 .. K] → Var such that for every states q, q ′ ∈ Q, if ∆ q,q ′ (drop x )(α) = 0 then x = P ℓ (ℓ(q)). A strongly layered PWA is a K-strongly layered PWA for some K.

Every 0-layered PWA is trivially 0-strongly layered. Moreover, if the set of variables appearing in drop transitions of a K-layered automaton is reduced to a singleton {x}, then this automaton is strongly layered.

Interestingly, we may now define in another way the notion of free variables of a strongly layered automaton as we know exactly the sequence of pebbles that may be dropped. Indeed, x ∈ Var is a free variable if it appears in a test from a transition starting in layer k such that x is not one of the pebbles dropped in upper layers, i.e., x / ∈ {P ℓ (j) | j > k}. Notice that this gives an algorithm to compute the set Free(A) of free variables of a strongly layered automaton.

Finally, notice that, at the price of extending the state space of an automaton, every series recognized by a K-layered PWA can also be recognized by a K-strongly layered PWA. Proposition 4.29. For every K-layered PWA A, we can construct an equivalent K-strongly layered PWA A ′ . Proof. Let A = (Q, A, D, I, ∆, F ) be a K-layered PWA, and ℓ be the mapping describing its layers as introduced in Definition 4.25. Let {z 1 , . . . , z K } be a fresh set of K pebble names. We construct a K-strongly layered PWA A ′ = ( 0≤k≤K ℓ -1 (k)×Var(A) K-k , A, D, I ′ , ∆ ′ , F ′ ) equivalent to A: the second component of the states records the sequence of pebble names of A that are supposed to be dropped, even though automaton A ′ simulates it by dropping some fresh pebble names. For initial and final weights, we simply set I ′ (q,ε) = I q and F ′ (q,ε) = F q if ℓ(q) = K and I (q,θ) = F (q,θ) = 0 if ℓ(q) < K. For the transitions, we first explain how to transform tests formulae: for every test formula α and every sequence θ = θ K • • • θ k+1 ∈ Var K-k , we let α θ be the test formula defined by replacing in α every basic test x?, for x = θ i for some i by the basic test z j ?, with j the smallest i such that x = θ i (this choice of j permits to conform with the reusability of pebble names). Then, we define the new weighted transition matrix with:

∆ ′ (q,θ),(q ′ ,θ ′ ) (d)(α θ ) = ∆ q,q ′ (d)(α) if θ ′ = θ 0 otherwise ∆ ′ (q,θ),(q ′ ,θ ′ ) (drop z )(α θ ) = ∆ q,q ′ (drop x )(α) if θ ′ = θ • x and z = z ℓ(q) 0 otherwise ∆ ′ (q,θ),(q ′ ,θ ′ ) (lift)(α θ ) = ∆ q,q ′ (lift)(α) if θ = θ ′ • y for some y ∈ Var 0 otherwise.
where d ∈ D, x ∈ Var. Clearly, by letting ℓ(q, θ) = ℓ(q), automaton

A ′ is K-layered.
Moreover, it is easy to check that A ′ is even K-strongly layered as only pebble name z k may be dropped in layer k. To prove that A and A ′ are equivalent, we construct a bijection f between configurations. This bijection transforms each configuration (G, σ, (q, θ), π, v)

appearing in a run of A ′ , with θ = θ K • • • θ K-k , into configuration (G, σ, q, π θ , v) of A
where π θ is built in the following way: every pair (z i , v i ) appearing in π is replaced by the pair (θ i , v i ). We extend the function f to runs. By distinguishing cases where the action is a direction, a drop or a lift, we may verify that this mapping transforms a run of A ′ into a run of A having the same weight. Moreover, this function is a bijection as it preserves the length of the runs and is a bijection when restricted to the configurations. Hence, this proves that

[[A]](G, σ) = [[A ′ ]](G, σ)
for every pointed graph G and valuation σ.

Dynamically Marked Graphs

In order to relate hybrid weighted expressions and pebble weighted automata, we need to further study the semantics of our automaton model. Looking for a more algebraic definition of the semantics similar to what we studied for weighted automata (without pebbles), we will define dynamically marked graphs, as an extension of marked graphs in which the content of the stack of pebbles will be encoded, as it can now change along the computation of a pebble weighted automaton.

A dynamically marked graph is of the form (G, σ, π, v, π ′ , v ′ ) where G ∈ G(A, D) is a pointed graph, σ : Var ⇀ V is a partial mapping encoding a valuation of pebbles, v, v ′ ∈ V are vertices, and π, π ′ ∈ (Var × V ) ⋆ are stacks of pebbles. Let DMG(A, D, Var) (or shortly DMG if the parameters are implicit) be the set of all dynamically marked graphs. The partial product defined over marked graphs may be extended over dynamically marked graph by defining

(G 1 , σ 1 , π 1 , v 1 , π ′ 1 , v ′ 1 ) • (G 2 , σ 2 , π 2 , v 2 , π ′ 2 , v ′ 2 ) = (G 1 , σ 1 , π 1 , v 1 , π ′ 2 , v ′ 2 ) in the case where G 1 = G 2 , σ 1 = σ 2 , π ′ 1 = π 2 and v ′ 1 = v 2 ,
this product being not defined in all other cases. By letting

DU(A, D, Var) = {(G, σ, π, v, π ′ , v ′ ) ∈ DMG(A, D, Var) | π = π ′ , v = v ′ }
be the set of dynamically partial units, we obtain the following algebraic structures, by simply extending the results from the non-dynamic case.

The Full Kleene-Schützenberger Theorem

We will now prove our completed Kleene-Schützenberger Theorem.

Theorem 4.31. Let S be a continuous semiring. 1. For each hybrid weighted expression E ∈ HWE(S), we can construct a layered pebble weighted automaton

A E ∈ PWA(S) with Free(A E ) = Free(E) equivalent to E, i.e., [[E]](G, σ) = [[A E ]](G, σ)
for every pointed graph G and every valuation σ with domain containing Free(E).

For each layered pebble weighted automaton A ∈ PWA(S), we can construct a hybrid weighted expression

E A ∈ HWE(S) with Free(E A ) = Free(A), equivalent to A, i.e., [[A]](G, σ) = [[E A ]](G, σ)
for every pointed graph G and every valuation σ with domain containing Free(A).

From Pebble Weighted Automata to Hybrid Weighted Expressions

As for the case without pebble, we will start with the proof of the second item. For that, we will need to introduce generalized pebble weighted automata, using a new sort of expressions over their transitions: these will not be hybrid weighted expressions, but pebble weighted expressions, able to perform decoupled drop and lift moves, contrary to the x!-operator of HWE.

Definition 4.32. We let PWE(S, A, D, Var) (or shortly PWE) be the set of pebble weighted expressions defined by the following grammar:

E ::= s | α | d | drop x | lift | E + E | E • E | E + where s ∈ S, α ∈ Test(A, D, Var), d ∈ D and x ∈ Var.
The semantics of these pebble weighted expressions is directly defined algebraically as a series over dynamically marked graphs. Indeed, we denote {|E| } the series of the continuous semiring S DMG(A, D, Var) inductively defined in Table 4. 1. We can now define generalized pebble weighted automata, as weighted automata with pebble weighted expressions over their transitions.

Definition 4.33. A generalized pebble weighted automaton is a tuple

A = (Q, A, D, I, ∆, F ) where • Q is a finite set of states; • A is a finite alphabet; • D is a finite set of directions; • I ∈ S Q is the initial vector; • ∆ ∈ PWE(S, A, D, Var) Q×Q is the transition matrix; • F ∈ S Test(A, D, Var) Q is the final vector.
The class of all generalized pebble weighted automata over S is denoted by gPWA(S) or gPWA if the semiring is clear from the context, or not relevant.

{|s| } = s1 DU {|α| } = 1 {(G,σ,π,v,π,v)∈DU|G,σπ,v|=α} {|d| } = 1 {(G,σ,π,v,π,v ′ )∈DMG|e=(v,v ′ )∈E∧d∈χ(e)} {|drop x | } = 1 {(G,σ,π,v,π(x,v),v (i) )∈DMG} {|lift| } = 1 {(G,σ,π ′ (y,v ′ ),v (f ) ,π ′ ,v ′ )∈DMG|y∈Var} {|E 1 + E 2 | } = {|E 1 | } ⊕ {|E 2 | } {|E 1 • E 2 | } = {|E 1 | } ⊗ {|E 2 | } {|E + | } = {|E| } +
The semantics is given by a variation of the semantics of PWA: now, the weight of a concrete transition (G, σ, q, π, v) ❀ (G, σ, q ′ , π ′ , v ′ ) (with fixed graph and valuation) is defined by

{|∆ q,q ′ | }(G, σ, π, v, π ′ , v ′ ).
Then, for a dynamically marked graph (G, σ, π, v, π ′ , v ′ ) ∈ DMG, we define

{|A q,q ′ | }(G, σ, π, v, π ′ , v ′ )
as the sum of weights of the runs from configuration (G, σ, q, π, v) to configuration (G, σ, q ′ , π ′ , v ′ ).

As for the case without pebbles, we can define the semantic matrix {|∆| } whose (q, q ′ )coefficient is given by {|∆ q,q ′ | } ∈ S DMG . Copying, mutatis mutandis, the proofs of Propositions 4.12 and 4.13 we obtain the following proposition. For all q, q ′ ∈ Q, the two series {|A q,q ′ | } and ({|∆| } ⋆ ) q,q ′ are equal. Moreover, we can construct a matrix Φ(∆) ∈ PWE Q×Q (whose entries are in the rational closure of the entries of ∆) satisfying the following matrix equality:

{|Φ(∆)| } = {|∆| } ⋆ .
In particular, the semantics of a generalized pebble weighted automaton verifies: (G,σ,v,v ′ ) with the dynamically marked graph (G, σ, ε, v, ε, v ′ ). Also, any pebble weighted automaton A = (Q, A, D, I, ∆, F ) can be considered as generalized pebble weighted automaton and the semantics over marked graphs coincide:

{|A| } = {|I| } ⊗ {|∆| } ⋆ ⊗ {|F | } = {|I| } ⊗ {|Φ(∆)| } ⊗ {|F | }.
[[A q,q ′ ]](G, σ, v, v ′ ) = {|A q,q ′ | }(G, σ, ε, v, ε, v ′ )
. This is in particular the case as we enforced the drop and lift actions to respectively reset the automaton to the initial vertex and to happen on the final vertex of the graph, which is coherent with the semantics of generalized pebble weighted automata.

By applying this remark, Proposition 4.34 constructs a pebble weighted expression equivalent over marked graphs to a pebble weighted automaton A. But our aim is to construct a hybrid weighted expression which is equivalent to A. This is achieved below using as a tool the detour via pebble weighted expressions.

First, we show that HWE can be seen as a fragment of PWE if we interpret x!E as a macro for drop x • E • lift. Indeed with this interpretation, the semantics coincide:

Lemma 4.36. Let E ∈ HWE and let (G, σ, π, v, π ′ , v ′ ) ∈ DMG. Then, {|E| }(G, σ, π, v, π ′ , v ′ ) = 0 implies π ′ = π . Moreover, if π ′ = π, we have {|E| }(G, σ, π, v, π, v ′ ) = [[E]](G, σ π , v, v ′ ) .
Proof. We proceed by structural induction on HWE. For atoms of HWE, the result is clear from the definition of {| -| }. For sum, concatenation and star, the result is trivial since both semantics are compositional. The interesting case is x!E which is interpreted as drop x •E •lift in PWE. By definition of {| -| } and the Cauchy product in S DMG we have

{|drop x • E • lift| }(G, σ, π, v, π ′ , v ′ ) = y∈Var(E) {|E| }(G, σ, π(x, v), v (i) , π ′ (y, v ′ ), v (f ) ) .
Since E ∈ HWE, we obtain by induction that each term of the sum above equals 0 if

π(x, v) = π ′ (y, v ′ ). Hence, {|drop x • E • lift| }(G, σ, π, v, π ′ , v ′ ) = 0 implies π ′ = π. Moreover, in that case, either v ′ = v and {|drop x • E • lift| }(G, σ, π, v, π ′ , v ′ ) = 0 = [[x!E]](G, σ π , v, v ′ ) , or v ′ = v and {|drop x • E • lift| }(G, σ, π, v, π ′ , v ′ ) = {|E| }(G, σ, π(x, v), v (i) , π ′ (x, v ′ ), v (f ) ) = [[E]](G, σ π(x,v) , v (i) , v (f ) ) = [[x!E]](G, σ π , v, v)
where the second equality holds by induction and the third one follows from the definition of σ π(x,v) .

Hence, HWE can be seen as a fragment of PWE, and, in Proposition 4.34, if ∆ is a matrix of hybrid weighted expressions, then, Φ(∆) is in the rational closure of the entries of ∆, hence is also a matrix of hybrid weighted expressions. However, if we start with A being a layered pebble weighted automaton, ∆ is not a matrix of hybrid weighted expressions, hence we must refine this proof to cope with this more specific setting.

We first start by extending the definition of layered pebble weighted automata to generalized pebble weighted automata. Again, the idea is to decompose the state space into layers: the transition matrix relates states of the same layer with expressions in HWE, states of a layer with states of the lower level (respectively, upper level) with pebble weighted expressions involving drop x (respectively, lift).

Definition 4.37. A generalized pebble weighted automaton

A = (Q, A, D, I, ∆, F ) is K- layered if there is a mapping ℓ : Q → [0 .. K] satisfying, for all q, q ′ ∈ Q,
• if I q = 0 or F q = 0 then ℓ(q) = K;

• transitions may only relate neighbor layers, i.e., if the expression ∆ q,q ′ is not equal to 0 then |ℓ(q)ℓ(q ′ )| ≤ 1;

• if ℓ(q) = ℓ(q ′ ), then ∆ q,q ′ ∈ HWE; • if ℓ(q ′ ) = ℓ(q) -1, then the pebble weighted expression ∆ q,q ′ is of the form x∈Var(A) δ x q,q ′ • drop x
with δ x q,q ′ ∈ S Test ;

• if ℓ(q ′ ) = ℓ(q) + 1, then the pebble weighted expression ∆ q,q ′ is of the form λ q,q ′ • lift with λ q,q ′ ∈ S Test . A layered generalized pebble weighted automaton is a K-layered generalized pebble weighted automaton for some K.

Notice that a K-layered pebble weighted automaton can be seen as a K-layered generalized pebble weighted automaton very easily. We now extend Proposition 4.13 to any K-layered generalized pebble weighted automaton. Proposition 4.38. Let A = (Q, A, D, I, ∆, F ) be a 1-layered generalized pebble weighted automaton. We can construct a 0-layered generalized pebble weighted automaton A (1) = (ℓ -1 (1), A, D, I (1) , ∆ (1) , F (1) ) which is equivalent to A, i.e., such that the two series {|A q,q ′ | } and {|A

(1) q,q ′ | } are equal for all q, q ′ ∈ ℓ -1 (1). By ordering the states of Q by layer, first states of layer 1 and then states of layer 0, we obtain as a block decomposition

∆ = N D L P
with N a square matrix indexed by states of layer 1, and P a square matrix indexed by states of layer 0.

Let q 1 , q ′ 1 ∈ ℓ -1 (1) be in layer 1 and q 0 , q ′ 0 ∈ ℓ -1 (0) be in layer 0. Then, D is a ℓ -1 (1) × ℓ -1 (0) drop-matrix whose (q 1 , q 0 )-entry can be written

x∈Var(A) δ x q1,q0 • drop x
with δ x q1,q0 ∈ S Test . The (q ′ 0 , q ′ 1 )-entry of the ℓ -1 (0) × ℓ -1 (1) lift-matrix L can similarly be written λ q ′ 0 ,q ′ 1 • lift with λ q ′ 0 ,q ′ 1 ∈ S Test . Now, P is a ℓ -1 (0) × ℓ -1 (0) matrix of hybrid weighted expressions in HWE and we may apply Proposition 4.34 in order to get a matrix Φ(P ) of hybrid weighted expressions which is equivalent to the iteration of P : {|Φ(P )| } = {|P | } ⋆ which also implies [[Φ(P )]] = [[P ]] ⋆ as P and Φ(P ) only contains hybrid weighted expressions (by using Lemma 4.36). From (D, P, L), we define the ℓ -1 (1) × ℓ -1 (1) matrix N ′ with coefficients in HWE by

N ′ q1,q ′ 1 = q0,q ′ 0 ∈ℓ -1 (0) x∈Var δ x q1,q0 • x! Φ(P ) q0,q ′ 0 • λ q ′ 0 ,q ′ 1 . ( 4.3)
The matrix N ′ is also denoted C(D, P, L) below. Note that the maximal depth of the entries of N ′ is at most 1 plus the maximal depth of the entries of P since the construction Φ(P ) does not increase the depth of expressions. Proof. Recall that when viewing hybrid weighted expressions as pebble weighted expressions, expression x!E is interpreted as drop x • E • lift. This implies that the hybrid weighted expression

x! Φ(P ) q0,q ′ 0 • λ q ′ 0 ,q ′ 1 is equivalent to drop x • Φ(P ) q0,q ′ 0 • λ q ′ 0 ,q ′ 1 • lift. We deduce that {|N ′ q1,q ′ 1 | } = q0,q ′ 0 {|D q1,q0 | } ⊗ {|Φ(P ) q0,q ′ 0 | } × {|L q ′ 0 ,q ′ 1 | } .
Since {|Φ(P )| } = {|P | } ⋆ by Proposition 4.34, the result follows.

To conclude the proof of Proposition 4.38, we simply set ∆ (1) = N + N ′ . Now, for all q, q ′ ∈ ℓ -1 (1), we have {|A q,q ′ | } = ({|∆| } ⋆ ) q,q ′ by Proposition 4.34. Moreover, the upper- (1) | } * . Using again Proposition 4.34, we finally get for all q, q ′ ∈ ℓ -1 (1) that {|A (1) q,q ′ | } = ({|∆ (1) | } ⋆ ) q,q ′ = ({|∆| } ⋆ ) q,q ′ = {|A q,q ′ | }. Proposition 4.38 can then be generalized to an arbitrary number of layers. Proposition 4.40. Let A = (Q, A, D, I, ∆, F ) be a K-layered generalized pebble weighted automaton. We can construct a 0-layered generalized pebble weighted automaton A (K) = (ℓ -1 (K), A, D, I (K) , ∆ (K) , F (K) ) which is equivalent to A, i.e., such that the two series

left block of {|∆| } ⋆ is ({|N | } + {|D| } ⊗ {|P | } ⋆ ⊗ {|L| }) * which is, by Lemma 4.39, equal to ({|N | } + {|N ′ | }) ⋆ = {|∆
{|A q,q ′ | } and {|A (K) q,q ′ | } are equal for all q, q ′ ∈ ℓ -1 (K).
Proof. The proof is by induction on K. When K = 0 we simply set A (0) = A. For K > 0, we order the states of Q by layer as previously, in a decreasing order. We obtain as a block decomposition

∆ =         N (K) D (K) 0 . . . 0 L (K-1) N (K-1) D (K-1) . . . 0 0 L (K-2) . . . . . . 0 . . . 0 . . . N (1) D (1) 0 0 . . . L (0) N (0)        
with N (k) a square matrix indexed by states of layer k. We set

∆ (K) = N (K) + C(D (K) , ∆ (K-1) , L (K-1) )
where the matrix ∆ (K-1) is the transition matrix of the 0-layered generalized pebble weighted automaton obtained by induction, by considering only states of layers ≤ K -1. Correctness follows from Proposition 4.38.

Finally, consider a K-layered pebble weighted automaton A = (Q, A, D, I, ∆, F ). By using Remark 4.35, we may see A as a K-layered generalized pebble weighted automaton with

{|A q,q ′ | }(G, σ, ε, v, ε, v ′ ) = [[A q,q ′ ]](G, σ, v, v ′ ) .
Proposition 4.40 then produces a 0-layered generalized pebble weighted automaton A (K) verifying the series (of dynamically marked graphs) equality

{|A (K) q,q ′ | } = {|A q,q ′ | }
for every states q, q ′ of layer K. From Proposition 4.34, we deduce that the matrix H = Φ(∆ (K) ) satisfies the series equality

{|H q,q ′ | } = {|A q,q ′ | }
for all q, q ′ of layer K. Notice that the coefficients of the transition matrix ∆ (K) of A (K) (with 0 layers) are necessarily pebble weighted expressions of HWE. This is also the case of matrix H = Φ(∆ (K) ). Hence, by Lemma 4.36, and using notations of this lemma, we have

{|H q,q ′ | }(G, σ, π, v, π, v ′ ) = [[H q,q ′ ]](G, σ π , v, v ′ )
for all q, q ′ of layer K. Therefore, the pebble weighted expression E A obtained by considering the matrix product of row I (with coefficients in S), square matrix H and column F (with

A = ι c N J U A = 1 0    0 J 0 N      c U   Figure 4.13: A standard automaton A x!A = ι ′ ι drop x τ ′ c lift N J U lift x!A = 1 0 0 0        0 0 drop x 0 0 0 0 0 0 c lift 0 J 0 U lift 0 N               0 1 0 0        Figure 4.14: Automaton for x!- coefficients in S) verifies [[E A ]](G, σ) = q,q ′ ∈Q I q ⊗ [[H q,q ′ ]](G, σ, v (i) , v (f ) ) ⊗ F q ′ = q,q ′ ∈Q I q ⊗ [[A q,q ′ ]](G, σ, v (i) , v (f ) ) ⊗ F q ′ = [[A]](G, σ)
This ends the proof of item 2 of Theorem 4.31. Notice that the depth of E A is at most K if A is a K-layered pebble weighted automaton.

From Hybrid Weighted Expressions to Pebble Weighted Automata

We now give the proof of item 1 of Theorem

A E ∈ PWA such that [[A E ]] = [[E]], i.e., for all (G, σ, v, v ′ ) ∈ MG we have [[A E ]](G, σ, v, v ′ ) = [[E]](G, σ, v, v ′ ) .
The translation from weighted expressions to weighted automata has to be completed to deal with the new operator x!E. We give this construction now: it should drop the pebble on the current position, evaluate E from the initial to the final vertex of the pointed graph and finally lift the pebble. We start from a standard automaton A equivalent to E, as depicted in Figure 4. 13. From it, we construct the following standard automaton x!A, depicted in Figure 4.14. In the matrix representation, we have put first the states ι ′ and τ ′ of the topmost layer.

E = → + a?x! (¬x?→) ⋆ b?(¬x?→) + c?← + d?→ + → ⋆ .
The construction applied to E, using an automaton for the expression inside the x!-operator obtained similarly to the one of Example 4.17, gives the pebble weighted automaton depicted in Figure 4.15.

It remains to prove the correctness of the new construction for the x!-operation. Assume for simplicity that A is a 0-layered automaton, then A ′ = x!A is a 1-layered automaton. We write the corresponding block decomposition of the transition matrix of A ′ as ∆ ′ = 0 D L ∆ where ∆ is the transition matrix of A, D is the drop-matrix with only non-zero entry being D ι ′ ,ι = drop x , and L is the lift matrix with non-zero entries being c lift and in the column matrix U lift. By Lemma 2.7, the upper-left block of

{|∆ ′ | } ⋆ is {|D| } ⊗ {|∆| } ⋆ ⊗ {|L| }.
By Remark 4.35, we have

[[A ′ ]](G, σ, v, v ′ ) = ({|∆ ′ | } ⋆ ) ι ′ ,τ ′ (G, σ, ε, v, ε, v ′ ) = ({|D| } ⊗ {|∆| } ⋆ ⊗ {|L| }) ι ′ ,τ ′ (G, σ, ε, v, ε, v ′ ) = ({|C(D, ∆, L)| }) ι ′ ,τ ′ (G, σ, ε, v, ε, v ′ ) .
Let Q be the set of non-initial states of A. By definition of C(D, M, L) given in (4.3), we have

C(D, M, L) ι ′ ,τ ′ = x!c + q∈Q x! Φ(∆) ι,q • U q which is equivalent to expression x! c + q∈Q Φ(∆) ι,q • U q . Hence, [[A ′ ]](G, σ, v, v ′ ) is different from 0 only if v = v ′ , as for [[x!E]](G, σ, v, v ′ ).
In that case, we have

[[A ′ ]](G, σ, v, v) = [[c + q∈Q Φ(∆) ι,q • U q ]](G, σ[x → v], v (i) , v (f ) )
.

By induction hypothesis, we have [[

A]](G, σ[x → v], v (i) , v (f ) ) = [[E]](G, σ[x → v], v (i) , v (f ) ) which implies that [[x!E]](G, σ, v, v) = [[E]](G, σ[x → v], v (i) , v (f ) ) = {|A| }(G, σ[x → v], ε, v (i) , ε, v (f ) ) = {|I| } ⊗ {|∆| } ⋆ ⊗ {|F | } (G, σ[x → v], ε, v (i) , ε, v (f ) ) = {|I| } ⊗ {|Φ(∆)| } ⊗ {|F | } (G, σ[x → v], ε, v (i) , ε, v (f ) ) = {|c + q∈Q Φ(∆) ι,q • U q | }(G, σ[x → v], ε, v (i) , ε, v (f ) ) = [[c + q∈Q Φ(∆) ι,q • U q ]](G, σ[x → v], v (i) , v (f ) ) = [[A ′ ]](G, σ, v, v) .
This ends the proof of Theorem 4.31.

CHAPTER 5

Query Evaluation

The value of an idea lies in the using of it. This chapter is devoted to the evaluation of a quantitative property over a given graph. For example, we may consider a quantitative property of XML documents (e.g., the number of nodes verifying a given property) and try to evaluate this query over a fixed database. This is the simplest problem to consider. However, it is far from trivial considering the quantitative queries we introduced in Part 1. Indeed, the semantics of several of the specification formalisms we introduced involve infinite sums, and trivial attemps to compute their semantics -even inefficient -are not possible a priori. We choose an automata-based approach to solve this problem, i.e., we consider that the specification is given as a pebble weighted automaton. It is another problem to efficiently translate other formalisms in automata models, and this has been presented previously. Our goal is henceforth to design algorithms evaluating pebble weighted automata over given graphs.

The first section presents a first generic approach for general classes of graphs, with a reasonable complexity. It is based on the computation of stars of matrices. Next sections present specialized algorithms for words, trees and nested words with better complexities. Whereas for words and nested words, we use the underlying linear order to guide our evaluation algorithm, the case of trees is resolved by considering a bottom-up computation. The special case of words has been originally published in [2], whereas the case of nested words is presented in [4].

Generic Evaluation of Pebble Weighted Automata

Our procedure of evaluation consists in constructing the weighted graph of configurations and, for each layer successively, computing the weights of paths for all pairs of vertices. Before explaining this procedure and its complexity in detail, we present an algorithm for computing the weights of paths in a weighted graph.

Weights of Paths in Weighted Graphs

In this section, we consider weighted finite graphs whose edges are equipped with weights in a continuous semiring S. Every finite path of this graph has a weight, defined as the product of the weights of the edges it visits. For every pair of vertices of this graph, we may consider the set of paths leading from one to the other, and we associate to this pair the sum of the weights of these paths.

As an example of instantiation, consider the tropical semiring (N∪{+∞}, min, +, +∞, 0). Every pair of vertices of a weighted graph is now associated with the distance separating them. In this context, we may use the Floyd-Warshall algorithm [START_REF] Warshall | A Theorem on Boolean Matrices[END_REF][START_REF] Floyd | Algorithm 97: Shortest Path[END_REF] to compute this distance for all pairs of points. The time complexity of this algorithm is cubic in the number of vertices of the graph. Our method consists in generalizing this approach to graphs equipped with weights in a general continuous semiring.

The method is based on matrix computations. Indeed, consider the adjacency matrix M of the graph, namely the matrix indexed by V × V whose (v, v ′ )-coefficient is the weight of the edge from vertex v to vertex v ′ if it exists, and 0 (the zero of the semiring) otherwise. Then, for every integer n, the (v, v ′ )-coefficient of matrix M n is the sum of the weights of the paths from v to v ′ of length exactly n. Hence, the weight we are searching for is exactly computed by the star M ⋆ = n≥0 M n of matrix M . We show below that computing the star of a square matrix has the same complexity as computing the product of matrices, i.e., can be done with a cubic number of sum and products in the semiring, to which we must add a linear number of scalar star operations.

M ⋆ = (A ⊕ B ⊗ D ⋆ ⊗ C) ⋆ A ⋆ ⊗ B ⊗ (D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ D ⋆ ⊗ C ⊗ (A ⊕ B ⊗ D ⋆ ⊗ C) ⋆ (D ⊕ C ⊗ A ⋆ ⊗ B) ⋆
This is not a good decomposition to obtain the complexity announced: in particular, to compute M ⋆ it requires to precompute A ⋆ and (A ⊕ B ⊗ D ⋆ ⊗ C) ⋆ which are two stars of (n-1)×(n-1)-matrices, generating in total an exponential number of scalar star operations.

In contrast, we propose an a priori more complicated formula to compute the star of matrix M , which will ensure the stated complexity:

M ⋆ = A ′ A ′ ⊗ B ⊗ D ⋆ D ⋆ ⊗ C ⊗ A ′ D ⋆ ⊕ D ⋆ ⊗ C ⊗ A ′ ⊗ B ⊗ D ⋆ .
(5.1)

with

A ′ = (A ⊕ B ⊗ D ⋆ ⊗ C) ⋆ .
Indeed, it is only necessary to prove that the two right blocks are equal, i.e.,

A ⋆ ⊗ B ⊗ (D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ = A ′ ⊗ B ⊗ D ⋆ (D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ = D ⋆ ⊕ D ⋆ ⊗ C ⊗ A ′ ⊗ B ⊗ D ⋆
These identities are corollaries of the identities of Theorem 2. 4. First,

A ′ ⊗ B ⊗ D ⋆ = (A ⊕ B ⊗ D ⋆ ⊗ C) ⋆ ⊗ B ⊗ D ⋆ = A ⋆ ⊗ (B ⊗ D ⋆ ⊗ C ⊗ A ⋆ ) ⋆ ⊗ B ⊗ D ⋆ by identity (ii) = A ⋆ ⊗ B ⊗ D ⋆ ⊗ (C ⊗ A ⋆ ⊗ B ⊗ D ⋆ ) ⋆ by identity (i) = A ⋆ ⊗ B ⊗ (D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ by identity (ii)
which proves the first identity. Then,

(D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ = D ⋆ ⊗ (C ⊗ A ⋆ ⊗ B ⊗ D ⋆ ) ⋆ by identity (ii) = D ⋆ ⊕ D ⋆ ⊗ C ⊗ A ⋆ ⊗ B ⊗ D ⋆ ⊗ (C ⊗ A ⋆ ⊗ B ⊗ D ⋆ ) ⋆ by Proposition 2.2
By using again that

A ′ ⊗ B ⊗ D ⋆ = A ⋆ ⊗ B ⊗ D ⋆ ⊗ (C ⊗ A ⋆ ⊗ B ⊗ D ⋆ ) ⋆
we finally obtain

(D ⊕ C ⊗ A ⋆ ⊗ B) ⋆ = D ⋆ ⊕ D ⋆ ⊗ C ⊗ A ′ ⊗ B ⊗ D ⋆
which proves the second identity, and also concludes the proof of (5.1).

Then, computing the matrix 1) requires one scalar star operation, and a quadratic number of scalar sum and product operations. By induction, we can then compute its star, the matrix A ′ . Then, (5.1) allows us to compute M ⋆ with an additional quadratic number of scalar sum and product operations. The result follows by induction.

A ⊕ B ⊗ D ⋆ ⊗ C ∈ S (n-1)×(n-

Application to the Evaluation Problem

We fix in this section an alphabet A, a set of directions D and a continuous semiring S. Let A be a layered pebble weighted automaton, G be a pointed graph and σ be a valuation with domain containing the free variables of A. We now explain how to compute

[[A]](G, σ) = qi,q f ∈Q I qi ⊗ [[A qi,q f ]](G, σ, v (i) , v (f ) ) ⊗ α∈Test | G,σ,v (f ) |=α F q f (α) .
This is done by induction on the number of layers of the automaton A.

In case of 0 layers, we may consider the weighted graph of configurations of A over a fixed pair (G, σ): its adjacency matrix has size |Q| × |V |, and its ((q, v), (q

′ , v ′ ))-coefficient is 0 in case (v, v ′ ) /
∈ E, and otherwise is given by

d∈D | (v,v ′ )∈E d α∈Test | G,σ,v|=α ∆ q,q ′ (d)(α) .
Remark 5.2. We suppose in the following that the set of all these coefficients, with v, v ′ being fixed, is computable with O(|∆|) scalar sum operations, which highly depends on the actual implementation of automata. Supposing that for every states q, q ′ , direction d, there exists only a bounded number of tests α such that ∆ q,q ′ (d)(α) would for example permit to bound this computation time by O(|Q| 2 ), supposing that D is fixed.

Then, notice that [[A qi,q f ]](G, σ, v (i) , v (f )
) is exactly the sum of the weights of the paths from configuration (G, σ, q i , v (i) ) to configuration (G, σ, q f , v (f ) ) in this weighted graph. Hence, using Lemma 5.1, by computing the star of the adjacency matrix, and multiplying by the initial and final weights, we obtain the semantics [[A]](G, σ). In total, we have We now apply the same technique to a K-layered pebble weighted automaton. Proof. We apply recursively the method previously presented in the case of 0 layers. More precisely, we denote by A k the k-layered pebble weighted automaton obtained by removing from A all the states of layer K, . . . , k+1. We then compute

[[A k q,q ′ ]](G, σ ′ , v (i) , v (f )
) for every states q, q ′ ∈ ℓ -1 (k) and every valuation σ ′ compatible with σ and the layer k: this means that we only consider valuations

σ ′ = σ[x K → v K ] • • • [x k+1 → v k+1 ] with x K , . .

. , x k+1

variables that may be dropped in layers K, . . . , k + 1, respectively. Indeed, notice that the semantics

[[A k q,q ′ ]](G, σ ′ , v (i) , v (f )
) is exactly the sum of the weights of the runs of A from configuration (G, σ, q, π, v (i) ) to configuration (G, σ, q ′ , π, v (f ) ), with intermediary states in layers no more than k, when σ ′ = σ π .

For the base case, A 0 is a 0-layered pebble weighted automaton. By applying Lemma 5.1, we can compute the weights

[[A 0 q,q ′ ]](G, σ ′ , v (i) , v (f )
) for every states q, q ′ ∈ ℓ -1 (0) and every valuation σ ′ = σ π with π a stack of K dropped pebbles. As we consider reusable pebbles, the number of possible valuations σ ′ is at most |V | p . Hence, all these weights can be computed with

• O(|ℓ -1 (0)| × |V | × |V | p ) scalar star operations, • O(|ℓ -1 (0)| 3 × |V | 3 × |V | p
) scalar products, and

• O((|ℓ -1 (0)| 3 × |V | 3 + |∆ |ℓ -1 (0)×ℓ -1 (0) | × |V | 2 ) × |V | p ) scalar sums.
Then, by supposing that all the weights for layers 0, 1, . . . , k have been computed, the weights for layer k + 1 can be computed by the following procedure. For every valuation σ ′ compatible with layer k + 1, we consider the square matrix of length |ℓ -1 (k + 1)| × |V | with the weights of the transitions inside layer k + 1 updated by adding the weight

x∈Var(A) q ′ ∈ℓ -1 (k)     q∈ℓ -1 (k) α∈Test | G,σ ′ ,v|=α ∆ r,q (drop x )(α) ⊗ [[A k q,q ′ ]](G, σ ′ [x → v], v (i) , v (f ) )     ⊗ α ′ ∈Test | G,σ ′ [x →v],v (f ) |=α ′ ∆ q ′ ,r ′ (lift)(α ′ )
in the coefficient ((r, v), (r ′ , v)). This update of the matrix can be done with some extra scalar sums and products in S: indeed, the element in the brackets requires in total a number of sums and products bounded by Afterwards, computing the star of the matrix permits to meet the requirement. For all valuations, the computation for layer k + 1 therefore requires

O(|ℓ -1 (k)| × |∆ |ℓ -1 (k+1)×ℓ -1 (k) |) whereas the external computations require an additional O(p × |ℓ -1 (k)| × |∆ |ℓ -1 (k)×ℓ -1 (k+1) |)
• O(|ℓ -1 (k + 1)| × |V | × |V | p ) scalar star operations, • O(|ℓ -1 (k + 1)| 3 × |V | 3 × |V | p ) scalar products, and • O((|ℓ -1 (k + 1)| 3 × |V | 3 + |∆ |ℓ -1 (k+1)×ℓ -1 (k+1) | × |V | 2 ) × |V | p ) scalar sums.
We obtain a total number of operations of the shape

• O( 0≤k≤K |ℓ -1 (k)| × |V | p+1 ) for the scalar star operations, • O((p + 1) × |Q| × |∆| × |V | p+2 + 0≤k≤K |ℓ -1 (k)| 3 × |V | p+3
) for the products, and

• O((p+1)×|Q|×|∆|×|V | p+2 + 1≤k≤K (|ℓ -1 (k)| 3 ×|V | p+3 +|∆ |ℓ -1 (k)×ℓ -1 (k) |×|V | p+2 ))
for the sums, which can be overapproximated by the bound in the theorem.

It is important to notice that the complexity with respect to the pebble weighted automaton does not depend on the number K of layers but only on the total number of states. The number of variables occurs in the exponent but since we allow reusability, this number may be rather small. This is in the same vein as restricting the number of variables in first-order logic, without restricting the quantifier depth. Restricting the number of variables often results in much lower complexity. For instance, the complexity of the evaluation (model-checking) problem of first-order logic over relational structures drops from PSPACE to PTIME when the number of variables is bounded [START_REF] Vardi | Alternating Automata and Program Verification[END_REF][START_REF] Vardi | On the Complexity of Bounded-Variable Queries[END_REF]. In our case, if we bound the number p of such variables, we obtain a polynomial complexity for the evaluation of a quantitative query, even for pebble weighted automata with a large number of layers.

In the two next sections, we will give specialized and more efficient algorithms in the case of words, trees and nested words.

Specialized Algorithm for Words

In this section, we study the evaluation problem of a K-layered pebble weighted automaton A over a given finite word w, represented as a graph: given a graph G ∈ Word(A) and a valuation σ : Var ⇀ V with domain containing the free variables of A, compute [[A]](G, σ).

Before explaining how to evaluate efficiently pebble weighted automata, we recall how this can be done for classical finite-state automata. In case of a deterministic finite-state automaton, we can easily check whether a word w is accepted by an automaton by following the single computation in the automaton labeled by w, from left to right: at every position of the word, we only have to keep one memory cell containing the state reached after the current prefix of w. This memory cell can be updated with each letter in constant time using the transition function. On the overall, this leads to a complexity O(|w|) (in particular, independent of the automaton size).

For a non-deterministic finite-state automaton, this complexity is not achievable anymore. A first solution consists of determinizing the automaton and then applying the previous method: we obtain a complexity O(2 n + |w|) where n is the number of states of the non-deterministic finite-state automaton. This method cannot be extended to weighted automata, as they are not necessarily determinizable. Hence, we would rather use a dynamic programming method. We will pay the price of non-determinism by using more memory cells during the left-to-right computation of the runs of the automaton over the word. We use one memory cell s q for every state q of the automaton. Cell s q is a Boolean which is true after reading a word w if, and only if, there exists a run labeled by w leading from some initial state to state q. Cells are initially true for initial states and false otherwise. The update of the cells when reading a letter a is done by the multiplication of the row vector of cells (of dimension 1 × |Q|) with the adjacency matrix of the transitions of the automaton labeled with letter a. Hence, each update requires a number of operations O(n 2 ), leading to an overall complexity of O(n 2 |w|). This method can naturally be extended to the weighted setting using memory cells containing values in S. More precisely, cell s q holds the sum of weights of runs starting from some initial state and ending in state q. The update now uses the weighted transition matrix and can be done with the same complexity.

We now explain how to evaluate layered pebble weighted automata with similar methods, in particular, permitting to avoid constructing the whole (|Q| × |V |)-square matrix as in the previous section, and hence saving some scalar operations in S. Proof. The navigation of automata is resolved by adding more memory cells (a quadratic number with respect to n = |Q|), namely those that compute weights of the back-loops and forth-loops. We deal with layers inductively. In the whole proof, we fix a word w ∈ A + encoded in a graph G ∈ Word(A) with1 V = {1, . . . , |w|}, and a valuation σ with domain containing the free variables of A.

Recall that, for all valuations σ ′ : Var ⇀ V , layers k ∈ {0, . . . , K} and states q, q ′ ∈ ℓ -1 (k), [[A q,q ′ ]](G, σ ′ ) is the sum of weights of the runs from configurations (G, σ ′ , q, 1, ε) to (G, σ ′ , q ′ , |w|, ε): observe that the stack of pebbles is empty at the beginning of these runs, hence they stay in layers k, k -1, . . . , 0. In the following, these values (and others that will be defined later) will be grouped into matrices indexed by subsets of states (and no longer by pairs of states and vertices). In particular, we let

B (k) σ ′ = ([[A q,q ′ ]](G, σ ′ , 1, |w|)) q,q ′ ∈ℓ -1 (k) be such a matrix indexed by ℓ -1 (k) × ℓ -1 (k).
Let k ∈ {0, . . . , K} be a layer of the automaton. If k > 0, we assume by induction that for all valuations σ ′ compatible with σ and layer k -1 (with the same definition as in the proof of Theorem 5.4) we have already computed the matrices B (k-1) σ ′

. For each valuation σ ′ compatible with σ and layer k, we will compute the matrix B (k) σ ′ reading the graph G from left to right. Formally, for 1 ≤ i ≤ |V |, we define the matrix B →i σ ′ = (B →i σ,q,q ′ ) q,q ′ ∈ℓ -1 (k) where B →i σ ′ ,q,q ′ is the sum of weights of the runs from configuration (G, σ ′ , q, ε, 1) to (G, σ ′ , q ′ , ε, i) with intermediary configurations of the form (G, σ ′ , r, π, j) with π = ε or j ≤ i (see left of Figure 5.1). These are the runs which move from the beginning of the word to position i, staying on the left of i, unless some pebbles are currently dropped (if a pebble is dropped, then automaton can read the whole word). In order to compute inductively B →i σ ′ using B →i-1 σ ′ , we also define the matrices B i σ ′ = (B i σ ′ ,q,q ′ ) q,q ′ ∈ℓ -1 (k) where B i σ ′ ,q,q ′ is the sum of weights of the runs from configuration (G, σ ′ , q, ε, i) to (G, σ ′ , q ′ , ε, i) with intermediary configurations of the form (G, σ ′ , r, π, j) with π = ε or j ≤ i (see right of Figure 5.1). Again, these runs stay on the left of their starting position except possibly when they drop pebbles.

By definition we have

B →1 σ ′ = B 1 σ ′ . Moreover, for 1 < i ≤ |V |
, a run from position 1 to position i staying on the left of i can be decomposed as a run from position 1 to position i -1 followed by a right move, followed by a back-loop over position i:

B →i σ ′ = B →i-1 σ ′ ⊗ M →,(k) σ ′ ,i-1 ⊗ B i σ ′ .
Here and in the following, we will denote by

M d,(k) σ ′ ,i the ℓ -1 (k) × ℓ -1 (k)-matrix with (q, q ′ )- coefficient given by α∈Test | G,σ ′ ,i|=α ∆ q,q ′ (d)(α) w w q q ′ i q q ′ i Figure 5
.1: Runs of a navigating automaton for d ∈ {→, ←}: this coefficient denotes the weight of taking a transition with move d from state q to state q ′ on position i with current valuation σ ′ . We will also need similar matrices for drop and lift moves. We denote by M

drop x ,(k) σ ′ ,i the ℓ -1 (k) × ℓ -1 (k -1)-matrix with (q, q ′ )-coefficient given by α∈Test|G,σ ′ ,i|=α ∆ q,q ′ (drop x )(α) .
Lift transitions only occur on position |w| of the word, hence we do not need to give a vertex to define similar matrix for lift: let

M lift,(k) σ ′ be the ℓ -1 (k -1) × ℓ -1 (k)-matrix with (q, q ′ )-coefficient given by α∈Test|G,σ ′ ,|w||=α ∆ q,q ′ (lift)(α) .
Notice that the precomputation of all these matrices (for every position and valuation) can be computed with an additional number of scalar sums bounded above by O(|∆| × |w| p+1 ).

We now explain how to compute the matrices B i σ ′ inductively from left to right. At the bottom layer (k = 0) no further pebble can be dropped so that we get

B 1 σ ′ = Id B i σ ′ = M ←,(k) σ ′ ,i ⊗ B i-1 σ ′ ⊗ M →,(k) σ ′ ,i-1 ⋆ if 1 < i ≤ |w| .
If k > 0, the run may immediately drop some pebble of name x ∈ Var on position 1 ≤ i ≤ |w| resulting in the nested computation of

N (k) σ ′ ,i = x∈Var(A) M drop x ,(k) σ ′ ,i ⊗ B (k-1) σ ′ [x →i] ⊗ M lift,(k) σ ′ [x →i] . Notice that matrix B (k-1) σ ′ [x →i] has been precomputed since σ ′ [x → i]
is compatible with σ and layer k -1 (σ ′ being compatible with σ and layer k). If i > 1, the run may also start by moving left, hence we obtain

B 1 σ ′ = N (k) σ ′ ,1 ⋆ B i σ ′ = N (k) σ ′ ,i ⊕ M ←,(k) σ ′ ,i ⊗ B i-1 σ ′ ⊗ M →,(k) σ ′ ,i-1 ⋆ if 1 < i ≤ |w|
Finally, once all these matrices have been obtained, we can compute the behavior of layer k with the formula

B (k) σ ′ = B →|w| σ ′ .
To conclude this proof, it remains to count the number of scalar operations in the whole computation. For this, we first count the number of matrix operations (sum, product and star) and then infer the number of scalar operations assuming standard algorithms on matrices (quadratic for sum, cubic for product and cubic for star using Lemma 5.1).

Fix a layer k. For all valuations σ ′ compatible with σ and layer k (there are at most |w| p such valuations), matrices B →i σ ′ , B i σ ′ must be computed for every 1 ≤ i ≤ |w|. When k = 0, the total number of matrix operations (sum, product, star) is O(|w| p × |w|), which corresponds to O(|ℓ -1 (0)| × |w| p+1 ) scalar star operations and O(|ℓ -1 (0)| 3 × |w| p+1 ) scalar sum and product operations. For k > 0, the computation of

N (k) σ ′ ,i takes O(p(|ℓ -1 (k)||ℓ -1 (k- 1)| 2 + |ℓ -1 (k)| 2 |ℓ -1 (k -1)|)
) scalar sums and products for each σ ′ and i. Hence, the total number of scalar sum and product operations for computing all matrices

B →i σ ′ , B i σ ′ of layer k is now O(p(|ℓ -1 (k)||ℓ -1 (k -1)| 2 + |ℓ -1 (k)| 2 |ℓ -1 (k -1)| + |ℓ -1 (k)| 3 )|w| p+1 ), whereas the total number of scalar star operations is O(|ℓ -1 (k)| × |w| p+1 ).
Summing over all k ≤ K, we get a total number of O((p + 1)|Q| 3 |w| p+1 ) scalar sum and products operations since

|ℓ -1 (0)| 3 + K k=1 |ℓ -1 (k)||ℓ -1 (k -1)| 2 + |ℓ -1 (k)| 2 |ℓ -1 (k -1)| + |ℓ -1 (k)| 3 ≤ |Q| 3
and similarly a total number of O(|Q| × |w| p+1 ) scalar star operations.

Indeed, we see below that it is possible to decrease again the complexity, if we start with a strongly layered pebble weighted automaton.

Theorem 5. 6. We can compute the semantics [[A]](w, σ) of a K-strongly layered pebble weighted automaton A that may drop p distinct variables, over a word w ∈ A + , for a valuation σ with domain containing the free variables of A,

• with O(|Q| × |w| max(p,1) ) scalar star operations,

• O(|Q| 3 × |w| max(p,1) ) scalar products, and 1) ) scalar sums.

• O(|Q| 3 × |w| max(p,1) + |∆| × |w| max(p,
Proof. The idea is to decrease by 1 the exponent of |w| in the complexity by reducing the total number of valuations σ ′ for which we must compute the matrices used in the proof of Theorem 5. 8. Indeed, knowing the unique pebble that may be dropped in a given layer permits to forget the precise position of this pebble when computing the matrices of this layer.

Let 0 ≤ k ≤ K be a layer of A. In addition to matrices defined in the proof of Theorem 5.8, we introduce new matrices B i σ ′ and B i→ σ ′ in order to compute the sum of weights of runs which stay on the right of their starting position (except when they drop pebbles). For every states q, q ′ ∈ ℓ -1 (k) and 1 ≤ i ≤ |w|, we denote by B i σ ′ ,q,q ′ the sum of weights of the runs from configuration (G, σ ′ , q, ε, i) to (G, σ ′ , q ′ , ε, i) with intermediary configurations of the form (G, σ ′ , r, π, j) with π = ε or j ≥ i. Finally, we denote by B i→ σ ′ ,q,q ′ the sum of weights of the runs from configuration (G, σ ′ , q, ε, i) to (G, σ ′ , q ′ , ε, |w|) with intermediary configurations of the form (G, σ ′ , r, π, j) with π = ε or j ≥ i.

Hence, we will compute twice as many matrices, however we will gain in complexity by replacing the usual valuation σ ′ by its restriction σ ′′ to the pebbles in Var(A)\{x k }, where we denote by x k the pebble name being dropped in layer k. Indeed, with j = σ ′ (x k ), we can compute the matrix B (k) σ ′ by splitting the word w into three parts: positions appearing before j, position j and positions appearing after j. Hence, for 1

< j = σ ′ (x k ) < |w|, we can compute B (k) σ ′ with (notice that σ ′′ [x k → j] = σ ′ ) B (k) σ ′ = B →j-1 σ ′′ ⊗ M →,(k) σ ′′ ,j-1 ⊗ M drop x k ,(k) σ ′ ,j ⊗ B (k-1) σ ′ ⊗ M lift,(k) σ ′ ⊕ M ←,(k) σ ′ ,j ⊗ B j-1 σ ′′ ⊗ M →,(k) σ ′′ ,j-1 ⊕ M →,(k) σ ′ ,j ⊗ B j+1 σ ′′ ⊗ M ←,(k) σ ′′ ,j+1 ⋆ ⊗ M →,(k) σ ′ ,j ⊗ B j+1→ σ ′′ . When j = 1, the formula becomes B (k) σ ′ = M drop x k ,(k) σ ′ ,1 ⊗ B (k-1) σ ′ ⊗ M lift,(k) σ ′ ⊕ M →,(k) σ ′ ,1 ⊗ B 2 σ ′′ ⊗ M ←,(k) σ ′′ ,2 ⋆ ⊗ M →,(k) σ ′ ,1 ⊗ B 2→ σ ′′ whereas for j = |w|, it is B (k) σ ′ = B →|w|-1 σ ′′ ⊗ M →,(k) σ ′′ ,|w|-1 ⊗ M drop x k ,(k) σ ′ ,|w| ⊗ B (k-1) σ ′ ⊗ M lift,(k) σ ′ ⊕ M ←,(k) σ ′ ,|w| ⊗ B |w|-1 σ ′′ ⊗ M →,(k) σ ′′ ,|w|-1 ⋆ .
It remains to compute the matrices B →i σ ′′ and B i σ ′′ for 1 ≤ i ≤ |w| (in particular we will use them in the previous formulae for i ∈ [1 .. j -1]), and the matrices B i σ ′′ and B i→ σ ′′ for 1 ≤ i ≤ |w| (we use them for i ∈ [j + 1 .. |w|]). First, if k > 0 then a pebble of name x k ∈ Var may be dropped on position 1 ≤ i ≤ |w| (with i = j) resulting in the nested computation of

N (k) σ ′′ ,i = M drop x k ,(k) σ ′′ ,i ⊗ B (k-1) σ ′′ [x k →i] ⊗ M lift,(k) σ ′′ [x k →i] .
We let N (0) σ ′′ ,i = 0. Then, it is easy to verify that for 1 < i ≤ |w|:

B 1 σ ′′ = N (k) σ ′′ ,1 ⋆ and B →1 σ ′′ = B 1 σ ′′ B i σ ′′ = N (k) σ ′′ ,i ⊕ M ←,(k) σ ′′ ,i ⊗ B i-1 σ ′′ ⊗ M →,(k) σ ′′ ,i-1 ⋆ B →i σ ′′ = B →i-1 σ ′′ ⊗ M →,(k) σ ′′ ,i-1 ⊗ B i σ ′′
and for 1 ≤ i < |w|:

B |w| σ ′′ = N (k) σ ′′ ,|w| ⋆ and B |w|→ σ ′′ = B |w| σ ′′ B i σ ′′ = N (k) σ ′′ ,i ⊕ M →,(k) σ ′′ ,i ⊗ B i+1 σ ′′ ⊗ M ←,(k) σ ′′ ,i+1 ⋆ B i→ σ ′′ = B i σ ′′ ⊗ M →,(k) σ ′′ ,i ⊗ B i+1→ σ ′′ .
The computation of the four types of matrices, for all valid positions i and all partial valuations σ ′′ , requires globally O(|w| p-1 × |w|) matrix operations (unless p = 0, in which case O(|w|) matrix operations are required). Notice also that the precomputation of the matrices M d,(k) σ ′′ ,i has to be done only for partial valuations σ ′′ and i, and also for the complete valuations σ ′′ [x → j] and i = j, which requires only O(|∆| × |w| max(p,1) ) scalar sums. Hence, this improves the overall complexity as announced.

Notice that if p ≤ 1 then any K-layered pebble weighted automaton is strongly K-layered. In this case, we get an evaluation algorithm using O(|Q| × |w|) scalar star operations and O(|Q| 3 × |w|) scalar products and O(|Q| 3 × |w| + |∆| × |w|) scalar sums.

Extension to Trees

We now study the evaluation problem of layered pebble weighted automata over ranked trees. Contrary to words, we modeled ranked trees by pointed graphs having their initial and final vertex equal to the root. Hence, a run of a 0-layered pebble weighted automaton is a sequence of configurations which follows a path from the root to the root. Hence, we only need to compute the loop matrices from the previous proofs, which permits to even simplify the proof. Proof. Again, we reason by induction on the layers of the automaton, and, we use similar notations as in the case of words. In particular, we consider a pointed graph G ∈ T ree(A), that models the tree t.

Let k ∈ {0, . . . , K} be a layer of the automaton. If k > 0, we assume by induction that for all valuations σ ′ compatible with σ and layer k -1 (with the same definition as in the proof of Theorem 5.4) we have already computed the matrices

B (k-1) σ ′
. For each valuation σ ′ compatible with σ and layer k, we now compute the matrix B (k) σ ′ by a bottom-up procedure on the tree. Formally, we define the matrices

B u σ ′ = (B u σ ′ ,q,q ′ ) q,q ′ ∈ℓ -1 (k) where B u σ ′ ,q,q ′
is the sum of weights of the runs from configuration (G, σ ′ , q, ε, u) to (G, σ ′ , q ′ , ε, u) with intermediary configurations of the form (G, σ ′ , r, π, v) with π = ε or v = uu ′ with u ′ ∈ N ⋆ (i.e., v in the subtree rooted in u). Again, these runs stay in the subtree of vertex u except when they drop pebbles.

For vertices u that are leaves, we have B u σ ′ = Id for layer k = 0, and

B u σ ′ = N (k-1) σ ′ ,u ⋆ otherwise.
For vertices u that are internal nodes, if k = 0, a loop under node u is composed of a succession of move to one of the children of u, a loop under that particular child, and a move back to u. Hence, we let

B u σ ′ = 0≤i≤ar(λ(u))-1 M ↓i,(k) σ ′ ,u ⊗ B ui σ ′ ⊗ M ↑i,(k) σ ′ ,ui ⋆
For k > 0, we must also consider the possibility to drop a pebble on u so that

B u σ ′ = N (k-1) σ ′ ,u ⊕ 0≤i≤ar(λ(u))-1 M ↓i,(k) σ ′ ,u ⊗ B ui σ ′ ⊗ M ↑i,(k) σ ′ ,ui ⋆
Once all these matrices are computed, we obtain the behavior of layer k with

B (k) σ ′ = B ε σ ′
since the root ε is both the initial vertex and the final one. The count of the number of operations is similar to the previous cases.

We believe that ideas similar to those used for words in Theorem 5.6 would permit to decrease the complexity in the case of trees. Indeed, a vertex of a tree separates the tree into two parts: the subtree rooted by the vertex, and its context, i.e., the tree where the previous subtree has been removed and the vertex replaced by a hole. Mimicking the procedure of Theorem 5.6 would require to introduce several types of matrices for every vertex v: loops in the subtree of v (the ones introduced in the previous proof), loops in the context, loops below the root in the context of v and paths from the root to v in the context of v and vice versa. Computing those five matrices for every vertex v requires to carefully order the set vertices, as a bottom-up procedure would not be enabled anymore. Full details of this procedure are left for future work.

Extension to Nested Words

Finally, we consider the case of nested words. A strategy could be to encode nested words into binary trees, in a way that layered pebble weighted automata could be translated faithfully. This is not at all trivial, since we consider walking automata and that usual encodings do i start(i) end(i)

B i→ σ p q B i σ p q i start(i) end(i) B ←i σ p q B i σ p q Figure 5
.2: Representation of the four types of matrices not preserve the paths between vertices: indeed, such paths must be translated in automata in a non ambiguous way to preserve the semantics. Instead of this encoding, we give a direct proof for nested words. This is also a good opportunity to illustrate the possibility to extend the algorithm we applied for words and trees for more complex classes of graphs of bounded degree: the key point is to consider carefully the different looping paths of a graph.

Nested words must then be seen as a complicated enough example permitting to illustrate this reasoning. Proof. In the whole proof, we fix a nested word G ∈ N est(A), with set of vertices V = {1, . . . , |V |}, and a valuation σ with domain containing the free variables of A. We follow the same basic idea used to evaluate pebble weighted automata over words, namely computing matrices of weights for partial runs. The navigation is resolved by computing simultaneously matrices of weights of the back-loops and forth-loops, whereas we deal with layers inductively. Finally, we deal with call-return edges by using a hierarchical order based on the call-depth to compute the different matrices. Hence, for every position i ∈ V we consider the pair (start(i), end(i)) of start and end positions as follows

start(i) = min{j ∈ V | j ≤ i ∧ ∀ℓ j ≤ ℓ ≤ i =⇒ c-d(ℓ) ≥ c-d(i)} end(i) = max{j ∈ V | i ≤ j ∧ ∀ℓ i ≤ ℓ ≤ j =⇒ c-d(ℓ) ≥ c-d(i)}
For positions of call-depth 0, the start position is 1 whereas the end position is |V |. For positions of call-depth at least 1 (see Figure 5.2), the start position is the linear successor of the closest call in the past such that its matched return is after position j, whereas its end position is the linear predecessor of this return position.

Let A = (Q, A, {→, ←, , }, I, ∆, F ) be a K-layered pebble weighted automaton. For every layer k ∈ {0, . . . , K}, we again want to compute the matrix B for every valuation σ ′ compatible with σ and layer k -1. For a valuation σ ′ compatible with σ and layer k, the matrix B (k) σ ′ will be obtained by the computation of four types of matrices for every position (see Figure 5.2). For example, B i→ σ ′ ,p,q (respectively, B i σ ′ ,p,q ) is the sum of weights of the runs from configuration (G, σ ′ , p, ε, i) to (G, σ ′ , q, ε, end(i)) (respectively, (G, σ ′ , q, ε, i)) with intermediary configurations of the form (G, σ ′ , r, π, j) with π = ε or i ≤ j ≤ end(i).

We compute these four types of matrices for every position i by decreasing value of call-depth. Suppose this has been done for every position of call-depth greater than d. We describe how to compute matrices B i→ σ ′ and B i σ ′ for every position i of call-depth d, by decreasing values of i. 2 Similarly, matrices B ←i σ ′ and B i σ ′ can be computed by increasing values of positions i having call-depth d.

We extend the definition of matrix M d,(k) σ ′ ,i to direction d ∈ { , } in a straighforward manner.

There are four distinct cases:

If i = end(i):
The only way to loop on the right of i, staying on the left of end(i) = i is to drop a pebble a certain number of times. With the same definition of the matrix N σ ′ ,i , we have

B i σ ′ = N σ ′ ,i ⋆ = B i→ σ ′ . If i < end(i
) and i is not a call: Then, looping on the right of i either starts by dropping a pebble over i, or starts with a right move, followed by a loop on the right of i + 1 and a left move. All of this may be iterated using a star operation:

B i σ ′ = N σ ′ ,i ⊕ M →,(k) σ ′ ,i ⊗ B i+1 σ ′ ⊗ M ←,(k) σ ′ ,i+1 ⋆ .
Moving to the right of position i, until end(i), can be decomposed as a loop on the right of i, followed by a right move (from that point, we will not reach position i anymore) and a run from i + 1 to end(i + 1) = end(i):

B i→ σ ′ = B i σ ′ ⊗ M →,(k) σ ′ ,i ⊗ B i+1→ σ ′ . If i < end(i) and i i + 1:
The situation is very similar except that there are two moves leading from i to i + 1 and two moves leading from i + 1 to i.

B i σ ′ = N σ ′ ,i ⊕ (M →,(k) σ ′ ,i ⊕ M ,(k) σ ′ ,i ) ⊗ B i+1 σ ′ ⊗ (M ←,(k) σ ′ ,i+1 ⊕ M ,(k) σ ′ ,i+1 ) ⋆ B i→ σ ′ = B i σ ′ ⊗ (M →,(k) σ ′ ,i ⊕ M ,(k) σ ′ ,i ) ⊗ B i+1→ σ ′ .
If i < end(i) and i j with j = i + 1: Looping on the right of i consists of either (1) dropping a pebble over i, or (2) looping on the right of i without ever reaching j, or (3) going to j, looping on j staying between positions i + 1 and end(i), and going back to i without reaching position j again. All of this is again possibly iterated using a star operation. Notice that positions i + 1 and j -1 have a call-depth greater than d, hence their four types of matrices have been computed previously. We have end(i) = end(j), end(i + 1) = j -1 and start(j -1) = i + 1. First we define a matrix for the runs going from i to j, another one for those looping over j, and a last one for those going from j to i:

Goto-Return σ ′ ,i = M ,(k) σ ′ ,i ⊕ M →,(k) σ ′ ,i ⊗ B i+1→ σ ′ ⊗ M →,(k) σ ′ ,j-1 Loop-Return σ ′ ,j = B j σ ′ ⊗ M ←,(k) σ ′ ,j ⊗ B j-1 σ ′ ⊗ M →,(k) σ ′ ,j-1 ⋆ ⊗ B j σ ′ Goto-Call σ ′ ,j = M ,(k) σ ′ ,j ⊕ M ←,(k) σ ′ ,j ⊗ B ←j-1 σ ′ ⊗ M ←,(k) σ ′ ,i+1 .
Notice that the product of these three matrices generates exactly the runs described above in (3). Runs looping on the right of i are then computed by

B i σ ′ = N σ ′ ,i ⊕ M →,(k) σ ′ ,i ⊗ B i+1 σ ′ ⊗ M ←,(k) σ ′ ,i+1 ⊕ Goto-Return σ ′ ,i ⊗ Loop-Return σ ′ ,j ⊗ Goto-Call σ ′ ,j ⋆ .
Finally, to go from i to end(i), we split the runs considering the last time we reach position i and the last time we visit a position on the left of j:

B i→ σ ′ = B i σ ′ ⊗ Goto-Return σ ′ ,i ⊗ B j σ ′ ⊗ M ←,(k) σ ′ ,j ⊗ B j-1 σ ′ ⊗ M →,(k) σ ′ ,j-1 ⋆ ⊗ B j→ σ ′ . If i = 1 then end(i) = |V | and we have B (k) σ ′ = B 1→ σ ′ .
Hence, we have computed the behavior of layer k.

Similar counts as for words permits to show the announced complexity of this algorithm.

Notice that if the nested word is in fact a word, our algorithm only needs to compute the two sets of matrices B i→ σ ′ and B i σ ′ with a backward visit of the positions of the word. This is indeed a slightly different algorithm than the one presented for words where the positions are visited in a forward manner.

CHAPTER

Logical Specifications

Tweedledum and Tweedledee Agreed to have a battle! For Tweedledum said Tweedledee Had spoiled his nice new rattle.

Just then flew down a monstrous crow, As black as a tar-barrel! Which frightened both the heroes so, They quite forgot their quarrel.

'I know what you're thinking about,' said Tweedledum; 'but it isn't so, nohow.' 'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic.' Lewis Carroll, Through the Looking Glass

In their book [CE11], the authors motivate the introduction of monadic logics over graphs by claiming:

Monadic second-order formulas are even more important for specifying sets of graphs than for specifying languages because there is no convenient notion of graph automaton. Indeed, monadic logics may be the foundations of a theory of regular languages of graphs. As a special case, for finite or infinite words and trees, those languages coincide with the ones recognized by some automata models. This is a hint for the robustness of this class of languages. In the weighted setting, weighted extensions of monadic logics have been defined [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF] that do not coincide with any of the weighted automata models that have been discovered so far. Indeed, it was shown by [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF] that a very restricted fragment of their logic generates exactly the languages recognized by weighted automata (one-way and without pebbles) over finite words, namely the syntactically restricted monadic second order logic. This logical characterization has been generalized to various other settings like finite ranked trees [START_REF] Droste | Weighted Tree Automata and Weighted Logics[END_REF], and unranked trees [START_REF] Droste | Weighted Tree Automata and Weighted Logics[END_REF], nested words [START_REF] Droste | Weighted Nested Word Automata and Logics Over Strong Bimonoids[END_REF], or infinite words [START_REF] Droste | Describing Average-and Longtime-Behavior by Weighted MSO Logics[END_REF].

Our idea was initially to follow another path to get some logical characterization of a family of weighted automata. Rather than starting from a very powerful logic, like weighted monadic second order logic, and strongly restricting it to recover the power of weighted automata, we chose to start with a weaker logic (weighted first order logic) to which we add a weighted transitive closure operator. This idea has been partly inspired by results of [START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF] claiming the equivalence, in the Boolean setting, between tree-walking automata with pebbles and first order logic with transitive closure.

In this chapter, we will hence consider different logical formalisms starting with the classical (Boolean) monadic second order logic. We show how to use the already known decidability results to deduce the decidability of the emptiness of pebble weighted automata under some hypotheses. We then develop our main weighted logic, composed of first-order constructs to which we add a weighted transitive closure. Sections 6.4 and 6.5 then present in full details the proof of equivalence between weighted logical and automatic formalisms. We finish this chapter with the quick investigation of hybrid navigational logics, which can be seen as an extension of weighted expressions with more powerful logical features. Some logics and proof ideas present in this chapter are published in restricted cases in [1,4], but the graph setting is a new contribution of this manuscript, as well as the detailed study of hybrid navigational logics.

Monadic Second Order Logic over Graphs

As a preliminary, we recall the classical definitions of monadic second order logic over graphs.

Let us fix infinite supplies of first-order variables Var = {x, y, z, t, x 1 , x 2 , . . .}, and of second-order variables VAR = {X, Y, X 1 , X 2 , . . .}. The set MSO(A, D) (or simply MSO if the alphabet A and the set D of directions are clear from the context) of monadic secondorder formulae over A and D is given by the grammar:

ϕ ::= ⊤ | (x = y) | init(x) | final(x) | P a (x) | R d (x, y) | R ⋆ d (x, y) | x ∈ X | ¬ϕ | ϕ ∨ ϕ | ∃x ϕ | ∃X ϕ
where a ∈ A, d ∈ D, x, y ∈ Var and X ∈ VAR. As usual, the set FO(A, D) (or simply FO) of first-order formulae over A is the fragment of MSO(A, D) without second-order quantifications ∃X.

For ϕ ∈ MSO(A, D), we define as usual Free(ϕ) the set of free variables of ϕ. If Free(ϕ) = ∅, then ϕ is called a sentence. For a pointed graph G ∈ G(A, D), we now consider a valuation σ to be a function that maps first-order variables in Var to elements of V and second-order For every pointed graph G and every σ with domain containing the free variables of ϕ, we define G, σ |= ϕ by induction over the formula ϕ, as shown in Table 6. 1. Note in particular that the semantics of ϕ only depends on the restriction of σ to the free variables of ϕ.

In the following, we will use several shortcuts in order to keep formulae readable and of reasonable size. It is however important to carefully notice what is the logical fragment needed to express them. For example, we allow to state the existence of a d-path of length k in a graph between two given vertices, with a formula denoted by R k d (x, y), with k ≥ 0: this formula can be obtained by the following recursive process, implying that this formula is expressible in FO

R 0 d (x, y) = (x = y) , R k+1 d (x, y) = ∃z R d (x, z) ∧ R k d (y, z) (6.1)
We will also allow modulo constraints on such paths following a direction d, denoted by (x, y) ≡ d m[ℓ] with 0 ≤ m ≤ ℓ -1: this formula is evaluated to true if, and only if, there exists a d-path from the vertex encoded by x to the one encoded by y, whose length is congruent to m modulo ℓ. This formula is MSO-definable by

((x, y) ≡ d m[ℓ]) = ∀X (y ∈ X) ∧ ∀z, z ′ (z ∈ X ∧ R ℓ d (z ′ , z)) =⇒ z ′ ∈ X =⇒ ∃z ∈ X R m d (x, z) .
Notice that this modulo operator may also be defined in first-order logic extended with a transitive closure operator. More formally, such an operator, denoted by TC in the following, takes a formula ϕ with two distinguished free variables, e.g., x and y, and gives a formula TC x,y ϕ with the same free variables as ϕ. Let G ∈ G(A, D) be a pointed graph and σ be a valuation of the free variables of ϕ. We may interpret the semantics of ϕ as a binary relation

R G,σ (ϕ) over V R G,σ (ϕ) = {(v, v ′ ) | G, σ[x → v, y → v ′ ] |= ϕ} meaning that G, σ |= ϕ if, and only if (σ(x), σ(y)) ∈ R G,σ (ϕ) Consider the transitive closure relation R G,σ (ϕ) + of R G,σ (ϕ) defined as usual as the union of the sequence (R G,σ (ϕ) k ) k≥1 defined by      R G,σ (ϕ) 1 = R G,σ (ϕ) R G,σ (ϕ) k+1 = {(v, v ′′ ) | (v, v ′ ) ∈ R G,σ (ϕ) and (v ′ , v ′′ ) ∈ R G,σ (ϕ) k for some v ′ ∈ V }
The semantics of TC x,y ϕ is then defined as G, σ |= TC x,y ϕ if, and only if (σ(x), σ(y)) ∈ R G,σ (ϕ) +

If we want to stress the fact that x and y are free variables of the new built formula, we may write it [TC x,y ϕ](x, y), or even [TC x,y ϕ](x ′ , y ′ ) if we want to change their name. We denote by FO + posTC the logic composed of first order logic to which we add positive transitive closure operators, i.e., having an even number of negations above them. Indeed, if we push the negations over the atoms, it is exactly the logic defined by

ϕ ::= ⊤ | (x = y) | init(x) | final(x) | P a (x) | R d (x, y) | R ⋆ d (x, y) | ¬⊤ | ¬(x = y) | ¬init(x) | ¬final(x) | ¬P a (x) | ¬R d (x, y) | ¬R ⋆ d (x, y) | ϕ ∨ ϕ | ϕ ∧ ϕ | ∃x ϕ | ∀x ϕ | TC x,y ϕ
where a ∈ A, d ∈ D and x, y ∈ Var. We may also denote formula ¬(x = y) by x = y in the following.

The modulo operator can then be equivalently defined with formula

((x, y) ≡ d m[ℓ]) = ∃z R m d (x, z) ∧ [TC x,y R ℓ d (x, y)](z, y) ∨ z = y .
In case D is an ordered set of directions, with a distinguished forward direction →, we will use formula x ≤ y as a shortcut for R ⋆ → (x, y): this is in reference of →-ordered graphs on which we may then interpret the formula, which come with a linear order ≤ generated by →.

Emptiness of Pebble Weighted Automata is Decidable

Monadic second-order logic has been extensively studied over graphs, in particular the decidability status of the satisfiability problem over a certain class G of graphs. For example, it is well-known that for graphs of bounded degree, this problem is decidable if, and only if, all the graphs of G have a bounded clique-width (see [START_REF] Courcelle | Graph Structure and Monadic-Second-Order Logic, a Language Theoretic Approach[END_REF] for the definition and the proof of this result).

Using this result, we now consider the emptiness problem of our classes of pebble weighted automata, which is, given a layered pebble weighted automaton A, does there exist a pointed graph G ∈ G and a valuation σ of the free variables of A such that [[A]](G, σ) = 0. This is the simplest question that may be asked, and this is indeed decidable if we consider layered automata over positive continuous semirings, and bounded clique-width graphs.

Theorem 6.1. Let G be a class of (A, D)-pointed graphs with bounded clique-width, and S be a positive continuous semiring. The following problem is decidable:

Data: a layered pebble weighted automaton A over A, D, S Question: does there exist G ∈ G and σ a valuation with domain containing Free(A) such that [[A]](G, σ) = 0?

Proof. We reduce this problem to the same problem in the Boolean semiring (which is a typical positive continuous semiring). We will then show the decidability status for the Boolean semiring.

Consider a layered pebble weighted automaton A = (Q, A, D, I, ∆, F ) over a positive continuous semiring S. Let G ∈ G(A, D) be a pointed graph and σ a valuation with domain containing the free variables of A. As the semiring is positive, it is zerosumfree (indeed, being continuous would have been sufficient here, by using the result of Proposition 2.5). Then, as the semantics of A over (G, σ) is defined as the sum of the weights of the accepting runs of A over (G, σ), we have that [[A]](G, σ) = 0 if, and only if, there exists an accepting run ρ of A over (G, σ) with weight different from 0. As the semiring is positive, it contains no zero divisor, and hence, every transition in ρ has a weight different from 0. Hence, let us consider the layered pebble weighted automaton B = (Q, A, D, I ′ , ∆ ′ , F ′ ) over the Boolean semiring ({0, 1}, ∨, ∧, 0, 1) obtained from A by replacing every weight different from 0 appearing in I, ∆ or F by 1, and letting the weight 0 unchanged. The previous reasoning permits to prove that for every pointed graph G

[[A]](G, σ) = 0 if, and only if, [[B]](G, σ) = 0 .
Now, we prove that the problem over the Boolean semiring is decidable. Let A = (Q, A, D, I, ∆, F ) be a layered pebble weighted automaton over the Boolean semiring. The decidability is shown by encoding runs of B into a formula of MSO. More precisely, we exhibit a formula ϕ with free variables Free(A) such that for every pointed graph G ∈ G(A, D) and every valuation σ with domain containing Free(A):

[[B]](G, σ) = 1 if,

and only if, G, σ |= ϕ

Hence, we reduce the initial problem to the satisfiability of a formula of MSO over a class of graphs which are of bounded clique-width. This problem is known to be decidable, as recalled previously.

We do not present the construction of the formula ϕ in full details, but rather use the translation from walking automata with nested pebbles into the logic FO + posTC proved by [START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF]: notice that their model of automata may have several heads and uses strong pebbles, hence our model can be translated in theirs. To conclude, it suffices to notice that all formulae of FO + posTC can be translated into equivalent formulae of MSO: proof of this fact is given in [CE11].

Weighted logics

Our aim is to define a denotational model to describe the behavior of weighted automata. This has already been done by Droste and Gastin [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF]: they have introduced weighted logics with syntax close to monadic second-order logic, extending the semantics by using addition and product of a semiring to evaluate disjunctions/existential quantifications, and conjunctions/universal quantifications, respectively. At the price of strong restrictions on the shape of the formulae, they succeeded to prove an expressiveness result (in our formalism, this result is stated in Theorem 6.8).

The syntax of [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF] is purely quantitative, though Boolean connectives can be expressed indirectly. As it may be somewhat confusing to interpret purely logical formulae in a weighted manner, we slightly modify the original syntax, by clearly separating the Boolean and the quantitative parts: our weighted logic consists of a Boolean kernel, such as MSO or FO, augmented with quantitative operators (addition, multiplication, sum and product quantifications, and possibly weighted transitive closure). Thus, our language will allow us to test explicitly for Boolean properties, and to perform computations. We shall see that, under some hypotheses, the formalism of [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF] and ours are equivalent. However, in addition to being more intuitive, the new syntax allows flexibility to study expressiveness. For instance, one can investigate how the underlying Boolean logic influences the computational power (see Lemma 6.5).

General definitions

Definition 6.2 (Weighted logics). Given a class L of Boolean formulae, we denote by wMSO(L) the class of weighted monadic second order logic defined by where s ∈ S, ϕ ∈ L, x ∈ Var and X ∈ VAR. Disabling the sum and product indexed by set variables, we define the class wFO(L) of weighted first order logic by

Φ ::= s | ϕ | Φ ⊕ Φ | Φ ⊗ Φ | x Φ | x Φ | X Φ | X Φ [[s]](G, σ) = s [[ϕ]](G, σ) = 1 if G, σ |= ϕ 0 otherwise [[Φ 1 ⊕ Φ 2 ]](G, σ) = [[Φ 1 ]](G, σ) ⊕ [[Φ 2 ]](G, σ) [[Φ 1 ⊗ Φ 2 ]](G, σ) = [[Φ 1 ]](G, σ) ⊗ [[Φ 2 ]]G, σ) [[ x Φ]](G, σ) = v∈V [[Φ]](G, σ[x → v]) [[ x Φ]](G, σ) = v∈V [[Φ]](G, σ[x → v]) [[ X Φ]](G, σ) = I⊆V [[Φ]](G, σ[X → I]) [[ X Φ]](G, σ) = I⊆V [[Φ]](G, σ[X → I])
Φ ::= s | ϕ | Φ ⊕ Φ | Φ ⊗ Φ | x Φ | x Φ
where s ∈ S, ϕ ∈ L and x ∈ Var.

We denote again by Free(Φ) the set of free variables of a formula Φ ∈ wMSO(L). The semantics [[Φ]] of Φ maps a pair (G, σ), composed of a pointed graph G ∈ G(A, D) and a valuation σ with domain containing the free variables of Φ, to a value in S as showed inductively in Table 6. 2. Hereby, if S is not commutative, we assume that the products follow a specified order of V and the associated lexicographic order on the power set {0, 1} V . As for the Boolean case, notice that the semantics [[Φ]] does not depend on the assignment of variables not in Free(Φ). Alternatively, we may see [[•]] as a series in S G(A, D) , defining only the semantics of sentences. Henceforth, a series f ∈ S G(A, D) is said to be wMSO(L)definable if there exists a sentence Φ ∈ wMSO(L) such that [[Φ]] = f . Example 6.3. In the Boolean semiring B, recognizable and wMSO(MSO)-definable series of words (encoded as graphs in Word(A)) coincide. In contrast, for the natural semiring N, the definition yields [[ x y 2]](G) = 2 |V | 2 for every G ∈ Word(A) modeling a word, which is not recognized by a weighted automaton over words as proved in Theorem 4.18.

Having the capability to mix Boolean and weighted operators permits to design more easily complex formulae. Example 6.4. Assume we have an XML document representing a database storing information about car models and car parts: it is depicted in Figure 6.1 in the shape of a tree, but we will consider it as a nested word in the following. Each car model is described, among other things, by its list of car parts (Figure 6.1 (a)). Each model of car part has an attached set of currently reported errors indicated by vertices labeled Err in Figure 6.1 (b). One can express that there is a car model using some car part with an error by the first order formula ∃x, y, z, t ϕ(x, y, z, t), where This is a purely logical statement where x ≺ y means that node x is an ancestor of node y in the XML document which can be written as

ϕ = [CModel(x) ∧ Part(y) ∧ x ≺ y] ∧ [PModel(z) ∧ Err(t) ∧ z ≺ t] ∧ Match(y, z)
∃z R (x, z) ∧ R ⋆ → (x, y) ∧ R ⋆ → (y, z)
and Match(y, z) is a shortcut meaning that the car part at y matches the part model at z. In this manuscript, we abstracted data away but this is typically the place where we could use data from an infinite alphabet to model more knowledge of the database.

One may want a more precise information, for example the total number of errors for all car models. This can be achieved by replacing existential quantifications with sums:

x,y,z,t ϕ(x, y, z, t), and computing in the natural semiring (N, +, ×, 0, 1) instead of the Boolean semiring.

Assume now that the database also includes car dealers, see Figure 6.1 (c). Each dealer records a list of performed sales. Here is the shape of a formula computing the maximal number of errors to be fixed per dealer:

d Dealer(d) ⊗ u (d ≺ u ∧ Car(u)) ⊗ x,y,z,t (Match ′ (u, x) ∧ ϕ(x, y, z, t))
Here, one needs to interpret ⊕ and ⊗ as max and sum operations which are available in the semiring (N ∪ {-∞}, max, +, -∞, 0). We denote by AP the class of atomic propositions, i.e., that contains only formulae x = y, init(x), final(x), P a (x), R d (x, y), R ⋆ d (x, y), x ∈ X and their negations. As explained at the beginning of the section, the logic wMSO(S) (respectively, wFO(S)) introduced in [DG09] over words is exactly the class of formulae wMSO(AP) (respectively, wFO(AP)). Transposed into our syntax, the transformation described in their Definition 4.3 and proved in Lemma 4.4, permits to state: Lemma 6.5. Let D be an ordered set of directions with a distinguished forward direction →. Then, for every Boolean formula ϕ ∈ MSO(A, D) (respectively, ϕ ∈ FO(A, D)), there exists a weighted formula Φ ∈ wMSO(AP) (respectively, Φ ∈ wFO(AP)), with the same set of free variables, such that for every →-ordered pointed graph G and every valuation σ,

[[ϕ]](G, σ) = [[Φ]](G, σ).
Proof. We will express Boolean connectives with their quantitative counterparts.

We simulate disjunction with ⊕, existential first-order quantification with x and existential second-order quantification with X . More precisely, for each MSO-formula ϕ, we effectively construct two weighted formulae Φ + ϕ , Φ - ϕ ∈ wMSO(AP) (which, in addition, belong to wFO(AP) if ϕ is an FO-formula) such that for every →-ordered pointed graph G and every σ with domain containing the free variables of ϕ, we have [

[Φ + ϕ ]](G, σ), [[Φ - ϕ ]](G, σ) ∈ {0, 1}
, and

[[Φ + ϕ ]](G, σ) = 1 ⇐⇒ G, σ |= ϕ and [[Φ - ϕ ]](G, σ) = 0 ⇐⇒ G, σ |= ϕ .
To simplify notations, x ≤ y will denote the atomic proposition R ⋆ → (x, y) with → generating the order ≤ over the vertices, whereas X ≤ Y will denote the lexicographic order over the sets of positions, that can be defined in wMSO(AP) by

X < Y = y y ∈ Y ⊗ ¬(y ∈ X) ⊗ z (y ≤ z ⊕ (z < y ⊗ z ∈ (X∆Y ) c )) X ≤ Y = X < Y ⊕ z z ∈ (X∆Y ) c , Here, z ∈ (X∆Y ) c denotes the formula (z ∈ X ⊗ z ∈ Y ) ⊕ (¬(z ∈ X) ⊗ ¬(z ∈ Y )), so that z (y ≤ z ⊕ (z < y ⊗ z ∈ (X∆Y ) c
)) tests whether X and Y agree before position y. We define formulae Φ + ϕ and Φ - ϕ by structural induction on ϕ, removing ambiguity by picking the leftmost witness of the formulae (in particular in disjunction and existential quantification):

• if ϕ ∈ AP then Φ + ϕ = ϕ and Φ - ϕ = ¬ϕ (with ¬¬ψ = ψ by convention);

• Φ + ϕ∨ψ = Φ + ϕ ⊕ (Φ - ϕ ⊗ Φ + ψ ) and Φ - ϕ∨ψ = Φ - ϕ ⊗ Φ - ψ ; • Φ + ¬ϕ = Φ - ϕ and Φ - ¬ϕ = Φ + ϕ ; • Φ + ∃xϕ = x Φ + ϕ ⊗ y [x ≤ y ⊕ (y < x ⊗ Φ - ϕ )] and Φ - ∃xϕ = x Φ - ϕ ; • Φ + ∃Xϕ = X Φ + ϕ ⊗ Y [X ≤ Y ⊕ (Y < X ⊗ Φ - ϕ )] and Φ - ∃Xϕ = X Φ - ϕ .
Hence, in ordered graphs, we can always replace a Boolean FO or MSO formula by its wFO(AP) or wMSO(AP) equivalent and we obtain: Corollary 6. 6

. Let S be a semiring and D be an ordered set of directions. Let f ∈ S G(A, D) . Then,

• f is wMSO(MSO)-definable if, and only if, f is wMSO(AP)-definable.

• f is wFO(FO)-definable if, and only if, f is wFO(AP)-definable.

For a Boolean formula ϕ ∈ L and two formulae Φ, Ψ ∈ wMSO(L), we define the macro ϕ? Φ : Ψ as ϕ?

Φ : Ψ = (ϕ ⊗ Φ) ⊕ (¬ϕ ⊗ Ψ)
as a natural generalization of the Boolean if-then-else operation: its semantics is [[Φ]] if ϕ holds, and [[Ψ]] otherwise. We simply write ϕ? Φ for ϕ? Φ : 1.

Previous expressiveness result

For L a Boolean logic closed under ∨, ∧ and ¬, an L-step formula is a formula obtained from the grammar

Φ ::= s | ϕ | Φ ⊕ Φ | Φ ⊗ Φ, with s ∈ S and ϕ ∈ L. (6.2)
The following lemma shows in particular that an L-step formula can take only a finite number of values. Proof. Call ϕ 1 , . . . , ϕ p the L-formulae occurring in the expression of Φ given by the grammar (6.2). For I ⊆ {1, . . . , p}, let Φ I be the formula obtained by replacing in Φ each ϕ i by 1 if i ∈ I and by 0 otherwise, so that Φ I has no free variable and [

[Φ I ]] is a constant s I ∈ S. Let ψ I = i∈I ϕ i ∧ i / ∈I ¬ϕ i , which is an L-formula, since L is closed under ∧ and ¬. Let Ψ = I (ψ I ⊗ s I ). Clearly, Free(Φ) = Free(Ψ).
Fix a graph G and a valuation σ.

Let J = {i | G, σ |= ϕ i }, so that G, σ |= ψ J and G, σ |= ψ I for I = J. Therefore, [[Ψ]](G, σ) = s J = [[Φ J ]](G, σ) = [[Φ]](G, σ)
, where the last equality comes from the definition of J.

From now on, we freely use Lemma 6.7, using the special form it provides for L-step formulae. All MSO-step formulae are clearly recognizable. By [DG09], x Φ is recognizable over words for any MSO-step formula Φ. A restricted fragment sREMSO of wMSO(AP) (called the syntactically restricted formulae) was defined in [START_REF] Droste | Weighted Automata and Weighted Logics[END_REF]. Essentially, sREMSO consists of wMSO(MSO) formulae Φ in existential normal form (i.e., no second-order universal quantifier and all second-order existential quantifiers at the beginning of the formula) such that if Φ contains Ψ ⊗ Ψ ′ as a subformula then the values in S appearing in Ψ and Ψ ′ commute element-wise, and such that the use of first-order product x is restricted to MSO-step formulae. Note that if the semiring is commutative, the requirement over the product Ψ ⊗ Ψ ′ is trivially verified. A consequence of their work is the following statement.

Theorem 6.8 ([DG09]). A formal power series over finite words is recognizable by a (classical) weighted automaton if, and only if

, it is definable in sREMSO.

Weighted transitive closure

We now define other fragments of wMSO(MSO), which also carry enough expressiveness to generate all recognizable series of words, and even series recognized by pebble weighted automata over some classes of graphs. Contrary to sREMSO that allows second-order quantitative operators, and finally restricts them, we rather extend the fragment wFO(AP), containing only first-order quantitative operators, with a weighted equivalent of the Boolean transitive closure.

Weighted transitive closure

For a formula Φ(x, y) with at least two free variables x and y, we introduce a weighted transitive closure operator wTC x,y Φ having as free variables the same variable as Φ. As for its Boolean counterpart, we may denote it [wTC x,y Φ](x, y) if we want to stress the existence of two special free variables, or even [wTC x,y Φ](x ′ , y ′ ) if we need to change the name of the variables. Its semantics is defined by

[[[wTC x,y Φ](x ′ , y ′ )]](G, σ) = σ(x ′ )=v0,v1,...,vm=σ(y ′ ) 0≤k≤m-1 [[Φ]](G, σ[x → v k , y → v k+1 ]) (6.
3) where the sum ranges over all m > 0 and all sequences (v k ) 0≤k≤m of vertices of the graph G with v 0 = σ(x ′ ) and v m = σ(y ′ ). Notice that this sum may be infinite, and hence requires the semiring to be continuous to be well-defined.

To ease notation, we sometimes write

[[Φ(x, y)]](G, v, v ′ ) instead of [[Φ(x, y)]](G, [x → v, y → v ′ ]).
In order to compare automata and logics, we need to define a bounded restriction on this very powerful operator.

Bounded restriction

We introduce a bounded weighted transitive closure operator wTC N

x,y for each integer N > 0 (or wTC b

x,y if N is unspecified). Its semantics consists in restricting the sequences of (6.3) so that d(v k , v k+1 ) ≤ N for every k ∈ {0, . . . , m -1}. Notice that given two vertices v and v ′ , formula d(x, y) ≤ N , defined by

(d(x, y) ≤ N ) = ∃x 1 ∃x 2 • • • ∃x N -1 d1,...,d N R d1 (x, x 1 ) ∧ 1≤n≤N -2 R dn+1 (x n , x n+1 ) ∧ R d N (x N -1 , y)
when interpreted over the graph with x mapped to v and y mapped to v ′ , verifies that d(v, v ′ ) ≤ N . Equivalently, wTC N

x,y Φ = wTC x,y (d(x, y) ≤ N ⊗ Φ) .

We will see later that this restriction is a priori unavoidable in the weighted case.

In the following, if L is a Boolean logic, we denote by wFO+wTC b (L) the weighted logic defined by Φ :

:= s | ϕ | Φ ⊕ Φ | Φ ⊗ Φ | x Φ | x Φ | wTC N x,y Φ
with s ∈ S, ϕ ∈ L, x, y ∈ Var and N ∈ N \ {0}. A formula Φ of wFO+wTC b (L) is said to be unambiguous if its semantics is either 0 or 1 for every possible graph and valuation. It has to be noticed that modulo formulae can be simulated in wFO+wTC b (AP). Indeed, for d a direction, we consider the formula

z R m d (x, z) ⊗ [wTC ℓ x1,x2 (x 1 = y ⊗ R ℓ d (x 1 , x 2 ))](z, y) ⊕ z = y
where R m d (x, z) is defined almost as in (6.1) but using z instead of ∃z and ⊗ instead of ∧. The only change is the verification x 1 = y in the transitive closure, making sure that we stop the first time y is reached. Notice that if y is not linked to x by a d-path, then the transitive closure will evaluate to 0 which is correct. Then, for every graph G ∈ G(A, D) and valuation σ of variables x and y, its semantics over (G, σ) is either 0 or 1. Moreover, it admits the same semantics as the modulo constraint (x, y) ≡ d m[ℓ]. Henceforth, we use formula (x, y) ≡ d m[ℓ] as a macro in the following.

From Logics to Automata

This section shows in which context series definable by formulae of wFO+wTC b (AP) are recognizable by layered PWA. Indeed, we do not know how to show such a result in general, but instead we need an hypothesis over the graphs on which the automata will run. This restriction consists in considering searchable classes of graphs, as described in [START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF]:

A family of graphs is searchable if there exists a (fixed) [...] deterministic graphwalking automaton with [...] pebbles that, for each graph in the family, and each node of the graph, when started in that node in the initial state the automaton halts after completing a walk along the graph during which each node is visited at least once. [...] Thus the automaton serves as a guide for the family of graphs, and makes it possible to establish and traverse a total order of the nodes of the graph.

We first define formally the notion of searchable class of graphs in our context1 , before giving the translation from logics into automata.

Searchable Classes of Graphs

Definition 6.9. A class of pointed graphs G is said to be searchable if there exists a weighted automaton A G ∈ WA with weights 0 and 1 (and hence independent from the semiring), without free variables, and with two distinguished states q i and q o , verifying that for every pointed graph G = (V, (E d ) d∈D , λ) ∈ G, there exists a total linear order ≤ over V , with minimal element v (i) and either v (f ) = v (i) or v (f ) is the maximal element of ≤, such that for every vertex v ∈ V \ {v (f ) }, there exists a unique non-zero run in A G from configuration (G, q i , v) reaching state q o : this run ends in configuration (G,

q i q o (1⊤)→ (1final?)← (1⊤)← (1¬←?)→ (1⊤)←
q o , v ′ ) where v ′ is the direct successor of v in ≤; 2. if v (f ) = v (i)
, there exists a unique non-zero run in A G from configuration (G, q i , v (f ) ) reaching state q o : this run ends in configuration (G, q o , v (i) ).

A G is called a guide for the class G.

Every class of pointed graphs G which contains only →-ordered pointed graphs is easily searchable, by the automaton A G depicted in Figure 6.2. Hence, the linear order of the previous definition matches the linear order ≤ defined in ordered graphs. However, not only ordered graphs are searchable. For example, pictures are searchable: one possible linear order is to read each line of the picture from left to right. Hence the automaton simply does a right move if it is possible, otherwise, it goes to the next line and comes back to its beginning. Notice that trees are also searchable by using a depth-first-search that may be done using our navigational automata as stated for example in [START_REF] Bojańczyk | Tree-Walking Automata[END_REF], and used in Example 4. 8.

Mazurkiewicz traces are also searchable. Indeed, we enumerate processes in increasing order, and once in the upper vertex of a given process, we may enumerate all vertices related to this process, that have not been visited by smaller processes. Moreover, jumping from a process to the next one can be done unambiguously in the following way: starting from the upper vertex of a process, we explore with a depth-first-search the processes reachable from this vertex, keeping in memory the (finite) set of processes visited so far. We stop when the next process is found, and we simply go up to reach its top vertex. The graphs being connected, this algorithm terminates. On the Mazurkiewicz trace depicted in Figure 2.5, jumping from process 3 to process 4 is achieved in the following way. Starting in the top vertex of process 3, we go down reaching a vertex in common with process 2. We reach the top vertex of process 2, and henceforth jump to process 1. Visiting process 1 stops very quickly, since its other vertex is common with process 2, already in memory. We go back to the top vertex of process 2, and go down. Reaching the vertex in common with process 4 permits to conclude the algorithm. Not all classes of graphs are known to be searchable however. For example, the class of planar graphs is known to be not searchable [START_REF] Rollik | Automaten in Planaren Graphen[END_REF]. Mazes (which are subgraphs of 2-dimensional finite grids) are known to be not searchable [START_REF] Budach | Automata and Labyrinths[END_REF], even if automata are allowed to use one pebble [START_REF] Hoffmann | One Pebbles Does Not Suffice to Search Plane Labyrinths[END_REF]. However, it is an open problem to know if those mazes are searchable with 2 or more layers of pebbles. We have chosen to restrict guides to be automata without pebbles for sake of simplicity, and because our practical examples of structures are all searchable without pebbles. However, we claim that our work may easily be extended with guides using pebbles, in a layered way.

Translation of Formulae into Automata

Theorem 6.10. Let S be a semiring and G a searchable class of pointed graphs. For every formula Φ ∈ wFO+wTC b (FO), there exists a layered pebble weighted automaton A Φ with Free(A Φ ) = Free(Φ), such that for every graph G ∈ G and every valuation σ with domain containing the free variables of Φ, [

[A Φ ]](G, σ) = [[Φ]](G, σ).
Proof. In all of this proof, we consider the guide A G of the searchable class G.

We give a proof by induction over the formulae in wFO+wTC b (FO). We start by proving the property for the unweighted part of wFO+wTC b (FO), i.e., for Booolean formulae of FO. The difficulty lies in the fact that we must simulate a Boolean formula -which henceforth has a weighted semantics [[-]] either 0 or 1 -with weighted automata that do not possess a Boolean fragment. Indeed, we must produce automata that simulate first-order formulae in an unambiguous way. Notice that, at least over the class of words, it could be rather easy to produce a deterministic finite state automaton simulating every first-order formula. However, the size of such an automaton would be non elementary in the size of the formula (because of the alternance of quantifiers), and this is a priori no longer possible with more general classes of graphs (even searchable). Indeed, we propose a totally different construction, that takes advantage of the pebbles, in order to design pebble weighted automata of linear size with respect to the size of the formula. More precisely, for every ϕ ∈ FO, we construct a layered pebble weighted automaton B ϕ having one initial state ι and two (final) states ok and ko such that for all pointed graph G ∈ G and valuation σ : Var ⇀ V with domain containing the free variables of ϕ, the semantics satisfies:

[[B ϕ ι,ok ]](G, σ, v (i) , v (f ) ) = 1 if G, σ |= ϕ 0 otherwise, [[B ϕ ι,ko ]](G, σ, v (i) , v (f ) ) = 0 if G, σ |= ϕ 1 otherwise.
We obtain automaton A ϕ by considering B ϕ with ι (respectively, ok) having initial (respectively, final) weight 1. To get an automaton for the negation of a formula, we simply exchange states ok and ko. These automata will use free variables to encode free variables of formula ϕ.

For formula init(x), the automaton starts by verifying that the initial vertex hosts variable x, and then follows the guide to reach the final vertex of the graph. Formula final(x) is dealt with similarly. For P a (x), the automaton simply scans the input graph using the guide, searching for a vertex that verifies the type a? ∧ x?. Similarly, for formula x = y, at vertex x, we verify that the vertex also holds variable y. For the atomic formula R d (x, y), the automaton scans the input graph, searching for a vertex holding variable x, and at that point follows the edge labeled with direction d to reach vertex holding variable y. It then follows the guide until the final vertex of the graph.

The construction for formula R ⋆ d (x, y) has to be made carefully. Indeed, the automaton must be able to compute both this formula and its negation. The latter states that there is no d-path from x to y: this is the case when either there exists a vertex z without d-successor but with a d-path from x to z not containing y, or there exists a d-cycle containing x but not y. These two conditions, as well as the positive check that x and y are related by a d-path, can be checked with an automaton. This automaton first follows the guide to reach the vertex holding variable x. It then follows the unique d-path until either it reaches y, or it reaches x, or it deadlocks. We finally follow the guide to reach the final vertex and accept or reject depending on the case.

The construction for disjunction ξ = ϕ ∨ ψ is described in Figure 6.3: in this picture, as well as the following ones, when the guide A G is called, we suppose it is from its initial state q i to its final state q o . We start computing ϕ and stop if it is verified, otherwise, we

= ∃x ϕ in case v (i) = v (f )
reset to the initial vertex of the graph using the guide, and check formula ψ. Notice that we use in this figure, and in the following, some transitions labeled with only tests, i.e., non moving transitions. It is not difficult to translate these transitions into our model, e.g., by enforcing the automaton to make a move d followed by its opposite d -1 in a deterministic way, or to remove this non-moving transitions by merging them with the next moving one.

Finally, the construction for existential quantification ξ = ∃x ϕ is described in Figure 6. 4. During a run of this automaton, a pebble of name x is successively dropped over each vertex of the graph using the guide, in order to simulate automaton B ϕ over every vertex: the apparent complexity of the tests in layer 0 takes care of both cases v (i) = v (f ) (then only the transition labeled by init? ∧ final? permits to exit in state ko ξ ) and v (i) = v (f ) (then only the transition labeled by final? ∧ ¬init? permits to exit in state ko ξ ). The simplest automaton, only taking care of the case v (i) = v (f ) is described in Figure 6. 5. If such a run ends in state ok ξ , it means that at some vertex v, formula ϕ has been positively verified (the part of the run in lower layer ended in state ok ϕ ). More precisely, as B ϕ is unambiguous, in that case, all the runs of non-zero weight will end in state ok ξ after dropping the pebble on vertex v, henceforth computing the weight 1, meaning that formula ξ is verified. On the contrary, if no position verifies formula ϕ, all the runs will end in state ko ξ , meaning that ξ is not verified.

It remains to prove that the class of layered pebble weighted automata is closed under the weighted constructs of wFO+wTC b (FO). First, notice that the constant series s ∈ S is easily recognized by a 0-layered PWA, using the guide to go from v (i) to v (f ) and computing the weight s at the beginning of the unique run. Note also that if a series is recognizable by a K-layered pebble weighted automaton, it is also recognizable by a (K + 1)-layered pebble weighted automaton. Therefore, given two layered pebble weighted automata, one can assume that they have the same number of layers, and the same set of pebble names.

Let A 1 , A 2 be two K-layered pebble weighted automata over A. Closure under ⊕ is as usual obtained using the disjoint union of the automata A 1 and A 2 .

The K-layered pebble weighted automaton that recognizes the Hadamard product which maps every graph G and valuation σ to

[[A 1 ]](G, σ) ⊗ [[A 2 ]
](G, σ) consists of three phases: first, it simulates the automaton A 1 until it reaches the final vertex v (f ) in a final state of A 1 ; then, using the guide, it reaches back the initial vertex of the graph, unless v (f ) = v (i) which it can test by using the basic test formula init? on its current position; finally, it simulates the automaton A 2 and exits in a final state of A 2 . Notice that the guide is only used in the topmost layer.

For first-order quantifiers, we use an extra layer. From a K-layered pebble weighted automaton A computing [[Φ(x)]], we construct two (K +1)-layered pebble weighted automata computing respectively [

[ x Φ]] and [[ x Φ]].
Automaton for x Φ follows the guide, and at some point nondeterministically (but not going over v (f ) , and unambiguously as the guide visits exactly once every vertex) chooses a vertex in the graph where it drops pebble x. Then, it simulates automaton A. After this simulation, it lifts the pebble and terminates the computation, going to the final vertex of the graph using again the guide. Notice that the guide visiting each vertex exactly once, the automaton computes exactly the semantics of x Φ.

For x Φ, the new automaton drops successively pebble x on every position of the input graph (again using the guide). Whenever it drops pebble x, it simulates A until it reaches the final vertex where it lifts the pebble.

Finally, assume that we have a K-layered pebble weighted automaton A which evaluates some wFO+wTC b (AP) formula Φ(x, y). We construct a (K + 2)-layered pebble weighted automaton A ′ in order to evaluate [wTC M

x,y Φ](x ′ , y ′ ): x ′ and y ′ are now two free variables. Following the guide, A ′ moves to the vertex v x ′ holding the free variable x ′ . It drops pebble x. Whenever A ′ drops pebble x on some vertex v x , it enters some special state q drop x . Starting again from the beginning, it searches for vertex v x with the guide, and then moves to some guessed vertex v y at a distance less or equal to M , remembering the sequence of directions it uses to reach it. It drops pebble y. In order to compute the transitive closure in an unambiguous way, the automaton now starts to check that the path it followed from v x to v y is the minimal one amongst those that lead from v x to v y : the minimiality criterion we consider is the lexicographic order over the sequences of directions, supposing an order has been fixed over D. To check this, A ′ explores deterministically the (finite) set of sequences of directions of length at most M in the lexicographic order: it stops the first time it reaches vertex v y and rejects the current run if the sequence of directions is not the one recorded before. Now, this sequence can be flushed from the memory: this is particularly interesting for complexity reasons we study after this proof. A ′ then simulates A resulting in the evaluation of Φ(v x , v y ). When the simulation of A is completed, A ′ uses the guide to return to vertex v y . Then, A ′ non-deterministically moves to vertex v x where pebble x was dropped remembering the sequence of directions in the reverse order between both vertices. Again, in order to simulate the transitive closure unambiguously, it checks that the guessed sequence of directions is the minimal one in the lexicographic order. A ′ lifts pebble y and pebble x, and then returns to vertex v y by using the memorized sequence of directions. If y ′ is held by the current vertex, A ′ enters a final state. Also -even if y ′ is at the current vertex -A ′ drops pebble x again in order to continue the evaluation of the transitive closure.

Notice that the layered pebble weighted automaton constructed in this proof has a number of states linear with respect to the size of the formula Φ, defined as the number of operators used in Φ, and denoted by |Φ| in the following. In particular, the constants M appearing in the bounded transitive closuresare not considered for the complexity. We suppose also that the size of A G is constant. In that case, every closure construction adds only a fixed finite number of states. 2 This is an interesting result even in the Boolean case as it shows that we can construct unambiguous layered pebble automata for every formula of first order logic (and even with some transitive closures). Remark 6.11. Notice that it would have been possible to add some other atomic Boolean formulae ϕ and still get the result of Theorem 6.10, as soon as we have an unambiguous automaton B ϕ equivalent to it and its negation. We cite two non-trivial examples here.

Consider the class of trees and a Boolean formula over variables x and y, stating that x is an ancestor of y, i.e., that there exists a {↓ i | i ≥ 0}-path from x to y. The unambiguous automaton for this formula first moves to vertex holding x, and then executes a depth-first search of the subtree rooted in x until either it finds y and accepts, or reaches back x and rejects.

As a second example, consider the class of pictures and a Boolean formula over variables x and y, stating that y is at the bottom-right of x, i.e., that there exists a {↓, →}-path from x to y. Getting an equivalent unambiguous automaton now requires the use of a pebble: indeed, starting from the vertex holding x, we search in every row below and on the right of x if y appears. This is done by marking with a pebble the vertex below x on this row and searching the row from left to right. The pebble is then moved from one row to the following one until the last row.

As a side effect of this translation from logic to automata, it is possible to evaluate a formula of wFO+wTC b (FO) by using the evaluation of layered pebble weighted automata, presented in Theorem 5.4, and get the following complexity result: Corollary 6.12. Let G be a searchable class of pointed graphs. We can compute the semantics This result can be made more efficient when specialized for words, trees or nested words, accordingly to what is showed in Chapter 5.

[[Φ]](G, σ) of a formula Φ ∈ wFO+wTC b (FO) that uses p distinct

From Automata to Logics

This section is devoted to a more theoretical result translating automata formalisms back into logics. Mainly, the aim is to show robustness of the automaton model we exhibited, even though the monadic second order logic is still unreachable by this mean.

Proofs of the next theorems are partly based on ideas present in [START_REF] Thomas | Classifying Regular Events in Symbolic Logic[END_REF] and [START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF]. The idea is to encode runs of automata into a formula using transitive closures. Interestingly, the weighted extension we present -moreover in the case of graphs -leads to new problems in this encoding: it is not sufficient to be able to simulate at least one run for every accepted structure, but this simulation has to be done faithfully with respect to the weights.

We split the proof into two parts. First, we define the notion of zonable classes of graphs, and prove that all of the graph classes we are interested in are zonable. Then, abstracting the technical difficulties inherent of this definition, we start from a zonable class of graphs and prove that we can construct a formula equivalent to a given automaton, for all the graphs of this class.

Zonable Classes of Graphs

Zonability is a combinatorial notion we introduce to cut a graph into small zones, however wide enough to encode each edge relating two distinct zones into one of these two zones. This zone decomposition will be used later to encode runs of a weighted automaton navigating in the graphs, abstracting the internal behaviors of a single zone, and simply considering the jump through edges relating two distinct zones. Henceforth, we also need the zonability to be uniformally computable by a fixed formula for the class. Definition 6. 13. Let A be an alphabet and D be a set of directions. A class G of pointed graphs G(A, D) is said to be zonable if for every natural number3 N ∈ N, there exists a bound M ∈ N such that for every pointed graph G = (V, (E d ) d∈D , λ, v (i) , v (f ) ) ∈ G, there exists

• an equivalence relation ∼ over V such that equivalence classes of ∼, which are called zones, have a diameter bounded by M , i.e., for every pair of vertices v, v ′ of the zone there exists a path composed of vertices of the zones from v to v ′ of length bounded by M . In the following, edges (v, v ′ ) ∈ E such that v ∼ v ′ are called wires, and the set of wires of a graph are denoted by W; • an injective mapping f : W × [0 .. N -1] → V such that for every wire (v, v ′ ) and every integer n ∈ [0 .. N -1], the vertex f ((v, v ′ ), n) is in the same zone as v or v ′ . Moreover, for L a weighted logic, the class G is said to be L-zonable if these objects can be effectively and uniformally definable by unambiguous formulae of L: for every natural number N ∈ N, we must have an unambiguous formula same-zone(z 1 , z 2 ) of L with free variables z 1 and z 2 , and for every n ∈ [0 .. N -1], an unambiguous formula f(z 1 , z 2 , n) = x of L with free variables x, z 1 and z 2 , verifying that for every pointed graph G ∈ G:

• v ∼ v ′ if, and only if, [[same-zone(z 1 , z 2 )]](G, [z 1 → v, z 2 → v ′ ]) = 1; • f ((v 1 , v 2 ), n) = v if, and only if, [[f(z 1 , z 2 , n) = x]](G, [z 1 → v 1 , z 2 → v 2 , x → v]) = 1.
Figure 6.6 depicts a zone partition of the vertices of a graph. In the sequel, wires will be depicted with the same dashed convention, and the red area linked to a vertex v part of a wire (v, v ′ ) depicts the set of vertices f ((v, v ′ ), n) (with n ∈ [0 .. N -1] used to encode this wire.

Notice that a zone, being of diameter bounded by M , must be of size bounded by |D| M , since the graphs we study are of bounded degree. Notice in particular that if a graph has a number of vertices bounded by M -which is verifyable by a formula of FO for example -then we can consider that there is a single zone containing all the vertices, and hence no wires. Therefore, in the examples we give below, we only consider graphs having at least M + 1 vertices. It has to be noticed that wires relate two distinct zones of the graph. Hence, they can be characterized by the formula

wire(z, z ′ ) = x n∈[0 .. N -1] (f(z, z ′ , n) = x)
which is an unambiguous formula as f is an injection.

Before stating the translation theorems, we give a non-exhaustive list of zonable classes of graphs.

Words

Zones of words will be subwords of length 2N (see Figure 6.7), except the last zone that may contain at most positions 3N -1 positions: hence each zone has a diameter bounded by M = 3N -1. They can be described using modulo computations: henceforth, we define formula same-zone(z 1 , z 2 ) by

x (init, x) ≡ → 0[2N ] ⊗ 0≤k1,k2<2N R k1 → (x, z 1 ) ⊗ R k2 → (x, z 2 ) ⊕ 0≤k<3N R k → (x, final) ⊗ 2N ≤k1,k2<k R k1 → (x, z 1 ) ⊗ R k2 → (x, z 2 ) .
Moreover, wires will simply be edges of the form (2kN -1, 2kN ) or (2kN, 2kN -1) (except possibly the last ones). For every integer n ∈ [0 .. N -1], we set f ((2kN -1, 2kN ), n) = 2kN -1n, and f ((2kN, 2kN -1), n) = 2kN + n. This defines an injection as wires are separated by a distance of 2N . These functions may be defined by the following f(z 1 , z 2 , n) = x formula:

R → (z 1 , z 2 ) ⊗ R n → (x, z 1 ) ⊗ ((init, z 2 ) ≡ → 0[2N ]) ⊕ R ← (z 1 , z 2 ) ⊗ R n → (z 1 , x) ⊗ ((init, z 1 ) ≡ → 0[2N ])
Hence, Word(A) is a wFO+wTC b (AP)-zonable class of graphs.

Pictures

Similar ideas to cut pictures into zones have been used for other purposes in [START_REF] Matz | One Quantifier Will Do in Existential Monadic Second-Order Logic over Pictures[END_REF]. Zones of pictures will be square subpictures of width 4N (see Figure 6.8), except the zones on the right and the bottom of the pictures that may be a little larger as in the case of words. The largest zone possible is the one on the right bottom corner which can have width and height bounded above by 6N -1. Hence, each zone has a diameter bounded by M = 2×(6N -1)-1.

Similarly to the previous case, this can be tested using modulo computations. Forgetting, for the sake of simplicity, about the zones on the right and on the bottom, we obtain as Figure 6.8: Zone partitioning of a picture formula same-zone(z 1 , z 2 ):

x,y (init, x)

≡ → 0[4N ] ⊗ (x, y) ≡ ↓ 0[4N ] ⊗ z 0≤k1,k2<4N R k1 → (y, z) ⊗ R k2 ↓ (z, z 1 ) ⊗ z 0≤k1,k2<4N R k1 → (y, z) ⊗ R k2 ↓ (z, z 2 )
Notice that in this formula, y denotes the position at the upper left corner of the zone containing z 1 and z 2 . Each zone (except the larger ones) has at most 4 × 4N wires, and we will encode a wire in the zone from which it exits (as for the case of words): hence each zone must have at least 4 × 4N × N = (4N ) 2 positions available which is exactly the case. Deciding of a decodable order between the wires, it is easy to design a formula f(z 1 , z 2 , n) = x for every n ∈ [0 .. N -1]: for example, we may consider a partitioning of each zone into 4 disjoint rectangles of height N each reserved for the wires of one border of the zone. This shows that Pict(A) is a wFO+wTC b (AP)-zonable class of graphs.

Trees

In ranked trees, we consider zones to be subtrees of height at least 2N with roots at height 0 modulo 2N : in particular, every subtree having a root at height 0 modulo 2N which has height less than 2N is not a zone and hence belongs to the zone which is above it. However, it is easy to check that each zone has a height bounded by 2 × 2N -1, and hence a diameter bounded by M = 2×(4N -1)-1. Notice that the height of a node modulo 2N is computable by a formula of wFO+wTC b (AP), as it suffices to check the length modulo 2N of the unique path leading from the root to the node, which can be done by formula height(x) ≡ k[2N ] Figure 6.9: Chunk decomposition of a nested word: special calls and returns are the square vertices, whereas special wires are depicted with dashed lines. There are 4 chunks, each of call-depth at most 2 × (2N ).

defined by

z (x, z) ∈ R k ↑ ⊗ [wTC 2N x,y (x, y) ∈ R 2N ↑ ](z, init) ⊕ z = init
where we have denoted (x,

y) ∈ R ℓ ↑ the formula z1,...,z ℓ-1 (x, z ℓ-1 ) ∈ R ↑ ⊗ (z ℓ-1 , z ℓ-2 ) ∈ R ↑ ⊗ • • • ⊗ (z 2 , z 1 ) ∈ R ↑ ⊗ (z 1 , y) ∈ R ↑ and (x, y) ∈ R ↑ the formula (x, y) ∈ R ↑1 ⊕ • • • ⊕ (x, y) ∈ R ↑ K with K the maximal arity of a letter in the ranked alphabet A.
Wires are edges that enter or exit the root of a zone: hence, each root, except the root of the whole tree is part of exactly two wires relating the root to its parent. Notice that it is not possible, as for the case of words, to encode a wire in the zone from which it exits. Indeed, a zone may be connected to an exponential number of wires -the wires at the bottomand the zone may not contain enough nodes to encode them all. Instead, we encode a wire in the subtree of the root. Hence, each zone must encode at most 2 × N pairs, which is possible as it contains at least this number of vertices (considering its height). Again, it is easy to decide of a decodable order and to design a formula f(z 1 , z 2 , n) = x: for example, we may consider the leftmost branch of this subtree of length 2N (which exists considering the hypothesis on its height) and use the N first to encode the entering wire, and the others to the exiting wire. This proves that T ree(A) is a wFO+wTC b (AP)-zonable class of graphs.

Nested Words

Let G ∈ N est(A) be a nested word of length n. Notice first that we cannot use the zone partitioning of the underlying word: indeed, since there are nesting edges, each zone may then be wired to too many zones, and it would then be impossible to encode all the wires.

Instead, we describe zones using two levels. First, we cut the nested words into chunks: a chunk is a connected subset of vertices having call-depth of the form 2N k + i for a fixed k and i ∈ [0 .. 2N -1]. For the same reasons than for trees, chunks that are have a size less than 4N -in particular, they necessarily have a call-depth bounded by 2N -are glued to the chunks above them. This implies that every chunk has a call-depth bounded by 2 × 2N . Every chunk (unless the topmost one with smallest call-depth) is surrounded by a pair of special vertices, related by a nesting edge. A chunk decomposition is depicted in Figure 6.9: the special vertices are represented by squares. More formally, we call v a special call (respectively, a special return) if it is a call vertex (respectively, a return vertex) of call-depth a multiple of 2N , such that there are at least 4N positions in-between the vertex and its matched call (respectively return). We call special wires the edges relating one chunk to another: these wires necessarily touch some special vertex.

Notice that we can test if a vertex x has a call-depth equal to 0 modulo 2N with the following expression starting at x:

x? ?→( → + ¬( ? ∨ ?)→) ⋆ ? 2N ⋆ →( → + ¬( ? ∨ ?)→) ⋆ final?
Intuitively, this expression iterates as many times as necessary a sequence of 2N moves decrementing of one unit the call-depth. Each decrement is composed of a →-edge at a return node, followed by the iteration of some moves not changing the call-depth: either a followed by a →, or a → move taking place on an internal vertex (neither a call or a return). After this iteration, we simply verify that the final vertex has the same-call depth than the current vertex.

One first attempt to prove that nested words are zonable could be to express with a logical formula this expression, transforming each Kleene star iteration into a bounded transitive closure. However, this is not immediate, since the external Kleene star iteration is unbounded in the sense that it can make unbounded steps, because of the internal Kleene star.

Henceforth, we test if a vertex x has a call-depth equal to 0 modulo 2N with a more advanced method. We indeed use as a tool summary paths. The summary path issued from a vertex v consists in the shortest path from position v to the final vertex of the nested word. Indeed, it is the only path from v that jumps through the -edges in call vertices, and otherwise follow the →-edges. On the nested word depicted in Figure 2.3 for example, the summary path from vertex 2 (first vertex labeled by b) visits exactly sequentially the vertices 2, 3, 4, 5, 11, 12 and 13. We will say that this vertex is at a summary-distance 6 from the final vertex. More generally, the summary-distance between a vertex v and the final vertex is defined as the length of the summary path issued from v.

We can verify that a vertex x is at summary-distance 0 modulo 2N from the final vertex with the following expression:

x? ( + ¬( ?)→) 2N ⋆ final? .

Notice that this Kleene star iteration is bounded, so that we can design an equivalent formula σ-dist(x) ≡ 0[2N ] of wFO+wTC b (AP) for this expression:

wTC 2N x0,y 2N ( x1,...,x 2N -1 0≤i<2N σ-step(x i , x i+1 ) (x, v (f ) ) with σ-step(x, y) = R (x, y) ⊕ ¬( z R (x, z)) ⊗ R → (x, y) .
The key ingredient is that we can moreover compute the call-depth of a vertex v by following the summary-path issued from v. Consider first a vertex v 0 at a summary-distance 0 modulo 2N from the final vertex. We denote by (v k ) 0≤k≤K the ordered sequence of vertices of the summary path issued from v 0 , with v K = v (f ) . Using the hypothesis over v 0 , we know that K is a multiple of 2N . We will maintain the call-depth modulo 2N of the vertices v 2iN for i ∈ [0 .. K/2N ], checking at the end that the call-depth of vertex v K we computed is 0. We finally explain how to compute the call-depth modulo 2N of the vertices v 2iN with a bounded transitive closure: the transitive closure jumps over vertices v 2iN + c that encode the call-depth c modulo 2N of vertices v 2iN . Henceforth, we must simply design a formula Φ(x ′ , y ′ ) with x ′ encoding v 2iN + c i and y ′ encoding v 2(i+1)N + c i+1 :

Φ(x ′ , y ′ ) = x0,...,x 2N k0,...,k 2N 0≤i<2N β ki,ki+1 (x i , x i+1 ) ⊗ σ-dist(x 0 ) ≡ 0[2N ] ⊗ σ-step k0 (x ′ , x 0 ) ⊗ σ-step k 2N (y ′ , x 2N )
Figure 6.10: Zone partitioning of a nested word and encoding of wires: the special call and returns on the right are parts of 4 wires (2 special wires and 2 non-special ones), and henceforth linked to two zones of encoding each.

where

4 β k,k (z, z ′ ) = R (z, z ′ ) ⊕ ¬( t R (z, t)) ⊗ R → (z, z ′ ) ⊗ ¬( t R (t, z ′ )) β k,k-1 (z, z ′ ) = ¬( t R (z, t)) ⊗ R → (z, z ′ ) ⊗ t R (t, z ′ )
and we denote by σ-step k (x, y) the iteration k times of formula σ-step, which is easily definable in wFO+wTC b (AP).

Then, formula

wTC 4N x ′ ,y ′ Φ(x ′ , y ′ ) (x -c, v (f ) )
when evaluated with x mapped to vertex v 0 (at summary-distance 0 modulo 2N from the final vertex), verifies that this vertex has call-depth equal to c modulo 2N . Notice that variables x and y must be linked by a piece of the summary-path of length 2N , so that variables x ′ and y ′ are at a distance at most 4N , justifying the bound on the transitive closure. Finally, we are able to design a formula c-d(x) ≡ 0[2N ] verifying that vertex x has call-depth 0 modulo 2N , by first considering the first vertex v 0 on the right of x with summary-distance 0 modulo 2N from the initial vertex, and by applying the previous formula with c the call-depth of v 0 deduced from the hypothesis that x has call-depth 0 modulo 2N . This is very easy to check that a call and its underlying return are separated by at least 4N positions, so that we can design formulae sc(x) and sr(y) of wFO+wTC b (AP) checking that x and y are respectively a special call and a special return.

Chunks may be arbitrarily large, and hence may have an unbounded diameter. To overcome this difficulty, we cut each chunk into zones by grouping vertices of a chunk into sets of 3N vertices, following the linear order. As for words, the last zone of a chunk may have between 3N and 4N -1 vertices. In any case, each zone has a diameter bounded by M = 4N -1, and we may design a formula same-zone(z 1 , z 2 ) similarly to the word case.

Finally, wires may be of two types: either a wire relates two vertices of different chunks (called special wires previously), in which case they are encoded into the chunks containing the vertices of greatest call-depth, or a wire relates two vertices of the same chunks, in which case we follow the same kind of encoding as for words. Notice that every zone may have many wires, but only hosts the vertices encoding at most two of them.

An example of zone partitionning, as well as the encoding of wires, is depicted in Figure 6.10. This finishes the outline of the proof that N est(A) is a wFO+wTC b (AP)-zonable class of graphs.

Mazurkiewicz Traces

We finally explain the zonability for the class MT race proc (A) of Mazurkiewicz traces, with a fixed distribution proc : A → P([1 .. n]) of the finite alphabet of rendez-vous or internal actions, into the sets of processes it concerns. We recall that the set of directions is

D = {↓ p , ↑ p | p ∈ [1 .
. n]}, i.e., we can follow the linear orders of each process.

Notice first that there exists a formula x < y whose semantics is exactly the partial order of a trace. Indeed, a vertex v is smaller in this partial order that v ′ if there exists some vertices v = v 1 , v 2 , . . . , v n , v n+1 = v ′ and a permutation σ of the n processes [1 .

. n] such that for all i ∈ [1 .. n], there exists a ↓ σ(i) -path from v i to v i+1 . 5 Then we can easily deduce the following formula x < y of FO:

∃x 1 , . . . , x n+1 (x 1 = x) ∧ (x n+1 = y) ∧ σ permutation of [1 .. n] 1≤i≤n R ↓ σ(i) (x i , x i+1 ) .
As for nested words, the zone partition of a Mazurkiewicz trace is achieved in a hierarchical way: we first split the trace considering only the first process, then considering the second one, etc. For each process, the splitting is done using the computation of some distances modulo a fixed integer on the linear order of this process, as for words. The idea is to consider the history of a vertex of the trace. In a trace G ∈ MT race proc (A), the history of vertex v is the set of vertices that are smaller than or equal to v in the partial order of the trace.

For a given natural number N , we now define the zone splitting of a trace G, with a bound M = 4n 2 N . We first consider the set V 1 of vertices attached to process 1. On the linear order defined by ↓ 1 , we consider all the vertices (v i ) 0≤i≤K1 at distance 0 modulo 2nN from the minimial element of the process: in particular

v i < v i+1 for every i ∈ [0 .. K 1 -1].
As for words, we may not consider the deepest such vertex if it is at a distance less than nN from the last vertex of the process. Those vertices define a partition of the vertices of the trace, by considering the histories they generate: we attach to vertex v i the set of vertices in the history of v i that are not in the history of v i-1 (in case i = 0). The last set of vertices of the partition consists of all the vertices that are not in the history of v K1 . The classes defined by this partition are called 1-classes below.

Notice that a 1-class is necessarily connected, and moreover, the restriction to every process is also connected: if it contains at least one vertex of process p ∈ [1 .

. n], we call minimum and maximum of the 1-class with respect to process p the smallest and the greatest vertices of process p in the class, respectively. If a 1-class contains at most M vertices, it is of diameter bounded by M , then it is considered as a zone. Otherwise, we further split the 1-class. Indeed, if the 1-class contains at least 4n 2 N +1 vertices, there should exist a process p such that at least 4nN + 1 vertices of the class are attached to process p: moreover, p must be different to 1 since each 1-class contains at most 3nN vertices. We consider the smallest p ∈ [2 .

. n] verifying this property. We then split considering the set V p of vertices attached to process p. More precisely, we denote by (v i ) 0≤i≤K2 the vertices attached to process p at distance 0 modulo 2nN from the minimum of the 1-class with respect to process p. Then, we split the 1-class into several p-classes with the same process than before. We may continue this construction until each class is indeed a zone (notice that we split the classes by increasing order of processes which ensures the termination).

We now explain how to build the formula same-zone(z 1 , z 2 ). The checking is done by searching for the hypothetical zone in which z 1 and z 2 could be, by considering the successive p-classes in which the two vertices are. Indeed, every zone is contained in a succession of p-classes, and hence, we represent this zone with the sequence of pairs of minimum and maximum with respect to process p of each p-class in which it is contained. We first consider the 1-class in which z 1 and z 2 lie: this is done in a similar way as for words, i.e., by considering the successive vertices attached to process 1 at a distance 0 modulo 2nN to the minimal element, and stopping when we obtain a vertex that has z 1 and z 2 in its history. We then check the size of the 1-class obtained, to know whether we should continue to split the current class or not. If it is the case, the process p along which we should split can be computed easily, and then, the following splitting is done similarly by considering the distance modulo the minimal element of the class with respect to p.

Finally, the encoding of the wires is very similar to the one of words. Indeed, each zone contains at most 2 wires per process, and hence at most 2n wires. We encode a wire in the zone from which it exits (as for words) so that 2nN vertices are required. Notice, from the construction above, that each p-class contains at least 2nN vertices attached to process p. Hence, the formula f(z 1 , z 2 , n) = x is written by considering any computable ordering of those vertices and the wires of the zone.

This finishes the outline of the proof that MT race proc (A) is a wFO+wTC b (AP)-zonable class of graphs.

Logical Characterization of Weighted Automata

Theorem 6.14. Let G be a wFO+wTC b (FO)-zonable class of graphs in G(A, D). Then, from every weighted automaton A, we can construct a formula Φ A of wFO+wTC b (FO), with Free(Φ A ) = Free(A), that is equivalent to A over G, i.e., such that for every graph G ∈ G and every valuation σ of the free variables of A, we have

[[A]](G, σ) = [[Φ A ]](G, σ).
Proof. From a weighted automaton A with set of states Q, we construct a formula of wFO+wTC b (FO) in several steps. First, we will use an outermost transitive closure in order to make macro steps in the graph, and then compute the weight of the runs in-between macro steps with a tower of transitive closures, inspired by the Kleene theorem. The main difficulty in this second step is that Kleene iterations in our weighted expressions are not naturally bounded (in the sense that they perform jumps of possibly unbounded length): otherwise, we could mimick proof of [START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF] and construct a formula of wFO+wTC(FO) equivalent to the automaton. The current impossibility to translate this fragment of logic back into our automaton model prevents us to use this simpler proof. As a way to overcome this challenge, we cut the input graph into zones that have a bounded diameter. Then, the outermost transitive closure simply jumps from one zone to an adjacent one, and the inner ones simulate the behavior of automaton A over a zone of bounded diameter, using McNaughton-Yamada construction [START_REF] Mcnaughton | Regular Expressions and State Graphs for Automata[END_REF] for example: this ensures that every transitive closure operator performs only bounded jumps.

Using formula same-zone(z 1 , z 2 ) and f(z 1 , z 2 , n) = x for N = |Q|, we may design a formula Ξ qi,q f that computes the weight of the runs from q i at initial vertex to q f at final vertex. Then, the semantics of the automaton A is obtained by considering the formula

qi,q f I qi ⊗ Ξ qi,q f ⊗ α∈Test ϕ α (final) ⊗ F q f (α) .
In this formula and in the following ones, we denote by ϕ α (z) the FO formula -with free variables z and the free variables of α -that permits to verify the local test α ∈ Test over the vertex denoted by z. We can easily associate such a formula with every test by induction, letting

ϕ ⊤ (z) = ⊤, ϕ init? (z) = init(z), ϕ final? (z) = final(z) ϕ a? (z) = P a (z), ϕ d? (z) = ∃y R d (z, y), ϕ x? (z) = (x = z)
and by directly translating the Boolean closure from test formulae to FO formulae.

We first describe a formula single-transition q,q ′ (z 1 , z 2 ) that computes the sum of the weights of the transitions going from vertex z 1 in state q to vertex z 2 in state q ′ : single-transition q,q ′ (z 1 , z 2 ) = d∈D,α∈Test

(ϕ α (z 1 ) ∧ R d (z 1 , z 2 )) ⊗ ∆ q,q ′ (d)(α) .
We will then use a transitive closure to compute the weights of the runs that remain in a given zone, knowing the first and last vertices and the states. This transitive closure will be bounded, since the zone is supposed to be of diameter bounded by M . More precisely, under the condition that vertices z 1 and z 2 are in the same zone Z, formula Φ q,q ′ (z 1 , z 2 ) computes the sum of the weights of the non-empty runs, that remain inside zone Z, going from vertex z 1 in state q to vertex z 2 in state q ′ . To build such a formula, we follow the McNaughton-Yamada algorithm, i.e., we generate formulae Φ R q,q ′ (z 1 , z 2 ) with R ⊆ Q, computing the sum of the weights of the non-empty runs, that remain inside zone Z, going from vertex z 1 in state q to vertex z 2 in state q ′ , that visit as intermediary states only states of R. We will then let Φ q,q ′ (z 1 , z 2 ) = Φ Q q,q ′ (z 1 , z 2 ). We construct these formulae by induction over R. As a base case, we have Φ ∅ q,q ′ (z 1 , z 2 ) = single-transition q,q ′ (z 1 , z 2 ) . Then, if q ′′ / ∈ R, the runs from q to q ′ with intermediary states in R ∪ {q ′′ } either do not visit state q ′′ or visit it at least once. Hence, we may compute their weights with formula

Φ R∪{q ′′ } q,q ′ (z 1 , z 2 ) = Φ R q,q ′ (z 1 , z 2 ) ⊕ z ′ 1 ,z ′ 2 same-zone(z 1 , z ′ 1 ) ⊗ Φ R q,q ′′ (z 1 , z ′ 1 ) ⊗ [wTC M x,y (Φ R q ′′ ,q ′′ (x, y))](z ′ 1 , z ′ 2 ) ⊕ (z ′ 1 = z ′ 2 ) ⊗ same-zone(z ′ 2 , z 2 ) ⊗ Φ R q ′′ ,q ′ (z ′ 2 , z 2 ) .
Finally, formula Ξ qi,q f initializes the run and then uses a transitive closure operator to jump from a zone to the following one (see Figure 6.11):

Ξ qi,q f = q,q ′ ∈Q z1,z2,z ′ 1 ,z ′ 2 same-zone(init, z 1 ) ⊗ Φ qi,q (init, z 1 ) ⊗ x ′ ,y ′ f(z 1 , z ′ 1 , q) = x ′ ⊗ f(z 2 , z ′ 2 , q ′ ) = y ′ ⊗ [wTC 3M x,y Ψ](x ′ , y ′ ) ⊗ same-zone(z ′ 2 , final) ⊗ q ′′ ∈Q single-transition q ′ ,q ′′ (z 2 , z ′ 2 ) ⊗ Φ q ′′ ,q f (z ′ 2 , final) with Ψ(x, y) the formula z1,z2,z ′ 1 ,z ′ 2 q,q ′ ∈Q (f(z 1 , z 2 , q) = x) ⊗ (f(z ′ 1 , z ′ 2 , q ′ ) = y) ⊗ q ′′ ∈Q single-transition q,q ′′ (z 1 , z 2 ) ⊗ Φ q ′′ ,q ′ (z 2 , z ′ 1 ) .
In formula Ψ as well as in the final part of formula Ξ qi,q f , as single transition has to be performed in order to jump through the wire: indeed, formula Φ q,q ′ only remains inside a zone and hence cannot perform it.

Notice that variables x and y in formula Ψ must be at a distance bounded by 3M since each zone has a diameter M and position encoding a wire must be in one of the two zones adjacent to this wire. Formula Ψ(x, y) simply makes the first step jumping over the wire, before using formula Φ q ′′ ,q ′ computing the weights of all the interesting parts of runs. The correctness of this construction follows from the fact that semirings are distributive: indeed, we merge the whole set of runs into subsets visiting the same sequence of wires.

Notice that the set of free variables of formula produced by this proof is exactly the set of free variables of the test formula appearing in the description of the automaton, which is exactly the set of free variables of the automaton.

z 2 z ′ 2 z 1 z ′ 1 x ′ y ′ v (i) v (f )
Figure 6.11: Instantiation of formula Ξ qi,q f 6.

Logical Characterization of Weighted Automata with Pebbles

We now generalize the previous result to also deal with pebbles.

Theorem 6.15. Let G be an wFO+wTC b (FO)-zonable class of graphs in G(A, D). Then, from every layered pebble weighted automaton A, we can construct an equivalent formula Φ A of wFO+wTC b (FO), with Free(Φ A ) = Free(A), equivalent to A over G, i.e., such that for every graph G ∈ G and valuation σ of the free variables of A, we have

[[A]](G, σ) = [[Φ A ]](G, σ).
Proof. Very little has to be done with respect to the proof in the case without pebbles. Indeed, the proof goes by an induction on the number of layers of automaton A. The case of 0 layer is done in Theorem 6.14. Then, considering a (K +1)-layered automaton A, we apply the same construction as before over the states of layer K +1, and simply enriching the formula single-transition q,q ′ (z 1 , z 2 ) to also deal with the pebbles. This formula must now compute the sum of the weights of the transitions from z 1 in state q to z 2 in state q ′ if z 1 = z 2 , and if z 1 = z 2 must compute the sum of the weights of the runs from z 1 in state q to z 1 in state q ′ with intermediary states in lower layers. By induction, for every states q ′ 1 and q ′ 2 of layer K, we have a formula Ξ x q ′ 1 ,q ′ 2 (z 1 ) that computes the sum of the weights of the runs only visiting states of layers at most K from the initial vertex in q ′ 1 to the final vertex in q ′ 2 , initially with pebble x dropped on vertex z 1 . Hence, we now define single-transition q,q ′ (z 1 , z 2 ) by

(z 1 = z 2 ) ⊗ d∈D,α∈Test (ϕ α (z 1 ) ∧ R d (z 1 , z 2 )) ⊗ ∆ q,q ′ (d)(α) ⊕ (z 1 = z 2 ) ⊗ q ′ 1 ,q ′ 2 ∈Q x∈Var α1,α2∈Test (ϕ α1 (z 1 ) ∧ ϕ α2 (final)) ⊗ ∆ q,q ′ 1 (drop x )(α 1 ) ⊗ Ξ q ′ 1 ,q ′ 2 (x → z 1 ) ⊗ ∆ q ′ 2 ,q ′ (lift)(α 2 ) where Ξ q ′ 1 ,q ′ 2 (x → z 1 ) denotes the formula Ξ q ′ 1 ,q ′
2 where free occurrences of x in the test formulae are replaced by z 1 . In particular, if a variable remains free in the automaton A, it will not be replaced in such a way in the construction, so that it will be a free variable of the formula produced.

Hybrid Navigational Logics

As a conclusion of this chapter dealing with logics, we now present some alternative ways of specifying quantitative properties. These are based on Propositional Dynamic Logic (PDL) introduced by Fischer and Ladner in [START_REF] Michael | Propositional Dynamic Logic of Regular Programs[END_REF], and that we formally define later, or XPath: this may seem very close to our weighted expressions, and this is indeed the case, as we designed the latter keeping PDL or XPath in mind. The main difference is the clear separation between state formulae and path formulae (also called programs in the literature). Moreover, in our weighted extension, we clearly separate the Boolean fragment from the weighted part, as we did for the previous logics. In weighted expressions, we inserted no Boolean fragment: henceforth this is the biggest novelty and advantage of this new fragment of logic. As we did for weighted expressions though, we then consider adding some expressive power by adding some variables that can be placed on the graph temporarily: this is refered in the literature as Hybrid Proposition Dynamic Logic (HPDL) (see, e.g., [START_REF] Areces | The Computational Complexity of Hybrid Temporal Logics[END_REF][START_REF] Franceschet | Hybrid Logics on Linear Structures: Expressivity and Complexity[END_REF]). Again, we give some efficient translation from these logics to weighted automata with pebbles. As a corollary, this may permit to apply the evaluation algorithms presented in Chapter 5, and hence extends algorithms presented in [START_REF] Michael | Propositional Dynamic Logic of Regular Programs[END_REF][START_REF] Lange | Model Checking Propositional Dynamic Logic with All Extras[END_REF] for model checking PDL formulae against some fixed Kripke structures.

Indeed, we may alternatively have considered linear temporal logics and their extensions by first-order quantifications, automata, or expressions as done for the Boolean case by [START_REF] Leucker | Regular Linear Temporal Logic[END_REF]. We have investigated this direction in [4]: it can be seen as a special case of the weighted propositional dynamic logic we present in this manuscript. The following example simply presents some ideas specific to temporal logics. Example 6.16. We consider in this example the probabilistic Linear Temporal Logic (LTL) presented in Chapter 1. Using pebbles in probabilistic expressions or automata is a natural and powerful way to deal with nesting in LTL formulae. Indeed, temporal logics implicitly use a free variable to denote the position where a formula has to be evaluated. We will mark this position with a pebble, say x, in expressions E ϕ (x) or automata A ϕ (x) associated with LTL formulas ϕ.

Consider an LTL formula F ϕ, for Finally ϕ. Given a word w and a position i in w, we are interested in the probability [[F ϕ]](w, i) that ϕ holds in w at position i. As reminder, the semantics has been defined by

[[F ϕ]](w, i) = j≥i i≤ℓ<j [[¬ϕ]](w, ℓ) × [[ϕ]](w, j) .
For every LTL formula ϕ, we are aiming at an equivalent hybrid weighted expression E ϕ (x) which evaluates to [[ϕ]](w, i) over word w when pebble x marks position i: in particular, we require the expression to run from the initial position to the final one. Let us illustrate this inductive construction for LTL formulas. For F ϕ, we set

E F ϕ (x) = init?→ ⋆ x? y!E ¬ϕ (y) → ⋆ y!E ϕ (y) → ⋆ final? .
The expression starts at the beginning of the word and moves to the right until it discovers the position marked with variable x. Then, for each j ≥ i, it iterates ji times the computation of ¬ϕ with the current position marked by y, moving to the right between two computations. Finally, it computes ϕ with y!E ϕ (y) before moving to the last position of the word. Indeed, we only need a single variable name, by using the reusability, so that we let

E F ϕ (x) = init?→ ⋆ x? x!E ¬ϕ (x) → ⋆ x!E ϕ (x) → ⋆ final? . Similarly, for G ϕ, we have [[G ϕ]](w, i) = j≥i [[ϕ]
](w, j), leading to the simpler expression

E G ϕ (x) = init?→ ⋆ x? x!E ϕ (x) → ⋆ final? .
The last test (final?) is useful to enforce the preceding star operation to capture the whole suffix of the word from the position marked by x.

Finally, the expression for the Until modality is

E ϕUψ (x) = init?→ ⋆ x? x!(E ¬ψ (x)← ⋆ E ϕ (x)) → ⋆ x!E ψ (x) → ⋆ final? . ok F ϕ ko F ϕ A ϕ (x) ok ϕ ko ϕ → x? → drop x final?lift final?lift → final?
Figure 6.12: Automata for the Finally operator

In terms of automata, let us assume -as in the proof of Theorem 6.10 -that, for every formula ϕ, there is an automaton A ϕ with two designated terminal states, ok and ko, such that runs ending in ok (and at the end of the word) compute expression E ϕ and those ending in ko compute expression E ¬ϕ . The figure below depicts the pebble weighted automaton for the modality Finally. The one for Globally is obtained by considering the equivalence G ϕ = ¬ F(¬ϕ), i.e., by exchanging the states ok ϕ and ko ϕ , as well as the two final states.

Weighted Propositional Dynamic Logic

First, we present the Boolean fragment of formulae from Propositional Dynamic Logic that we consider. It is composed of state formulae α and local path formulae (or programs) π defined by

α ::= ⊤ | init | final | a | x | ¬α | α ∧ α | α ∨ α | Eπ π ::= ⊥ | stay | d | π; π | α? π : π
where a ∈ A, d ∈ D and x ∈ Var. We let DPDL (for Deterministic Propositional Dynamic Logic) the set of state formulae hence defined. The determinism comes from the fact that we can see a program π as deterministic once the state formula α are evaluated (no disjunction or Kleene iteration over programs in particular). We consider this restriction for technical reasons that we stress later.

The semantics of a state formula α is a set of vertices of a graph equipped with a valuation of free variables. The semantics of a path formula π is a set of pairs of vertices of a graph equipped with a valuation of free variables. These semantics are defined in Table 6.3 for a given pointed graph G ∈ G(A, d), for vertices v and v ′ , and a valuation σ of domain containing the free variables of the formula. Remark 6.17. The path formula α? stay : ⊥ is necessarily non moving, in the sense that if G, σ, v, v ′ |= α? stay : ⊥ then v = v ′ , and is indeed equivalent to the state formula α.

The fact that we disallow disjunction and Kleene iteration of path formulae implies the following deterministic condition: Lemma 6.18. Programs of DPDL are deterministic, i.e., for every program π ∈ DPDL, graph G, valuation σ, and vertices v,

• either there exists a unique vertex

v ′ such that G, σ, v, v ′ |= π; • or for all vertices v ′ , G, σ, v, v ′ |= π.
Proof. The proof goes by induction over the program π ∈ DPDL.

If π = ⊥, the second case holds. If π = stay, the first case holds with v

′ = v. If π = d, either d ∈ type(v) (d is enabled in v), in which case the first case holds with v ′ the unique vertex such that (v, v ′ ) ∈ E d , or d /
∈ type(v), in which case the second case holds. If π = π ′ ; π ′′ , by applying the induction hypothesis to π ′ , we may have two cases:

Table 6.3: Semantics of DPDL formulae G, σ, v |= ⊤ G, σ, v |= init if, and only if, v = v (i) G, σ, v |= final if, and only if, v = v (f ) G, σ, v |= a if, and only if, λ(v) = a G, σ, v |= x if, and only if, σ(x) = v G, σ, v |= ¬α if, and only if, G, σ, v |= α G, σ, v |= α ∧ α ′ if, and only if, G, σ, v |= α and G, σ, v |= α ′ G, σ, v |= α ∨ α ′ if, and only if, G, σ, v |= α or G, σ, v |= α ′ G, σ, v |= Eπ if, and only if, there exists v ′ ∈ V such that G, σ, v, v ′ |= π G, σ, v, v ′ |= ⊥ G, σ, v, v ′ |= stay if, and only if, v = v ′ G, σ, v, v ′ |= d if, and only if, (v, v ′ ) ∈ E d G, σ, v, v ′ |= π; π ′ if, and only if, there exists v ′′ ∈ V such that G, σ, v, v ′′ |= π and G, σ, v ′′ , v ′ |= π ′ G, σ, v, v ′ |= α? π : π ′ if, and only if, G, σ, v |= α and G, σ, v, v ′ |= π, or G, σ, v |= α and G, σ, v, v ′ |= π ′
• either there exists a unique vertex v ′ such that G, σ, v, v ′ |= π ′ : the property then follows from the induction hypothesis applied to π ′′ starting in vertex v ′ ; • or for all vertex v ′ , G, σ, v, v ′ |= π ′ , in which case the same property holds for π. Finally, for π = α? π ′ : π ′′ , there are two cases again:

• either G, σ, v |= α, in which case the result follows from the induction hypothesis applied to π ′ ; • or G, σ, v |= α, in which case the result follows from the induction hypothesis applied to π ′′ .

On top of that fragment of logic, we add weights by mimicking the Boolean operators with a weighted semantics. Definition 6.19. We denote by WPDL the class of weighted propositional dynamic logic defined by

ϕ ::= s | ϕ ⊕ ϕ | ϕ ⊗ ϕ | Σψ ψ ::= d | α? ψ : ψ | ϕ | ψ • ψ | ψ + ψ | ψ + where s ∈ S, a ∈ A, d ∈ D and α ∈ DPDL.
As for weighted expressions, the semantics will map a pointed graph, a valuation and either one or two vertex(ices) to a weight of a continuous semiring S, as described in Table 6. 4. As for weighted expressions, we denote in this table, ψ n the n-th iterate of ψ defined inductively by

ψ 1 = ψ and ψ n+1 = ψ n • ψ for n ∈ N .
Remark 6.20. Notice that if ϕ and ϕ ′ are state formulae of WPDL, the weighted path formula α? ϕ : ϕ ′ is necessarily non moving and is indeed equivalent to the state formula Σ(α? ϕ : ϕ ′ ). This is the reason why we did not introduce construction α? ϕ : ϕ ′ directly in the weighted state formulae.

Every weighted expression of WE can be seen as a path formula of WPDL where the Boolean path formulae are disallowed. In particular, notice that a Boolean state formula α Table 6.4: Semantics of WPDL

[[s]](G, σ, v) = s [[ϕ ⊕ ϕ ′ ]](G, σ, v) = [[ϕ]](G, σ, v) ⊕ [[ϕ ′ ]](G, σ, v) [[ϕ ⊗ ϕ ′ ]](G, σ, v) = [[ϕ]](G, σ, v) ⊗ [[ϕ ′ ]](G, σ, v) [[Σψ]](G, σ, v) = v ′ ∈V [[ψ]](G, σ, v, v ′ ) [[d]](G, σ, v, v ′ ) = 1 if G, σ, v, v ′ |= d 0 otherwise. [[α? ψ : ψ ′ ]](G, σ, v, v ′ ) = [[ψ]](G, σ, v, v ′ ) if G, σ, v |= α [[ψ ′ ]](G, σ, v, v ′ ) otherwise. [[ϕ]](G, σ, v, v ′ ) = [[ϕ]](G, σ, v) if v = v ′ 0 otherwise. [[ψ • ψ ′ ]](G, σ, v, v ′ ) = v ′′ ∈V [[ψ]](G, σ, v, v ′′ ) ⊗ [[ψ ′ ]](G, σ, v ′′ , v ′ ) [[ψ + ψ ′ ]](G, σ, v, v ′ ) = [[ψ]](G, σ, v, v ′ ) ⊕ [[ψ ′ ]](G, σ, v, v ′ ) [[ψ + ]](G, σ, v, v ′ ) = n≥1 [[ψ n ]](G, σ, v, v ′ )
can be transformed into a non moving path formula by the construction α? 1 : 0. However, this logic seems strictly more expressive, by the use of a richer Boolean fragment, and the summation operator Σψ. We now prove that we can efficiently translate this logic into the formalism of pebble weighted automata.

Theorem 6.21. Let S be a continuous semiring and G be a searchable class of graphs.

For each path formula ψ in WPDL, we can construct a layered pebble weighted automaton (using a single variable) A ∈ PWA(S) with Free(A) = Free(ψ), equivalent to ψ, i.e.,

[[ψ]](G, σ, v, v ′ ) = [[A]](G, σ, v, v ′ )
for every pointed graph G, every valuation σ with domain containing Free(ψ) and every vertices v and v ′ .

Proof. Once again the proof contains two separate parts: the constructions for the Boolean part, and the ones for the weighted operators.

We first explain the constructions for the Boolean part DPDL. As in Theorem 6.10, we produce, for every Boolean state formula α, a layered pebble weighted automaton B α with one initial state ι and two (final) states ok and ko such that for all pointed graph G ∈ G, every vertex v and every valuation σ,

[[B α ι,ok ]](G, σ, v, v ′ ) = 1 if G, σ, v |= α and v = v ′ 0 otherwise, [[B α ι,ko ]](G, σ, v, v ′ ) = 1 if G, σ, v |= α and v = v ′ 0 otherwise.
Notice that contrary to the previous proof, automaton B α starts in vertex v (which is not encoded as a free variable anymore), and must accept on this vertex. The constructions for all the formulae but the new construct Eπ are very similar to the proof for first-order formulae 6 . E.g., for the atom α = a, the automaton is depicted in Figure 6.13, whereas the disjunction α ∨ α ′ is depicted in Figure 6.14.

B α ok α ko α B α ′ ok α ′ ko α ′ ok α ′′ ko α ′′
For a formula α = Eπ, we follow an exploration close to the first-order existential quantification. Indeed, we start by dropping a pebble x on the current position, in order to be able to come back to it at the end of the computation. However, during the computation of the path formula π we do not use the variable x. When the pebble is dropped, we use the guide to find the pebble again. We now explain how to translate the program π into an automaton B π with a single initial state and two final states ok and ko again. For every graph G, valuation σ, and vertices v, there are two possibilities thanks to Lemma 6.18 • either there exists a unique vertex v ′ such that G, σ, v, v ′ |= π in which case, for every

v ′′ ∈ V : [[B π ι,ok ]](G, σ, v, v ′′ ) = 1 if v ′′ = v ′ 0 otherwise , [[B π ι,ko ]](G, σ, v, v ′′ ) = 0 ;
• or for all vertex v ′ , G, σ, v, v ′ |= π in which case there exists a unique vertex v ′ such that for all v ′′ ∈ V :

[[B π ι,ok ]](G, σ, v, v ′′ ) = 0 [[B π ι,ko ]](G, σ, v, v ′′ ) = 1 if v ′′ = v ′ 0 otherwise .
Automaton B π is produced similarly to the proof of Theorem 4.9 (by induction over π), and the proof works since the programs are supposed to be deterministic. Indeed, automata for atoms ⊥, stay and d are depicted in Figure 6.15, whereas the one for the concatenation is depicted in Figure 6. 16. Notice that it verifies the desired property since, either π is not executable (the second case above), and then the exit point is uniquely determined by it, or π is executable (the first case above) and reach a unique vertex from which we can apply the property to π ′ : however, it can be the case that π; π ′ is not executable but still do not accept in state ko π ′′ in the vertex in which it started. Finally, making use of automaton B α constructed inductively, we give an automaton for program α? π : π ′ in Figure 6.17: again the property is verified for this automaton because the test α is either true or false at the current position and then we can use the inductive property for π and π ′ . Finally, we

B π ok π ko π B π ′ ok π ′ ko π ′ ok π ′′ ko π ′′ Figure 6.16: Automaton for program π ′′ = π; π ′ B α ok α ko α B π ok π ko π B π ′ ok π ′ ko π ′ ok π ′′ ko π ′′ Figure 6
.17: Automaton for program π ′′ = α? π : π ′ obtain the automaton for state formula Eπ as explained before by dropping a pebble, using the guide A G to find it, simulating automaton B π and lifting the pebble to come back to the original vertex (indeed, we need to use the guide again to reach the final vertex before lifting the pebble, but we forget about this search in the picture). This construction is depicted in Figure 6. 18.

It remains to translate the weighted constructions of WPDL. We construct for every state formula ϕ an automaton

A ϕ such that [[A ϕ ]](G, σ, v, v ′ ) = 0 if v = v ′ and [[A ϕ ]](G, σ, v, v) = [[ϕ]](G, σ, v) .
Simultaneously, we construct for every path formula ψ an automaton A ψ such that

[[A ψ ]](G, σ, v, v ′ ) = [[ψ]](G, σ, v, v ′ ) .
These constructions are done with a simulatneous induction.

For base cases, namely s for state formulae and d for path formulae, this is done as for weighted expressions in Theorem 4.9. The sum ϕ ⊕ ϕ ′ and the product ϕ ⊗ ϕ ′ are translated respectively with a non-deterministic choice or a sequential composition: we strongly use at that point that automata A ϕ and A ϕ ′ come back to their original position at the end of their computation. For the Σψ formula, exactly the same construct as for Eπ is done

A G B π ok π ko π ok α ko α drop x lift lift Figure 6
.18: Automaton for state formula α = Eπ in this weighted case: supposing that automaton A ψ is constructed, the automaton starts by dropping a pebble at the current vertex, uses the guide to find it, and then simulates automaton A ψ (ignoring the pebble however); at the end of its computation, we simply lift the pebble (after reaching the final vertex by using the guide again) to come back to the original vertex (since Σψ is a state formula). Path formulae are translated using exactly the same constructions as in the proof of Theorem 4.9: notice that we add the if-thenelse construct that simply use automaton B α before launching one of the two continuations depending on the result obtained.

The number of layers of the automaton constructed is linear in the depth of operators Σ in the formula. Moreover, the number of states of A is linear in the size of ψ. We strongly used the determinism of the Boolean path formulae DPDL in order to obtain this result. Indeed, notice that we could extend the fragment of Boolean path formulae as long as the result of Lemma 6.18 holds: for example, a construction (α?π) ⋆ ; ¬α, iterating the program π as many times as α holds, would still be deterministic and enable the same proof, modulo some cycle checking. As an example, we refer to Chapter 8 where expressions are made deterministic (before adding to them probabilities) in a more general setting.

Hybrid Weighted Propositional Dynamic Logic

In Hybrid Propositional Dynamic Logics, variables are used to mark temporarily some positions in order to be able to come back to it later in the computation. This is similar to the variable feature we adopted in hybrid weighted expressions. Indeed, we simply extend WPDL with an operator x!ψ whose semantics is the semantics of ψ from the initial vertex to the final one with a valuation updated with x mapping to the current vertex. As we restricted ourselves to local Boolean formulae, it is useless to add this operator in the Boolean setting. Definition 6.22. We denote by HWPDL the class of hybrid weighted propositional dynamic logic defined by

ϕ ::= s | ϕ ⊕ ϕ | ϕ ⊗ ϕ | Σψ | x!ψ ψ ::= d | α? ψ : ψ | ϕ | ψ • ψ | ψ + ψ | ψ +
where s ∈ S, a ∈ A, d ∈ D, x ∈ Var, and α ∈ DPDL.

We simply give the definition of the new operator x!ψ: for every graph G, valuation σ and vertices v, v ′ , we let

[[x!ψ]](G, σ, v, v ′ ) = [[ψ]](G, σ[x → v], v (i) , v (f ) ) if v = v ′ , 0 otherwise.
The proof of Theorem 6.21 coupled with the translation of the operator x!-proved in Theorem 4.31 permits to translate efficiently every formula of this extended logic into layered pebble weighted automata. Theorem 6.23. Let S be a continuous semiring and G be a searchable class of graphs. For each path formula ψ in HWPDL, we can construct a layered pebble weighted automaton A ∈ PWA(S) with Free(A) = Free(ψ), equivalent to ψ, i.e.,

[[ψ]](G, σ, v, v ′ ) = [[A]](G, σ, v, v ′ )
for every pointed graph G, every valuation σ with domain containing Free(ψ), and every vertices v and v ′ .

CHAPTER 7 Simple and One-Way Restrictions of the Specification Languages

La semplicità è l'ultima forma della sofisticazione. 1Leonardo da Vinci We consider in this chapter some restrictions of the specification languages that permit to consider non necessarily continuous semirings, and in particular (R, +, ×, 0, 1) and its subsemirings. In order to avoid infinite sums in the semantics, which are no longer welldefined, we have to limit the constructions of expressions and logics, and the power of automata. We mainly focus on automata. In the following, we will consider two possible directions. The first one is of a semantical nature, namely to consider a simple semantics of automata by taking into account only those runs that do not contain cycles. Another orthogonal possibility would consist in a syntactical restrictions over automata, we consider one-way pebble weighted automata, being able to move in ordered graphs only in the forward direction. Indeed, we will see that these two restrictions generate the same behaviors, at least for the word case.

The first section gives a formal definition of a simple semantics of automata, disallowing cyclic runs. In Section 2, we define one-way pebble weighted automata. In both cases, weights are taken from a (non necessarily complete) semiring. We show in Section 3 that this relaxation over the semiring permits to turn the emptiness problem of an automaton undecidable very quickly. Finally, we prove that over words, the semantical and syntactical restrictions generate the same class of formal power series. Last section is devoted to some perspectives. Most of the results are extracted from [1], and further extended to the setting of this manuscript.

Simple Semantics of Pebble Weighted Automata

A run (respectively a K-run) of a weighted automaton (respectively, a pebble weighted automaton) is said to be simple if it contains at most one occurrence of each configuration (respectively K-configuration). Equivalently, a run is not simple if it contains twice the same configuration.

Lemma 7.1. The number of simple runs (respectively, K-runs) of a weighted automaton (respectively, a pebble weighted automaton) over a given pointed graph is finite.

Proof. The number of configurations or K-configurations is finite, and hence so is the number of simple runs which are sequences of pairwise distinct configurations.

The simple semantics of a weighted automaton or a pebble weighted automaton is then adapted from the semantics we defined before by only considering simple runs. In the following, it will be denoted by [[A]] s for a weighted automaton A and [[A]] s,K for a pebble weighted automaton A. Notice that this simple semantics may be defined even in noncontinuous semirings, since the number of simple runs is finite and hence, this semantics only involves a finite summation. Before taking advantage of this relaxation, we consider in the two following propositions cases of continuous semirings. Over Boolean semirings first, this does not add any power. Proposition 7.2. Over the Boolean semiring, both semantics coincide. More precisely, for every pebble weighted automaton A over the Boolean semiring, and integer K (equal to 0 if A is a weighted automaton), we have

[[A]] K = [[A]] s,K .
Proof. In the Boolean semiring, a pointed graph G is mapped to 1 by the semantics [[A]] K if, and only if, there exists an accepting run of A over G that uses only stack of height at most K. If such an accepting run contains a loop, we may simply remove it, i.e., remove all configurations in-between the two occurrences of the same configuration as well as one occurrence of this latter. By repeating this process, we may construct a simple run, which permits to prove that a pointed graph G is mapped to 1 by the semantics [[A]] K if, and only if, there exists a simple accepting run of A over G that uses only stack of height at most K.

This property is very specific to the Boolean semiring, as in other continuous semirings, simple semantics may restrict the power of a weighted automaton. Proposition 7. 3. Over the continuous semiring (R + ∪ {+∞}, +, ×, 0, 1), there exists a series over finite words that is recognizable by a weighted automaton with the usual semantics, and not the simple one.

Proof. Consider the weighted automaton A depicted in Figure 7.1 over alphabet A = {a}, already studied in Example 4. 7.

We fix a pointed graph G ∈ Word(A) with n > 0 vertices. We now show that [[A]](G) = 1 n . To prove it, let p i be the sum of the weights of the runs that start in vertex i ∈ [0 .. n -1] and end in vertex n -1 (in this vertex, any run is blocked as no transition of non-zero weight is still fireable). Indeed, [[A]](G) = p 0 . First, notice that p n-1 = 1 and p 0 = 1 2 p 1 . Then, for every i ∈ [1 .. n -2], we have

p i = 1 2 p i-1 + 1 2 p i+1
This recurrence relation admits as solutions the sequences

p i = λ + µi
since the polynomial X = 1 2 + 1 2 X 2 admits 1 as only root. Then, using the seed equation p n-1 = 1, we obtain λ + µ(n -1) = 1, and using the seed relation p 0 = 1 2 p 1 , it comes λ = 1 2 (λ + µ). We deduce from the second that λ = µ, and with the first conclude that

λ = µ = 1 n
From this, we obtain p 0 = λ = 1 n . Suppose now that there exists a weighted automaton

A such that [[A]] s (G) = 1
|V | for every pointed graph G ∈ Word(A). Denoting by s 1 , . . . , s k the set of non-negative reals appearing in the transition matrix and in the initial and final vectors of A, we obtain that the set of {1/n | n ∈ N \ {0}} should then be entirely included into the N[s 1 , . . . , s k ] the set of polynomials over s 1 , . . . , s k with coefficients in N. A fortiori, {1/n | n ∈ N \ {0}} is also included in ring generated by s 1 , . . . , s k over Z. As the ring generated by {1/n | n ∈ N \ {0}} over Z is Q, this would mean that Q is included in a finitely generated ring over Z, which is false (as the remark after this proof recalls). Finally, this proves that there is no weighted automaton A such that [[A]] s (G) = 1 |V | for every pointed graph G ∈ Word(A). Remark 7. 4. We simply recall why Q cannot be included in a finitely generated ring K over Z. If it was so, considering I a maximal ideal of K, we know that the quotient K/I would be a field (by maximality) which is finite (using, e.g., [START_REF] Bourbaki | Algèbre commutative[END_REF], Corollary 1, page 64). By considering an homomorphism of the ring Q into the ring K, and by taking the quotient of K by I, we would obtain a homomorphism from the field Q to the finite field K/I: however, as a homomorphism of fields is injective, this leads to a contradiction.

The previous proposition shows that loops are indeed useful in weighted automata navigating in graphs (even without pebbles): this must be understood as the fact that the classical semantics is strictly more expressive than the simple one. However, we will see that this is no longer the case if we consider weighted automata (with or without pebbles) that may only visit ordered graphs in a one-way fashion.

One-way Pebble Weighted Automata

We restrict our attention to ordered pointed graphs in this section. Similarly to our study of one-way pebble weighted expression, we will first define a special class of automata that may run over these ordered graphs and generate a semantics even in non-continuous semirings. We will afterwards come back to the relation between these one-way pebble weighted automata and the pebble weighted automata equipped with the simple semantics. Definition 7. 5. A one-way pebble weighted automaton over a semiring S is a pebble weighted automaton A = (Q, A, D, I, ∆, F ) with D an ordered set of directions, verifying • ∆ q,q ′ (d)(α) = 0 for every states q, q ′ ∈ Q, α ∈ Test and backward direction d ∈ D ← ; • if ∆ q,q ′ (lift)(α) = 0 for some states q, q ′ ∈ Q, and test α ∈ Test, then ∆ q ′ ,q ′′ (drop x )(α ′ ) = 0 for every state q ′′ ∈ Q, α ′ ∈ Test and x ∈ Var. The class of all one-way pebble weighted automata over S is denoted by 1PWA(S) or 1PWA if the semiring is clear from the context, or not relevant.

Notice that the second condition is easily justifiable: indeed, a lift transition followed by a drop transition would just result in resetting the current position to the initial vertex of the graph, without dropping a new pebble. Similarly, we may adapt this definition to let 1WA(S) be the class of one-way weighted automata over S (only the first condition is necessary in that case).

As subclasses of PWA and WA, these one-way (pebble) weighted automata inherit the notions of configurations and runs. We show that, over an ordered pointed graph, these automata have a finite number of accepting K-runs for every K. This will permit to define their semantics, even over non-continuous semirings. Indeed, we show that all runs of a one-way (pebble) weighted automaton are simple. Lemma 7.6. All runs of a one-way pebble weighted automaton are simple. As a special case, this is also true for one-way weighted automata.

Proof. Consider a one-way pebble weighted automaton A = (Q, A, D, I, ∆, F ) and its semantics [[A]] K with K ≥ 0: in the following, we only consider K-configurations. Given an ordered pointed graph G, we define a total order on the set of configurations of A over G, so that runs of A over G form an increasing sequence of configurations.

To do so, we consider the measure of a K-configuration (G, σ, q, π, v) (with π ∈ (Var × V ) k , k ≤ K) to be the word over the alphabet V ⊎ {⊥, ⊤} defined by2 meas(G, σ, q, π, v)

=      π |V • v • ⊥ if ∃q ′ ∈ Q, α ∈ Test, x ∈ Var such that ∆ q,q ′ (drop x )(α) = 0 π |V • v • ⊤ otherwise.
We order the set V ⊎ {⊥, ⊤} by the order ≤ given by the ordered graph, and by letting ⊥ < v < ⊤ for every vertex v ∈ V . Henceforth, finite sequences over this set are ordered with the associated lexicographic (total) order, denoted by ≺.

We now show that for every accepting K-run ρ = (G, σ, q m , π m , v m ) 0≤m≤h of A, the sequence of measures of the configurations is increasing, i.e., meas(G, σ, q m , π m , v m ) ≺ meas(G, σ, q m+1 , π m+1 , v m+1 ) for all 0 ≤ m < h. This ensures that the run is simple (and also that it is of bounded length as the set of K-configurations is finite). Let 0 ≤ m < h. The concrete transition from configuration γ m = (G, σ, q m , π m , v m ) to configuration γ m+1 = (G, σ, q m+1 , π m+1 , v m+1 ) has non-zero weight (as the run ρ is accepting). In particular,

• If π m = π m+1 , then the weight of the transition is

d∈D|(vm,vm+1)∈E d α∈Test|G,σπ m ,vm|=α ∆ qm,qm+1 (d)(α)
Using the first condition in the definition of one-way pebble weighted automata, we know that this weight is non-zero only if one of the directions is a forward direction d ∈ D → . By definition of ordered graphs, this ensures that v m < v m+1 . Therefore, for some α, β ∈ {⊤, ⊥}:

meas(γ m ) = (π m ) |V • v m • α ≺ (π m ) |V • v m+1 • β = meas(γ m+1 ) .
• If π m+1 = π m (x, v m ) and v m+1 = v (i) (the initial vertex), then the non-zero weight of the transition is

α∈Test|G,σπ m ,vm|=α ∆ qm,qm+1 (drop x )(α)
Again, this implies that for some α ∈ {⊥, ⊤} we have

meas(γ m ) = (π m ) |V • v m • ⊥ ≺ (π m ) |V • v m • v (i) • α = meas(γ m+1 ) .
• If π m = π m+1 (y, v m+1 ) for some y ∈ Var, then the non-zero weight is

α∈Test|G,σπ m ,vm|=α ∆ qm,qm+1 (lift)(α)
Hence, for some α ∈ {⊥, ⊤} we have

meas(γ m ) = (π m+1 ) |V • v m+1 • v m • α ≺ (π m+1 ) |V • v m+1 • ⊤ = meas(γ m+1 ) .
Notice that the ⊤ in meas(γ m+1 ) comes from the fact that lift transitions may not be followed by drop transitions, by definition of 1PWA. In all cases, we have meas(γ m ) ≺ meas(γ m+1 ), which concludes the proof.

Alternatively, we may define the semantics of one-way (pebble) weighted automata as the simple semantics defined in the previous section. The previous lemma shows that this indeed define the same semantics.

Undecidability of Emptiness

Recall from Theorem 6.1 that the emptiness problem is decidable for layered pebble weighted automata over continuous semirings with no zero divisors. The fact that the semantics of one-way pebble weighted automata may be defined over non-continuous semirings makes the emptiness problem become undecidable.

Theorem 7. 7. The emptiness problem of threshold languages of series recognizable by oneway pebble weighted automata is undecidable. This is already the case when automata have 2 pebbles names, 2 layers and weights in the semiring (Z, +, ×, 0, 1) (in particular, a semiring without zero divisor).

= (ℓ 0 , D 1 , ℓ 1 ) • • • (ℓ n-1 , D n , ℓ n ) ∈ ∆ ⋆ and D ∈ Instr, we set |w| D = |{k ∈ [1 .. n] | D k = D}|, and w j = (ℓ 0 , D 1 , ℓ 1 ) • • • (ℓ j-1 , D j , ℓ j ) for 1 ≤ j ≤ n.
= (ℓ 0 , D 1 , ℓ 1 ) • • • (ℓ n-1 , D n , ℓ n ) ∈ ∆ + such that:
1. ℓ 0 = init and ℓ n ∈ F , 2. c p j (w) ≥ 0 for all j ∈ {1, . . . , n} and p ∈ {1, 2}, 3. if D j = ZTest p , then c p j-1 (w) = 0 for all j ∈ {1, . . . , n} and p ∈ {1, 2}. We also denote c p j (G) the value c p j (w) in the following. The emptiness problem for 2-counter machines consists in deciding whether a given 2-counter machine has an accepting run. It is well known to be undecidable [START_REF] Minsky | Computation: Finite and Infinite Machines[END_REF]. This problem reduces to emptiness of one-way weighted automata with 2 pebble names and 2 layers over (Z, +, ×, 0, 1), as we show now. The value computed to check that the counter always stays non-negative can also be computed with the 1-layered one-way pebble weighted automaton of Figure 7.2: this automaton drops a pebble on each letter Dec p and then computes the difference between the number of Inc p symbols and the number of Dec p symbols before the pebble, using a non deterministic choice to mimic the sum. We now prove that this automaton computes the weight in (7.1).

We fix a graph G ∈ Word(∆) representing a word w = (ℓ 0 , D 1 , ℓ 1 ) • • • (ℓ n-1 , D n , ℓ n ), and denote by i 1 < i 2 < • • • < i m the vertices of G such that D i = Dec p . Notice that each accepting run of the automaton drops pebble x on each vertex i k (for every 1 ≤ k ≤ m), and, after each such drop, must choose a vertex j k to follow the transition from state 2 to state 3: moreover, we have 1 ≤ j k < i k and D j k ∈ {Inc p , Dec p }. Denoting J k the set of such vertices j k for every k, the set of accepting runs is therefore in bijection with the set

J = J 1 × • • • × J m .
The weight of the run defined by the tuple (j k ) 1≤k≤m is then given by

m k=1 f (j k )
where f (j) = 1 if D j = Inc p , -1 if D j = Dec p , and 0 otherwise. Hence, the semantics of the automaton over G is given by

(j k ) 1≤k≤m ∈J m k=1 f (j k ) = j1∈J1 j2∈J2 • • • jm∈Jm m k=1 f (j k ) = m k=1 j k ∈J k f (j k ) (by distributivity of × over +) = m k=1 c p i k -1 (G)
Next, if 2 holds, w violates 3 if, and only if, for some p ∈ {1, 2}, there exists j ∈ Z p such that c p j-1 (G) > 0, that is, if, and only if, . This weight can be computed with the 2-layered one-way pebble weighted automaton of Figure 7. 3. Intuitively, it drops pebble x sequentially on every position performing action ZTest p to compute the external product. When pebble x is dropped (over a vertex j), on every vertex k before the one holding x (i.e., k ≤ j -1), it drops a pebble y choosing non-deterministically either to compute c p j-1 (G) (the upper part) or -k (the lower part). The proof of correctness is done similarly to the previous automaton, and strongly relies on the distributivity of the multiplication over the addition again.

j∈Z p 1≤k≤j-1 (c p j-1 (G) -k) = 0 (7.
Furthermore, automaton A has weight 0 transitions to check if 1 is violated, or if two consecutive letters of ∆ are not consecutive transitions in M. Further, on each position j ∈ D 1 ∪ D 2 ∪ Z 1 ∪ Z 2 , automaton A drops a pebble in order to compute the products (7.1) or (7.2) as explained just before.

It is easy to construct a formula of wFO(AP) equivalent to automaton A, showing that emptiness is also undecidable for wFO(AP). Indeed, the weight of (7.1) may be computed by3

x P Dec p (x)? y y < x ⊗ P Inc p (y) ⊕ (P Dec p (y) ⊗ (-1))

whereas the one of (7.2) may be computed by

x P ZTest p (x)? z z < x? y (-1 ⊗ y ≤ z) ⊕ y < x ⊗ P Inc p (y) ⊕ (-1 ⊗ P Dec p (y))
An anecdotic, yet intriguing, question concerns the emptiness problem of threshold language of automata with one or zero layers. We do not know the decision status of these problems, and let them as open questions.

One-way versus Simple over Words

We show in this section that every pebble weighted automaton equipped with the simple semantics can be effectively translated into an equivalent (over words) one-way pebble weighted automaton, with the same number of layers. Notice that the simple assumption is necessary to state such a result, as Proposition 7.3 exhibits a weighted automaton that cannot be recognized by a simple weighted automaton.

In all the rest of this section, we let D = {→, ←}. The only hypothesis required over the semiring is its commutativity. We suppose at the beginning that the pebble weighted automaton is K-strongly layered, but Proposition 4.29 and Lemma 4.27 show that this is not a restriction indeed.

Theorem 7.8. Let S be a commutative semiring. For every K-strongly layered pebble weighted automaton A with the simple semantics over words, there exists an equivalent Kstrongly layered one-way pebble weighted automaton B with the same set of free variables, i.e., for every non-empty finite word w ∈ A + , and every valuation σ, we have

[[A]] s (w, σ) = [[B]](w, σ).
The proof is by induction on the number of layers. We start with the base case of automata without pebbles. The next proposition is a generalization in the weighted setting of the result, originally proved in [START_REF] Michael | Finite Automata and Their Decision Problems[END_REF], stating that two-way feature does not add expressive power to non-deterministic finite automata over finite strings. There are mainly two proof techniques for this result. Most textbooks presenting this result, or article elaborating over it, use the proof of [START_REF] Shepherdson | The Reduction of Two-Way Automata to One-Way Automata[END_REF], which starts with a two-way automaton and construct an equivalent one-way automaton by enriching the state with a relation table recording for every pair of states (q, q ′ ), whether it is possible to reach q ′ from q with a loop on the current prefix. The key argument is that there is a finite number of such tables and that it can be computed simultaneously to the main run.

Observe that this method is not applicable in our weighted setting. Indeed, the relation table should now be enriched with the precomputed weights of the subruns, which cannot be recorded within a finite memory (as the weights may grow with the length of the prefix read so far). Instead, we will use the crossing-sequence method which is closer to the proof technique in [START_REF] Michael | Finite Automata and Their Decision Problems[END_REF], and fully explained in [START_REF] Hopcroft | An Introduction to Automata Theory, Languages, and Computation[END_REF]. For the sake of clarity, we provide a complete proof below in our weighted setting. In [Ans90], a similar proof was given for weighted automata without pebbles, but we discovered it only after the publication of our article [1]. However, it has to be noticed that our proof is a priori stronger. Indeed, Anselmo considers only syntactically simple weighted automaton, i.e., automata that only generate simple accepting runs, whereas we consider the simplicity as a semantical restriction. Proposition 7.9. Let S be a commutative semiring. For every weighted automaton A with the simple semantics over words, there exists an equivalent one-way weighted automaton B, i.e., for every word w ∈ A + and every valuation σ, we have Intuitively, the idea is to record in a state of B the crossing-sequence of states of A which is observed in some accepting run ρ while scanning the current position of the input word, see Figure 7. 4. Since the simple semantics of a weighted automaton is computed as the sum over simple accepting runs, a crossing-sequence consists of pairwise distinct states and its length is therefore bounded by the number of states of A. Finally, the commutativity of the semiring allows us to compute the weight of an accepting run ρ along a corresponding run of B.

[[A]] s (w, σ) = [[B]](w, σ).
In order to ease the matching of consecutive crossing-sequences of A, we also record in a state of B the input letter from A of the current position, its type (as a subset of D),

• • • a a ′ • • • r 0 → r 1 → r 2 ← r 3 ← r 4 ← r 5 → r 6 → Figure 7
.4: Run of a WA and some crossing-sequences and the sequence of moves from D performed by A. Therefore, we will define Q ′ as a finite subset of

T = A × P(D) × Free(A) × (RD) ⋆ (R ∪ R→) .
The first component records the letter of the current position, the second component its type, and the third the exact set of free variables over it. Those three components together are sufficient to decide whether a test formula α ∈ Test is verified or not over the current position. Indeed, if (a, t, P) ∈ A × P(D) × Free(A), we define in Table 7.1 the satisfaction relation (a, t, P) |= α by induction over α. We can easily verify by induction that for every

(v), type(v), σ -1 (v)) |= α
We say that a state in T is R-simple if the word in its (RD) ⋆ (R ∪ R→)-component does not contain two occurrences of some state in R. For instance, Figure 7.4 exhibits two crossing-sequences which are q = (a, D, ∅, r 0 →r 3 ←r 4 ←r 5 →) and q ′ = (a ′ , D, ∅, r 1 →r 2 ←r 6 →) .

We describe now the transition matrix ∆ ′ of B. Two states q = (a, t, P, τ ) and q ′ = (a ′ , t ′ , P ′ , τ ′ ) in Q ′ can be matched in a transition of B if τ has one more right move than the number of left moves in τ ′ : |τ | → = 1 + |τ ′ | ← . The weight 4 ∆ q,q ′ (→)(a? ∧ t? ∧ P?) associated with this transition is the product of the weights of the transitions of A contained in the pair (q, q ′ ), i.e., right transitions from q to q ′ and left transitions from q ′ to q. On Figure 7.4, these transitions are on a gray background. If q and q ′ cannot be matched we let ∆ q,q ′ to be 0.

Formally, a triple (r, →, r ′ ) with r, r ′ ∈ R is said to be contained in (q, q ′ ) if there exists k ∈ [1 .. |q| → ] such that (1) r is the state just before the kth occurrence of → in q, and (2) r ′ the state just after the (k -1)th occurrence5 of ← in q ′ . Similarly, a triple (r ′ , ←, r) with r, r ′ ∈ R is said to be contained in (q, q ′ ) if there exists k ∈ [1 .. |q ′ | ← ] such that (1) r ′ the state just before the kth occurrence of ← in q ′ , and (2) r is the state just after the kth occurrence of → in q. For instance in Figure 7.4, triples contained in the depicted pair of states are (r 0 , →, r 1 ), (r 5 , →, r 6 ), and (r 2 , ←, r 3 ).

We let Tr(q, q ′ ) be the set of triples contained in (q, q ′ ). We then define the polynomial ∆ ′ q,q ′ (→) ∈ S Test of → transitions of B induced by the matching states (q, q ′ ) as the monomial6 : ∆ ′ q,q ′ (→)(a? ∧ t? ∧ P?) = (r,→,r ′ )∈Tr(q,q ′ ) α∈Test (a,t,P)|=α ∆ r,r ′ (→)(α)

⊗ (r ′ ,←,r)∈Tr(q,q ′ ) α∈Test (a ′ ,t ′ ,P ′ )|=α ∆ r ′ ,r (←)(α) (7.3)
where q = (a, t, P, τ ) and q ′ = (a ′ , t ′ , P ′ , τ ′ ). Finally, the initial vector I ′ maps the R-simple states of the form (a, {→}, P, r→(R→) ⋆ ) or (a, ∅, P, r)

to I r , and all other states to 0. The final vector F ′ must moreover check that the (a, t, P)component of the final state is correct, so that it maps the R-simple states of the form (a, {←}, P, (R←) ⋆ r) or (a, ∅, P, r)

to the monomial of S Test given by F r (a? ∧ t? ∧ P?)

with t = {←} or t = ∅ respectively, and other states to 0. Lemma 7.10 below proves that there is a weight preserving bijection between the simple accepting runs of A and the accepting runs of B. We conclude that Proof. Let G ∈ Word(A) with n vertices be a graph denoting a word w = a 0 • • • a n-1 , and a valuation σ. We first show how to map a simple accepting run ρ = ρ 0 ρ 1 • • • ρ m of A over (G, σ) (where each ρ j is a configuration of the form (G, σ, q, v)), to an accepting run of B over (G, σ).

For i ∈ [0 .. n -1], we construct the crossing-sequence q i = (a i , type(i), σ(i), τ i ) of B associated with vertex i, as illustrated in Figure 7. 4. Formally, we define τ i as the "projection" of the configurations visiting vertex i, where configuration (G, σ, r, i) is "projected" to r→ (respectively, r← or r) if it is followed by some (G, σ, r ′ , i + 1) (respectively, (G, σ, r ′ , i -1) or is the last configuration). Note that the word τ i is R-simple since ρ is a simple run, so that q i ∈ Q ′ .

Observe also that |τ i | → = 1 + |τ i+1 | ← for every i ≤ n -2. Indeed, ρ must reach position i + 1 for a first time, and then, each time the run ρ goes to the left of position i + 1, it will in the future come back to i + 1 from i. Therefore, q i and q i+1 can be matched for all i ≤ n -2. Moreover, the weight ∆ ′ qi,qi+1 (→)(a i ? ∧ type(i)? ∧ σ(i)?) is not equal to zero, since for every triple (r, d, r ′ ) ∈ Tr(q i , q i+1 ) there is at least one weight ∆ r,r ′ (d)(α) of ( 7.3) which is different from 0 (the run ρ being accepting). We deduce that f (ρ) = (G, σ, q 0 , 0) • • • (G, σ, q n-1 , n -1) is an accepting run of B.

We now show that f preserves the weights, i.e., that the weight of ρ in A is equal to the weight of f (ρ) in B, for all simple run ρ of A over (G, σ). Indeed, the weight of ρ in A is the product of the weights of (left or right) transitions appearing in ρ. With f (ρ) = (G, σ, q 0 , 0) • • • (G, σ, q n-1 , n -1), every right transition of ρ starting from vertex i is contained in the pair (q i , q i+1 ), so that its weight is computed in the transition from i to i + 1 in f (ρ), whereas every left transition of ρ starting from vertex i is contained in the pair (q i-1 , q i ), so that its weight is computed in the transition from i -1 to i in f (ρ). We obtain the result by commutativity of the semiring S. Moreover, initial and final weights are preserved by the transformation.

We finally prove that f is a bijection by constructing its inverse function. We consider an accepting run (G, σ, q 0 , 0) • • • (G, σ, q n-1 , n -1) of B. Write q i = (a i , t i , P i , τ i ) for i ∈ [0 .. n -1]: necessarily, t i = type(i) and P i = σ(i). We recover a simple run ρ of A over (G, σ) as the output of Run(0, τ 0 , . . . , τ n-1 ) where the recursive function Run is defined by: Function Run(i, τ 0 , . We can show by induction that f (Run(0, τ 0 , . . . , τ n-1 )) = (G, σ, q 0 , 0)

• • • (G, σ, q n-1 , n -1)
Also, for every simple accepting run ρ of A with

f (ρ) = (G, σ, (a 0 , t 0 , P 0 , τ 0 ), 0) • • • (G, σ, (a n-1 , t n-1 , P n-1 , τ n-1 ), n -1)
we have Run(0, τ 0 , . . . , τ n-1 ) = ρ. Therefore, f is a bijection.

The proof of Proposition 7.9 may be easily adapted to various extensions of weighted automata. For instance, instead of restricting to simple runs when computing the semantics of a weighted automaton A, we may allow k-simple runs (for some fixed k) in which no configuration is visited more than k times. Even when k = 2, we do not know an easy way to construct a weighted automaton A ′ whose semantics over 1-simple runs coincide with the semantics of A over 2-simple runs. But the proof of Proposition 7.9 allows to cope with this extension simply by allowing k-simple words when defining the set Q ′ of states of B. Hence, we can construct a one-way weighted automaton B whose semantics coincides with the semantics of A over k-simple runs, showing that this extension does not add expressive power.

• • • a a ′ • • • r 0 → r 1 → r 2 ← r 3 drop x lift r 4 ← r 5 drop x lift r 6 → r 7 → Figure 7
.5: Run of a pebble weighted automaton and some crossing-sequences

We introduce another extension which will be useful in the proof of Theorem 7.8 below. We generalize the initial and final vectors of a weighted automaton A = (R, A, D, I, ∆, F ) by letting I (respectively, F ) be a mapping from simple sequences of R + to S (respectively, S Test ). The weight of a run is adapted by considering as initial weight the one computed by I over the sequence of states visiting the initial position, and the final weight computed by verifying the test formula on the last configuration of the run as usual. Notice that this is indeed a generalization as every weighted automaton A = (R, A, D, I, ∆, F ) can be encoded into this new formalism by letting I (respectively, F ) map all simple sequences of states starting with a state q (respectively, ending with a state q) to the original initial weight (respectively, final polynomial) of this state. Again, the proof of Proposition 7.9 allows to cope with this extension easily.

We extend now the translation of Proposition 7.9 to pebble weighted automata. The general idea is an induction on the number of layers, but it has to be done with great care so that all and only the simple runs of the weighted automaton are taken into account.

Proof of Theorem 7. 8. We start with a K-strongly layered pebble weighted automaton A = (R, A, D, I, ∆, F ), and a generalized acceptance condition: I (respectively, F ) is mapping of simple sequences in R + to S (respectively, to S Test ). The semantics is computed as previously by appending to the weight of the runs the initial weight of the sequence of states visiting the initial position while no pebbles are dropped, and the final weight of the sequence of states visiting the final position while no pebbles are dropped with the test formula verified on the last configuration of the run. This generalization will be useful in the inductive step of the construction.

If K = 0, Proposition 7.9 permits to conclude, as noticed previously. We now explain the construction for K > 0. By the strongly layered hypothesis, we know that the states in layer K of the automaton may only drop pebbles of a certain name, that we denote by x in the following. In particular, a crossing-sequence may now also include drop x moves, see Figure 7. 5. The parts of a run having at least one pebble dropped (dashed in Figure 7.5) will be deferred to the inductive step. Hence, a crossing-sequence consists only of the states visiting some position when no pebbles are dropped. If the run is simple, then this sequence of states is also simple.

layers K -1, . . . , 0 of A s ′ 0 s 1 (1 init?)→ (∆ q ) s1,r (←)← s ′ 1 (1⊤)← s 2 (1 init?)→ (∆ q ) s2,r (←)← s ′ 2 (1⊤)← s 3 (1 init?)→ (∆ q ) s3,r (←)← s ′ 3 (1 init?)→ (∆ q ) r ′ ,s ′ 3 (←)← (∆ q ) r ′ ,s ′ 1 (←)← (∆ q ) r ′ ,s ′ 2 (←)← Figure 7
.6: The pebble weighted automaton A q filling the drop-lift gaps of the crossingsequence q

As in the proof of Proposition 7.9, we let Q ′ be the (finite) set of R-simple states in T = A × P(D) × Free(A) × (R{←, →, drop x }) * (R ∪ R→). For instance, Figure 7.5 exhibits the crossing-sequence q = (a, D, ∅, r 0 →r 3 drop x r 4 ←r 5 drop x r 6 →) in which the states r 0 , r 3 , r 4 , r 5 , r 6 must be pairwise distinct.

For each state q = (a, t, P, τ ) ∈ Q ′ , we construct a (K -1)-strongly layered pebble weighted automaton A q = (R q , A, D, I q , ∆ q , F q ) which computes the sum of the weights of the tuples of runs filling the drop-lift gaps in the crossing-sequence q, i.e., the dashed lines in Figure 7. 5.

From a crossing-sequence q = (a, t, P, τ ) ∈ Q ′ , we first extract the sequence θ(τ ) of pairs of states surrounding drop x actions. For instance, θ(r 0 →r 3 drop x r 4 ←r 5 drop x r 6 →) = (r 3 , r 4 )(r 5 , r 6 ) and θ(r 1 drop x r 2 drop x r 3 →) = (r 1 , r 2 )(r 2 , r 3 ) .

We assume below that θ(τ ) = (r 1 , r ′ 1 )(r 2 , r ′ 2 ) • • • (r N , r ′ N ) with N > 0, and ℓ(r i ) = ℓ(r ′ i ) = K. Note that N ≤ |R| since r 1 , r 2 , . . . , r N must be pairwise distinct.

We let R q = {r ∈ R | ℓ(r) < K} ⊎ {s ′ 0 , s 1 , s ′ 1 , . . . , s N , s ′ N } be the set of states of A q . The automaton A q should fill the drop-lift gaps (r j , r ′ j ) for all j ∈ [1 .

. N ]. To do so, it simply simulates A from state r j to r ′ j without jumping in layer K: here we use the fact that a pebble weighted automaton may test the presence of a pebble without even having dropped it. The additional states in {s ′ 0 , s 1 , s ′ 1 , . . . , s N , s ′ N } and transitions will make sure that all gaps (r j , r ′ j ) are filled, see Figure 7. 6. States s ′ j-1 are used to reset the head to the initial vertex between two simulations, and we move from s ′ j-1 to s j at the beginning of the word7 :

(∆ q ) s ′ j-1 ,s ′ j-1 (←)(⊤) = 1 for 1 < j ≤ N (∆ q ) s ′ j-1 ,sj (→)(init?) = 1 for 1 ≤ j ≤ N .
A drop x transition of A from state r j , j ∈ [1 .

. N ], to state r of layer K -1 is simulated in A q by a ← transition from s j to r reading the second letter of the word (note that when A q is in state s j it must be on the second position of the word due to the → transition from s ′ j-1 to s j ): it outputs weight (∆ q ) sj ,r (←)(⊤) defined by

(∆ q ) sj ,r (←) = α∈Test (a,t,P)|=α ∆ rj ,r (drop x )(α)⊤ . ( 7.4)
A lift transition of A from a state r ′ of layer K -1 reaching r ′ j , j ∈ [1 .

. N ], is simulated in A q by a ← transition from r ′ to s ′ j given by (∆ q ) r ′ ,s ′ j (←) = a ′ ∈A,P ′ ⊆Free(A) α∈Test (a ′ ,{←},P ′ )|=α ∆ r ′ ,r ′ j (lift)(α)(a ′ ? ∧ {←}? ∧ P ′ ?) .

Finally, when A q reaches s ′ N , it terminates with → moves until the final vertex of the word:

(∆ q ) s ′ N ,s ′ N (→)(⊤) = 1
All other unspecified coefficients of the matrix ∆ q are set to 0.

We finally let I q map simple sequences in

s ′ 0 R ⋆ s ′ 1 R ⋆ • • • s ′ N -1 R
⋆ to 1 and others to 0, and we let F q map simple sequences in R ⋆ s ′ N to 1⊤ and others to 0. Considering these definitions, an accepting run ρ of A q can be split into a sequence of runs ρ

= ρ ′ 0 ρ1 ρ ′ 1 • • • ρN ρ ′ N where for each 1 ≤ j ≤ N
• the run ρj fills the drop-lift gap (r j , r ′ j ). It goes from s j to s ′ j and simulates a run ρ j of A which starts with a drop x transition from r j to a state r of layer K -1, and ends with a lift transition from a state r ′ of layer K -1 to r ′ j without lifting this pebble in-between. Moreover, runs ρj and ρ j have the same weight, for all 1 ≤ j ≤ N ;

• the run ρ ′ 0 consists of a single transition from s ′ 0 to s 1 , the run ρ ′ j for 0 < j < N loops on state s ′ j to reset the head to the initial position and then moves to state s j+1 , and the run ρ ′ N consists of transitions looping on s ′ N to reach the final position. Moreover, runs ρ ′ j have weight 1, for all 0 ≤ j ≤ N . Note that, the run ρ is simple if, and only if, the sequence of runs ρ 1 , . . . , ρ N is globally simple, i.e., a configuration may not occur twice in some ρ j and it may not occur both in ρ i and ρ j with i = j. This is important since the runs ρ 1 , . . . , ρ N fill the drop-lift gaps of the crossing-sequence (a, t, P, τ ) and are therefore part of a single run of A. This explains why we have a single copy of A in A q . If instead we used N copies of A inside A q , one for each drop-lift gap (r j , r ′ j ) then the simplicity of ρ would not imply the global simplicity8 of ρ 1 , . . . , ρ N .

Clearly, all accepting runs of A q start from state s ′ 0 and end in state s ′ N . But this basic initial and final condition is not sufficient to ensure that the drop-lift gaps are filled correctly. For instance, A q could go directly from s ′ 0 to s ′ N without ever visiting s ′ 1 , . . . , s ′ N -1 . It could also visit all the new states but not in the intended order, which would not correspond to a sequence of runs of A filling the gaps (r

1 , r ′ 1 ) • • • (r N , r ′ N )
. This is why we use the generalized acceptance condition for I q .

Towards a uniform construction below, we also define an automaton A q when the crossing-sequence q has no drop x (N = 0). In this case, A q has a single state s ′ 0 with a loop moving right with weight 1 in order to simply scan the word from beginning to end.

By induction, for each q ∈ Q ′ we can construct a (K -1)-strongly layered one-way pebble weighted automaton B q which is equivalent to A q , more precisely, such that for each graph G ∈ Word(A) and each valuation σ, there is a weight preserving bijection between the simple accepting runs of A q over (G, σ) and the accepting runs of B q over (G, σ). We let B q = (Q ′ q , A, D, I ′ q , ∆ ′ q , F ′ q ). Note that, if the crossing-sequence q has no drop then we may choose B q = A q .

We define now the K-strongly layered one-way pebble weighted automaton B = (Q, A, D, I ′ , ∆ ′ , F ′ ) associated with A. Its set of states is

Q = Q ′ ⊎ Q ′ ⊎ q∈Q ′ Q ′ q . Moreover, for 0 ≤ i ≤ n -1 with N i = |τ i | drop x , we extract from ρ the tuple g i = (ρ i 1 , . . . , ρ i Ni ) of subruns of the form (G, σ, r 0 , ε, i)(G, σ, r 1 , π 1 , 0) • • • (G, σ, r k-1 , π k-1 , n -1)(G, σ, r k , ε, i)
where π ℓ = (x, i) • π ′ ℓ for all 0 < ℓ < k, i.e., where the first pebble is continuously dropped on position i.

We first show that f is a bijection from simple accepting runs of A over (G, σ) to the set, denoted Seq G,σ , of sequences (q 0 , g 0 , q 1 , g 1 , . . . , q i , g i , . . . , q n-1 , g n-1 ) verifying:

•

q i ∈ Q ′ for all i ∈ [0 .. n -1], I ′ q0 = 0, and F ′ qn-1 = 0; • for all i ∈ [0 .. n -2], the pair (q i , q i+1 ) matches, i.e., |τ i | → = 1 + |τ i+1 | ← ; • for all i ∈ [0 .. n -1], denoting N i = |τ i | drop x , g i is a tuple (ρ i 1 , . .

. , ρ i

Ni ) of subruns of A, globally simple, each starting with a drop x on position i, ending with the first time this pebble is lifted, and that matches with θ(q i ) (i.e., the jth pair in θ(q i ) contains exactly the pair of first and last states of the run ρ i j ). It is not difficult to check that f (ρ) ∈ Seq G,σ whenever ρ is a simple accepting run of A over (G, σ). We define the weight of such a sequence in Seq G,σ as

I ′ q0 ⊗ n-2 i=0 ∆(g i ) ⊗ ∆ ′ qi,qi+1 (→)(a i ? ∧ t i ? ∧ P i ?) ⊗ ∆(g n ) ⊗ F ′ qn-1
where ∆(g i ) is the product of the weights of runs ρ

i j for j ∈ [1 .. N i ] if g i = (ρ i 1 , . . . , ρ i Ni )
. We can easily show that f preserves the weights.

We finally prove that f is a bijection by constructing its inverse function. For every (q 0 , g 0 , q 1 , g 1 , . . . , q n-1 , g n-1 ) ∈ Seq G,σ , consider q i = (a i , t i , P i , τ i ) for i ∈ [0 .. n -1]. We recover a simple accepting run ρ of A over (G, σ) as the output of RunP(0, τ 0 , g 0 , . . . , τ n-1 , g n-1 ) where the recursive function RunP is defined by: Function RunP(i, τ 0 , g 0 , . . . , τ n-1 , g n-1 )

match τ i with r→τ ′ i : output (G, σ, r, ε, i); RunP (i + 1,(. . . , τ ′ i , g i , . . .)); r←τ ′ i : output (G, σ, r, ε, i); RunP (i -1,(. . . , τ ′ i , g i , . . .)); rdrop x τ ′ i : match g i with (ρ ′ , g ′ i ) : output ρ ′ ; RunP (i,(. . . , τ ′ i , g ′ i , . . .)); r : (* necessarily i = n -1 *) output (G, σ, r, ε, n -1);
We then consider each tuple g i of runs of A with the first pebble x dropped. It has already been explained in the previous proof how to construct a weight preserving bijection between a tuple g i = (ρ i 1 , . . . , ρ i N ), which matches with a sequence of pairs θ(q i ), and an accepting run ρi = ρ

′ 0 ρi 1 ρ ′ 1 • • • ρi N ρ ′ N of A qi over (G, σ[x → i]
) so that g i is globally simple if, and only if, ρi is simple: it consists of filling some gaps (with the runs ρ ′ j ).

Using the induction hypothesis, we know that there is a weight preserving bijection between simple accepting runs ρi of A qi over (G, σ[x → i]) and accepting runs ρ i of B qi over (G, σ[x → i]).

We finally build a weight preserving bijection between accepting runs ρ i of B qi over (G, σ[x → i]) and runs g i of B over (G, σ) from position 0 to position n -1. Finally, coming back to the sequences of Seq G,σ , these intermediary bijections permit to build a weight preserving bijection from sequences (q 0 , g 0 , . . . , q i , g i , . . . , q n-1 , g n-1 ) ∈ Seq G,σ to accepting runs (G, σ, q 0 , ε, 0)g 0 (G, σ, q 0 , ε, 0)

• • • (G, σ, q n-1 , ε, n -1)g n-1 (G, σ, q n-1 , ε, n -1)
of B over (G, σ), which concludes the proof of correctness. This theorem does not hold in the case of more general classes of ordered graphs, as nested words for example. Indeed, even in the Boolean semiring, consider the language of nested words where every call vertex is labeled with the same letter as its matching return. This language is clearly recognizable with an automaton (without any pebbles) walking in the nested word from left to right and checking on every call vertex -by jumping back and forth to its matching return -that these two vertices are labeled with the same letter. Notice that this automaton requires only simple runs. However, it is not difficult to prove that no one-way automaton can recognize this language. Indeed, consider such a one-way automaton A (without pebbles), having n = |Q| states. We consider nested words belonging to the language and of length 2n + 1, where vertex i ∈ [0 .. n -1] is a call vertex matched with the return vertex 2ni, and vertex n is labeled with a fixed letter. Over an alphabet with two letters, there are 2 n such nested words, since it suffices to choose the labels of the n first vertices (those of index i ∈ [0 .. n -1]). For each of these nested words, automaton A must have an accepting run, that visits every vertex (otherwise we may easily swap the labels of one of the vertex not visited and obtain a contradiction). As it is one-way, it necessarily visits the first n vertices before the n last ones. Considering the state reached on vertex n (the one with a fixed letter), there are two distinct nested words with this state being identical. By considering the nested word composed of the first n letters of one, and the last n ones of the other, we obtain a nested word that is not in the language, but that is recognized by A. Hence, this contradicts the existence of a one-way automaton recognizing the language.

However, even for general classes of graphs, every layered pebble weighted automaton equipped with the simple semantics is equivalent to a weighted graph automaton, namely a graph automaton covering graphs with tiles as described, e.g., by [START_REF] Thomas | On Logics, Tilings, and Automata[END_REF], where transitions are moreover equipped with weights. This model has been explored in [START_REF] Fichtner | Characterizations of Recognizable Picture Series[END_REF]. We do not investigate the question in further details in this manuscript but the idea is again to use crossing-sequences: whereas for words, we can verify with a one-way automaton that two successive crossing-sequences can be matched, we need the power of graph automata for more general classes of graphs. For example, in nested words, at a given return vertex, we may use the information of the corresponding call vertex to check if the crossing-sequences form a real run.

Restrictions over Expressions and Logics

We informally propose in this last section some possibilities to restrict expressions and logics to remove the need of computing infinite sums. Throughout this section, we only consider ordered graphs. Hence, we let D be an ordered set of directions, and we denote by D → and D ← the partition of D into forward and backward directions. We also fix a semiring (S, ⊕, ⊗, 0, 1), not necessarily continuous.

One-way Weighted Expressions

Restricting ourselves to continuous semirings seems somewhat annoying but unavoidable in order to ensure the well-definition of the semantics of expressions E + which, in the most general case, involve an infinite sum (see Table 3.2). Mimicking one-way pebble weighted automata, we may consider one-way hybrid weighted expressions, with a proper restriction, as considered by Schützenberger: proper expressions are the only expressions allowed under a Kleene star operation. Hence, we consider the set of one-way hybrid weighted expressions E defined by the following grammar:

E ::= s | α | x!E | E | E + E | E • E E ::= d → | E + E | E • E | E • E | E +
where s ∈ S, α ∈ Test, d → ∈ D → , and x ∈ Var. Expressions E are called proper one-way hybrid weighted expressions.

As a subclass of HWE, one-way hybrid weighted expressions inherits their semantics from those of hybrid weighted expressions, in the case of a continuous semiring. We now show that, indeed, we can extend the semirings to non necessarily continuous ones. Lemma 7.12. Let E and E be respectively a one-way and proper one-way hybrid weighted expression. Then,

[[E]](G, σ, v, v ′ ) = 0 implies v ≤ v ′ and [[E]](G, σ, v, v ′ ) = 0 implies v < v ′
for every ordered pointed graph G ∈ G(A, D), vertices v, v ′ ∈ V and valuation σ : Var ⇀ V , where ≤ denotes the order on the vertices of G.

Proof. The proof is by simultaneous induction over one-way and proper one-way hybrid weighted expressions. For convenience, we present first the induction over one-way hybrid weighted expressions.

If E = s ∈ S, E = α ∈ Test or E = x!E ′ , [[E]](G, σ, v, v ′ ) = 0 implies v = v ′ , and hence v ≤ v ′ .
If E = E is proper, we directly conclude by induction.

If E = E 1 + E 2 , then [[E]](G, σ, v, v ′ ) = 0 implies that either [[E 1 ]](G, σ, v, v ′ ) = 0 or [[E 2 ]](G, σ, v, v ′ ) =
0 (as 0 ⊕ 0 = 0), which permits to conclude by induction.

If

E = E 1 • E 2 , then [[E]](G, σ, v, v ′ ) = 0 implies that there exists a vertex v ′′ ∈ V such that [[E 1 ]](G, σ, v, v ′′ ) ⊗ [[E 2 ]](G, σ, v ′′ , v ′ ) = 0, and hence that both [[E 1 ]](G, σ, v, v ′′ ) = 0 and [[E 2 ]](G, σ, v ′′ , v ′ ) = 0 (
as 0 ⊗ s = s ⊗ 0 = 0 for every s ∈ S). By induction, this proves that v ≤ v ′′ and v ′′ ≤ v ′ , which permits to deduce that v ≤ v ′ by transitivity.

We now turn to the part of the induction proof related to proper one-way hybrid weighted expressions

. If E = d → ∈ D → , [[E]](G, σ, v, v ′ ) = 0 implies (v, v ′ ) ∈ E d→ : by definition of ordered graphs, this ensures that v < v ′ . The proofs in case E is of the form E 1 + E 2 , E 1 • E 2 or E 1 • E 2 are similar to the one-way case, achieved previously. Finally, if E = (E 1 ) + , then [[E]](G, σ, v, v ′ ) = 0 implies that there exists n ≥ 1 such that [[(E 1 ) n ]](G, σ, v, v ′ ) = 0. An easy induction over n permits to show that [[(E 1 ) n ]](G, σ, v, v ′ ) = v1,...,vn-1∈V n-1 j=0 [[E 1 ]](G, σ, v j , v j+1 )
where we let v 0 = v and v n = v ′ . Hence, we can deduce that there exists v 1 , . . . , v

n-1 ∈ V such that for all j ∈ [0 .. n -1], [[E 1 ]](G, σ, v j , v j+1 ) = 0. By induction, this shows that v = v 0 < v 1 < • • • < v n-1 < v n = v ′ Knowing that n ≥ 1, this shows by transitivity that v < v ′ .
This lemma shows that the a priori infinite sum used to define the semantics of E + contains indeed only a finite number of non-zero elements, and hence exists in all semirings S: more precisely, if n is the number of vertices in an ordered pointed graph G, and E is a proper one-way pebble weighted expressions, we have

[[E k ]](G, σ, v, v ′ ) = 0
for every k ≥ n + 1, valuation σ : Var ⇀ V (with Free(E) ⊆ dom(σ)), and v, v ′ ∈ V . Finally, we have shown that we can define the semantics of one-way hybrid weighted expressions with weights in a semiring, non necessarily continuous.

We believe that it is now possible to prove another correspondence theorem between one-way pebble weighted automata and one-way hybrid weighted expressions. The idea would be to adapt the proof of Theorem 4.31 so that both constructions ensure the one-way restrictions. Starting with an automaton, we would need to prove that the proof of the general case (in particular the computation of the star of a matrix) still goes through this one-way restriction: even though the set of series over (dynamically) marked graphs is no longer a continuous semiring, we think that it would be possible to extract from it a star semiring (see e.g., [START_REF] Kuich | Semirings, Automata and Languages[END_REF] for a formal definition) considering only proper marked graphs, i.e., those in which initial and final vertices are not the same. For the other direction, the construction of an automaton from an expression is exactly the same, and only the proof of correctness has to be adapted, again dealing with star semirings.

Our choice of one-way pebble weighted expressions may seem too restrictive. In particular, for the operator x!E, it is not absolutely necessary that E is one-way too. We could also imagine that E is going backward only, or more generally is changing from a forward to a backward computation and vice versa only a finite number of times. However, Kleene iterations must still be applied over expressions using only one type of directions, and being proper. Hence, a Kleene operator will only be allowed over forward-proper or backwardproper expressions, namely expressions that may only move in one direction, and will not stay on the same position. An alternative restriction would then consist in defining simultaneously forward, forward-proper, backward, backward-proper and one-way hybrid weighted expressions by the following grammar:

E ::= F | B | E + E | E • E F ::= s | α | x!E | F | F + F | F • F F ::= d → | F + F | F • F | F • F | F + B ::= s | α | x!E | B | B + B | B • B B ::= d ← | B + B | B • B | B • B | B + where s ∈ S, α ∈ Test, d → ∈ D → , d ← ∈ D ← ,
and x ∈ Var. Expressions F (respectively, B) are called forward hybrid weighted expressions (respectively, backward hybrid weighted expressions), whereas their underlined versions are their proper versions.

The proof of Lemma 7.12 can easily be adapted to prove that Lemma 7. 13. Let F and F be respectively a forward and proper forward hybrid weighted expression. Then,

[[F ]](G, σ, v, v ′ ) = 0 implies v ≤ v ′ and [[F ]](G, σ, v, v ′ ) = 0 implies v < v ′ for every ordered pointed graph G = (V, E, λ, χ, v (i) , v (f ) ) ∈ G(A, D), vertices v, v ′ ∈ V and valuation σ : Var ⇀ V
, where ≤ denotes the order on the vertices of G.

Similarly, let B and B be respectively a backward and proper backward hybrid weighted expression. Then,

[[B]](G, σ, v, v ′ ) = 0 implies v ′ ≤ v and [[B]](G, σ, v, v ′ ) = 0 implies v ′ < v .
Indeed, only the base case of formulae x!E has to be adapted, and the proof for the backward version is symmetrical. Hence, this shows that we can again define the semantics of one-way hybrid weighted expressions with weights in a semiring, not necessarily continuous.

In the case of words, reversal-bounded hybrid weighted expressions can not generate more behaviors than one-way hybrid weighted expressions. Indeed, using Theorem 4.31 again, reversal-bounded hybrid weighted expressions can be translated into pebble weighted automata that do not loop: in particular, we can use their simple semantics and use Theorem 7.8 to transform them into one-way pebble weighted automata. We may then conclude by the result stated before linking one-way hybrid weighted expressions and one-way pebble weighted automata.

First-order logic with Restricted Transitive Closure

We now finish this chapter by presenting a logical fragment permitting to express exactly the expressive power of pebble weighted automata equipped with a simple semantics. We have studied this extension in [1] in a slightly different formalism and thus do not develop it further in this manuscript.

Indeed, the idea is to restrict the transitive closure to a simple and a one-way transitive closure, as we did for automata.

The simplicity restriction, which is a semantical restriction, permits to define a transitive closure in non-continuous semirings. For a formula Φ(x, y) with at least two free variables x and y, the simple weighted transitive closure operator [swTC x,y Φ](x ′ , y ′ ) has as free variables the fresh variables x ′ and y ′ , and all the free variables of Φ except x and y. Its semantics is defined by the same formula as in (6.3) where the sum now runs over all m > 0 and all sequences (v k ) 0≤k≤m of vertices of the graph G with v 0 = σ(x ′ ) and v m = σ(y ′ ), such that, either m = 1, or m > 1 and all positions of the sequence are pairwise distinct. This sum is finite as the graph has finitely many vertices. Notice that if σ( For the one-way restriction, we introduce the operator wTC →

x ′ ) = σ(y ′ ) = v, then the semantics is [[Φ]](G, σ[x → v, y → v]).
x,y Φ whose semantics consists in restricting the sum of (6.3) when m > 1 to increasing sequences (v k ) 0≤k≤m of vertices of the ordered graph G. Equivalently, we can define it by wTC →

x,y Φ = swTC x,y (x ≤ y ⊗ Φ) = (x = y ⊗ Φ(x, y)) ⊕ wTC x,y (x < y ⊗ Φ) as the simplicity condition ensures that non-decreasing simple sequences of length m > 1 are indeed increasing. Intuitively, the wTC → x,y operator generalizes the forward transitive closure operator of the Boolean case: a formula ϕ(x, y) with two free variables defines a binary relation on positions of a word w, namely {(i, j) | (i < j) ∧ w, i, j |= ϕ}. The relation defined by wTC →

x,y ϕ is the transitive closure of this relation. An alternative to define the semantics of this operator, is to use powers of the formula: we define recursively the m-th power of a formula Φ, with this one-way restriction

Φ 1 ≤ (x, y) = (x ≤ y) ⊗ Φ(x, y), Φ m+1 ≤ (x, y) = z (x < z < y) ⊗ Φ(x, z) ⊗ Φ m ≤ (z, y) , for m ≥ 1.
The left-to-right restriction of the transitive closure permits finally to give a third equivalent definition, a priori simpler to use:

[[wTC → x,y Φ]] = m≥1 [[Φ m ≤ (x, y)]] .
This infinite sum is well-defined, since on each pair (G, σ), only finitely many terms assume a nonzero value: indeed [[Φ m ≤ (x, y)]](G, σ) = 0 if m ≥ |V |, the number of vertices of G. Finally, we can reconsider the bounded restriction considered in Chapter 6, and introduce bounded one-way and bounded simple weighted transitive closure operators, respectively denoted by wTC b→

x,y Φ and swTC b x,y Φ. Following exactly the same proof as the one of Theorem 6.10 with the one-way restriction over the transitive closure, we would be able to prove that every formula of wFO+wTC b→ (FO) can be translated into an equivalent layered one-way pebble weighted automaton 1PWA, over a searchable class of graphs. This is an extension of Theorem 11(3) in [1].

Reciprocally, we proved in the case of words in [1] that layered pebble weighted automata equipped with the simple semantics can be translated into a formula of wFO+wTC b→ (FO), first by making them one-way and then by mimicking the proof we gave in a more general setting for Theorem 6.15.

CHAPTER 8 Probabilistic Specification Formalisms

Les grands artistes ont du hasard dans leur talent et du talent dans leur hasard. 1Victor Hugo, Océan Prose This chapter is devoted to the study of probabilistic specifications. There are actually a variety of models for probabilistic systems, comprising Segala systems, generative systems, stratified systems, Markov chains, etc. (see [START_REF] Van Glabbeek | Reactive, Generative and Stratified Models of Probabilistic Processes[END_REF][START_REF] Segala | Probability and Nondeterminism in Operational Models of Concurrency[END_REF] for overviews). Those models may involve non-determinism and generate some behavior according to probability distributions over states. Alternatively, they may make a probabilistic decision depending on the input letter, like (reactive) probabilistic automata [START_REF] Paz | Introduction to Probabilistic Automata[END_REF]. The latter go back to Rabin [START_REF] Michael | Probabilistic Automata[END_REF] and are an object of ongoing research considering decision problems such as emptiness, language equivalence [Sch61, Tze92, CMR06, KMO + 12], and the value 1 problem [START_REF] Gimbert | Probabilistic Automata on Finite Words: Decidable and Undecidable Problems[END_REF].

Our starting point of view, as in all this manuscript, is that specifications shall represent quantitative properties of graphs. In particular, rather than at bisimulation equivalence, we are looking at language equivalence in terms of formal power series, i.e., mappings from graphs to elements from the real-valued interval [0, 1]. Our goal is to apply our results in this particular case of probabilistic specifications. Especially, what kind of probabilistic properties can we specify with hybrid weighted expressions/pebble weighted automata/formulae? As a first attempt, we could simply consider these specification formalisms with weights restricted to the subset [0, 1] of the continuous semiring (R + ∪ {+∞}, +, ×, 0, 1). However, this first naive solution is not satisfactory. Indeed, having only weights in [0, 1] does not ensure that the semantics of every graph will lie in the interval [0, 1] and henceforth be interpreted as a probability.

In the first section, we consider pebble probabilistic automata (that capture two-way probabilistic automata [START_REF] Dwork | On the Power of 2-Way Probabilistic Finite State Automata[END_REF][START_REF] Ravikumar | On some Variations of Two-Way Probabilistic Finite Automata Models[END_REF] over words for instance) and define the class of hybrid probabilistic expressions, as a syntactical fragment of hybrid weighted expressions. In particular, the sum and the Kleene star operator have to be handled with care. We prove that these two models generate exactly the same probabilistic behaviors: it has to be noticed that we have not been able to avoid redoing the whole proof of Theorem 4.31.

In the second section, we study the special case of classical Rabin probabilistic automata, i.e., one-way automata over finite words. We define a set of probabilistic expressions that are equivalent to probabilistic automata.

It has to be noted that there have been numerous approaches to characterizing probabilistic systems in terms of algebraic expressions and process calculi [vGSS95, BK01, DP07]. A unifying framework is due to [START_REF] Silva | Quantitative Kleene Coalgebras[END_REF], who consider probabilistic systems in a general coalgebraic setting. This allows them to derive algebraic expressions and a corresponding Kleene theorem, as well as full axiomatizations for many of those (and even for weighted automata over arbitrary semirings). Their and above-mentioned works are mainly aiming at axiomatization of probabilistic-system behaviors in terms of bisimulation equivalence, so their focus is on system models including non-determinism and generative probability distributions. In this chapter, we consider probabilistic automata, which are a more appropriate machine model for our purpose, e.g., for evaluating queries. Moreover, while the syntax of process-algebraic expressions is tailored to modeling probabilistic systems and uses action prefixing, fixed points, and process variables, we provide expressions with concatenation and a Kleene star. Thus, our expressions are closer to language-theoretic operations and more convenient to use in query languages.

Note that the fact that we also consider navigating devices distinguishes our work from all above-mentioned references. To the best of our knowledge, we present the first Kleene-Schützenberger correspondence for probabilistic two-way automata. Results of this chapter have been presented in [3] in the case of words.

Throughout this chapter, we consider the continuous semiring (R + ∪ {+∞}, +, ×, 0, 1).

Pebble Probabilistic Automata

In this section and the following, we explain how to interpret (pebble) weighted automata and (hybrid) weighted expressions in a probabilistic setting. Considering first automata, not every pebble weighted automaton with weights in the subset [0, 1] of the semiring (R + ∪ {+∞}, +, ×, 0, 1) can be interpreted as a probabilistic automaton. Indeed, a first property of interest should be that every graph (e.g., word) is mapped to a weight in [0, 1]. The definition below puts some syntactical restrictions over the pebble weighted automata to ensure it. Naturally, they have the flavor of those for probabilistic Rabin automata, as introduced in [START_REF] Michael | Probabilistic Automata[END_REF].

We reuse here ideas introduced in the proof of Theorem 7.8, namely the fact that a test formula α can be verified using a finite abstraction of the current configuration of an automaton. Whereas only three components were needed over words (namely the letter, the type and the set of pebbles), we now add two more Booleans b i and b f in {0, 1} to check respectively formula init? and final?. Indeed, we define (a, τ, P, b i , b f ) |= α as in Table 7.1, simply changing the cases where α is either init? and final? by A pebble probabilistic automaton (PPA) is a pebble weighted automaton A = (Q, A, D, I, ∆, F ) over (R + ∪ {+∞}, +, ×, 0, 1) such that the following conditions hold:

if, v = v (i) (respectively, v = v (f ) ). Then, G, σ, v |= α if, and only if, (λ(v), type(v), σ -1 (v), b i (v), b f (v)) |= α .
1. I is a probability distribution over the states, i.e., q∈Q I q = 1; 2. for all q ∈ Q, and local configuration γ ∈ Γ, we have

2 α∈Test|γ|=α F q (α) + m∈Actions,q ′ ∈Q ∆ q,q ′ (m)(α) ≤ 1 .
The idea is to ensure that for every possible configuration, the transition function defines a probability distribution over the possible continuations (or termination), i.e., the next action to follow, and the next state. Remark 8.2. In the following, a state q ∈ Q will be said accepting if F q is different from 0.

A priori, [[A]

] K associates to every pair (G, σ) of graph and valuation an element of R + ∪ {+∞}. However, one can show the following: Proposition 8.3. For every pebble probabilistic automaton A and bound K > 0, every graph G ∈ G(A, D) and every valuation σ, we have

[[A]] K (G, σ) ∈ [0, 1].
Proof. For every pair (G, σ), we prove that the graph of K-configurations is a finite Markov chain, so that the semantics [[A]] K (G, σ), being interpreted as a probability to reach a set of states of the Markov chain, must be in [0, 1].

We first recall that a K-configuration has the shape (G, σ, q, π, v) with q ∈ Q, π ∈ (Var(A) × V ) k with k ≤ K, and v ∈ V . For a fixed pair (G, σ), this generates a finite set of states for the Markov chain. To this set of K-configurations, we add a single fresh state denoted .

Clearly, the initial distribution reflects the distribution I, so that the K-configuration (G, σ, q, ε, v (i) ) has initial probability I q and others have probability 0.

The transitions of the Markov chain are defined by the concrete transitions between K-configurations (G, σ, q, π, v) ❀ (G, σ, q ′ , π ′ , v ′ ), whose weight has been defined after Definition 4.19. Moreover, we add a transition from any final K-configuration (G, σ, q, ε, v (f ) ) to the state with probability defined by the polynomial F q where test formulae are again interpreted as before. It is not difficult to see that the weights only depend on the lo-

cal configuration (λ(v), type(v), σ -1 (v), b i (v), b f (v))
, so that the restriction of Definition 8.1 actually generates a Markov chain.

Finally, the semantics [[A]] K (G, σ) is the probability to reach the state , so that it belongs to [0, 1].

The proof above establishes a strong connection between pebble probabilistic automata and finite Markov chains. This connection also provides an algorithm for evaluating a pebble probabilistic automaton with respect to a given graph and valuation, which reduces to computing the probability of reaching a final configuration in the synchronized Markov chain (see, for example, [START_REF] Baier | Principles of Model Checking[END_REF]). where s = 1-p p , for every G ∈ Word(A).

Hybrid Probabilistic Expressions

Now, we define hybrid probabilistic expressions that capture the expressive power of probabilistic pebble automata. These are syntactical restrictions of hybrid weighted expressions in HWE. In the following, we consider hybrid weighted expressions with weights in [0, 1], modulo the following trivial identities:

0 + E ≡ E + 0 ≡ E E • 0 ≡ 0 • E ≡ 0 E • 1 ≡ 1 • E ≡ E 0 * ≡ 1 as well as p • E ≡ E • p (for p ∈ [0, 1
]) which models commutativity.

As for automata, we have to restrict the syntax of expressions since otherwise values greater than 1 could be obtained. For instance, the weighted expression over words (a + ab)(ba + a) should not be a probabilistic expression since it evaluates to 2 on the word aba. The restriction will be both on sum and star.

Since we aim at expressions which are equivalent to pebble probabilistic automata, we examine first which type of hybrid weighted expressions are obtained from pebble probabilistic automata by applying our construction of Theorem 4.31 (interpreting a pebble probabilistic automaton as a pebble weighted automaton). For the example automaton in Figure 8.2, the weighted expression would be 1 6 a(a + b) + 1 2 a ⋆ • ( 1 3 a? + b?). Now, the expression 1 6 a(a + b) + 1 2 a ⋆ • (a? + b?), obtained by changing the subexpression 1 3 a? into a?, should be disallowed, because it corresponds to an automaton violating the condition over its transition matrix. On the other hand, 1 6 a(a+b)+ 1 2 a * •( 1 3 a?+ 1 2 b?) would be acceptable: we obtain a corresponding probabilistic automaton from the previous automaton depicted in Figure 8.2 by setting P(1, b, 3) = 1 2 . Henceforth, we will restrict the sum and star operations to get the probabilistic fragment. Doing so, we lose commutativity, associativity and distributivity hence we enforce these properties explicitly. The rule for introducing concatenation is also strengthened to allow concatenation inside a context: if E 1 + E 2 and G are probabilistic expressions, so does • the atom rules:

E 1 + E 2 • G.
(p) p ∈ [0, 1] p ∈ HPE (α) α ∈ Test α ∈ HPE (d) d ∈ D d ∈ HPE
• the inductive rules:

(+ det ) E 1 ∈ HPE E 2 ∈ HPE α ∈ Test α • E 1 + (¬α) • E 2 ∈ HPE (+ prob ) E 1 ∈ HPE E 2 ∈ HPE p ∈ [0, 1] p • E 1 + (1 -p) • E 2 ∈ HPE (•) E 1 + E 2 ∈ HPE G ∈ HPE E 1 + E 2 • G ∈ HPE (⋆) E 1 + E 2 ∈ HPE E ⋆ 1 • E 2 ∈ HPE (x!) E ∈ HPE x ∈ Var x!E ∈ HPE
• the following associativity, commutativity and distributivity rules (later denoted as ACD-rules):

A + E + (G + H) ∈ HPE ←→ (E + G) + H ∈ HPE C + E + G ∈ HPE ←→ G + E ∈ HPE A • E • (G • H) ∈ HPE ←→ (E • G) • H ∈ HPE D • E • (G + H) ∈ HPE ←→ E • G + E • H ∈ HPE D • (E + G) • H ∈ HPE ←→ E • H + G • H ∈ HPE D x! x!(E + G) ∈ HPE ←→ x!E + x!G ∈ HPE
There are two guarded sums. The first one (+ det ) is deterministic and guarded by a test formula. The second one (+ prob ) is probabilistic. Also, the star operation contains an implicit choice which is either to iterate again the expression or to exit the loop. This choice also has to be guarded which is the reason for the precondition E 1 + E 2 ∈ PE in the rule (⋆). The guard could be deterministic as in (ab) ⋆ b, i.e., (a? • → • b? • →) ⋆ • b? • → when written in plain, or probabilistic as in ( 13 (aa + bb)) ⋆ 2 3 . Finally, with the above restrictions, we lose the classical ACD identities, hence we enforce these properties explicitely with the ACD-rules which allow to rewrite a hybrid probabilistic expression in order to apply the star rule as needed.

The semantics of hybrid probabilistic expressions is inherited from the one of hybrid weighted expressions. It is not straightforward that expressions from HPE generate only probabilistic behaviors, in particular because of the rules (•) and (⋆). We will indeed not prove it directly but obtain this fact from Theorem 8.8 translating every hybrid probabilistic expression into an equivalent pebble probabilistic automaton. Moreover, let G = p(¬final?)→ + (1p)← so that E = G ⋆ final? p. Notice that E is indeed an expression in HPE because G + final? p ∈ HPE, since it can be rewritten by ACD-rules, and equivalences into p(final? + ¬final?→) + (1p)← ∈ HPE.

We define now the multiset Terms(E) of terms of an expression E ∈ HPE. This will be crucial for the translation from expressions to automata in the next section. Intuitively, if we suppose that summation is pushed up as much as possible by means of ACD-rules, then the multiset of terms consists of all expressions that occur in this big outermost sum. Formally, the definition is by induction over E ∈ HPE. When E is an atom, we let Terms(E) = { {E} } be the singleton multiset containing only the atom itself. Moreover,4

Terms(

E 1 + E 2 ) = Terms(E 1 ) ⊎ Terms(E 2 ) Terms(E 1 • E 2 ) = { {E ′ 1 • E ′ 2 | E ′ 1 ∈ Terms(E 1 ), E ′ 2 ∈ Terms(E 2 )} } Terms(E ⋆ ) = { {E ⋆ } } Terms(x!E) = { {x!E ′ | E ′ ∈ Terms(E)} } .
Note that, if an expression G can be obtained from an expression E through ACD-rules, then we have Terms(G) = Terms(E). Also, it is immediate by induction that the converse also holds:

Lemma 8.7. Let E ∈ HPE with Terms(E) = { {E i | i ∈ I} }. Using ACD-rules, we can rewrite E into i∈I E i . In particular, we have [[E]] = i∈I [[E i ]]
. Henceforth, we identify E and i∈I E i .

Notice finally that, by making use of the context in the rule (•), any sum of (some) terms of a probabilistic expression is also a probabilistic expression: if I ′ ⊆ I we get i∈I ′ E i ∈ HPE by concatenating expression 0 after expressions E i with i / ∈ I ′ , and applying equivalences.

The Probabilistic Kleene-Schützenberger Theorem

We prove in this section that pebble probabilistic automata are effectively equivalent to hybrid probabilistic expressions. Notice that we cannot simply use the proof of the general Schützenberger-Kleene theorem, stated in Theorem 4.31, as there are restrictions both on the automata and the expressions, which are of different natures.

We start with the construction of automata from expressions. The problematic cases are concatenation and iteration due to the precondition E + F ∈ HPE. To deal with these cases, we construct from E ∈ HPE a pebble probabilistic automaton A which simultaneously recognizes all terms of E. Theorem 8.8. From any expression E ∈ HPE, we can effectively construct an equivalent layered pebble probabilistic automaton A = (Q, A, D, I, ∆, F ). More precisely, if Terms(E) = { {E i | i ∈ I} }, the set of accepting states of A is {f i | i ∈ I} and for all i ∈ I the expression E i is equivalent to the pebble probabilistic automaton A[f i ] = (Q, A, D, I, ∆, F ) obtained by considering f i as only accepting state, i.e., F fi = F fi and F q = 0 for q = f i . Proof. The construction is by structural induction on the expression E ∈ HPE. As for Theorem 4.31, the automaton we construct is a standard automaton, i.e., it has a unique initial state ι, with no ingoing transition. We have depicted in Figure 8.3 the pebble probabilistic automaton A constructed from a hybrid probabilistic expression E. In particular, we separate the matrix ∆ of transitions, in blocks, J regrouping the transitions from the initial state ι, and N the transitions from (and to) states distinct from ι.

ι 1 F ι F f1 F f2 . . .
In this proof, we say that A and E are equivalent if, for all graphs G ∈ G(A, D), valuation σ : Free(E) → V , and vertices u, v ∈ V ,

[[E]](G, σ, u, v) = q,q ′ ∈Q I q × [[A q,q ′ ]](G, σ, u, v) × α∈Test|G,σ,v|=α F q ′ (α) .
The cases p ∈ [0, 1], α ∈ Test, and d ∈ D are done as in the non-probabilistic case. For each atom, the resulting automaton is in fact a probabilistic automaton, making use of the fact that F may contain some test for the expression α.

Now let E, E ′ ∈ HPE be such that Terms(E) = { {E i | i ∈ I} } and Terms(E ′ ) = { {E ′ j | j ∈ J } }. By induction hypothesis, we have constructed two suitable pebble probabilistic automata A = (Q, A, D, I, ∆, F ) and A ′ = (Q ′ , A, D, I ′ , ∆ ′ , F ′ ) with respective accepting states {f i | i ∈ I} and {f ′ j | j ∈ J }. Without loss of generality, we assume that Q ∩ Q ′ = ∅, and we denote ι and ι ′ their respective unique initial states.

Consider E ′′ = αE + ¬αE ′ . We have Terms(E ′′ ) = { {αE i | i ∈ I} } ⊎ { {¬αE ′ j | j ∈ J } }. We construct a pebble probabilistic automaton A ′′ = (Q ⊎ Q ′ ⊎ {ι ′′ }, A, D, I ′′ , ∆ ′′ , F ′′ ) with a fresh state ι ′′ , unique initial state in the distribution I ′′ . We let

F ′′ ι ′′ = α ′ ∈Test F ι (α ′ ) (α ∧ α ′ ) + F ′ ι ′ (α ′ ) (¬α ∧ α ′ )
whereas F ′′ q = F q if q ∈ Q and F ′′ q = F ′ q if q ∈ Q ′ . From the new initial state ι ′′ , we duplicate each transition from ι to a state q ∈ Q by testing moreover the formula α, and similarly for transitions to q ′ ∈ Q ′ :

∆ ′′ ι ′′ ,q (d)(α ∧ α ′ ) = ∆ ι,q (d)(α ′ ) for q ∈ Q, α ′ ∈ Test, d ∈ D ∆ ′′ ι ′′ ,q (d)(¬α ∧ α ′ ) = ∆ ′ ι ′ ,q (d)(α ′ ) for q ∈ Q ′ , α ′ ∈ Test, d ∈ D
∆ ′′ q,q ′ = ∆ q,q ′ for q, q ′ ∈ Q ∆ ′′ q,q ′ = ∆ ′ q,q ′ for q, q ′ ∈ Q ′

The construction for E ′′ = pE + (1p)E ′ is similar, and depicted in Figure 8. 4. We simply multiply the probability of the first transition from ι ′′ by the probability p or 1p depending on whether the next state is in Q or Q ′ , and let F ′′ ι ′′ = pF ι + (1p)F ′ ι ′ . Notice that in the picture, we did not mention the previous initial states ι and ι ′ as they are not reachable anymore.

For the concatenation, we assume that E = G + H and E ′′ = G + H • E ′ . We have I = K ⊎ L with Terms(G) = { {E i | i ∈ K} } and Terms(H) = { {E i | i ∈ L} }. Hence, we have

ι ′′ 1 pF ι + (1 -p)F ′ ι ′ F f1 F f2 . . . F fn N pJ F ′ f ′ 1 F ′ f ′ 2 . . . F ′ f ′ n ′ N ′ (1 -p)J ′
G N J F ′ f ′ 1 . . . F ′ f ′ n ′ N ′ F fm J ′ . . . F ′ f ′ 1 . . . F ′ f ′ n ′ N ′ F fn J ′                H • E ′
E ′′ = G + H • E ′ Terms(E ′′ ) = { {E i | i ∈ K} } ⊎ { {E i • E ′ j | (i, j) ∈ L × J } }.
Notice that the construction used in Theorem 4.9 does not work here, because of the requirement to keep track of the different terms of the expression. The idea is rather to use multiple copies of A ′ , one for each term of E ′′ , as depicted in Figure 8. 5. More precisely, the automaton A ′′ for E ′′ consists of one copy of A and a copy A ′ i of A ′ for every i ∈ L. First, A ′′ simulates A until it reaches some final state f i of A. Then, if i ∈ L, transitions starting from the initial state of A ′ i are duplicated from f i in the same way as previously. The accepting states of A ′′ consist of {f i | i ∈ K} and a copy of accepting states in Q ′ for each i ∈ L.

For the Kleene star, we assume that E = G + H and E ′′ = G ⋆ • H. We have I = K ⊎ L with Terms(G) = { {E i | i ∈ K} } and Terms(H) = { {E i | i ∈ L} }. Hence, we have Terms(E ′′ ) = { {G ⋆ • E i | i ∈ L} }. We construct the pebble probabilistic automaton A ′′ = (Q, A, D, I, ∆ ′′ , F ′′ ) with accepting states {f i | i ∈ L} and by duplicating transitions exiting from ι, to transitions from the states f i for i ∈ K.

Construction for E ′′ = x!E is done similarly as for the non-probabilistic case: however, as for the previous construction for the rule (•), we need to keep track of the terms of E ′′ , henceforth we must duplicate the final states. More precisely, the terms of E ′′ are of the form x!E i for all terms E i of E. Hence, we construct the automaton We turn now to the construction of expressions (HPE) which are equivalent to automata (PPA). We cannot directly follow the same procedure as in the non-probabilistic case (Theorem 4.31). Indeed, we must ensure throughout the proof that we produce expressions in HPE. To this aim, we strongly rely on ACD-rules. The rough idea is again to construct a generalized automaton and remove one by one each state (Brzozowski-McCluskey algorithm), starting with the deepest layers. For the purpose of the presentation, we rather follow a method similar to the McNaughton-Yamada algorithm. For each state q ∈ ℓ -1 (k) (k < K), we let End q = γ∈Γ γ? • α∈Test|γ|=α q ′ ∈ℓ -1 (k+1)

A ′′ = (Q ⊎ {ι ′′ } ⊎ {f ′′ i | ι 1 . . .
∆ q,q ′ (lift)(α) be the hybrid probabilistic expression representing the lift transitions starting from state q: it is a hybrid probabilistic expression since α∈Test|γ|=α q ′ ∈ℓ -1 (k+1)

∆ q,q ′ (lift)(α) ∈ [0, 1] by using the fact that A is a pebble probabilistic automaton, and by using repeatedly rule (+ det ) over each local configuration 5 . Similarly, when q ∈ ℓ -1 (K), we let

End q = γ∈Γ γ? • α∈Test|γ|=α F q (α)
which is a hybrid probabilistic expression, for the same reason.

For each q ∈ ℓ -1 (k) (k ≤ K), we will construct a hybrid probabilistic expression

E q = End q + q ′ ∈ℓ -1 (k)
E q,q ′ • End q ′ with E q,q ′ that computes the sum of the probabilities of non-empty runs starting from state q, ending in state q ′ and visiting only states in layers 0, . . . , k. This construction is by induction on k ∈ {0, . . . , K}. Within each layer k ≤ K, we follow usual procedures to translate automata into expressions.

For q ∈ ℓ -1 (k) and X ⊆ ℓ -1 (k) we let End X q = End q if q ∈ X 1 otherwise.

and we will construct by induction on X a hybrid probabilistic expression E X q = End q + q ′ ∈ℓ -1 (k) E X q,q ′ • End X q ′ .

For every q, q ′ ∈ ℓ -1 (k), [[E X q,q ′ ]](G, σ, v, v ′ ) is the sum of the probabilities of non-empty runs starting from configuration (G, σ, q, v, ε), ending in configuration (G, σ, q ′ , v ′ , ε), with intermediary states either in X or in layers 0, . . . , k -1. Notice in particular that E q = E ℓ -1 (k) q . We now present the details of the induction over (k, X) (with the lexicographic order): for presentation purpose, we start by first presenting the base case on X, i.e., X = ∅, for k = 0 and then k > 0, followed by the inductive step on X, common for all k.

• Consider first the construction for X = ∅. Recall that, for each state q ∈ ℓ -1 (k), and for every local configuration γ ∈ Γ, by definition of pebble probabilistic automata, we have α∈Test|γ|=α F q (α) + m∈Actions,q ′ ∈Q ∆ q,q ′ (m)(α) ≤ 1 . (

-We start with the case k = 0 and K = 0. Now, since q is in layer 0, drop actions may be discarded. Moreover, layer 0 is the only layer, so that lift transitions are also discarded. Starting from (8.1) and using (+ det ) rule repeatedly, we obtain that γ∈Γ γ? • α∈Test|γ|=α F q (α) + d∈D,q ′ ∈ℓ -1 (0)

∆ q,q ′ (d)(α) is a hybrid probabilistic expression. Hence, using ACD-rules and rule (•), expression

E ∅ q = γ∈Γ γ? • α∈Test|γ|=α F q (α) + q ′ ∈ℓ -1 (0) γ∈Γ γ? • α∈Test|γ|=α d∈D ∆ q,q ′ (d)(α) • d
is a hybrid probabilistic expression. We conclude by letting

E ∅ q,q ′ = γ∈Γ γ? • α∈Test|γ|=α d∈D ∆ q,q ′ (d)(α) • d
and noticing that the first term of the sum in E ∅ q is equal to End q and that End ∅ q ′ = 1. -In case k = 0 but K > 0, layer 0 is not the topmost layer. Henceforth, we will consider lift transitions, rather than the probabilities of acceptance: starting again from (8.1), we obtain that γ∈Γ γ? • α∈Test|γ|=α q ′ ∈ℓ -1 (1)

∆ q,q ′ (lift)(α) + d∈D,q ′ ∈ℓ -1 (0)

∆ q,q ′ (d)(α) is a hybrid probabilistic expression. Similarly to the previous case, expression

E ∅ q = γ∈Γ γ? • α∈Test|γ|=α q ′ ∈ℓ -1 (1)
∆ q,q ′ (lift)(α) + q ′ ∈ℓ -1 (0) γ∈Γ γ? • α∈Test|γ|=α d∈D ∆ q,q ′ (d)(α) • d is a hybrid probabilistic expression. We conclude as previously letting

E ∅ q,q ′ = γ∈Γ γ? • α∈Test|γ|=α d∈D
∆ q,q ′ (d)(α) • d .

-We then consider the case 0 < k = K. Compared to the case k = 0, we also have to consider drop transitions which lead to the lower layer. By induction, we have already constructed expressions E ℓ -1 (k-1) r for all states r ∈ ℓ -1 (k -1) of the lower layer:

E ℓ -1 (k-1) r = End r + r ′ ∈ℓ -1 (k-1) E ℓ -1 (k-1) r,r ′ • End r ′ .

Recall that

End r = γ∈Γ γ? • α∈Test|γ|=α q ′ ∈ℓ -1 (k)

∆ r,q ′ (lift)(α) .

By applying ACD-rules, we obtain that E ℓ -1 (k-1) r is equivalent to the hybrid probabilistic expression

q ′ ∈ℓ -1 (k) γ∈Γ γ? • α∈Test|γ|=α ∆ r,q ′ (lift)(α) + r ′ ∈ℓ -1 (k-1) E ℓ -1 (k-1) r,r ′ • γ∈Γ γ? • α∈Test|γ|=α ∆ r ′ ,q ′ (lift)(α) .
We may use the rule (x!), as well as ACD-rules again to obtain the hybrid probabilistic expression

G r = q ′ ∈ℓ -1 (k) G r,q ′ G r,q ′ = x! γ∈Γ γ? • α∈Test|γ|=α ∆ r,q ′ (lift)(α) + r ′ ∈ℓ -1 (k-1) E ℓ -1 (k-1) r,r ′ • γ∈Γ γ? • α∈Test|γ|=α ∆ r ′ ,q ′ (lift)(α) .
Then, if q ∈ ℓ -1 (k), (8.1) can be rewritten (removing the lift transitions since we are in the topmost layer) as α∈Test|γ|=α F q (α) + α∈Test|γ|=α d∈D,q ′ ∈ℓ -1 (k)

∆ q,q ′ (d)(α) + ∆ q,r (drop x )(α) • G r is a hybrid probabilistic expression. Finally, using ACD-rules a last time, we may rewrite it as γ∈Γ γ?

• α∈Test|γ|=α F q (α) + q ′ ∈ℓ -1 (k) γ∈Γ γ? • α∈Test|γ|=α d∈D ∆ q,q ′ (d)(α) • d + x∈Var(A) r∈ℓ -1 (k-1) ∆ q,r (drop x )(α) • G r,q ′
We conclude as previously by letting

E ∅ q,q ′ = γ∈Γ γ? • α∈Test|γ|=α d∈D ∆ q,q ′ (d)(α) • d + x∈Var(A) r∈ℓ -1 (k-1)
∆ q,r (drop x )(α) • G r,q ′ .

-The last case, 0 < k < K, requires to combine the two last cases: indeed, contrary to the case k = K, lift transitions rather than probabilities of acceptance have to be taken into account.

• We turn now to the induction step on X, which is common for every layer k. Let X ⊆ ℓ -1 (k) and r ∈ ℓ -1 (k) \ X. By induction, we assume that hybrid probabilistic expressions E X q have been constructed for all q ∈ ℓ -1 (k). We construct E X∪{r} q

.

We have E X r = End r + q ′ ∈ℓ -1 (k) E X r,q ′ • End X q ′ ∈ HPE and End X r = 1 since r / ∈ X. With rule (⋆) we get

G X r = E X r,r ⋆ • End r + q ′ ∈ℓ -1 (k)\{r} E X r,q ′ • End X q ′ ∈ HPE .
Now, E X q = End q + q ′ ∈ℓ -1 (k) E X q,q ′ • End X q ′ ∈ HPE and End X r = 1. Using rule (•), we can plug G X r after E X q,r and we obtain the hybrid probabilistic expression

E X∪{r} q = End q + E X q,r • G X r + q ′ ∈ℓ -1 (k)\{r} E X q,q ′ • End X q ′ = End q + E X q,r • E X r,r ⋆ • End r + q ′ ∈ℓ -1 (k)\{r} E X q,q ′ + E X q,r • E X r,r ⋆ • E X r,q ′ • End X q ′ = End q + q ′ ∈ℓ -1 (k) E X∪{r} q,q ′ • End X∪{r} q ′
where the last equality uses End X∪{r} r = End r and End

X∪{r} q ′ = End X q ′ if q ′ ∈ ℓ -1 (k) \ {r}.
Finally, the HPE q∈ℓ -1 (K) I q • E q is equivalent to the automaton A which concludes the proof.

What it Implies for Rabin Probabilistic Automata

We finish this chapter by some corollaries of the previous result in terms of classical probabilistic finite automata as introduced and studied in [START_REF] Michael | Probabilistic Automata[END_REF][START_REF] Paz | Introduction to Probabilistic Automata[END_REF], recognizing finite words. A probabilistic finite automaton over alphabet A is usually a tuple A = (Q, I, P, F ) where Q is the finite set of states, I ∈ [0, 1] Q is an initial probability distribution, F ∈ [0, 1] Q is a column vector mapping every state to its probability of acceptance, and P : (A → [0, 1]) Q×Q is a matrix that assigns a probability to every pair of states, and every letter of the alphabet, verifying q ′ ∈Q P q,q ′ (a) ≤ 1 for all (q, a) ∈ Q × A.

A run of A over w = a 0 • • • a n-1 ∈ A + is a sequence of states ρ = q 0 q 1 • • • q n . In particular, after reading letter a n-1 the automaton ends without any letter to read, forced to accept or reject the word, i.e., giving it a probability of acceptance 6 . For such a run ρ, we set Notice that this model is not formally a special case of the pebble probabilistic automata introduced previously. Indeed, a pebble probabilistic automaton can only test the last letter of a word by making either a left move, by dropping a pebble or by accepting. In the contrary, finite-state automata -and thus probabilistic finite automata too -may read the last letter and access a virtual position on the right of the word, forced to accept (or reject) when they reach this deadlock position. As done in Example 4.2, we may however very easily translate every probabilistic finite automaton into a pebble probabilistic automaton by merging the final acceptance probability with the last transition.

Example 8.11. We depict in Figure 8.7 as a classical probabilistic automaton the pebble probabilistic automaton depicted in Figure 8. 2. Transitions with probability 0 are omitted. You may observe that state 3 is not used in the pebble probabilistic automaton since it is not neccessary anymore after the transformation explained before this example. Theorems 8.8 and 8.10 indeed permit to define a fragment of hybrid probabilistic expressions equivalent to these probabilistic automata. Again, we use a as a shortcut for the expression a?→. However, to stop the computation, we use test formula final? signifying that the expression has reached the end of the word. Definition 8.12. We let PE be the class of probabilistic expressions, fragment of WE, defined by the following rules:

• the atom rules:

(p) p ∈ [0, 1] p ∈ PE (a) a ∈ A a ∈ PE (final?) final? ∈ PE

• the inductive rules:

(+ act ) E a ∈ PE (∀a ∈ A) p ∈ [0, 1] final?p + a∈A a • E a ∈ PE (+ prob ) E 1 ∈ PE E 2 ∈ PE p ∈ [0, 1] p • E 1 + (1 -p) • E 2 ∈ PE (• weak ) E 1 ∈ PE E 2 ∈ PE E 1 • E 2 ∈ PE (⋆) E 1 + E 2 ∈ PE E ⋆ 1 • E 2 ∈ PE
• the following associativity, commutativity and distributivity rules (later denoted as ACD-rules):

A + E + (G + H) ∈ PE ←→ (E + G) + H ∈ PE C + E + G ∈ PE ←→ G + E ∈ PE A • E • (G • H) ∈ PE ←→ (E • G) • H ∈ PE D • E • (G + H) ∈ PE ←→ E • G + E • H ∈ PE D • (E + G) • H ∈ PE ←→ E • H + G • H ∈ PE
There are two guarded sums. The first one (+ act ) is deterministic and guarded by the letter to be read. The second one (+ prob ) is probabilistic. Probabilistic expressions clearly are a subset of hybrid probabilistic expressions. However, contrary to hybrid probabilistic expressions, probabilistic expressions are forced to read the last letter (as for probabilistic finite automata). Henceforth, to define easily their semantics, we may add a last position on the right of the word, labeled with a fresh symbol ⊳, and define the semantics [[E]](w) of the probabilistic expression E ∈ PE over a word w, as the probability [[E]](w⊳) where E is seen as an expression of HPE here. For instance, the probabilistic automaton in Figure 8.7 may be translated into probabilistic expression 1 6 a(a + b) + 1 2 a ⋆ • ( 1 3 a + b) • final?: in particular, the last position labeled with ⊳, is never tested by probabilistic expression. Notice that the concatenation rule (•) has been weakened to (• weak ) in this definition. In this simpler case, the stronger rule can indeed be derived from the weaker one, which we do not know for the general case: Lemma 8. 13. Let E ∈ PE with Terms(E) = { {E i | i ∈ I} }. Let F i ∈ PE for each i ∈ I.

We have

E = i∈I E i • F i ∈ PE .
E = i∈I G ⋆ • H i • F i .
Using special cases of the proofs of the main general theorem, it is possible to show: Theorem 8.14. Probabilistic finite automata and probabilistic expressions in PE recognize the same series of finite words.

With Theorem 8.14, decidability of the equivalence problem for probabilistic automata carries over to probabilistic expressions (provided the probabilities in an expression are rational numbers), whereas their threshold problem is undecidable (as this problem is undecidable for automata, as originally proved in [START_REF] Paz | Introduction to Probabilistic Automata[END_REF]). We could also state further undecidability results about isolated cutpoints using, e.g., results of [START_REF] Bertoni | Some Recursive Unsolvable Problems Relating to Isolated Cutpoints in Probabilistic Automata[END_REF]. Plural declension of latine word for "how much". We describe in this last chapter an implementation of some algorithms presented in this manuscript. It is available in tool called QuantiS. Further informations and the instruction to install this tool may be found on the webpage http://www.lsv.ens-cachan.fr/ Software/quantis/.

Objective and Implementation Details

The goal of this tool is to permit the evaluation of quantitative specifications over finite words. Henceforth, we focus on the specialized algorithms presented in Theorem 5. 5. We also use the translation presented in Theorem 4.31 from hybrid weighted expressions to layered pebble weighted automata.

The tool has been written in Objective Caml 1 . The first released version of QuantiS permits the evaluation of a hybrid weighted expression over a word in the semiring (R + ∪ {+∞}, +, ×, 0, 1). The syntax to use the tool is the following:

QuantiS -expr <expression> -word <non-empty word> [-timer]

The expression may be written in plain text2 , since a parser deduces from it the formal hybrid weighted expression. For instance,

Perspectives

The aim of this manuscript was to study high-level formalisms to specify quantitative properties, and to use automata techniques in order to evaluate them efficiently over general classes of graphs. The process of specification and verification in the quantitative field requires a three-dimensional diagram: the first dimension consists of selecting the set of weights -semirings in all this manuscript -in which the desired quantitative result lies, the second contains the classes of graphs representing the model to be verified -finite words, trees, nested words, pictures, traces, or abstract sets of graphs, for instance -and the last dimension permits to choose the language of specification adequate to model faithfully the property of interest -we studied hybrid weighted expressions, weighted first order logic with transitive closure and other fragments of weighted monadic second order logic, hybrid weighted propositional dynamic logic, and probabilistic special cases.

Along the manuscript, we already presented some short-term perspectives, that are the basis for future works. For instance, in Chapter 7, we briefly presented high-level formalisms (expressions and logics) able to recognize exactly the quantitative behaviors of one-way weighted automata (with and without pebbles). In this case, where the semiring must not be continuous, we may try to apply the results to various areas. However, this application process may require to further refine the high-level specification languages, in order to make them more practical. In this perspective, the chop expressions that we introduced in Definition 3.12 can be seen as a first step to reduce the usage of variables in the high-level frameworks. For instance, we believe that one-way chop expressions, i.e., where we restrict the use of directions to forward directions (over ordered pointed graphs), would be equivalent to one-way pebble weighted automata in the case of finite words: whereas the translation from these chop expressions to automata is made possible by Theorem 3.13, the reverse translation would certainly hold in this very specialized case. In other cases, it would be interesting to find some strong enough specification formalisms not using variables, still able to generate a large class of quantitative behaviors: it appears, at the end of this manuscript, that a compromise always seems to be done between the use of variables (sometimes not handy) and the potential power of the specifications.

In Chapter 5, we presented several specialized algorithms for evaluating a layered pebble weighted automaton over words, trees and nested words. Whereas we considered the case of strongly layered automata for words, we did not explore it in the setting of general classes of graphs, trees or nested words. We believe it is of the greatest interest: in particular, the case of strongly layered automata is very useful if the high-level specification formalism we consider is directly translatable into a strongly layered pebble weighted automaton, as it 155 CHAPTER 10. PERSPECTIVES is the case, e.g., for weighted propositional dynamic logic in Theorem 6.21, or probabilistic linear temporal logic as we briefly showed in Example 6. 16.

In the probabilistic setting of Chapter 8, we only considered expressions as a high-level formalism. It could be interesting to also find a syntactical fragment of logical formalisms translatable into the model of probabilistic automata we considered. For instance, such probabilistic logics equivalent to probabilistic automata (without pebbles) have been considered in [START_REF] Weidner | Probabilistic Automata and Probabilistic Logic[END_REF], for finite and infinite words.

We conclude this manuscript with some broader perspectives. First, the structures we consider, finite graphs with labeled vertices and edges, could be further generalized. For instance, we may consider adding data in the models, i.e., consider the labeling of vertices as a pair composed of a letter from a finite alphabet and a data value from an infinite data domain. This is of great interest when considering nested words or trees as a model of databases. For instance, in Example 6.4, we used a formula Match(x, y) supposed to match two nodes of an XML document holding similar data: in the setting of logics over data words for instance, this would be a new atom of the logic. Notice that hybrid propositional dynamic logics are close to logics used in this context, like freeze linear temporal logic [START_REF] Demri | LTL with the Freeze Quantifier and Register Automata[END_REF]. Moreover, pebble automata have also been studied in the context of models with data [START_REF] Neven | Finite State Machines for Strings over Infinite Alphabets[END_REF]. Pebbles are then used both as a way to mark a vertex of the graph, but also to store the data value of this vertex in order to compare it with other data values. It would be interesting to study the interleaving of weighted specifications and the data part of XML documents: can we extend the translation results and the evaluation algorithms presented in this manuscript for instance?

Another way to generalize the structures we consider might be to add weights in the models (notice that this can be seen as a special case of the previous one, since weights are data from an infinite data domain being the semiring). Indeed, our graphs currently do not handle any weights: only the specification generates some weights. In certain applications, like in the probabilistic setting, it is important that the model contains probabilities too. We believe that this generalization could be handled by the following method. First, we must consider a new operator (both in the high-level formalisms, and the automata) in order to replace a constant weight of the semiring, by the weight in the graph. Afterwards, we believe that it is easy to modify the translations from specification formalisms to automata, as well as the evaluation algorithms in order to take into account this new operator.

A second direction of further research lies in the evaluation problem itself. Indeed, with respect to usual model-checking problems, we consider an instance where we check one single fixed structure against a specification. A natural question is then the following: considering a model generating some structures, a finite-state automaton generating finite words for example, can we evaluate the specification over all the generated structures, and aggregate the results? The aggregation operator should be able to take as an input a (possibly infinite) set of weights from the semiring, and generate a weight as output.

For instance, considering the semiring of positive real numbers equipped with the usual addition and product, we may consider an aggregation operator being a supremum (or an infimum) of the set of weights. This way, we would be able to check that all the specified values of the generated structures are lower (or greater) than a given threshold: this becomes closer to the traditional point of view of probabilistic computation tree logic (see [START_REF] Baier | Principles of Model Checking[END_REF], for an overview) or the quantitative languages studied in [START_REF] Chatterjee | Quantitative Languages[END_REF].

The frontier between decidability and undecidability is very thin when we consider this extension: for instance, as we recalled in Chapter 8, the threshold problem of probabilistic Rabin automata -whether or not all probabilities generated by such an automaton are greater than a constant probability (that can be seen as a special case of the previous problem where the finite-state automaton generates all words) -is undecidable [START_REF] Paz | Introduction to Probabilistic Automata[END_REF].

Another way to extend the model-checking problem is to rather consider bisimulation tasks, i.e., comparing two models to check whether they can simulate each other, and hence behave the same in every context. This setting has been generalized recently in [START_REF] Fahrenberg | Quantitative Analysis of Weighted Transition Systems[END_REF]: authors consider some distances between weighted automata models. We believe that this direction is promising and would be worth to be considered with the broader and more powerful models of automata introduced in this manuscript.

Last, but not least, we would like to apply the techniques developped in this manuscript to several areas, like natural language processing or for the quantitative verification of softwares. This requires a richer implementation of the algorithms presented. The tool QuantiS developped, and presented in Chapter 9, must be seen as a first prototype in this context: the latter is focused on a single semiring and only for words. We would like to extend this tool to richer semirings and graph structures, in a modularised way, similar to the Vaucanson platform [START_REF] Sylvain Lombardy | Introducing Vaucanson[END_REF].

P(E)

Powerset

  [a, b] the closed real interval {x ∈ R | a ≤ x ≤ b} [a .. b] the closed integer interval {i ∈ Z | a ≤ i ≤ b} A → B mapping (or function) from A to B A ⇀ B partial mapping (or function) from A to B f |A restriction of a function f : B → C to subset A of B

Definition 2 . 1 .

 21 An (A, D)-graph (or simply a graph, if A and D are clear from the context) is a tuple G = (V, (E d ) d∈D , λ) such that • V is a non-empty and finite set of vertices;

Figure 2 . 3 :

 23 Figure 2.3: A nested word

Lemma 2 . 7 .

 27 Let S be a continuous semiring and M ∈ S I×I be a square matrix. For any block decomposition M = A B C D with A and D square matrices, we have

Example 3 . 1 .

 31 We consider a word over the alphabet {a, b}. The classical regular expression (a + b) ⋆ • b • (a + b) ⋆ checks that the given word contains an occurrence of letter b. For conciseness reasons, and for seek of uniformity, we will rather use the shortcut → to denote the non-guarded move to the right encoded by the choice (a + b), and use a weighted semantics, for example in the semiring (N ∪ {+∞}, +, ×, 0, 1). Hence, expression → ⋆ • b • → ⋆ counts the number of occurrences of letter b in the word: 4 in the word baabbaba for example. Possibly, we can decouple the test and the move understood in the symbol b: indeed, we introduce the test b? that stay on the same position and checks whether the current position holds letter b. Therefore, we may alternatively use the equivalent expression → ⋆ • b? • → • → ⋆ .

Figure 3 . 1 :

 31 Figure 3.1: A picture with a highly contrasted rectangle

vFigure 3 . 2 :

 32 Figure 3.2: Chop decomposition of a graph associated to vertex v

Figure 4 . 1 :

 41 Figure 4.1: A first weighted automaton

Figure 4 . 2 :

 42 Figure 4.2: Weighted automaton A ′

  in the case where A has no free variables.

Example 4 . 4 (

 44 Continued from Example 4.

Example 4 . 7 .Figure 4 . 3 :

 4743 Figure 4.3: A weighted automaton A ∈ WA(R + ∪ {+∞})

Figure 4 . 4 :

 44 Figure 4.4: Weighted automaton A mimicking a depth-first-search of a binary tree

Proof .

 . We construct by induction a matrix Φ(∆) with coefficients in WE such that [[Φ(∆)]] = [[∆]] ⋆ . If |Q| = 1, i.e., when ∆ ∈ WE, then we simply let Φ(∆) = ∆ ⋆ . From the algebraic definition of the semantics of weighted expressions, we directly obtain [[Φ(∆)]] = [[∆]] ⋆ .Next, if |Q| > 1, we apply Lemma 2.7 in the semiring S MG with the decomposition

Figure 4 . 5 :

 45 Figure 4.5: Graphical and matrix representations of automata

Figure 4 . 6 :

 46 Figure 4.6: Automata for atomic expressions

Figure 4 . 7 :

 47 Figure 4.7: Automata for sum and concatenation

Figure 4 .

 4 Figure 4.9: A pebble weighted automaton

Figure 4 . 1 2( 1 Figure 4 .

 4114 Figure 4.11: A 2-layered pebble weighted automaton

Figure 4 .

 4 Figure 4.11 schematizes a 2-layered PWA, whereas Figure4.12 depicts a 1-layered PWA with mapping ℓ given by: ℓ(0) = ℓ(1) = 1 and ℓ(2) = 0.We naturally obtain the following lemma relating pebble weighted automaton and layered ones.

Proposition 4 .

 4 30. (DMG(A, D, Var), •, DU(A, D, Var)) is a partial monoid, and for every continuous semiring S, (S DMG(A, D, Var) , ⊕, ⊗, 0, 1 DU (A,D,Var) ) is a continuous semiring. Proof. (DMG(A, D, Var), •, DU(A, D, Var)) is a partial monoid for exactly the same reasons as the ones developped in Example 3.15. Then, we conclude using Proposition 3.16.

Proposition 4 .

 4 34. Let A = (Q, A, D, I, ∆, F ) be a generalized pebble weighted automaton.

Remark 4 .

 4 35.The partial monoid MG is embedded in DMG by identifying the marked graph

Lemma 4 . 39 .

 439 Series over dynamically marked graphs {|N ′ | } and {|D| } ⊗ {|P | } ⋆ ⊗ {|L| } are equal.

1 Figure 4 .

 14 Figure 4.15: Automaton equivalent to the expression of Example 4.42

Thomas A. Edison 5 . 1 5 . 1 . 1 5 . 1 . 2 5 . 2 5 . 3 5 . 4

 51511512525354 Generic Evaluation of Pebble Weighted Automata . . . . . . . . . . . 68 Weights of Paths in Weighted Graphs . . . . . . . . . . . . . 68 Application to the Evaluation Problem . . . . . . . . . . . . . 69 Specialized Algorithm for Words . . . . . . . . . . . . . . . . . 71 Extension to Trees . . . . . . . . . . . . . . . . . . . . . . 75 Extension to Nested Words . . . . . . . . . . . . . . . . . . . 76

Lemma 5 . 1 .

 51 Let S be a continuous semiring and M ∈ S n×n be a square matrix of dimension n. We can compute M ⋆ with n scalar star operations and O(n 3 ) scalar sum and product operations.Proof. Let M ∈ S n×n be a matrix over a continuous semiring S. Consider the block decomposition M = A B C D with A a square matrix in S (n-1)×(n-1) and D ∈ S. The Conway computation of the star of matrix given in Lemma 2.7 gives

Proposition 5 . 3 .

 53 We can compute the semantics [[A]](G, σ) of a 0-layered pebble weighted automaton A over a pointed graph G, for a valuation σ with domain containing the free variables of A, with • O(|Q| × |V |) scalar star operations, • O(|Q| 3 × |V | 3 ) scalar products, and • O(|Q| 3 × |V | 3 + |∆| × |V | 2 ) scalar sums.

Theorem 5 . 4 .

 54 We can compute the semantics [[A]](G, σ) of a K-layered pebble weighted automaton A that may drop p distinct variables, over a pointed graph G, for a valuation σ with domain containing the free variables of A, with • O(|Q| × |V | p+1 ) scalar star operations, • O((p + 1) × |Q| × |∆| × |V | p+2 + |Q| 3 × |V | p+3 ) scalar sums and products.

  sums and products. In total, for all the layers, vertices and valuations, these update operations require O((p + 1) × |Q| × |∆| × |V | p+2 ) scalar sums and products.

Theorem 5 . 5 .

 55 We can compute the semantics [[A]](w, σ) of a K-layered pebble weighted automaton A that may drop p distinct variables, over a nonempty finite word w ∈ A + , for a valuation σ with domain containing the free variables of A, • with O(|Q| × |w| p+1 ) scalar star operations, • O((p + 1) × |Q| 3 × |w| p+1 ) scalar products, and • O((p + 1) × |Q| 3 × |w| p+1 + |∆| × |w| p+1 ) scalar sums.

Theorem 5 . 7 .

 57 We can compute the semantics [[A]](t, σ) of a K-layered pebble weighted automaton A that may drop p distinct variables, over a ranked tree t, for a valuation σ with domain containing the free variables of A, with • O(|Q| × |t| p+1 ) scalar star operations, • O((p + 1) × |Q| 3 × |t| p+1 ) scalar products, and • O((p + 1) × |Q| 3 × |t| p+1 + |∆| × |t| p+1 ) scalar sums.

Theorem 5 . 8 .

 58 We can compute the semantics [[A]](G, σ) of a K-layered pebble weighted automaton A that may drop p distinct variables, over a pointed graph G ∈ N est(A) modeling a nested word, for a valuation σ with domain containing the free variables of A, with • O(|Q| × |V | p+1 ) scalar star operations, • O((p + 1) × |Q| 3 × |V | p+1 ) scalar products, and • O((p + 1) × |Q| 3 × |V | p+1 + |∆| × V p+1 ) scalar sums.

  k ∈ {0, . . . , K} of the automaton. Suppose by induction that we have already computed matrices B (k-1) σ ′

Figure 6 . 1 :

 61 Figure 6.1: Part of an XML document for the car database

Lemma 6 . 7 .

 67 For every L-step formula Φ, one can construct an equivalent formula Ψ = I∈K (ψ I ⊗ s I ) with K finite, ψ I ∈ L and s I ∈ S. More precisely, Free(Φ) = Free(Ψ) and [[Φ]](G, σ) = [[Ψ]](G, σ) for all pairs (G, σ) of graph and valuation.

Figure 6 . 2 :

 62 Figure 6.2: Automaton exploring the class of →-ordered pointed graphs

Figure 6 . 3 :Figure 6 . 4 :Figure 6 . 5 :

 636465 Figure 6.3: Weighted automaton for disjunction ξ = ϕ ∨ ψ

  variables, over a pointed graph G ∈ G, for a valuation σ with domain containing the free variables of A, with O(|Φ| × |V | p+1 ) scalar star operations and O((p + 1) × |Φ| 3 × |V | p+3 ) scalar sums and products in S.

Figure 6 . 6 :

 66 Figure 6.6: Zone partitioning of a graph: zones are related by wires depicted with dashed lines. The encoding of wire (v, v ′ ), for every integer n ∈ [0 .. N -1] is depicted by a red area linked to the vertex v ′ , or containing vertex v ′ .

- 1 Figure 6 . 7 :

 167 Figure 6.7: Zone partitioning of a word and description of the encoding function f

Figure 6 . 13 :

 613 Figure 6.13: Automaton for state formula a

Figure 6 .

 6 Figure 6.14: Weighted automaton for disjunction α ′′ = α ∨ α ′

Figure 6 .

 6 Figure 6.15: Automata for program ⊥, stay and d

7. 1

 1 Simple Semantics of Pebble Weighted Automata. . . . . . . . . . . . 114 7.2 One-way Pebble Weighted Automata . . . . . . . . . . . . . . . . 115 7.3 Undecidability of Emptiness . . . . . . . . . . . . . . . . . . . 117 7.4 One-way versus Simple over Words . . . . . . . . . . . . . . . . 120 7.5 Restrictions over Expressions and Logics . . . . . . . . . . . . . . 129 7.5.1 One-way Weighted Expressions . . . . . . . . . . . . . . . . 130 7.5.2 First-order logic with Restricted Transitive Closure. . . . . . . . . 132

Figure 7 . 1 :

 71 Figure 7.1: A weighted automaton A ∈ WA(R + ∪ {+∞})

Proof .

 . We reduce the emptiness problem of 2-counter machines. A 2-counter machine M is a tuple (Loc, ∆, init, F ) with Loc a finite set of locations, ∆ = Loc × Instr × Loc the set of transitions where Instr = {Inc p , Dec p , ZTest p | p ∈ {1, 2}}, init ∈ Loc the initial location and F ⊆ Loc the set of final locations. If w

  We define the value of counter p ∈ {1, 2} after step j ∈ {1, . . . , n} as c p j (w) = |w j | Inc p -|w j | Dec p , and we also set c p 0 = 0. An accepting run of M may be seen as a graph G ∈ Word(∆), representing a word w

Figure 7 . 2 :

 72 Figure 7.2: Automaton checking that the counter p is non-negative

Figure 7 . 3 :

 73 Figure 7.3: Automaton checking the zero tests ZTest p

Proof .

 . Let A = (R, A, D, I, ∆, F) be a weighted automaton. We construct an equivalent one-way weighted automatonB = (Q ′ , A, D, I ′ , ∆ ′ , F ′ ) such that [[B]] = [[A]] s over the set of words A + (represented as graphs in Word(A)).

  [[B]] = [[A]] s since for all G ∈ Word(A) and valuation σ, [[A]] s (G, σ) is the sum of the weights of the simple accepting runs of A over (G, σ), whereas [[B]](G, σ) is the sum of the weights of the accepting runs of B over (G, σ). Lemma 7.10. For every G ∈ Word(A) and valuation σ, there is a weight preserving bijection between the simple accepting runs of A over (G, σ) and the accepting runs of B over (G, σ).

Example 7 .

 7 14. Let Ψ = swTC x,y 1 over N. Then for a word u of length n, we have[[Ψ]](u, 1, n) = n-2 m=0 m! n-2m , since the sum in the semantics of swTC ranges over all sequences of pairwise distinct positions in[1 .. n] starting in 1 and ending in n.

8. 1

 1 Pebble Probabilistic Automata . . . . . . . . . . . . . . . . . . 136 8.2 Hybrid Probabilistic Expressions . . . . . . . . . . . . . . . . . 138 8.3 The Probabilistic Kleene-Schützenberger Theorem . . . . . . . . . . . 140 8.4 What it Implies for Rabin Probabilistic Automata . . . . . . . . . . . 147

  (a, τ, P, b i , b f ) |= init? if, and only if, b i = 1 (a, τ, P, b i , b f ) |= final? if, and only if, b f = 1 For other formulae, b i and b f are not used. Similarly to the case of words, for every graph G ∈ G(A, D), valuation σ and vertex v ∈ V , we may define b i (v) (respectively, b f (v)) to be 1 if, and only

8. 1 .

 1 PEBBLE PROBABILISTIC AUTOMATA In the following, a tuple (a, τ, P, b i , b f ) will be called a local configuration. The set of local configurations of an automaton A is denoted Γ: Γ = A × P(D) × P(Var(A)) × {0, 1} 2 and such a local configuration will be denoted by γ. Definition 8.1.

Figure 8 . 1 :Example 8 . 4 .

 8184 Figure 8.1: A probabilistic automaton A ∈ PPA and the Markov chain obtained by synchronizing A with a word of length n

Figure 8 . 2 :Definition 8 . 5 .

 8285 Figure 8.2: A probabilistic automaton equivalent to 1 6 a(a + b) + 1 2 a ⋆ • ( 1 3 a? + b?)

Example 8 . 6 (

 86 Continued from Example8.4). An equivalent probabilistic expression to describe the probability associated with the previous random walk is given by E = (p(¬final?)→ + (1p)←) ⋆ final? p .

Figure 8 . 3 :

 83 Figure 8.3: Standard pebble probabilistic automaton produced by the construction, from a hybrid probabilistic expression with terms { {E 1 , E 2 , . . . , E n } }. Notice that the initial state ι may be related to one of the terms, as it is shown on the picture.

Figure 8 . 4 :

 84 Figure 8.4: Construction for the rule (+ prob )

F

  fm-1 F fm . . .

F

Figure 8 . 5 :

 85 Figure 8.5: Construction for the rule (•): on the top, automaton A equivalent to expression E = G + H (for simplifying, ι is supposed to be not associated to a term in this picture), and on the bottom, automaton A ′′ equivalent to expression E ′′ = G + H • E ′

Figure 8 . 6 :Corollary 8 . 9 .

 8689 Figure 8.6: Construction for the rule (⋆), supposing that automaton A, equivalent to expression E = G + H, is given in Figure 8.5: the automaton depicted is equivalent to expression E ′′ = G ⋆ • H.

Theorem 8 .

 8 10. Let A = (Q, A, D, I, ∆, F ) be a K-layered pebble probabilistic automaton. We can effectively construct a hybrid probabilistic expression E such that[[E]](G, σ) = [[A]](G, σ) for every pair of graph G ∈ G(A, D) and valuation σ.

Proof .

 . As usual, we denote by ℓ the mapping defining the layers of A. For every local configuration γ = (a, τ, P, b i , b f ) ∈ Γ, we use a macro γ? denoting the test formula a? ∧ τ ? ∧ P? ∧ α i ∧ α f with α i being init? if b i = 1 and ¬init? otherwise, and similarly for α f . It simply tests whether the current configuration verifies the local configuration γ.

  x∈Var(A) r∈ℓ -1 (k-1) ∆ q,r (drop x )(α) ∈ [0, 1]Using rule (+ det ) repeatedly to concatenate the tests γ? to the left, and rule (•) to concatenate the previous G r expression on the right of the drop transition, as well as the directions d, we obtain thatγ∈Γ ∈ℓ -1 (k) ∆ q,q ′ (d)(α) • d + x∈Var(A) r∈ℓ -1 (k-1)

P 1 i=0P 1 Figure 8 . 7 :

 1187 Figure 8.7: A probabilistic finite automaton

Proof .

 . We proceed by structural induction over the rules generating E. This is trivial for atoms and also for ACD-rules since they preserve the multiset of terms. Let G, H ∈ PE with Terms(G) = { {G j | j ∈ J } } and Terms(H) = { {H k | k ∈ K} }. Consider E = p•G+(1-p)•H. Then, Terms(E) = { {p•G j | j ∈ J } }⊎{ {(1-p)•H k | k ∈ K} }. Hence we have I = J ⊎K, E i = p•G i for i ∈ J and E i = (1-p)•H i for i ∈ K. By induction, we have G = i∈J G i •F i ∈ PE and H = i∈K H i •F i ∈ PE. Therefore, p•G+(1-p)•H ∈ PE.This expression can be rewritten into E with ACD-rules.The proof is similar forE = final?p + a∈A a • E a . Consider E = G • H so that I = J × K and E (j,k) = G j • H k for (j, k) ∈ I.By induction, for every j ∈ J , we getH j = k∈K H k • F (j,k) ∈ PE.Again by induction we obtain j∈J G j • H j ∈ PE. This expression can be rewritten into E with ACD-rules.Consider now E = G ⋆ • H assuming G + H ∈ PE instead of G, H ∈ PE. We have I = K and E i = G ⋆ • H i for i ∈ I. Applying the induction hypothesis to the expression G + H with F j = 1 for j ∈ J , we obtain j∈J G j + ( k∈K H k • F k ) ∈ PE. From the star rule we deduce that ( j∈J G j ) ⋆ • ( k∈K H k • F k ) ∈ PE. Using ACD-rules, this can be rewritten into

Corollary 8.15. 1 . 9 Implementation :

 19: The equivalence problem for probabilistic expressions is decidable: given probabilistic expressions E and F of PE, does [[E]] = [[F ]] hold? 2. The threshold problem for probabilistic expressions is undecidable: given an alphabetA, a probabilistic expression E ∈ PE and 0 < p < 1, is there a word w ∈ A + such that[[E]](w) ≥ p?CHAPTER QuantiS toolQuanti, Quantos, Quantorum, Quantis, Quantis.

9. 1

 1 Objective and Implementation Details .. . . . . . . . . . . . . . 151 9.2 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . 152

Figure 9 . 1 :Figure 9 . 2 :Figure 9 . 3 :

 919293 Figure 9.1: Plot of the execution time of the tool over expression (¬final? • (0.25 • → + 0.75 • ←)) ⋆ • final? as a function of the length of the word

  . . 14 2.1.4 Grids and Pictures . . . . . . . . . . . . . . . . . . . . 15 2.1.5 Mazurkiewicz Traces . . . . . . . . . . . . . . . . . . . . 15 2.1.6 Ordered Graphs . . . . . . . . . . . . . . . . . . . . . 16 2.2 Weight Domains

  . . 18 2.2.3 Formal Power Series and Polynomials. . . . . . . . . . . . . . 20 2.2.4 Matrices

  Syntactical Subclasses of Hybrid Weighted Expressions . . . . . . . . . 28 3.2.1 Weighted Expressions . . . . . . . . . . . . . . . . . . . 28 3.2.2 Chop Weighted Expressions: An Alternative to Variables . . . . . . 30 3.3 Algebraic Semantics of Hybrid Weighted Expressions . . . . . . . . . . 32 3.3.1 Partial Monoids . . . . . . . . . . . . . . . . . . . . . 34 3.3.2 Application to the Semantics of Hybrid Weighted Expressions . . . . . 35

3.1 Hybrid Weighted

Expressions . . . . . . . . . . . . . . . .

. . 24 3.2

Table 3 .

 3 1: Semantics of tests in Test(A, D, Var)

	G, σ, v |= ⊤
	G, σ, v |= init? if, and only if, v = v (i)
	G, σ, v |= final? if, and only if, v = v (f )
	G, σ, v |= a? if, and only if, λ(v) = a
	G, σ, v |= d? if, and only if, d ∈ type(v)
	G, σ, v |= x? if, and only if, σ(x) = v
	G, σ, v |= ¬α if, and only if, G, σ, v |= α
	G, σ, v |= α ∧ α ′ if, and only if, G, σ, v |= α and G, σ, v |= α ′
	G, σ, v |= α ∨ α ′ if, and only if, G, σ, v |= α or G, σ, v |= α ′
	formally, we denote Free(E) the (finite) set of free variabes in E, which is defined inductively
	by letting
	Free

  Indeed, the crucial point differentiating expressions in HWE and chop expressions is that E 1 and E 2 are evaluated on subgraphs G 1 and G 2 of the original graph G, whereas hybrid weighted expressions E ′ 1 and E ′ 2 are evaluated on the same graph G. In particular, if expression E 1 performs a test d? or a move d with d ∈ D, it may fail in the subgraph G 1 on which it is evaluated, even though it would have succeeded in the whole graph G: this is the case if the particular edge labeled with d of the whole graph has been chopped. Hence, we have to slightly modify E ′ 1 and E ′ 2 before combining them to get expression E ′ . This is done by first replacing every test d? over a direction d ∈ D → appearing in E ′ 1 by the concatenation d • d -1 , and, similarly, every test d? over a direction d ∈ D ← appearing in E ′ 2 by d • d -1 . Then, we replace every move d with d ∈ D → , appearing in E ′ 1 by

1

  Charles Perrault, Le Petit Poucet 4.1 Weighted Automata over Graphs . . . . . . . . . . . . . . . . . 40 4.1.1 Syntax and Semantics over a Continuous Semiring . . . . . . . . . 40 4.1.2 A First Kleene-Schützenberger Theorem. . . . . . . . . . . . . 44 4.2 Pebble Weighted Automata . . . . . . . . . . . . . . . . . . . 51 4.2.1 Extended Syntax and Semantics . . . . . . . . . . . . . . . 52 4.2.2 Layered Pebble Weighted Automata . . . . . . . . . . . . . . 56 4.2.3 Dynamically Marked Graphs . . . . . . . . . . . . . . . . . 58 4.2.4 The Full Kleene-Schützenberger Theorem . . . . . . . . . . . . 59

Table 4 .

 4 1: Semantics of pebble weighted expressions

  6.1 Monadic Second Order Logic over Graphs . . . . . . . . . . . . . . 6.2 Emptiness of Pebble Weighted Automata is Decidable . . . . . . . . . 6.3 Weighted logics. . . . . . . . . . . . . . . . . . . . . . . . 6.3.1 General definitions . . . . . . . . . . . . . . . . . . . . 6.3.2 Previous expressiveness result . . . . . . . . . . . . . . . . 6.3.3 Weighted transitive closure . . . . . . . . . . . . . . . . . 6.4 From Logics to Automata . . . . . . . . . . . . . . . . . . . . 6.4.1 Searchable Classes of Graphs . . . . . . . . . . . . . . . . . 6.4.2 Translation of Formulae into Automata . . . . . . . . . . . . . 6.5 From Automata to Logics . . . . . . . . . . . . . . . . . . . . 6.5.1 Zonable Classes of Graphs . . . . . . . . . . . . . . . . . . 6.5.2 Logical Characterization of Weighted Automata . . . . . . . . . . 6.5.3 Logical Characterization of Weighted Automata with Pebbles . . . . . 6.6 Hybrid Navigational Logics . . . . . . . . . . . . . . . . . . . 6.6.1 Weighted Propositional Dynamic Logic . . . . . . . . . . . . .

6.6.2

Hybrid Weighted Propositional Dynamic Logic .

. . . . . . . . .

Table 6 .

 6 |= ϕ 1 ∨ ϕ 2 if, and only if, G, σ |= ϕ 1 or G, σ |= ϕ 2 G, σ |= ∃x ϕ if, and only if, there exists v ∈ V such that G, σ[x → v] |= ϕ G, σ |= ∃X ϕ if, and only if, there exists I ⊆ V such that G, σ[X → I] |= ϕ

	1: Semantics of MSO

variables in VAR to subsets of V . As usual, for x ∈ Var and v ∈ V , σ[x → v] denotes the valuation that maps x to v and, otherwise, coincides with σ, and for X ∈ VAR and I ⊆ V , σ[X → I] is defined similarly.

Table 6 . 2

 62

: Semantics of formulae in wMSO(L)

Table 7 .

 7 P) |= ¬α if, and only if, (a, t, P) |= α (a, t, P) |= α ∧ α ′ if, and only if, (a, t, P) |= α and (a, t, P) |= α ′ (a, t, P) |= α ∨ α ′ if, and only if, (a, t, P) |= α or (a, t, P) |= α ′ pointed graph G ∈ Word(A), valuation σ and vertex v, G, σ, v |= α if, and only if, (λ

	1: An alternative definition of the semantics of tests in Test
	(a, t, P) |= ⊤
	(a, t, P) |= init? if, and only if, ← / ∈ t
	(a, t, P) |= final? if, and only if, → / ∈ t
	(a, t, P) |= b? if, and only if, a = b
	(a, t, P) |= d? if, and only if, d ∈ t
	(a, t, P) |= x? if, and only if, x ∈ P
	(a, t,

  . . , τ n-1 )

	match τ i with r→τ ′ i : output (G, σ, r, i);
	Run (i + 1, τ 0 , . . . , τ ′ i , . . . , τ n-1 );
	r←τ ′ i : output (G, σ, r, i);
	Run (i -1, τ 0 , . . . , τ ′ i , . . . , τ n-1 );
	r : (* necessarily i = n -1 *)
	output (G, σ, r, n -1);

  of set E, page 11 Set of graph representations of the words in A + , page 13

	f |A S S Z S Z S I×J supp(f ) Test(A, D, Var) T ree(A) type(v) U(A, D, Var) Var(E) WA(S) PWA(S) gWA(S) gPWA(S) 1WA(S) 1PWA(S) |w| w Word(A) Index Cauchy product, 20 partial, 34 chop weighted expression, 31 Restriction of a function, page 11 Semiring, page 18 Set of polynomials over Z with coefficients in S, page 20 Set of formal power series over Z with coefficients in S, page 20 Matrices indexed by I × J with coefficients in S, page 20 Support of a formal power series f , page 20 Set of test formulae, page 26 Set of graph representations of the ranked trees over A, page 13 Type of vertex v, page 12 Set of units of the marked graphs, page 34 Set of variables in E, page 26 Set of weighted automata over S, page 41 Set of pebble weighted automata over S, page 52 Set of generalized weighted automata over S, page 44 Set of generalized pebble weighted automata over S, page 59 Set of one-way weighted automata over S, page 116 Set of one-way pebble weighted automata over S, page 116 Length of word w, page 13 Word, page 13 direction, 12 ordered, 16 symmetrical, 12 formal power series, 20, 33 proper, 33 regular, 33 support, 20 gradation, 17 graph, 12 cycle, 12 distance, 12 ordered, 16 ordered pointed, 17 path, 12 pointed graph, 12 searchable, 90 zonable, 96 Hadamard product, 20 logic transitive closure, 83 bounded one-way weighted, 133 bounded simple weighted, 133 bounded weighted, 89 one-way weighted, 132 simple weighted, 132 weighted, 89 tree, 13 child, 13 internal node, 13 leaf, 13 node, 13 parent, 13 ranked, 13 type, 12 weighted automaton, 40 accepting run, 42 configuration, 41 final state, 42 generalized, 44 initial state, 42 run, 42 simple run, 114 weighted expression, 29 depth, 27 free variable, 26 hybrid, 26 literal-length, 48 one-way hybrid, 130 pebble, 59 word, 13 hybrid weighted propositional dynamic, INDEX length, 13

Here, N ⋆ denotes the set of words over the infinite alphabet N.

One may equivalently state that (s⊗ s ′ ) ⋆ = 1 S ⊕ s ⊗ (s ′ ⊗ s) ⋆ ⊗ s ′ .

The notation ⊙ used instead of the more natural one, ⊗, to denote the lifting of the product is motivated by the introduction of the Cauchy product below, often considered as the natural product of formal power series.

We will indeed focus on proper weighted regular expressions as it is enough for our purpose.

We recall that sw denotes the formal power series whose only non-zero coefficient is the one of w ∈ A ⋆ , which is equal to s ∈ S.

The neutral element for the Cauchy product, 1 U , is the characteristic series of the partial units of M, defined by 1 U (m) = 1 if m ∈ U , and 0 otherwise.

"Little Thumb let them cry on, knowing very well how to get home again, for, as he came, he took care to drop all along the way the little white pebbles he had in his pockets."

We recall that Test(A, D, Var) is the set of test formulae defined in Chapter

3, sometimes called Test in the following.

The weight of a run is the product (in the semiring) of the weights of the transitions of the run: here the product operation of the semiring is an addition...

The rational closure is the closure under sum (+), product (•) and star ( ⋆ ).

Moreover, notice that we denote by M 1 M 2 the product of matrices and elements in drawings, whereas it is denoted by M 1 ⊗ M 2 in texts, for spacing reasons.

We locally change in this proof the encoding of the positions of a word from {0, . . . , |w|-1} to {1, . . . , |w|} in order to ease some notations.

These positions can be partitioned according to their associated start and end positions, and computed independently.

Whereas, in[START_REF] Engelfriet | Automata with Nested Pebbles Capture First-Order Logic with Transitive Closure[END_REF] they use strong pebbles, i.e., pebbles that may be lifted without moving back the head to the position of the pebble, we indeed chose to consider weak pebbles.

Notice that if M is taken into account for the complexity, then the construction for the transitive closure requires an additional number of states of the form |D| M to remember the paths.

Natural number N will encode the number of states of the automaton to translate into the logic.

In the second formula, if k = 0, we assume that k -1 is equal to 2N -1, as we count modulo 2N .

The definition of the partial order permits to use any {↓p | p ∈ [1 .. n]}-path, but we can transform any such path into the succession of some ↓ σ(i) -paths for a given permutation σ: in fact, the path comes back to a process p already visited before, we can simply replace the path in-between by a succession of ↓p moves, and hence simplify the path.

Here again, we allow the use of non-moving transitions, knowing that we can remove them with standard techniques, as explained in page 93.

"Simplicity is the ultimate sophistication".

In this proof, for π ∈ (Var × V ) k , we denote by π |V the word in V k obtained from π by erasing the name of the variables in Var.

We recall that if ϕ is a Boolean formula and Φ a weighted formula, ϕ? Φ denotes the formula (ϕ ⊗ Φ) ⊕ (¬ϕ). Intuitively, it computes Φ only when ϕ holds.

In the following, for t ∈ P(D) (respectively, P ⊆ Free(A)), we use t? (respectively, P?) as a shortcut for d∈t d? ∧ d / ∈t ¬d? (respectively, x∈P x? ∧ x∈Free(A)\P ¬x?).

In case k = 1, the state just after the 0th occurrence of ← in q ′ is simply the first state of q ′ .

All coefficients of tests distinct from a? ∧ t? ∧ P? are set to 0. Notice also that a product over an emptyset is equal to1.

In case w is a single letter word, we may precompute the whole weight and compute it by using final weight (testing also that the current vertex is both initial and final). Henceforth, we suppose in the following that w / ∈ A.

Alternatively, we could define an equivalence relation ∼ on states of Aq and use a ∼-simple semantics of runs, as originally done in[1].

"Great artists have randomness in their talent and talent in their randomness."

The rules have to be understood in the following sense: on the top, there are preconditions to be fullfilled, in which case, the bottom builds a new hybrid probabilistic expression. For example, the rule (+ prob ) constructs the expression p • E 1 + (1 -p) • E 2 at the condition that E 1 and E 2 are hybrid probabilistic expressions and that p is a probability.

Here, and in the following, A ⊎ B denotes the sum (i.e., the disjoint union) of the multisets A and B: in particular, it takes into account the repetitions.

Indeed, we use again some semantical equivalence, noticing that if γ = γ ′ are two different local configurations, test formula γ? ∧ ¬(γ ′ ?) is equivalent to γ?.

This definition is not completely consistent with the rest of this manuscript where runs are sequences of configurations, each of these being attached to a position of the word.

http://caml.inria.fr

Notice that weights being floating numbers, they must have a dot: e.g., the real number 2 may be written 2., whereas the real number 0.2 may be written either 0.2 or .2. Also, the Kleene operators are written ˆ* and ˆ+, in order to differentiate them with the sum of two expressions.

unambiguous formula, 90 weighted first order, 86 weighted monadic second order, 85 weighted propositional dynamic, 108 marked graph, 33 dynamically, 58 dynamically partial units, 59 partial unit, 34 product, 34 matrix, 20 monoid, 17 commutative, 17 complete, 17 continuous, 17 graded, 17 least upper bound, 17 morphism, 17 natural order, 17 partial, 34 submonoid, 17 pebble weighted automaton, 52 K-configuration, 53 generalized, 59 layered, 56 one-way, 115 strongly layered, 57 polynomial, 20 probabilistic automaton, 147 pebble, 137 probabilistic expression, 148 hybrid, 139 semiring, 18 arctic semiring, 18 Boolean semiring, 18 commutative, 18 complete, 18 continuous, 18 divisor of zero, 19 idempotent, 20 integer semiring, 18 morphism, 18 natural completed semiring, 18 natural semiring, 18 positive, 19 positive real completed semiring, 18 quasi-inverse, 18 rational semiring, 18 real semiring, 18 star, 18 subsemiring, 18 tropical semiring, 18 zerosumfree, 19 test formula, 26 free pebble name, 26

Remerciements

Remerciements vii

The initial mapping I ′ maps the states in Q ′ of the form (a, {→}, P, (R{→, drop x }) ⋆ R→) or (a, ∅, P, (Rdrop x ) ⋆ R) to the weight given by I over their projections on R. Similarly, the final mapping F ′ maps the states in q ′ ∈ Q ′ with q ′ of the form (a, {←}, P, (R{←, drop x }) ⋆ R) or (a, ∅, P, (Rdrop x ) ⋆ R) to the polynomial given by F over their projections on R with the test formulae enriched with a? ∧ t? ∧ P?, where t = {←} or t = ∅ respectively.

The automaton B contains a copy of each B q in order to simulate the parts of a run when the first pebble x is dropped (dashed lines in Figure 7.5).

From each state q = (a, t, P, τ ) ∈ Q ′ , we first call (the copy of) the automaton B q dropping pebble x and when the computation of B q is done we lift the pebble returning to the copy q

Then, we perform a → action to the next crossing-sequence q ′ ∈ Q ′ . As in the proof of Proposition 7.9, two crossing-sequences q = (a, t, P, τ ) and

We assume Tr(q, q ′ ) to be defined as in the proof of Proposition 7.9, so that we may define the weight of → moves of B induced by the matching crossing-sequences (q, q ′ ) as the product of the weights of the (left or right) transitions of A contained in (q, q ′ ): Proof. Let G ∈ Word(A) with n vertices denoting a word w = a 0 • • • a n-1 , and a valuation σ. We will decompose the bijection into several ones, all preserving the weights in an adequate manner.

To extend the proof of Lemma 7.10, we first associate with a simple accepting run ρ of A over (G, σ) a tuple

where q i = (λ(i), type(i), σ(i), τ i ) is the crossing-sequence at vertex i ∈ [0 .. n -1] and the tuple g i = (ρ i 1 , . . . , ρ i Ni ) consists of the sequence of subruns of ρ with pebble x dropped on vertex i, together with the surrounding drop-lift transitions.

Formally, for 0 ≤ i ≤ n-1, to define the crossing sequence q i , we let τ i be the "projection" of the configurations visiting vertex i with an empty stack of pebbles, where configuration (G, σ, r, ε, i) is "projected" to r → (respectively, r ←, rdrop x or r) if it is followed by some (G, σ, r ′ , ε, i+1) (respectively, (G, σ, r ′ , ε, i-1), (G, σ, r ′ , (x, i), 0) or is the last configuration). The use of a timer permits to observe the time of execution of the evaluation algorithm (the transformation from the expression to the automaton is not taken into account here).

Experiments

In the archive containing the tool, the script file tests.sh of directory /examples contains a list of examples of usage of the tool. Here are the expressions we may find in this list:

, in order to test the use of a variable;

, mapping a word w to 2 (|w|-1) 2 ;

• → + a?x! (¬x?→) ⋆ b?(¬x?→) + c?← + d?→ + → ⋆ , used in Example 4.42;

, testing the reusability of variables, and mapping a word w to 2 (|w|-1) 3 . In particular, over the word a 10 , the tool outputs the value 2.82 × 10 219 : even if this value is large, the computation time is only of roughly 8 milliseconds, instead of 0.3 milliseconds over the word aa; • (¬final? • (0.25 • → + 0.75 • ←)) ⋆ • final?, inspired from Examples 4.7 and 8.4. Figure 9.1 depicts the execution time needed to evaluate the expression over a word of the form a n as a function of n. We may clearly observe the linear dependency in the size n of the word, as observed in Theorem 5.5 (here the number p of variables that may be dropped by the automaton equivalent to E is 0). • (→ ⋆ • ← ⋆ ) n , concatenating n zigzag expressions. This a priori useless expression permits to observe the behavior of the tool over expressions of increasing size. Figure 9.2 depicts the execution time needed to evaluate the expression over a word of length 1000 as a function of the parameter n. We may guess a cubic dependency in n, as observed in Theorem 5.5.

• expressions E n constructed by induction letting for n ≥ 1:

Expression E n uses n different variables, henceforth, this example permits to observe the behavior of the tool over expressions with increasing number of variables. Figure 9.3 depicts the execution time needed to evaluate E n over a word of length 3 as a function of the parameter n: notice the use of a logarithmic scale for the vertical axis. We may see an exponential dependency in n, as observed again in Theorem 5. 5.

List of Tables

Semantics of tests in

Semantics of HWE(S, A, D,

Semantics of pebble weighted

Semantics of formulae in wMSO