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

Negative numeric types? #1226

Closed
robdockins opened this issue Jun 29, 2021 · 2 comments
Closed

Negative numeric types? #1226

robdockins opened this issue Jun 29, 2021 · 2 comments
Labels
language Changes or extensions to the language question Not a task, but rather a question or discussion topic

Comments

@robdockins
Copy link
Contributor

While working on support for enumerations with explicit strides, it occurred to me that we can't write the following:

[ -10 .. 10 ]: [_]Integer

Cryptol complains that -10 is not a numeric type. Obviously, there are other ways to achieve the intended effect, but I don't think any are as clear. It also turns out to be pretty tricky to find a way to express something like:

[-10 .. 10 by 3 ]

especially if one wants to be parametric in the stride.

One way to handle this would be to simply allow numeric types to be some version of the integers (extended with either one or two infinities depending on the properties we want) instead of the extended naturals. I don't know exactly what effects this would have, but probably it would mostly mean that the [n]a type constructor would gain a n >= 0 well-formededness condition. It would also have some impact on the questions regarding the Literal class and its downward closure.

I don't really know if this is worth doing, but I thought I'd write down my thoughts.

@robdockins robdockins added question Not a task, but rather a question or discussion topic language Changes or extensions to the language labels Jun 29, 2021
@yav
Copy link
Member

yav commented Jun 29, 2021

I think we probably have quite a lot of places where we are assuming that the sizes are naturals, so it'd be pretty tricky to do that, I think.

I wonder, though, if we may want to rethink the part where enumerations are types. Perhaps we can revert them back to being normal values, with some rules that we should be able to determine statically the length of the sequence... It might be a bit ad-hoc, but I wonder if it would end up being more intuitive. That's kind of how it used to be on Cryptol 1, so there is a precedent...

@robdockins
Copy link
Contributor Author

This would be a pretty big change, and this is a relatively weak motivation for it, so I think we probably won't do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language Changes or extensions to the language question Not a task, but rather a question or discussion topic
Projects
None yet
Development

No branches or pull requests

2 participants