Rewriting Tables and Memorized Semirings

Cyrille Bertelle ^{∗}, Gérard H. E. Duchamp ^{†}

and Khalaf Khatatneh^{‡}^{§}

Keywords: Tables, k-subsets, efficient data structures, efficient algebraic structures.

0 Introduction

The following is intended to be a contribution in the area of what could be called efficient algebraic structures or efficient data structures. In fact, we define and construct a new data structure, the tables (abstract and reduced), which are at first special multisets of two-raws arrays. The first raw is filled with words (or more generally, elements taken in some semigroup) and the second with some coefficients taken in a semiring [7]. Reduced tables realize the (finite) k-sets sets of Eilenberg [6], they are versatile (one can vary the monomials and the coefficients), easily implemented and fast computable. Varying the scalars and the transformations on them, one can obtain many different structures and, among them, semirings. Examples will be provided and worked out in full detail. Here, we present a new semiring (with several semiring structures) which can be applied to the necessity of automatic processing multiagents behaviour problems. The purpose of this account/paper is to present also the basic elements of these new structures from a combinatorial point of view. These structures present a bunch of properties. They will be endowed with several laws namely : Sum, Hadamard product, Cauchy product, Fuzzy operations (min, max, complemented product). Two groups of applications are presented. The first group is linked to the process of “forgetting” information in the tables and then obtaining, for instance, a memorized semiring. The latter is specially suited to solve the shortest path with addresses problem using the repeated squaring algorithm on matrices with entries in this semiring. The second, linked to multi-agent systems, is announced by showing a methodology to manage emergent organization from individual behaviour models.

∗LIH, Laboratoire d’Informatique du Havre, 25 rue Philippe Lebon, BP 540 76058 Le Havre cedex, France †LIPN, Institut Galilée - Université Paris XIII 99, avenue Jean-Baptiste Clément, 93430 Villetaneuse, France ‡LIFAR, Faculté des Sciences et des Techniques, 76821 Mont-Saint-Aignan Cedex, France §cyrille.bertelle@univ-lehavre.fr, gerard.duchamp@lipn.univ-paris13.fr, khalaf.khatatneh@univ-rouen.fr

1 Description of the data structure

1.1 Tables

The input alphabet being set by the automaton under consideration, we will here rather focus on the definition of semirings providing transition (or transfer) coefficients. For convenience, we first begin with various examples of laws on ℝ_{+} := [0, +∞[ including

1. + (ordinary sum)

2. × (ordinary product)

3. min (if over [0, 1], with neutral 1, otherwise must be extended to [0, +∞] and then, with neutral +∞) or max

4. +_{a} defined by x +_{a} y := log_{a}(a^{x} + a^{y}) (a > 0)

5. +_{[n]} (Hölder laws) defined by x +_{[n]} y :=

\sqrt[n]{x^{n} + y^{n}}

6. +^{s} (shifted sum, x +^{c} y := x + y − 1, over whole ℝ, with neutral 1)

7. ×^{c} (complemented product, x + y − xy, can be extended also to whole ℝ, stabilizes the range of probabilities or fuzzy [0, 1] and is distributive over the shifted sum)

For other examples and applications see, for example [7].

A table T is a two-rows array, the first row being filled with monomials taken in a given semigroup (see [4], [8] or [9]). To be more precise, if

T = \begin{matrix}u_{1} & u_{2} & ⋯ & u_{k} \\ p_{1} & p_{2} & ⋯ & p_{k} \end{matrix}

individual columns are allowed to be repeated that is, for instance that one can get

\begin{matrix}⋯ & u_{i} & ⋯ & u_{i} & ⋯ \\ ⋯ & p_{i} & ⋯ & p_{i} & ⋯ \end{matrix}

and columns commute between themselves, that is

\begin{matrix}⋯ & u_{i} & ⋯ & u_{j} & ⋯ \\ ⋯ & p_{i} & ⋯ & p_{j} & ⋯ \end{matrix} =

\begin{matrix}⋯ & u_{j} & ⋯ & u_{i} & ⋯ \\ ⋯ & p_{j} & ⋯ & p_{i} & ⋯ \end{matrix}

This is equivalent to saying that a Table is a finite multiset of columns. Multisets

http://mathworld.wolfram.com/Multiset.html

are extensively used in rewriting theory and sometimes named bags. A multiset M = s_{1}, s_{2}, ⋯ is a set in which elements are allowed to be repeated which amounts to the data of a mapping f : Dom(f) ↦ ℕ^{+}, Dom(f) is the support of the multiset and f the multiplicity function. If the support is finite, so is called the multiset. The set of words which are present in the first row will be called the indices of the table (I(T)) and for the second row the values or (coefficients)of the table. The order of the columns is not relevant (as in Computer Algebra Systems where this data structure is impemented). Thus, a table reads

\{ \begin{matrix}indices & set of words I(T) \\ values & bottom row V (T) \end{matrix}  (1)

In the sequel, we will consider two types of laws: pointwise type (subscript _{p}) and convolution type (subscript _{c}). In order to define the pointwise and convolution composition, we must first construct the one of the two central features of the paper, namely the reduction system red.

1.2 The reduction system red

1.2.1 Reduction

Let T be a table with indices in a semigroup and values in a commutative semigroup (k, +).

If T owns two columns c_{i} = \frac{u_{i}}{p_{i}} i = 1, 2 with

the same index u_{1} = u_{2} = u, we define the reduction

T ⟶^{red} T − {c_{1}, c_{2}} + c_{3}

where c_{3} = \frac{u}{p_{1} + p_{2}}

Definition/Proposition 1 i) The reduction system defined above, denoted red_{1}, is noetherian and confluent. ii) The second reduction red_{2} consists in withdrawing the columns with coefficient 0. iii) A total reduction red consists in running successively red_{1} and red_{2}.

1.3 Tables and operations on tables

Let us consider, two tables T_{1}, T_{2} and a law ∗

T_{1} = \begin{matrix}u_{1} & u_{2} & ⋯ & u_{k} \\ p_{1} & p_{2} & ⋯ & p_{k} \end{matrix}

and

T_{2} = \begin{matrix}v_{1} & v_{2} & ⋯ & v_{l} \\ q_{1} & q_{2} & ⋯ & q_{l} \end{matrix}

then T_{1}∗_{p}T_{2} is defined by T_{i}[w] if w ∈ I(T_{i}) and w ∉ I(T_{3−i}) and by T_{1}[w] ∗ T_{2}[w] if w ∈ I(T_{1}) ∩ I(T_{2})

In particular one has I(T_{1}∗_{p}T_{2}) = I(T_{1})∪I(T_{2}).

Note 1 i) At this stage one do no need any neutral. The structure automatically creates it (see algebraic remarks below for full explanation). ii) The above is a considerable generalization of an idea appearing in [3], aimed only to semirings with units.

For convolution type, one needs two laws, say ⊕, ⊗, the second being distributive over the first, i.e. identically

x ⊗ (y ⊕ z) = (x ⊗ y) ⊕ (x ⊗ z) and
(y ⊕ z) ⊗ x = (y ⊗ x) ⊕ (z ⊗ x)  (2)

(see

http://mathworld.wolfram.com/
Semiring.html).

The set of indices of T_{1}∗_{c}T_{2} (I(T_{1}∗_{c}T_{2})) is the concatenation of the two (finite) langages I(T_{1}) and I(T_{2}) i.e. the (finite) set of words

I(T_{1})I(T_{2}) = {uv}_{(u,v)∈I(T_{1})×I(T_{2})}. (3)

then, for w ∈ I(T_{1})I(T_{2}), one defines

T_{1} ⊗_{c} T_{2}[w] = ⨁_{uv=w} (T_{1}[u] ⊗ T_{2}[v]) (4)

the interesting fact is that the constructed structure (call it T for tables) is then a semiring (T , ⊕_{p}, ⊗_{c}) (provided ⊕ is commutative and - generally - without units, but this is sufficient to perform matrix computations). There is, in fact no mystery in the definition (3) above, as every table can be decomposed in elementary bits

T_{1} = \begin{matrix}u_{1} & u_{2} & ⋯ & u_{k} \\ p_{1} & p_{2} & ⋯ & p_{k} \end{matrix} = ⨁_{i=1}^{k} \frac{u_{i}}{p_{i}} (5)

one has, thanks to distributivity, to understand the convolution of these indecomposable elements, which is, this time, very natural

