Zulip Chat Archive
Stream: mathlib4
Topic: simpNF issues in Computability.RegularExpressions !4#2306
Arien Malec (Feb 16 2023 at 16:14):
In !4#2306, if I lint at line 99 after comp_def
, I'm told that I'm able to simplify the definition of a large number of methods that were all created as a side effect of the inductive
definition...
Arien Malec (Feb 16 2023 at 16:16):
I'm also told that matches'
can simplify matches'._eq_4
, which seems unhelpful.
Arien Malec (Feb 16 2023 at 16:31):
I also get the strangest possible path for simp
for matches'_add
, so I think that's safe to nolint.
Arien Malec (Feb 16 2023 at 22:16):
It's also very confusing how simpNF
is saying that it can "prove" matches'
which is a def
Arien Malec (Feb 16 2023 at 22:37):
OK, I used this trick to nolint the generated declarations: https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/nolinting.20generated.20decls/near/328300300
But I can't stop simpNF
from complaining about matches'
despite a nolint
Arien Malec (Feb 16 2023 at 22:43):
OK, attribute [nolint simpNF] matches'._eq_4
does it...
Arien Malec (Feb 16 2023 at 22:47):
Here is how simpNF
proposed to "prove" the +
branch of this def
def matches' : RegularExpression α → Language α
| 0 => 0
| 1 => 1
| char a => {[a]}
| P + Q => P.matches' + Q.matches'
| P * Q => P.matches' * Q.matches'
| star P => P.matches'∗
simp only [matches', add_eq_sup, ge_iff_le, le_eq_subset, sup_eq_union]
Arien Malec (Feb 16 2023 at 22:54):
I highlight add_eq_sup
, which is defined on IdemSemiring α
Arien Malec (Feb 16 2023 at 22:55):
WHICH RegularExpression
IS NOT....
Arien Malec (Feb 16 2023 at 22:58):
and the rest that are defined on Set
which RegularExpression
isn't. (And also simpNF
wants to prove matches'
by matches'
). Something is wrong here.
Gabriel Ebner (Feb 16 2023 at 23:19):
Arien Malec said:
I also get the strangest possible path for
simp
formatches'_add
, so I think that's safe to nolint.
nolint
is bad here because the problem is still there. I'd just remove the @[simp]
on matches'_add
.
Gabriel Ebner (Feb 16 2023 at 23:21):
Looking at the file, the best solution is to remove the @[simp]
on def matches'
, because that does something different than in Lean 3.
Gabriel Ebner (Feb 16 2023 at 23:21):
And now the generated simp lemmas reference plus a b
instead of a + b
which is not in simp nf.
Gabriel Ebner (Feb 16 2023 at 23:34):
Arien Malec said:
I highlight
add_eq_sup
, which is defined onIdemSemiring α
WHICH RegularExpression IS NOT....
This is not about regular expressions, this is about languages. And the way simp works here is indeed super unfortunate. It rewrites (a + b : Language A)
first to a ⊔ b
and then to a ∪ b
.
Gabriel Ebner (Feb 16 2023 at 23:41):
I guess that's because we haven't merged !4#2307 yet.
Arien Malec (Feb 16 2023 at 23:57):
Ahhh. Yes, super unfortunate.
Removing @[simp]
from matches'
addresses things... Thanks!
Arien Malec (Feb 18 2023 at 20:03):
Sadly, this PR wasn't merged & after some changes to Language
and the PR for NFA
caused a merge conflict, needed to merge with master, which caused the PR to go from green to red, I assume because of the changes to Language
?
I can get the failing proofs in matches'_map
to work by removing map
from the simp only
but now run into issues with recursion, which previously Lean had no issues with...
Arien Malec (Feb 19 2023 at 00:34):
The only branch that Lean complains about is the R + S
branch, which makes me think it's a side effect of the issues above?
Eric Wieser (Feb 19 2023 at 13:12):
I think my lean 3 refactor of docs#language will help here, #18451
Arien Malec (Feb 19 2023 at 16:25):
will cross tag -- thanks!
Last updated: Dec 20 2023 at 11:08 UTC