-
Notifications
You must be signed in to change notification settings - Fork 297
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
[Merged by Bors] - feat(computability/regular_expressions): define regular expressions #5036
Conversation
Co-authored-by: Johan Commelin <johan@commelin.net>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Lifting this from a "resolved" comment so that it doesn't get lost... You'll find when you try to prove If you instead work with |
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 feel like the definitions go completely the wrong way here. First you define the Brzozowski derivative, and only at the end show that the algorithm matches the expected language.
I think it would be better to have it be the other way around, with the more fundamental definition first. First define the language of the regular expression, and only then show that it can be computed using the derivative:
def matches : regular_expression α → set (list α)
| zero := ∅
| null := {[]}
| (char x) = {[x]}
| (comp r1 r2) = r1.matches ∪ r2.matches
...
def deriv : regular_expression α → α → regular_expression α
...
def rmatch : regular_expression α → list α → bool
...
lemma rmatch_correct (r : regular_expression α) (xs : list α) :
r.rmatch xs ↔ r.match xs :=
...
It might also be a good idea to introduce an explicit language
type:
@[derive has_union, derive has_emptyc]
def language (α) := set (list α)
namespace language
instance : has_mul (language α) := -- composition
def star (l : language α) : language α := ...
end language
Then you can state properties about star more easily, like (star r).matches = r.matches.star
(also makes for nice simp lemmas!).
You could also define the derivative on languages first, but I'm not sure how much this would help with the long proofs here.
🎉 Great news! Looks like all the dependencies have been resolved: 💡 To add or remove a dependency please update this issue/PR description. Brought to you by Dependent Issues (:robot: ). Happy coding! |
This reverts commit e448842.
bors r+ |
…5036) Very basic definitions for regular expressions Co-authored-by: foxthomson <11833933+foxthomson@users.noreply.github.com>
Pull request successfully merged into master. Build succeeded: |
…5036) Very basic definitions for regular expressions Co-authored-by: foxthomson <11833933+foxthomson@users.noreply.github.com>
Very basic definitions for regular expressions