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

Constraint conjunction #123

Open
MattWindsor91 opened this issue Dec 13, 2016 · 6 comments
Open

Constraint conjunction #123

MattWindsor91 opened this issue Dec 13, 2016 · 6 comments

Comments

@MattWindsor91
Copy link
Collaborator

MattWindsor91 commented Dec 13, 2016

If we write

constraint Foo(bar) -> baz;
constraint Foo(fizz) -> buzz;

Starling should collapse this to

constraint Foo(bar) -> baz && buzz[bar\fizz]

It should be ok to substitute the first set of parameters for all subsequent instances of the constraint as long as all substitutions are done in parallel.

If we write

constraint Foo(bar) -> baz;
constraint Foo(fizz) -> ?;

it should perhaps be an error (eventually this might have special semantics, eg. allowing HSF to infer a constraint no weaker than baz.

This is needed for #122 but is useful on its own.

@MattWindsor91
Copy link
Collaborator Author

Adding this might also be helpful for #130, as we could synthesise

shared bool ok;
constraint emp -> ok;

whenever post-state divergence modelling is needed.

@MattWindsor91
Copy link
Collaborator Author

Just trying to think how to handle the problem of, say

shared bool foo, bar;

constraint baz(foo, x) -> bar == foo;
constraint baz(x, bar) -> bar == foo;

We can't just rename one of the constraints to the parameters of the other, and I'd rather not introduce a massive wad of alpha renaming logic.

I think what we might need to do is rename all constraint parameters to positional names during desugaring:

shared bool foo, bar;

constraint baz($1, $2) -> bar == $1;
constraint baz($1, $2) -> $2 == foo;

Then we can desugar directly to

constraint baz($1, $2) -> (bar == $1) && ($2 == foo);

This shouldn't be too difficult, though it's definitely nontrivial software engineering work.

@septract
Copy link
Owner

septract commented Feb 2, 2017 via email

@MattWindsor91
Copy link
Collaborator Author

@septract I'll go fishing in the examples, I seem to remember there was something where we ideally wanted to AND a disjoint and a constraint together. (Though idk what we're doing about disjoint and friends. I think they might need a bit of a syntactic overhaul.)

@MattWindsor91
Copy link
Collaborator Author

@septract in the array version of Peterson's algorithm we have:

constraint holdLock(me) * waiting(you) -> me != you && turn == you;
constraint flagDown(me) * flagDown(you) -> me != you;
constraint flagUp(me)   * flagUp(you)   -> me != you;
constraint flagUp(me)   * waiting(you)  -> me != you;
constraint flagUp(me)   * holdLock(you) -> me != you;
constraint waiting(me)  * waiting(you)  -> me != you;

Ideally this should be replaced with something like

disjoint holdLock, flagDown, flagUp, waiting;
constraint holdLock(me) * waiting(you) -> turn == you;

@septract
Copy link
Owner

septract commented Feb 2, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants