No public endorsements yet.
Loading review…
Sign in with ORCIDConcept map
In the paper
- page 59 of the paper of lax-157538, Transducers
Definition
A weighted automaton over a semiring (Definition B.3.2 of Transducers) is defined like a nondeterministic automaton with output, except that the transitions carry elements of instead of output strings, and that every input string is required to have only finitely many accepting runs. Its semantics is the function mapping an input string to
the sum over the accepting runs over of the product of the weights of the transitions of , taken in the order of the run — which matters when the multiplication of is not commutative. The finiteness requirement is what makes the sum well defined. Over the Boolean semiring weighted automata are nondeterministic automata; over the semiring of regular languages they are the rational relations; over they have decidable equivalence (Theorem B.3.3).
Lean source view on GitHub
| 1 | import Mathlib.Algebra.BigOperators.Finprod |
| 2 | import Lax132576.LabelledAutomata |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Weighted automata |
| 7 | type: definition |
| 8 | --- |
| 9 | A *weighted automaton* over a semiring (Definition B.3.2 of |
| 10 | *Transducers*) is defined like a nondeterministic automaton with output, except |
| 11 | that the transitions carry elements of instead of output strings, |
| 12 | and that every input string is required to have only finitely many accepting |
| 13 | runs. Its semantics is the function mapping an input |
| 14 | string to |
| 15 | |
| 16 | the sum over the accepting runs over of the product of the weights |
| 17 | of the transitions of , taken in the order of the run — which matters when |
| 18 | the multiplication of is not commutative. The finiteness |
| 19 | requirement is what makes the sum well defined. Over the Boolean semiring |
| 20 | weighted automata are nondeterministic automata; over the semiring of regular |
| 21 | languages they are the rational relations; over they have |
| 22 | decidable equivalence (Theorem B.3.3). |
| 23 | |
| 24 | # Formalization notes |
| 25 | |
| 26 | A semiring (Definition B.3.1) is mathlib's `Semiring`. A weighted automaton is |
| 27 | a labelled automaton (`LabelledAutomata`) with labels in `S`; `weightOf` is |
| 28 | the ordered product of the labels of a path, `FinitelyManyRuns` the |
| 29 | requirement of the definition, and `wEval` the sum over the set of accepting |
| 30 | runs, written as mathlib's finite sum over a set (`∑ᶠ`), which is the intended |
| 31 | sum whenever the set is finite. `IsWeighted f` asks for a finite state space |
| 32 | and an automaton satisfying the finiteness requirement. |
| 33 | -/ |
| 34 | |
| 35 | namespace Lax132576.WeightedAutomata |
| 36 | |
| 37 | open Lax132576.LabelledAutomata |
| 38 | |
| 39 | variable {A S Q : Type} [Semiring S] |
| 40 | |
| 41 | /-- The weight of a path: the product of the weights of its transitions, in the |
| 42 | order in which they are taken. -/ |
| 43 | def weightOf (ts : List (Q × List A × S × Q)) : S := (LabAut.labelsOf ts).prod |
| 44 | |
| 45 | /-- The semantics of a weighted automaton: the sum of the weights of the accepting |
| 46 | runs over the input. -/ |
| 47 | noncomputable def wEval (M : LabAut A S Q) (w : List A) : S := |
| 48 | ∑ᶠ ts ∈ M.acceptingOn w, weightOf ts |
| 49 | |
| 50 | /-- The requirement of Definition B.3.2: every input string has only finitely |
| 51 | many accepting runs. -/ |
| 52 | def FinitelyManyRuns (M : LabAut A S Q) : Prop := ∀ w : List A, (M.acceptingOn w).Finite |
| 53 | |
| 54 | /-- A function `A* → S` computed by a weighted automaton over the semiring `S` |
| 55 | with a finite state space. -/ |
| 56 | def IsWeighted {A S : Type} [Semiring S] (f : List A → S) : Prop := |
| 57 | ∃ (Q : Type) (_ : Finite Q) (M : LabAut A S Q), FinitelyManyRuns M ∧ wEval M = f |
| 58 | |
| 59 | end Lax132576.WeightedAutomata |
| 60 |
Formalization notes
A semiring (Definition B.3.1) is mathlib's . A weighted automaton is a labelled automaton () with labels in ; is the ordered product of the labels of a path, the requirement of the definition, and the sum over the set of accepting runs, written as mathlib's finite sum over a set (), which is the intended sum whenever the set is finite. asks for a finite state space and an automaton satisfying the finiteness requirement.
Community review
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.
0 comments