Add implementation of Kleene's algorithm to show each regular language has a regex matching it #35600
Add implementation of Kleene's algorithm to show each regular language has a regex matching it #35600yisiox wants to merge 4 commits intoleanprover-community:masterfrom
Conversation
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary dffa0f2129
|
| File | Base Count | Head Count | Change |
|---|---|---|---|
| Mathlib.Computability.EpsilonNFA | 706 | 716 | +10 (+1.42%) |
Import changes for all files
| Files | Import difference |
|---|---|
Mathlib.Computability.EpsilonNFA |
10 |
Declarations diff
+ ExtendedState
+ ExtendedState.equivSum
+ IsPath.from_accept
+ IsPath.state_accept
+ IsPath.toSingleεNFA_lift_extendedState
+ IsRestrictedMatch
+ IsRestrictedMatch.mono
+ IsRestrictedPath
+ accepts_toRegex
+ accepts_toSingleεNFA
+ directRegex
+ e
+ instance [FinEnum σ] : FinEnum (ExtendedState σ)
+ instance {M : εNFA α σ}
+ isRestrictedMatch_iff_exists_isPath
+ isRestrictedMatch_iff_exists_isRestrictedPath
+ isRestrictedMatch_nil
+ isRestrictedMatch_of_mem_pathRegex
+ isRestrictedMatch_star
+ isRestrictedPath_iff_isPath
+ matches'_foldl_acc
+ matches'_foldl_sum
+ mem_matches'_directRegex
+ mem_matches_mul_star_mul
+ mem_matches_star_concat
+ mem_matches_star_singleton
+ mem_pathRegex_iff_isRestrictedMatch
+ mem_pathRegex_of_isRestrictedMatch
+ pathRegex
+ pathRegex_mono
+ pathRegex_trans
+ toRegex
+ toSingleεNFA
You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>The doc-module for scripts/declarations_diff.sh contains some details about this script.
No changes to technical debt.
You can run this locally as
./scripts/technical-debt-metrics.sh pr_summary
- The
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
This PR adds a proof that every regular language has some regular expression matching it.
This was achieved by the following constructions and proofs of their correctness
toSingleεNFAto transform any epsilon-NFA to an equivalent one with only a single start and accept state (and the type isExtendedState)ExtendedStateandFin (FinEnum.card (ExtendedState σ))to index the statespathRegexwhich implements Kleene's algorithmtoRegexwhich takes an epsilon-NFA, appliestoSingleεNFAon it, and computes the corresponding regex usingpathRegexThe proofs of correctness chain together to yield
(toRegex M).matches' = M.acceptswhich asserts the direction of Kleene's theorem required.