Skip to content

Commit 25de019

Browse files
committed
feat: add non-branching lnot
1 parent 7310a17 commit 25de019

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Init/Data/Bool.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ public section
1212

1313
namespace Bool
1414

15+
/--
16+
Boolean complement, or “logical not”. `lnot x`.
17+
18+
`lnot x` is `true` when `x` is `false`. It is functionally the same as
19+
`!x` but it uses non-branching code at runtime.
20+
21+
Examples:
22+
* `lnot true = false`
23+
* `lnot false = true`
24+
-/
25+
@[expose, extern "lean_bool_complement"]
26+
def lnot (x : Bool) : Bool := !x
27+
28+
@[simp] theorem lnot_eq_not (x : Bool) : lnot x = (!x) := rfl
29+
1530
/--
1631
Boolean “logical and”. `land x y`.
1732

0 commit comments

Comments
 (0)