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

[BUG] Multiple composition #245

Open
iincer opened this issue Mar 11, 2023 · 1 comment
Open

[BUG] Multiple composition #245

iincer opened this issue Mar 11, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@iincer
Copy link
Collaborator

iincer commented Mar 11, 2023

Describe the bug
Multiple composition has incorrect top-level IO.

To Reproduce
This is the current test:

def test_multiple_composition() -> None:
    c1 = PolyhedralContract.from_string(
        assumptions=["x <= 1"], guarantees=["y <= 0"], input_vars=["x"], output_vars=["y"]
    )
    c2 = PolyhedralContract.from_string(
        assumptions=["y <= 0"], guarantees=["z <= 0"], input_vars=["y"], output_vars=["z"]
    )
    c3 = PolyhedralContract.from_string(
        assumptions=["y <= 0"], guarantees=["q <= 0"], input_vars=["y"], output_vars=["q"]
    )
    c4 = PolyhedralContract.from_string(
        assumptions=["q <= 0"], guarantees=["v <= 0"], input_vars=["q"], output_vars=["v"]
    )

    contract = compose_multiple_contracts([c1, c2, c3, c4])

    assert str(contract.a.to_str_list()[0]) == "y <= 0.0"

The assertion shown implies that y is a top-level input of the composition, which is wrong, as the only top-level input should be x. When we print the composed contract, we get

InVars: [y]
OutVars:[z]
A: [       
  y <= 0.0 
]
G: [       
  z <= 0.0 
]

Expected behavior
x should be a top-level input to the composed contract. I am puzzled as to where x went in this composition.
Note that the contract contract is exactly the same as c2.
The implementation and test need to be fixed. Please add more tests to make sure the implementation is right.

@iincer
Copy link
Collaborator Author

iincer commented Mar 23, 2023

@pierg, please note there is a branch associated with this issue. Please create a PR when ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants