Skip to content

RmFinalEpsilon: Only remove epsilon arcs if semiring is left distributive or state is non-final#75

Merged
copybara-service[bot] merged 1 commit intomainfrom
copybara/899380338
Apr 17, 2026
Merged

RmFinalEpsilon: Only remove epsilon arcs if semiring is left distributive or state is non-final#75
copybara-service[bot] merged 1 commit intomainfrom
copybara/899380338

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service bot commented Apr 14, 2026

RmFinalEpsilon: Only remove epsilon arcs if semiring is left distributive or state is non-final

Pushing final weights backward across an epsilon transition (folding
arc.weight * final_weight into the current state's final weight)
inherently assumes left distributivity: A * (B + C) = A * B + A * C.

For semirings that are not left distributive (such as StringWeight
with STRING_RIGHT), unconditionally folding these weights alters the
accepted semantics of the FST.

This change ensures that RmFinalEpsilon only sums up epsilon arcs if
the semiring has the kLeftSemiring property, fixing test failures in
algo_test_right_string (MyMap/MapTest/0.EncodeDestructive).

@copybara-service copybara-service bot force-pushed the copybara/899380338 branch 3 times, most recently from e38536b to 314e52d Compare April 15, 2026 14:09
@copybara-service copybara-service bot changed the title RmFinalEpsilon: Only remove final epsilon arcs if the semiring is left distributive RmFinalEpsilon: Only remove epsilon arcs if semiring is left distributive or state is non-final Apr 15, 2026
@copybara-service copybara-service bot force-pushed the copybara/899380338 branch 2 times, most recently from 0ef6a5d to de2c5a8 Compare April 17, 2026 15:25
…tive or state is non-final

Pushing final weights backward across an epsilon transition (folding
`arc.weight * final_weight` into the current state's final weight)
inherently assumes left distributivity: `A * (B + C) = A * B + A * C`.

For semirings that are not left distributive (such as `StringWeight`
with `STRING_RIGHT`), unconditionally folding these weights alters the
accepted semantics of the FST.

This change ensures that `RmFinalEpsilon` only sums up epsilon arcs if
the semiring has the `kLeftSemiring` property, fixing test failures in
`algo_test_right_string` (`MyMap/MapTest/0.EncodeDestructive`).

PiperOrigin-RevId: 901317228
@copybara-service copybara-service bot merged commit 818817b into main Apr 17, 2026
@copybara-service copybara-service bot deleted the copybara/899380338 branch April 17, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant