Skip to content

Prove FST associativity and distant idempotence#37

Merged
ibbem merged 15 commits intodevelopfrom
FST-assoc
May 29, 2024
Merged

Prove FST associativity and distant idempotence#37
ibbem merged 15 commits intodevelopfrom
FST-assoc

Conversation

@ibbem
Copy link
Copy Markdown
Collaborator

@ibbem ibbem commented May 27, 2024

No description provided.

ibbem added 6 commits May 27, 2024 23:10
Due to the argument order of `_⊙_`, the children got merged in the wrong
order. Hence, the merge order of the children kind of reversed after
each level. Notice that the new argument order agrees with the usual
`List.foldl` argument order.

Example of what changed:
Previously, we had
    ((0 -< rose-leaf 1 ∷ [] >- ∷ []) ⊕ (0 -< rose-leaf 2 ∷ [] >- ∷ []))
  ≡  (0 -< rose-leaf 2 ∷                     rose-leaf 1 ∷ [] >- ∷ [])
and
    ((0 -< 1 -< rose-leaf 2 ∷ [] >- ∷ [] >- ∷ []) ⊕ (0 -< 1 -< rose-leaf 3 ∷ [] >- ∷ [] >- ∷ []))
  ≡  (0 -< 1 -< rose-leaf 2 ∷                                  rose-leaf 3 ∷ [] >- ∷ [] >- ∷ [])
now we have
    ((0 -< rose-leaf 1 ∷ [] >- ∷ []) ⊕ (0 -< rose-leaf 2 ∷ [] >- ∷ []))
  ≡  (0 -< rose-leaf 1 ∷                     rose-leaf 2 ∷ [] >- ∷ [])
and
    ((0 -< 1 -< rose-leaf 2 ∷ [] >- ∷ [] >- ∷ []) ⊕ (0 -< 1 -< rose-leaf 3 ∷ [] >- ∷ [] >- ∷ []))
  ≡  (0 -< 1 -< rose-leaf 2 ∷                                  rose-leaf 3 ∷ [] >- ∷ [] >- ∷ [])
In the paper, we do not presume the standard library so we define `_⊕'_`
without `foldl`.
The `FeatureAlgebra` concept is based on the paper "An algebraic
foundation for automatic feature-based program synthesis" by Apel et.
al. which is a little vague and inconsistent with the order of their
composition operator. While discussing the buggy children order fixed in
f3ccb0f, we discovered that the
distant idempotence law is dictated by the order during composition.

Using our current definition of `_⊕_`, we have
    ((0 -< rose-leaf 1 ∷ [] >- ∷ []) ⊕ (0 -< rose-leaf 2 ∷ rose-leaf 3 ∷ [] >- ∷ []))
  ≡  (0 -< rose-leaf 1 ∷                     rose-leaf 2 ∷ rose-leaf 3 ∷ [] >- ∷ [])
which gives rise to the law
  i₁ ⊕ i₂ ⊕ i₁ ≡ i₁ ⊕ i₂

In contrast, with the alternative definition of `_⊕_`, with swapped
composition order, we have
    ((0 -< rose-leaf 1 ∷ [] >- ∷ []) ⊕ (0 -< rose-leaf 2 ∷ rose-leaf 3 ∷ [] >- ∷ []))
  ≡  (0 -< rose-leaf 2 ∷ rose-leaf 3 ∷                     rose-leaf 1 ∷ [] >- ∷ [])
which gives rise to the law
  i₂ ⊕ i₁ ⊕ i₂ ≡ i₁ ⊕ i₂

Although Apel et. al. state the distant idempotence law as
  i₂ ⊕ i₁ ⊕ i₂ ≡ i₁ ⊕ i₂
we decided to use the more intuitive composition order.
@pmbittner pmbittner self-requested a review May 28, 2024 06:05
@pmbittner pmbittner added the enhancement New feature or request label May 28, 2024
@pmbittner
Copy link
Copy Markdown
Member

I love how this PR did not have to touch any of the existing proofs on FSTs, which we just merged. 🚀

@pmbittner
Copy link
Copy Markdown
Member

I am beginning to review in-file this time.

Copy link
Copy Markdown
Member

@pmbittner pmbittner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed my review. I also integrated some minor improvements myself, including enhanced documentation and extraction of some utility lemmas.

@ibbem
Copy link
Copy Markdown
Collaborator Author

ibbem commented May 29, 2024

Nice!
I worked through the comments and did the requested changes.

@ibbem ibbem merged commit 7a8d3f6 into develop May 29, 2024
@ibbem ibbem deleted the FST-assoc branch May 29, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants