Skip to content

feat(Language): characterizing regular languages using syntactic monoids - #903

Open
ctchou wants to merge 4 commits into
leanprover:mainfrom
ctchou:syntactic-monoid
Open

ctchou wants to merge 4 commits into
leanprover:mainfrom
ctchou:syntactic-monoid

Conversation

@ctchou

@ctchou ctchou commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

This PR develops yet another characterization of regular languages: a language is regular if and only if its syntactic monoid is finite. The syntactic monoid is the quotient of the free monoid by the Myhill congruence, which is a two-sided congruence on finite words that is finer than the Nerode congruence used in the Myhill-Nerode theorem.

As part of this PR, both left and two-sided congruences on finite words are defined and all congruences on finite words are moved from the namespace Cslib to the more appropriate namespace Language.

Comment on lines +28 to +29
class RightCongruence (α : Type*) extends eq : Setoid (List α) where
right_cov : CovariantClass _ _ (fun x y => y ++ x) eq

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It might be worth copying Con and RingCon here; that is, skipping CovariantClass and writing these more directly as append_left and append_right.

Note that those also don't override toSetoid to eq, and instead add a FunLike instance.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

But wouldn't that require a Mul (List α) with ++ being the multiplication? My impression from the following Zulip thread is that that is not considered a good idea:
#Is there code for X? > List as a monoid

Comment thread Cslib/Computability/Languages/SyntacticMonoid.lean Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants