-
Notifications
You must be signed in to change notification settings - Fork 17
Support access to type instance #153
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
Support access to type instance #153
Conversation
ca2a07e to
4cd34fd
Compare
9e22d64 to
aaaf284
Compare
aaaf284 to
c9df904
Compare
|
I will help out here because this is a very tricky topic |
|
@melodyoncode my personal laptop broke - it will take me a bit of time to get to this. But I promise to do so. |
|
Hi @florianschanda , |
703a0cf to
469fe2d
Compare
469fe2d to
aa939e4
Compare
|
A few thoughts so far.
That would allow you to rely on some properties when referring to linked objects; instead of having to check everything to avoid errors. |
|
Hi @melodyoncode I have a working laptop again, and I just wanted to assure you I have not forgotten about this feature. |
|
Hi @florianschanda, (Just quietly saying, maybe we can stick to minimal changes.) |
|
It's not. It's a new laptop :D I have been thinking about this problem more, and I think I have now figure out all the issues. We need to tighten up the semantics of when checks are evaluated. I think the correct form will be:
I believe the UF way to access record fields will work. It'll give us, for free:
We do need to emit quantifiers to enforce some type constraints, there is no way around this. Specifically for arrays we need to enforce min/max bounds, and we also need to take care of frozen record fields. (Although that one we can probably do without a quantifier.) |
* Update PyVCG and CVC5 * Permit record field references * Add new LRM rule that the prefix of a dereference may not be null * Add unsupported note in VCG (this will be done in step 2)
|
There are some complications when tuples interact with records. For example this test is kinda fun: This actually uncovered a pre-existing in evaluation bug that I'll fix. |
|
I found some additional issues:
|
|
I have commit where things work now, but some additional work is needed to display counter-examples, because we now need to show more than one record in the example. |
* Add basic support for record references in VCG. Some bits (like references in quantifiers) do not work yet.
|
I have had a deep look now and there are large systematic issues with the way VCG works. I would propose the following approach:
And I then follow this up with a bigger patch that makes VCG work properly. |
|
One thing I know for sure is that we want to have two kinds of checks:
Existing checks would be checks, and invariants are the new kind of check permitted. Some changes would need to be done for evaluation, to make null / non-null checks work correctly. The name |
* Add basic support for record references in VCG. Some bits (like references in quantifiers) do not work yet.
|
I've created #156 to track this work |
|
@melodyoncode I have created PR #158 that partially implements field access and also fixes CI. I am sorry I could not get this PR to work directly, and I truly appreciate you trying; you managed to pick a extremely nasty issue and it will require basically a re-write of VCG to make it work properly. |
|
Hi @florianschanda |
|
@florianschanda
And I found a funny thing that I have doubt here, why this condition can work? |
Yes, this is due to an existing limitation regarding quantifiers. In my rewrite of VCG I expect to lift this restriction.
This should work. Does it not?
Because
None of these are possible here, ans so while the check itself can pass or fail; there are no errors possible here. If |
|
If you're interested here is the branch: https://github.com/florianschanda/trlc/blob/vcg_rewrite/trlc/vcg.py Nothing works yet, but if you want to contribute something (e.g. unary operators) I can give you direct push access to that repo. Right now I am trying to sort out all the truly horribly bits first, and then fill in the easy parts. Specifically:
None of the glue is there, specifically there is no actual solving of VCs / error reporting / counter-examples. I am just trying to get the algorithm sorted out and am manually inspecting the SMTLIB. Other than the limitations you already mentioned in your previous post, I also found a bug when it comes to order-of-evaluation of multiple check blocks that I am now doing correctly. Here is a fun quiz:
|
|
I think fatal checks of the parent type are treated as preconditions for all checks in the derived type. |
It does work. I just misunderstood it as a warning. |
|
Correct answer ;) Also I had a second thought on the example above. The check works and is error free. However it would actually always evaluate to false... eventually. Since there is no valid set of TRLC files for which this check would not fail somewhere. However this is totally out of scope for now, for now lint/vcg checks if there are run-time checks, not if its actually possible to build a set of files that pass :) |
depends-on florianschanda/PyVCG#6