-
Notifications
You must be signed in to change notification settings - Fork 29
feat: new design for automata theory, results on regular languages, and deterministic labelled transition systems #144
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
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
bot fix style |
Does this work??? Very cool if so. I was surprised to see the bot commenting at all actually, it had been silently failing to post recently... did you do something to fix it? |
chenson2018
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.
Just some small style suggestions. The design seems fine to me, but I think you are more in touch with the requirements than I am.
| namespace Cslib.Automata | ||
|
|
||
| /-- An `Acceptor` is a machine that recognises strings (lists of symbols in an alphabet). -/ | ||
| class Acceptor (α : Type _) (Symbol : outParam (Type _)) 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.
It is mildly jarring to half follow the Mathlib convention of lowercase Greek for type variables.
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.
I was in doubt myself, it gives some goosebumps. But I couldn't come up with a better name than alpha.. maybe A for automaton or M for machine?
| rw [IsRegular.iff_cslib_dfa] at h ⊢ | ||
| obtain ⟨State, _, ⟨da, acc⟩, rfl⟩ := h | ||
| use State, inferInstance, ⟨da, accᶜ⟩ | ||
| ext ; grind |
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.
| ext ; grind | |
| grind |
|
Can we not use "Finite" in
in which the two "Finite"s mean totally different things. Even more confusing is that "finite automata" is a well-established terminology where the "finite" means that at least the state space is finite and perhaps the alphabet is finite as well. That is why I chose the name See the 1st commit of #145: |
|
I suggest we merge Acceptor.lean and OmegaAcceptor.lean into a single |
|
Re FinAcc: agreed, I'll switch. Re Accept: I need to think about it a bit. My thinking was that they're conceptually separate. Maybe we'll use Acceptor somewhere else, or maybe the different substructures of DA and NA will get bigger and merit their own files. Re all the patches by @chenson2018 : will integrate. |
|
For the |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chris Henson <[email protected]>
Co-authored-by: Chris Henson <[email protected]>
Co-authored-by: Chris Henson <[email protected]>
Co-authored-by: Chris Henson <[email protected]>
Co-authored-by: Chris Henson <[email protected]>
That's great, thanks. I'll merge it as soon as I'm done applying all the other suggestions. |
|
In the commit: `
If you like this, I can make similar changes to {DA,NA}.{Buchi,Muller} as well. |
|
I thought and tried to do the same. My first impression was that we get better ergonomics with making them But I chose to avoid it for now because it adds redundant definitions to every automaton, which kinda kills the point of having a typeclass. There were discussions about supporting dot notation for instances of a class, which would solve our problem. I'd like to take this discussion up with the Lean developers first. (I'll do that now.) So I'm just gonna cherry-pick 99fb99e for now (the |
|
All done. I've been thinking and searching more about the dot notation thing from the typeclass: if we really want to use dot notation for I'm not sure we should though.. we should ask the mathlibbers about their experience with this. |
|
In my opinion, such "redundant" definitions and theorems are very much in the style of Lean mathlib. For example, take a look at: More importantly, don't you find an expression like: |
|
Here's an example from mathlib's theorem mul_def (l m : Language α) : l * m = image2 (· ++ ·) l m := theorem mem_mul : x ∈ l * m ↔ ∃ a ∈ l, ∃ b ∈ m, a ++ b = x := |
|
Not all of these examples are direct copies of the definitions/theorems in the class, but that's beyond the point: as I wrote, my problem is not with having the copied definitions for dot notation (btw, these definitions should always just be a reference to the class definitions/theorems), but more with doing so manually. I would just much rather explore a systematic way, e.g., supplying a simple annotation when one creates an instance that produces all the copies needed for dot notation automatically. I'm now discussing this on Zulip. |
|
Link to the Zulip discussion: #Is there code for X? > Deriving dot notation from class instances |
|
Another response to the problem we are facing in this PR is to ask: Why is having an "acceptor" class preferable to the last design in #142, which doesn't have an "acceptor" class? What exactly is being gained from having an "acceptor" class? BTW, this brings up another question: Why do you need two acceptor classes? |
Then we'd have things like: which looks totally fine to me. I'll get to it, that's even more deduplication. :-) |
|
Do we really get code deduplication? If I still have to explicitly make instances of |
|
Note that the |
…Cslib in some automata files
Mmh actually doesn't work quite as expected, as Acceptor.language returns a Language whereas OmegaAcceptor.language returns an OmegaLanguage... I'll keep them separate for the time being. |
This PR merges the developments that @ctchou and I carried out in the
automatabranch, #141, and #142, as discussed on Zulip (#CSLib > Question Lean structure and extends). If this is merged, theautomatabranch and the two mentioned PRs should be erased.The design based on
Acceptorand structure extension works pretty well. Many definitions could be removed because of theAcceptortypeclass, and some proofs got easier thanks to the combination of structure extension, record updates, and grind.Co-authored with @ctchou.