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

Internal consistency of saw-core typechecking #1264

Open
robdockins opened this issue Mar 18, 2021 · 7 comments
Open

Internal consistency of saw-core typechecking #1264

robdockins opened this issue Mar 18, 2021 · 7 comments
Labels
needs design Technical design work is needed for issue to progress subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem tech debt Issues that document or involve technical debt type: enhancement Issues describing an improvement to an existing feature or capability
Milestone

Comments

@robdockins
Copy link
Contributor

It's hard for me to track things through the typechecker, but it doesn't appear that Pi types collapse into Prop when the conclusion is in Prop, as I would expect. Instead it seems to follow the same rules as the predicative sort tower.

For example, the type assigned to (x : Bool) -> Eq Bool x x is sort 0 even though Eq is in Prop. Likewise the type of (A:sort 0) -> (x:A) -> Eq A x x is sort 1.

Related question regarding EqTrue. Why is it defined in sort 1?

EqTrue : Bool -> sort 1;
EqTrue x = Eq Bool x True;
@eddywestbrook
Copy link
Contributor

That is very strange. Here is the line that computes the sort of a pi type:

https://github.com/GaloisInc/saw-core/blob/master/saw-core/src/Verifier/SAW/SCTypeCheck.hs#L402

It looks like it is checking whether the output type is a Prop, and, if so, is returning Prop.

@eddywestbrook
Copy link
Contributor

I am guessing that EqTrue is just old: until recently, Eq was defined as a sort 1.

@robdockins
Copy link
Contributor Author

Interesting. Looks like that doesn't agree with the scTypeOf operator, which is mainly the one that is used in SAW.

https://github.com/GaloisInc/saw-core/blob/1dce64877bb720f48db9500ca1d399c6fc8a5e8e/saw-core/src/Verifier/SAW/SharedTerm.hs#L918

@eddywestbrook
Copy link
Contributor

Doh! I guess I can claim some of the fault there. I wrote the current version of SCTypeCheck.hs, but I guess I didn't update scTypeOf. Sounds like a bug then?

@robdockins
Copy link
Contributor Author

Looks like it. Easy enough to fix, I think.

Ensuring these functions stay in sync somehow... that's not so easy.

@eddywestbrook
Copy link
Contributor

Yeah, I was just thinking about how one would do that. I could imagine modifying the TypeInfer class so that typeInfer takes a Bool flag for whether to do thorough checking or to just assume that the input is already type-correct? I dunno...

@robdockins
Copy link
Contributor Author

The core issue was solved in GaloisInc/saw-core#190, but maybe we should keep this ticket open to discuss ways to keep the type-checking code in sync.

@brianhuffman brianhuffman transferred this issue from GaloisInc/saw-core Apr 27, 2021
@brianhuffman brianhuffman added type: question Issues that are primarily asking questions subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem labels Apr 27, 2021
@sauclovian-g sauclovian-g changed the title is Prop supposed to be impredicative? Internal consistency of saw-core typechecking Oct 30, 2024
@sauclovian-g sauclovian-g added type: enhancement Issues describing an improvement to an existing feature or capability tech debt Issues that document or involve technical debt needs design Technical design work is needed for issue to progress and removed type: question Issues that are primarily asking questions labels Oct 30, 2024
@sauclovian-g sauclovian-g added this to the Someday milestone Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs design Technical design work is needed for issue to progress subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem tech debt Issues that document or involve technical debt type: enhancement Issues describing an improvement to an existing feature or capability
Projects
None yet
Development

No branches or pull requests

4 participants