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

Add disjointness reasoning for BbML #260

Open
wants to merge 16 commits into
base: hkmc2
Choose a base branch
from

Conversation

NeilKleistGao
Copy link
Member

@NeilKleistGao NeilKleistGao commented Jan 8, 2025

  • Track outer regions for disjointness reasoning
  • Support outer variables for functions polymorphic types
  • Fix some pretty-print bugs
  • Fix negative type elaboration
  • Refactor type variable collection logic
  • Fix some missing cases

This PR is still being prepared, e.g., containing redundant code. Such problems will be addressed after the main problems are discussed in the meeting.



fun annohelper: Region[outer] ->{outer} @outer Pair[out Ref[Int, out outer], out Ref[Int, out Any]]
fun annohelper: [outer, T extends outer] -> Region[T] ->{T} Pair[out Ref[Int, out T], out Ref[Int, out Any]]
Copy link
Contributor

Choose a reason for hiding this comment

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

A more natural signature could be

Suggested change
fun annohelper: [outer, T extends outer] -> Region[T] ->{T} Pair[out Ref[Int, out T], out Ref[Int, out Any]]
fun annohelper: [outer, T] -> Region[T] ->{T | outer} Pair[out Ref[Int, out T], out Ref[Int, out outer]]

Does it work? If it does, it would be good to add it to the test file (in addition to the existing one).

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it doesn't. We can only track the evidence that r2 <: ~outer, but not r2 <: ~T. So this code will be rejected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why would we need r2 <: ~T here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The disjointness requirement is (T | outer) & r2 <: bot, i.e., (T & r2) | (outer & r2) <: bot. Then only the second subterm (outer & r2) <: bot can be solved. The equivalent one should be T & outer instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, right, ofc.



fun annohelper: Region[outer] ->{outer} @outer Pair[out Ref[Int, out outer], out Ref[Int, out Any]]
fun annohelper: [outer, T extends outer] -> Region[T] ->{T} Pair[out Ref[Int, out T], out Ref[Int, out Any]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have Any in Ref[Int, out Any]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the second reference returned by fork is located in r2. It is extruded after we leave the scope of r2. But it can be written as out ~outer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, ~outer is what I meant in my other comment.

@LPTK
Copy link
Contributor

LPTK commented Jan 13, 2025

BTW, since you are modifying the way forall types are printed. Why not print them like in the source? Eg [A, B, outer C] -> ...

@NeilKleistGao NeilKleistGao marked this pull request as ready for review January 13, 2025 07:53
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.

2 participants