lean4-htt/tests/lean/run/lean_nat_bitwise.lean
Joe Hendrix 1118931516
feat: add bitwise operations to reduceNat? and kernel (#3134)
This adds bitwise operations to reduceNat? and the kernel. It
incorporates some basic test cases to validate the correct operations
are associated.
2024-01-11 18:12:45 +00:00

37 lines
1.4 KiB
Text

-- This confirms that Nat bitwise operations are implemented in kernel
-- and performs a few basic tests.
-- Without kernel support the tests containing the 2^20 constant will
-- fail with "error: (kernel) deep recursion detected"
example : 0 &&& 0 = 0 := rfl
example : 0 &&& 0b1111 = 0 := rfl
example : 0b1111 &&& 0 = 0 := rfl
example : 0b1111 &&& 0b1111 = 0b1111 := rfl
example : 0b1100 &&& 0b1010 = 0b1000 := rfl
example : let x := 2^20; x &&& x = x := rfl
example : 0 ||| 0 = 0 := rfl
example : 0 ||| 0b1111 = 0b1111 := rfl
example : 0b1111 ||| 0 = 0b1111 := rfl
example : 0b1111 ||| 0b1111 = 0b1111 := rfl
example : 0b1100 ||| 0b1010 = 0b1110 := rfl
example : let x := 2^20; x ||| x = x := rfl
example : 0 ^^^ 0 = 0 := rfl
example : 0 ^^^ 0b1111 = 0b1111 := rfl
example : 0b1111 ^^^ 0 = 0b1111 := rfl
example : 0b1111 ^^^ 0b1111 = 0 := rfl
example : 0b1100 ^^^ 0b1010 = 0b0110 := rfl
example : 0b0110 ^^^ 0b0101 = 0b0011 := rfl
example : let x := 2^20; x ^^^ x = 0 := rfl
example : 0 >>> 0 = 0 := rfl
example : 0b1011 >>> 1 = 0b0101 := rfl
example : 0b1011 >>> 2 = 0b0010 := rfl
example : 0 >>> 2^20 = 0 := rfl
example : 0 <<< 0 = 0 := rfl
example : 0b1011 <<< 1 = 0b010110 := rfl
example : 0b1011 <<< 2 = 0b101100 := rfl
example : 0 <<< 2^20 = 0 := rfl