Skip to content

Commit

Permalink
feat: add Bitvec.ofInt_ofNat (leanprover#5081)
Browse files Browse the repository at this point in the history
We use `no_index` to work around special-handling of `OfNat.ofNat` in
`DiscrTree`, which has been reported as an issue in
leanprover#2867 and is currently in the
process of being fixed in leanprover#3684.
As the potential fix seems non-trivial and might need some time to
arrive in-tree, we meanwhile add the `no_index` keyword to the
problematic subterm.

---------

Co-authored-by: Eric Wieser <[email protected]>
  • Loading branch information
tobiasgrosser and eric-wieser authored Aug 26, 2024
1 parent b54a9ec commit c6feffa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Init/Data/BitVec/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ theorem toInt_ofNat {n : Nat} (x : Nat) :
@[simp] theorem ofInt_natCast (w n : Nat) :
BitVec.ofInt w (n : Int) = BitVec.ofNat w n := rfl

@[simp] theorem ofInt_ofNat (w n : Nat) :
BitVec.ofInt w (no_index (OfNat.ofNat n)) = BitVec.ofNat w (OfNat.ofNat n) := rfl

theorem toInt_neg_iff {w : Nat} {x : BitVec w} :
BitVec.toInt x < 02 ^ w ≤ 2 * x.toNat := by
simp [toInt_eq_toNat_cond]; omega
Expand Down

0 comments on commit c6feffa

Please sign in to comment.