\frac{u_{1}}{p_{1}} ⨂_{c} \frac{u_{2}}{p_{2}} := \frac{u_{1}u_{2}}{p_{1} × p_{2}}  (6)

1.4 Why semirings ?

In many applications, we have to compute the weights of paths in some weighted graph (shortest path problem, enumeration of paths, cost computations, automata, transducers to cite only a few) and the computation goes with two main rules: multiplication in series (i.e. along a path), and addition in parallel (if several paths are involved). This paragraph is devoted to showing that, under these conditions, the axioms of Semirings are by no means arbitrary and in fact unavoidable. A weighted graph is an oriented graph together with a weight mapping ω : A ↦ K from the set of the arrows (A) to some set of coefficients K, an arrow is drawn with its weight (cost) above as follows a = q_{1} →^{α} q_{2}. For such objects, one has the general conventions of graph theory.

• t(a) := q_{1} (tail)

• h(a) := q_{2} (head)

• w(a) := α (weight).

A path is a sequence of arrows c = a_{1}a_{2} ⋯ a_{n} such that h(a_{k}) = t(a_{k+1}) for 1 ≤ k ≤ n − 1. The preceding functions are extended to paths by t(c) = t(a_{1}), h(c) = h(a_{n}), w(c) = w(a_{1})w(a_{2}) ⋯ w(a_{n}) (product in the set of coefficients).

For example with a path of length 3 and (k = N),

u = p →^{2} q →^{3} r →^{5} s  (7)

one has t(u) = p, h(u) = s, w(u) = 30.

As was stated above, the (total) weight of a set of paths with the same head and tail is the sum of the individual weights. For instance, with

q1  →^{α} ; →^{β}  q2  (8)

the weigth of this set of paths est α + β. From the rule that the weights multiply in series and add in parallel one can derive the necessity of the axioms of the semirings. The following diagrams shows how this works.

Diagram  Identity

→^{α}

p →^{β} q  α + (β + γ) = (α + β) + γ

→^{γ}

p →^{α} ; →^{β}q  α + β = β + α
p →^{α} q →^{β} r →^{γ} s α(βγ) = (αβ)γ
p →^{α} ; →^{β}q →^{γ} r  (α + β)γ = αγ + βγ
p →^{α} q →^{β} ; →^{γ}r  α(β + γ) = αβ + αγ

these identities are familiar and bear the following names:

Line Name
I  Associativity of +
II  Commutativity of +
III Associativity of ×
IV Distributiveness (right) of × over +
V  Distributiveness (left) of × over +

1.5 Total mass

The total mass of a table is just the sum of the coefficients in the bottom row. One can check that

mass(T 1 ⊕ T 2) = mass(T 1) + mass(T 2);
mass(T 1 ⊗ T 2) = mass(T 1) · mass(T 2)(9)

this allows, if needed, stochastic conditions.

1.6 Algebraic remarks

We have confined in this paragraph some proofs of structural properties concerning the tables. The reader may skip this section with no serious harm. First, we deal with structures with as little as possible requirements, i.e. Magmas and Semirings. For formal definitions, see

http://
encyclopedia.thefreedictionary.com/
Magma%20category
http://mathworld.wolfram.com/
Semiring.html

Proposition 1 (i) Let (S, ∗) be a magma, Σ an alphabet, and denote T [S] the set of tables with indices in Σ^{∗} and values in S. Define ∗_{p} as in (1.3). Then

i) The law ∗ is associative (resp. commutative) iff ∗ is. Moreover the magma (T [S], ∗) always possesses a neutral, the empty table (i.e. with an empty set of indices). ii) If (K, ⊕, ⊗) is a semiring, then (T_{K}, ⊕, ⊗) is a semiring.

Proof. (Sketch) Let S_{(1)} the magma with unit built over (S ∪ {e}) by adjunction of a unit. Then, to each table T, associate the (finite supported) function f_{T} : Σ^{∗} ↦ S_{(1)} defined by

f_{T} (w) = \{ \begin{matrix}T [w] & if w ∈ I(T) \\ e & otherwise \end{matrix}  (10)

then, check that f_{T_{1} ∗_{p}T_{2}} = f_{T_{1}} ∗_{1}f_{T_{2}} (where ∗_{1}

is the standard law on S_{(1)}^{(Σ^{∗})}) and that the correspondence is a isomorphism. Use a similar technique for the point (ii) with K_{0,1} the semiring with units constructed over K and show that the correspondence is one-to-one and has K_{0,1}⟨Σ⟩ as image.

Note 2 1) Replacing Σ^{∗} by a simple set, the (i) of proposition above can be extended without modification (see also K-subsets in [6]).

