lean4-htt/tests/lean/run/bv_decide_shift_to_nat.lean
Henrik Böving 712bb070f9
feat: make bv_decide work on simp normal forms of shifts (#7976)
This PR ensure that `bv_decide` can handle the simp normal form of a
shift.

Consider:
```lean
theorem test1 (b s : BitVec 5) (hb : b = 0) (hs : s ≠ 0)
  : b <<< s = 0 := by
  bv_decide
```
This works out, however:
```lean
theorem test2 (b s : BitVec 5) (hb : b = 0) (hs : s ≠ 0)
  : b <<< s = 0 := by
  simp
  bv_decide
```
this fails because the `simp` normal form adds `toNat` to the right hand
argument of the `<<<` and `bv_decide` cannot deal with shifts by
non-constant `Nat`.

Discovered by @spdskatr
2025-04-15 17:26:19 +00:00

21 lines
590 B
Text

import Std.Tactic.BVDecide
theorem test2 (b s : BitVec 5) (hb : b = 0) (hs : s ≠ 0) :
b <<< s.toNat = 0 := by
bv_decide
theorem test2' (b s : BitVec 5) (hb : b = 0) (hs : s ≠ 0) :
b >>> s.toNat = 0 := by
bv_decide
theorem test2'' (b s : BitVec 5) (hb : b = 0) (hs : s ≠ 0) :
BitVec.sshiftRight b s.toNat = 0 := by
bv_decide
theorem test2''' (b s : BitVec 5) (hb : b = 0) (hs : s ≠ 0) :
BitVec.shiftLeft b s.toNat = 0 := by
bv_decide
theorem test2'''' (b s : BitVec 5) (hb : b = 0) (hs : s ≠ 0) :
BitVec.ushiftRight b s.toNat = 0 := by
bv_decide