-
Notifications
You must be signed in to change notification settings - Fork 53
feat: define the Transducer class as recognizing a function from input strings to weights
#286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…t strings to weights from a `Semigroup`
| - partial functional string transducers, | ||
| by having output strings with an annihilator `none` as the weights -/ | ||
| class Transducer | ||
| (T : Type u) (Symbol : outParam (Type v)) (Weight : outParam (Type w)) [Semigroup Weight] where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of the T and t : T arguments here and below? They never seem to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T is a type of transducers implementing the type class Transducer. The function recognized by some transducer t : T can then be accessed via transduce t.
e.g. If we have def WeightedDFA : Type := ..., then the function recognized by a wdfa : WeightedDFA will be implemented as transduceFrom wdfa in instance : Transducer WeightedDFA Symbol Weight where ....
In this sense, T and t : T are analogous to A and a : A in Acceptor.lean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. Perhaps something like you wrote above should be part of the doc-string.
|
|
||
| variable {Symbol : Type v} {Weight : Type w} | ||
|
|
||
| section |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give a name to this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback 👍 This is now named Monoid as the section that takes weights to be from a Monoid.
ctchou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some general comments:
- Please run
lake exe mk_all --module, so thatimports for any files you add will also be added toCslib.lean. - I'm not sure weighted automata are a widely known subject. (I for one don't know anything about it.). So please provide some references, which you can add to the file
references.bibin the root directory and refer to them in a comment here.
|
A good reference for weighed automata is Droste et al. 2009. As in the chapter Mohri 2009, weighted automata have shortest-distance interpretations when weights are from an idempotent semiring. In this commit, just a semigroup is sufficient for stating the definition. |
ctchou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file looks fine by itself. So I'm approving it. But I wonder if we should wait for more material about weighted automata to be PR-ed to see how everything fits together. I leave that decision to @fmontesi .
| - partial functional string transducers, | ||
| by having output strings with an annihilator `none` as the weights -/ | ||
| class Transducer | ||
| (T : Type u) (Symbol : outParam (Type v)) (Weight : outParam (Type w)) [Semigroup Weight] where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. Perhaps something like you wrote above should be part of the doc-string.
…t-associative implementation
|
Thanks for all the feedback @ctchou. Here's a second iteration that works with an implementation of typical deterministic FSTs (
|
Transducer class as recognizing a function from input strings to weights from a SemigroupTransducer class as recognizing a function from input strings to weights
This definition easily specializes to:
noneto the weightsnoneas the weightsThe design is similar to the related
Acceptor.lean