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

incorrect choco output for reference to a constant #89

Open
mantkiew opened this issue Sep 8, 2016 · 2 comments
Open

incorrect choco output for reference to a constant #89

mantkiew opened this issue Sep 8, 2016 · 2 comments
Assignees
Milestone

Comments

@mantkiew
Copy link
Member

mantkiew commented Sep 8, 2016

For a model

abstract ASIL -> integer
A : ASIL -> 1
B : ASIL -> 2
C : ASIL -> 3
D : ASIL -> 4

the compiler produces

...
c0_ASIL.refToUnique(Int);
c0_A.extending(c0_ASIL).refTo(Int);
c0_B.extending(c0_ASIL).refTo(Int);
c0_C.extending(c0_ASIL).refTo(Int);
c0_D.extending(c0_ASIL).refTo(Int);

whereas the correct output should be

...
c0_ASIL.refToUnique(Int);
c0_A.extending(c0_ASIL).refToUnique(1);
c0_B.extending(c0_ASIL).refToUnique(2);
c0_C.extending(c0_ASIL).refToUnique(3);
c0_D.extending(c0_ASIL).refToUnique(4);
@mantkiew mantkiew added this to the 0.4.5 milestone Sep 8, 2016
@mantkiew mantkiew self-assigned this Sep 8, 2016
@mantkiew mantkiew changed the title incorrect choco output for reference to constant incorrect choco output for reference to a constant Sep 8, 2016
@JLiangWaterloo
Copy link
Member

JLiangWaterloo commented Sep 8, 2016

That's not supported right now by the backend (the refToUnique(1) part), but can't it be encoded easily with constraints like the following?

c0_A.extending(c0_ASIL);
c0_A.addConstraint(equal(joinRef($this()), 1));
c0_B.extending(c0_ASIL);
c0_B.addConstraint(equal(joinRef($this()), 2));
c0_C.extending(c0_ASIL);
c0_C.addConstraint(equal(joinRef($this()), 3));
c0_D.extending(c0_ASIL);
c0_D.addConstraint(equal(joinRef($this()), 4));

There would be no loss of efficiency since the backend has very good static analysis for these types of constraints and it will easily figure out that A/B/C/D must refer to 1/2/3/4 respectively.

@mantkiew
Copy link
Member Author

mantkiew commented Sep 8, 2016

Ok, I'll do it this way for int literals.

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

No branches or pull requests

2 participants