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

More predicate operators #400

Closed
jldodds opened this issue Feb 3, 2017 · 5 comments
Closed

More predicate operators #400

jldodds opened this issue Feb 3, 2017 · 5 comments
Labels
feature request Asking for new or improved functionality

Comments

@jldodds
Copy link
Contributor

jldodds commented Feb 3, 2017

I would like to see syntactic sugar to allow all comparison operators (<, >, <=) in predicates

@jldodds jldodds added the feature request Asking for new or improved functionality label Feb 3, 2017
@brianhuffman
Copy link
Contributor

I'm not sure what you mean; are you talking about something analogous to (===) and (!==) : {a, b} (Cmp b) => (a -> b) -> (a -> b) -> a -> Bit for the other comparisons?

@jldodds
Copy link
Contributor Author

jldodds commented Feb 3, 2017

Maybe this is a documentation limitation, or maybe there's an ambiguity issue I hadn't considered. It'd be nice to write a type like

(fin n, fin x, n < x) => ...
instead of
(fin n, fin x, x-1 >= n)

@yav
Copy link
Member

yav commented Feb 3, 2017

If we add the constraint synonyms that Brian suggested (which mostly requires us to pick a syntax, I think), we could just add synonyms for these to the Prelude. For example:

constraint x <= y = y >= x
etc.

@brianhuffman
Copy link
Contributor

This could be accomplished with the proposed "constraint synonyms" feature (#373), if we extend it to allow infix operators.

@brianhuffman
Copy link
Contributor

Pull request #627 will make it possible to add these definitions to the Cryptol prelude:

type constraint i > j = i >= j + 1
type constraint i < j = j >= i + 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Asking for new or improved functionality
Projects
None yet
Development

No branches or pull requests

3 participants