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

Tuple equality is very incomplete #164

Closed
marcoeilers opened this issue Feb 6, 2024 · 1 comment
Closed

Tuple equality is very incomplete #164

marcoeilers opened this issue Feb 6, 2024 · 1 comment

Comments

@marcoeilers
Copy link
Owner

Found by @PascalDevenoge, the following program should verify but doesn't:

from typing import *

from nagini_contracts.contracts import *

Shape = Tuple[int, ...]

class ndarray:
  @property
  def shape(self) -> Shape:
    ...

  @shape.setter
  def shape(self, new_shape: Shape) -> None:
    ...


@Predicate
@ContractOnly
def array_pred(array: ndarray) -> bool:
  return True

@Pure
@ContractOnly
def array_shape(array: ndarray) -> Shape: #type: ignore[return]
  Requires(Acc(array_pred(array), 1/2))
  ...

@ContractOnly
def ones(shape: Shape) -> ndarray: #type: ignore[return]
  Requires(len(shape) > 0)
  Requires(Forall(shape, lambda l: l > 0))

  Ensures(array_pred(Result()))
  Ensures(array_shape(Result()) == shape)
  # Ensures(shape == Old(shape))
  ...

shape = (2,)
array1 = ones(shape)
array2 = ones(shape)


array1.shape = (3,)

assert array_shape(array1) == shape
assert array_shape(array2) == shape
# assert array1.shape == shape
assert array_shape(array1) == array_shape(array2)
@marcoeilers
Copy link
Owner Author

Fixed in #165

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

1 participant