The infix operators &&
, ||
, and ^^
are notations for Bool.and
, Bool.or
, and Bool.xor
, respectively.
term ::= ...
| Boolean “and”, also known as conjunction. `and x y` can be written `x && y`.
The corresponding propositional connective is `And : Prop → Prop → Prop`, written with the `∧`
operator.
The Boolean `and` is a `@[macro_inline]` function in order to give it short-circuiting evaluation:
if `x` is `false` then `y` is not evaluated at runtime.
Conventions for notations in identifiers:
* The recommended spelling of `&&` in identifiers is `and`.
term && term
term ::= ...
| Boolean “or”, also known as disjunction. `or x y` can be written `x || y`.
The corresponding propositional connective is `Or : Prop → Prop → Prop`, written with the `∨`
operator.
The Boolean `or` is a `@[macro_inline]` function in order to give it short-circuiting evaluation:
if `x` is `true` then `y` is not evaluated at runtime.
Conventions for notations in identifiers:
* The recommended spelling of `||` in identifiers is `or`.
term || term
term ::= ...
| Boolean “exclusive or”. `xor x y` can be written `x ^^ y`.
`x ^^ y` is `true` when precisely one of `x` or `y` is `true`. Unlike `and` and `or`, it does not
have short-circuiting behavior, because one argument's value never determines the final value. Also
unlike `and` and `or`, there is no commonly-used corresponding propositional connective.
Examples:
* `false ^^ false = false`
* `true ^^ false = true`
* `false ^^ true = true`
* `true ^^ true = false`
Conventions for notations in identifiers:
* The recommended spelling of `^^` in identifiers is `xor`.
term ^^ term