lean4-htt/src/Init/Data/Nat
Siddharth 77211029da
feat: BitVec.toFin/ToInt BitVec.ushiftRight (#6238)
This PR adds theorems characterizing the value of the unsigned shift
right of a bitvector in terms of its 2s complement interpretation as an
integer.
Unsigned shift right by at least one bit makes the value of the
bitvector less than or equal to `2^(w-1)`,
makes the interpretation of the bitvector `Int` and `Nat` agree.
In the case when `n = 0`, then the shift right value equals the integer
interpretation.

```lean
theorem toInt_ushiftRight_eq_ite {x : BitVec w} {n : Nat} :
  (x >>> n).toInt = if n = 0 then x.toInt else x.toNat >>> n
```

```lean
theorem toFin_uShiftRight {x : BitVec w} {n : Nat} :
  (x >>> n).toFin = x.toFin / (Fin.ofNat' (2^w) (2^n))
```

---------

Co-authored-by: Harun Khan <harun19@stanford.edu>
Co-authored-by: Tobias Grosser <github@grosser.es>
2024-12-04 01:49:58 +00:00
..
Bitwise feat: BitVec.toFin/ToInt BitVec.ushiftRight (#6238) 2024-12-04 01:49:58 +00:00
Basic.lean feat: @[deprecated] requires a replacement identifier or message, and a since field (#6112) 2024-11-26 08:45:54 +00:00
Bitwise.lean chore: update copyrights (#5449) 2024-09-24 05:27:53 +00:00
Compare.lean chore: upstream Std.Data.Nat (#3634) 2024-03-08 17:00:46 +00:00
Control.lean feat: Nat.(fold|foldRev|any|all)M? take a function which sees the upper bound (#6139) 2024-11-22 03:05:51 +00:00
Div.lean chore: cleanup unused variables (#5579) 2024-10-02 01:51:22 +00:00
Dvd.lean chore: robustify for byAsSorry (#6287) 2024-12-02 23:53:16 +00:00
Fold.lean feat: relate Nat.fold/foldRev/any/all to List.finRange (#6235) 2024-11-27 05:38:18 +00:00
Gcd.lean chore: variables appearing on both sides of an iff should be implicit (#5254) 2024-09-04 08:33:24 +00:00
Lcm.lean fix: add instances to make ac_rfl work out of the box (#3942) 2024-04-24 06:12:36 +00:00
Lemmas.lean feat: add Nat.mod_eq_sub and fix dependencies from Nat.sub_mul_eq_mod_of_lt_of_le (#6160) 2024-11-27 03:48:59 +00:00
Linear.lean perf: use RArray in simp_arith meta code (#6068 part 2) 2024-11-14 14:08:48 +01:00
Log2.lean chore: don't use simp_arith when simp will do (#5256) 2024-09-04 07:56:25 +00:00
MinMax.lean fix: add instances to make ac_rfl work out of the box (#3942) 2024-04-24 06:12:36 +00:00
Mod.lean chore: update copyrights (#5449) 2024-09-24 05:27:53 +00:00
Power2.lean refactor: redefine unsigned fixed width integers in terms of BitVec (#5323) 2024-10-16 07:28:23 +00:00
Simproc.lean fix: replace unary Nat.succ simp rules with simprocs (#3808) 2024-04-04 23:15:26 +00:00
SOM.lean