-
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
feat(computability): prove equivalence of NFAs and regular expressions #14250
base: master
Are you sure you want to change the base?
feat(computability): prove equivalence of NFAs and regular expressions #14250
Conversation
This adds a working proof that NFAs are equivalent to regular expressions. This is *not* meant to be committed into the actual library yet, rather just so people can see my work so far. I will soon fix style things and add comments on parts that I'm unsure about.
Add documentation, TODOs, and questions about my proof. Still a WIP.
Use standard brace placement in tactic mode. Replace intermediate simp with rw and simp only.
Fix all style issues
src/computability/GNFA.lean
Outdated
Given an equivalence between `σ` and `τ`, convert an NFA with state type `σ` into the corresponding | ||
NFA with state type `τ`. | ||
|
||
TODO: possibly move to computability/NFA |
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.
Since this is your first PR and it's rather large; I recommend you split this definition and the lemma below into a second PR (adding it to the NFA file), and then come back to this one once that's merged.
* probably move this into computability/regular_expression | ||
* maybe change the order to `pow n * r`? | ||
-/ | ||
def pow (r : regular_expression α) : ℕ → regular_expression α |
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.
Is monoid (regular_expression a)
true?
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.
Ah no, because regexes have no useful meaning of equality.
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've moved this definition to #14261 and added a lemma.
end | ||
|
||
theorem star_iff_pow {r : regular_expression α} {x} : | ||
x ∈ r.star.matches ↔ (∃ (n : ℕ), x ∈ (r ^ n).matches) := |
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 think this follows trivially from language.star_eq_supr_pow
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.
Thank you for all your feedback, Eric. I will be making changes and keeping an eye on #14261 .
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's now merged :)
Merge updates to master, including a regular expression power operator that will be used in the proof of correctness for the star case of regular expression to NFA
Refactored GNFA proofs to use fintype.induction_empty_option instead of fin.
Provide a way to convert NFAs to regular expressions and vice versa, and prove that the conversions accept the same language.
TODO: statement of some theorems, style, adding @[simp] annotations appropriately, conversions between DFAs and regular expressions