2) If one replaces the elements of free monoid on the top row by elements of a semigroup S and admits some colums with a top empty cell, we get the algebra of S_{(1)}.

3) Pointwise product can be considered as being constructed with respect to the (Hadamard) coproduct c(w) = w ⊗ w whereas convolution is w.r.t. the Cauchy coproduct

c(w) = ∑_{uv=w} u ⊗ v  (11)

(see [5]).

2 Applications

2.1 Specializations and images

1. Multiplicities, Stochastic and Boolean. —

Whatever the multiplicities, one gets the classical automata by emptying the alphabet (setting Σ = ∅). For stochastic, one can use the total mass to pin up outgoing conditions.

2. Memorized Semiring. —

We explain here why the memorized semiring, devised at first to perform efficient computations on the shortest path problem with memory (of addresses) can be considered as an image of a ”table semiring” (thus proving without computation the central property of [10]). Let T be here the table semiring with coefficients in ([0, +∞], min, +). Then a table

T = \begin{matrix}u_{1} & ⋯ & u_{k} & ⋯ & u_{n} \\ l_{1} & ⋯ & l_{k} & ⋯ & l_{n} \end{matrix} (12)

can be written so that l_{1} = ⋯ = l_{k} < l_{m} for m > k (this amounts to say that the set where the minimum is reached is {u_{1}, u_{2} ⋯ u_{k}}). Then, to such a table, one can associate ϕ(T) := [{u_{1}, u_{2} ⋯ u_{k}}, l_{1}] in the memorized semiring. It is easy to check that ϕ transports the laws and the neutrals and obtain the result.

2.2 Application to evolutive systems

Tables are structured as semirings and are flexible enough to recover and amplify the structures of automata with multiplicities and transducers. They give operational tools for modelling agent behaviour for various simulations in the domain of distributed artificial intelligence [2]. The outputs of automata with multiplicities or the values of tables allow to modelize in some cases agent actions or in other cases, probabilities on possible transitions between internal states of agents behaviour. In all cases, the algebraic structures associated with automata outputs or tables values is very interesting to define automatic computations in respect with the evolution of agents behaviour during simulation.

One of ours aims is to compute dynamic multiagent systems formations which emerge from a simulation. The use of table operations delivers calculable automata aggregate formation. Thus, when table values are probabilities, we are able to obtain evolutions of these aggregations as adaptive systems do.

With the definition of adapted operators coming from genetic algorithms, we are able to represent evolutive behaviors of agents and so evolutive systems [1]. Thus, tables and memorized semiring are promizing tools for this kind of implementation which leads to model complex systems in many domains.

References

[1] Bertelle C., Flouret M., Jay V., Olivier D., Ponty J.-L., Genetic Algorithms on Automata with Multiplicities for Adaptative Agent Behaviour in Emergent Organisations.

[2] Bertelle C., Flouret M., Jay V., Olivier D., Ponty J.-L., Automata with Multiplicities as Behaviour Model in Multi-Agent Simulations SCI 2001.

[3] Champarnaud J.-M., Duchamp G., Derivatives of rational expressions and related theorems, T.C.S. 313 31 (2004).

[4] Duchamp G., Hatem Hadj Kacem, Éric Laugerotte, On the erasure of several letter-transitions, JICCSE’04

[5] Duchamp G., Flouret M., Laugerotte E., Luque J-G., Direct and dual laws for automata with multiplicites, Theoret. Comput. Sci. 267 (2001) 105-120.

[6] Eilenberg S., Automata, languages and machines, Vol A, Acad. Press (1974).

[7] Golan, J. S., Power algebras over semirings with applications in Mathematics and Computer Science, Kluwer (1999).

[8] Laugerotte E., Abbad H., Symbolic computation on weighted automata, JICCSE’04.

[9] Lothaire M., Combinatorics on words, Cambridge University Press (new edition), 1997.

[10] Khatatneh K., Construction of a memorized semiring, DEA ITA Memoir, University of Rouen (2003).