-
Notifications
You must be signed in to change notification settings - Fork 5
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
Specify Logic Resource. #266
Conversation
specification/hugr.md
Outdated
| `not` | `bool` | `bool` | logical "not" | | ||
| `and` | `bool`, `bool` | `bool` | logical "and" | | ||
| `or` | `bool`, `bool` | `bool` | logical "or" | | ||
| `xor` | `bool`, `bool` | `bool` | logical "xor" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In two minds about including this. It's rarely used as a logical operation and can be constructed from the others if needed ... then again why not ... then again again why not include nand
as well... Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of changes I'd like to make here on reflection:
- remove
xor
; - allow
and
andor
to take any number of inputs.
(Thentrue
is justand
with 0 inputs andfalse
is justor
with 0 inputs and we just have three basic op types.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is not
not N-ary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also where do you see operations like xor
being defined? It's too primitive to be defined as a library function no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably that would mean applying N nots in parallel -- so N inputs and N outputs? Yes we could define this, but it seems less useful. N-ary and and or save us from chaining a bunch of them together in a tree, taking advantage of associativity and commutativity, but I don't think there's a particularly compelling reason to combine parallel nots into one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also where do you see operations like
xor
being defined? It's too primitive to be defined as a library function no?
Well, I wonder about this. As far as I can see xor is very rarely used as a logical operation (I can't think of any examples in tket), and on occasions when it is it can be implemented as something like "(A or B) and not (A and B)". It is much more often used in bit-twiddling or as addition mod 2; in both these cases I imagine one would use int<1>
from the arithmetic resource (where addition is xor).
But I will add it if you think it's useful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any of C, C++ or Python have a logical xor operation (analogous to &&
or ||
, or and
and or
) (though they all have bitwise xor).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense - happy with current state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments already added as single comments
No description provided.