Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

RussellEmerine
Copy link
Collaborator

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

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.
@RussellEmerine RussellEmerine added the awaiting-review The author would like community review of the PR label May 19, 2022
Given an equivalence between `σ` and `τ`, convert an NFA with state type `σ` into the corresponding
NFA with state type `τ`.

TODO: possibly move to computability/NFA
Copy link
Member

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 α
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

@eric-wieser eric-wieser added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels May 20, 2022
end

theorem star_iff_pow {r : regular_expression α} {x} :
x ∈ r.star.matches ↔ (∃ (n : ℕ), x ∈ (r ^ n).matches) :=
Copy link
Member

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

Copy link
Collaborator Author

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 .

Copy link
Member

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.
@semorrison semorrison added the too-late This PR was ready too late for inclusion in mathlib3 label Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author A reviewer has asked the author a question or requested changes too-late This PR was ready too late for inclusion in mathlib3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants