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

fix: use dsimp to remove abstraction overhead of our parsing stage #225

Merged
merged 75 commits into from
May 13, 2024

Conversation

tobiasgrosser
Copy link
Collaborator

@tobiasgrosser tobiasgrosser commented Apr 13, 2024

Our current approach, 'change_mlir_context', does this by forcing reduction but does not reach certain subproofs in the goal. As a result, we currently have three failing test cases. By using dsimp to remove abstraction overhead from the goal, these abstractions are known to be removed everywhere. While there remains a risk that we miss certain simp lemmas, these can be added as a need arises. @alexkeizer also works on an alternative approach (#247) which might supersede this PR in the future.

Interestingly, our alive_case_bash tactic an introduce multiple goals which not always can be closed in AliveStatements. Hence, we add for now a set of two try sorry to cover this case. This should be investigate further in subsequent PRs.

@tobiasgrosser
Copy link
Collaborator Author

I feel #226 will be useful to debug this test case further. Waiting until it is merged.

@alexkeizer
Copy link
Collaborator

@bollu and I were talking about this, and we are going to explore some alternative setups, probably some mix of simpprocs and custom meta-code, that is hopefully more robust.
Endlessly polishing the simp-sets feels like a bit of of a waste of time, given that our automation tends to break in inscrutable ways whenever we so much as sneeze near them.

Then again, if your happiness/sanity points can tolerate dealing with this mess: don't let me discourage you

@tobiasgrosser
Copy link
Collaborator Author

Endlessly polishing the simp-sets feels like a bit of a waste of time, given that our automation tends to break in inscrutable ways whenever we so much as sneeze near them.

Who said that things are broken because of simp-sets being wrong? This test case seems to be independent of the simp sets. I carefully debugged this and it seems this is more likely a lean bug, than a bug in the simp sets. That might be worth discussing, before you go ahead and implement a pile of meta-code. I feel we should first reduce the bug before building solutions to an unclear problem. I am happy to do the reduction.

@alexkeizer
Copy link
Collaborator

alexkeizer commented Apr 15, 2024

I'm not saying the simp set is wrong, this kind of error is frustrating exactly because we do have a simp-lemma that should have rewritten the goal, but hasn't.

This also isn't the first time we've had this kind of issue. We've run into Valuation.snoc V (toSnoc v) not simplifying before. That time, the bug was caused by the fact that the type of V was something like [.bitvec (.mvar 0), .bitvec (.mvar 0), ...].map <meta-var instantation code>, which is def-eq to [.bitvec <concrete-width>, .bitvec <concrete-width>], but simp apparently wasn't able to see this.
That is why we now have change_mlir_context, to first reduce the context in the type of the valuation.

It would be nice to know what is causing the current issue we have, and even more amazing if it can be fixed upstream, but I think that regardless, it makes a lot of sense to find a more robust solution. For example, we can have a simp-proc that matches an application of Valuation.toSnoc more loosely, and then tries the different possible rewrites we have a bit more aggressively. I suspect that will solve the issue we are seeing here, and hopefully save us from seeing yet another variation of it in the future.

I am happy to do the reduction.

Great! I wasn't suggesting you shouldn't, just wanted to make you aware of some thoughts we were having

@bollu bollu force-pushed the broken_alive_autogenerated branch from 322e432 to 38574a1 Compare April 18, 2024 14:42
github-merge-queue bot pushed a commit that referenced this pull request May 10, 2024
These theorems will allow us to reason about the context and MVar with
less unfolding about low-level theorems. While uses of these theorems
are still worked on, the theorems seem to be generally useful so lets
upstream them already to keep later patches small.

Co-Authored-By : Siddharth Bhat<siddu.druid@gmail.com>

These are factored out of #225.

Co-authored-by: Siddharth Bhat <siddu.druid@gmail.com>
@tobiasgrosser tobiasgrosser marked this pull request as ready for review May 10, 2024 21:29
@tobiasgrosser tobiasgrosser requested a review from bollu May 10, 2024 21:29
@tobiasgrosser tobiasgrosser changed the title Broken alive autogenerated in case of mismatched types fix: use dsimp to remove abstraction overhead of our parsing stage May 11, 2024
@@ -85,7 +85,7 @@ def getStatement(preamble: List[str], id : int, proof: List[str]) -> str:

stmt = name
stmt += msg
stmt += " := by\n simp_alive_undef\n simp_alive_ops\n simp_alive_case_bash\n try alive_auto\n try sorry"
stmt += " := by\n simp_alive_undef\n simp_alive_ops\n simp_alive_case_bash\n try alive_auto\n try sorry\n try sorry"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stmt += " := by\n simp_alive_undef\n simp_alive_ops\n simp_alive_case_bash\n try alive_auto\n try sorry\n try sorry"
stmt += " := by\n simp_alive_undef\n simp_alive_ops\n simp_alive_case_bash\n try alive_auto\n all_goals sorry"

I think all_goals should already be fine with the case of 0 goals, otherwise we might want all_goals (try sorry) or some variation thereof

github-merge-queue bot pushed a commit that referenced this pull request May 13, 2024
#225 will fix three statements, one
of which will introduce multiple goals in `AliveStatements.lean`. This
PR makes `AliveStatements.lean` robust against multiple worries by using
`all_goals`.

Thank you @alexkeizer for proposing this.
@alexkeizer
Copy link
Collaborator

I still feel that mvar instantiation should never escape the elaborator. But, since #247 is at the moment still broken, let's merge this PR. Once the alternative does go through, we can deprecate this simp_alive_meta tactic

@alexkeizer alexkeizer added this pull request to the merge queue May 13, 2024
Merged via the queue into main with commit 146c822 May 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants