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

Propagating fin constraints through /^ operator #581

Closed
brianhuffman opened this issue Mar 18, 2019 · 2 comments
Closed

Propagating fin constraints through /^ operator #581

brianhuffman opened this issue Mar 18, 2019 · 2 comments
Assignees

Comments

@brianhuffman
Copy link
Contributor

Cryptol's type checker fails on something that seems like it should work:

foo : {i, j} (fin i, fin j, j >= 1) => [i /^ j][32]
foo = take [0...]
[error] at ./foo.cry:3:1--3:18:
  Failed to infer the following types:
    • ?back`845, type argument 'back' of 'take' at ./foo.cry:3:7--3:11
  while validating user-specified signature
    in the definition of 'foo', at ./foo.cry:3:1--3:4,
    we need to show that
      for any type i, j
      assuming
        • fin i
        • fin j
        • j >= 1
      the following constraints hold:
        • i /^ j + ?back`845 == inf
            arising from
            matching types
            at ./foo.cry:3:12--3:18
@brianhuffman
Copy link
Contributor Author

Note that the above example works if /^ is replaced with +, *, /, ^^, min, max, etc. It fails for /^ and %^.

@brianhuffman
Copy link
Contributor Author

The problem seems to have to do with function tryEqAddInf, which implements the rule (t1 + t2 = Inf, fin t1) ~~> t2 = Inf.

https://github.com/GaloisInc/cryptol/blob/master/src/Cryptol/TypeCheck/Solver/Numeric.hs#L369

@brianhuffman brianhuffman self-assigned this Mar 18, 2019
brianhuffman pushed a commit that referenced this issue Mar 18, 2019
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