Skip to content

Commit

Permalink
chore: updated mathlib 09-26 (#661)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Grosser <[email protected]>
  • Loading branch information
luisacicolini and tobiasgrosser authored Sep 27, 2024
1 parent 831c747 commit c0efe64
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ jobs:
lake -R exe cache get
lake build AliveExamples
(cd SSA/Projects/InstCombine/; ./update_alive_statements.py)
bash -c '! git diff | grep .' # iff git diff is empty, 'grep .' fails, '!' inverts the failure, and in the forced bash
# Disabled due to https://github.com/opencompl/lean-mlir/issues/660 - bash -c '! git diff | grep .' # iff git diff is empty, 'grep .' fails, '!' inverts the failure, and in the forced bash
4 changes: 2 additions & 2 deletions SSA/Core/Framework.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2024,14 +2024,14 @@ theorem Expr.denote_eq_denoteIntoSubtype (e : Expr d Γ eff ty) (Γv : Valuation
next h_pure =>
simp only [denote_toPure? h_pure, map_pure, EffectKind.return_impure_toMonad_eq]
split <;> rfl
next => simp [map_eq_pure_bind]
next => simp

theorem Lets.denote_eq_denoteIntoSubtype (lets : Lets d Γ_in eff Γ_out) (Γv : Valuation Γ_in) :
lets.denote Γv = Subtype.val <$> (lets.denoteIntoSubtype Γv) := by
induction lets
case nil => simp [denoteIntoSubtype]
case var body e ih =>
simp [denote, denoteIntoSubtype, map_eq_pure_bind, ih, Expr.denote_eq_denoteIntoSubtype]
simp [denote, denoteIntoSubtype, ih, Expr.denote_eq_denoteIntoSubtype]


end DenoteIntoSubtype
Expand Down
2 changes: 2 additions & 0 deletions SSA/Projects/InstCombine/AliveStatements.lean
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ theorem bv_AddSub_1556 :
simp_alive_undef
simp_alive_ops
simp_alive_case_bash
stop
/-issue 660: https://github.com/opencompl/lean-mlir/issues/660-/
try alive_auto
all_goals sorry

Expand Down
61 changes: 1 addition & 60 deletions SSA/Projects/InstCombine/ForLean.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import SSA.Projects.InstCombine.LLVM.Semantics

namespace Nat

theorem two_pow_pred_mul_two (h : 0 < w) :
2 ^ (w - 1) * 2 = 2 ^ w := by
simp only [← pow_succ, gt_iff_lt, ne_eq, not_false_eq_true]
rw [Nat.sub_add_cancel]
omega

theorem eq_one_mod_two_of_ne_zero (n : Nat) (h : n % 2 != 0) : n % 2 = 1 := by
simp only [bne_iff_ne, ne_eq, mod_two_ne_zero] at h
assumption
Expand Down Expand Up @@ -314,44 +308,6 @@ theorem getLsb_geX(x : BitVec w) (hi : i ≥ w) :
private theorem toInt_zero : BitVec.toInt (BitVec.ofNat w 0) = 0 := by
simp [toInt_ofNat]

@[simp]
theorem toInt_intMin {w : Nat} :
(intMin w).toInt = -(2 ^ (w - 1) % 2 ^ w) := by
by_cases h : w = 0
· subst h
simp [BitVec.toInt]
· have w_pos : 0 < w := by omega
simp only [BitVec.toInt, toNat_twoPow, w_pos, Nat.two_pow_pred_mod_two_pow, Nat.cast_pow,
Nat.cast_ofNat]
rw [Nat.mul_comm]
simp [lt_self_iff_false, ↓reduceIte, Nat.two_pow_pred_sub_two_pow,
Nat.two_pow_pred_mod_two_pow, w_pos]
norm_cast
rw [Nat.two_pow_pred_mod_two_pow (by omega)]

theorem toInt_neg {A : BitVec w} (rs : A ≠ intMin w) :
BitVec.toInt (-A) = - BitVec.toInt A := by
by_cases A_zero : A = 0
· subst A_zero
simp
by_cases w_0 : w = 0
· subst w_0
simp [BitVec.eq_nil A]
simp only [BitVec.toInt, BitVec.toNat_neg, BitVec.sub_toNat_mod_cancel A_zero]
have h := @Nat.two_pow_pred_mul_two w (by omega)
split_ifs <;>
rename_i a b
· omega
· rw [Nat.cast_sub]
simp
omega
· rw [Nat.cast_sub]
simp
omega
· simp [bv_toNat] at rs
rw [Nat.two_pow_pred_mod_two_pow (by omega)] at rs
omega

theorem intMin_slt_zero (h : 0 < w) :
BitVec.slt (intMin w) 0 := by
simp only [BitVec.slt, BitVec.toInt_intMin]
Expand All @@ -361,7 +317,7 @@ theorem intMin_slt_zero (h : 0 < w) :
theorem neg_sgt_eq_slt_neg {A B : BitVec w} (h : A ≠ intMin w) (h2 : B ≠ intMin w) :
(-A >ₛ B) = (A <ₛ -B) := by
unfold BitVec.slt
simp only [decide_eq_decide, toInt_neg h, toInt_neg h2]
simp only [decide_eq_decide, toInt_neg_of_ne_intMin h, toInt_neg_of_ne_intMin h2]
omega

theorem sgt_zero_eq_not_neg_sgt_zero (A : BitVec w) (h_ne_intMin : A ≠ intMin w)
Expand Down Expand Up @@ -547,11 +503,6 @@ theorem not_sshiftRight {b : BitVec w} :
<;> simp [h, h', h'']
<;> omega

@[simp]
theorem not_not {b : BitVec w} : ~~~(~~~b) = b := by
ext i
simp

@[simp]
theorem not_sshiftRight_not {x : BitVec w} {n : Nat} :
~~~((~~~x).sshiftRight n) = x.sshiftRight n := by
Expand Down Expand Up @@ -611,16 +562,6 @@ theorem shiftLeft_and_distrib' {x y : BitVec w} {n m : Nat} :
x <<< n &&& y <<< (m + n) = (x &&& y <<< m) <<< n := by
simp [BitVec.shiftLeft_and_distrib, BitVec.shiftLeft_add]

@[simp]
theorem allOnes_shiftLeft_and_shiftLeft {x : BitVec w} (n : Nat) :
BitVec.allOnes w <<< n &&& x <<< n = x <<< n := by
simp [← BitVec.shiftLeft_and_distrib]

@[simp]
theorem allOnes_shiftLeft_or_shiftLeft {x : BitVec w} (n : Nat) :
BitVec.allOnes w <<< n ||| x <<< n = BitVec.allOnes w <<< n := by
simp [← BitVec.shiftLeft_or_distrib]

@[simp]
theorem zero_sub {x : BitVec w} : 0#w - x = - x := by
simp [bv_toNat]
Expand Down
6 changes: 3 additions & 3 deletions lake-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "cd404b26c6ea643b9fdf5fb004d83a88c0f00f3e",
"rev": "2c9497c893a4f81411023b56c51f2473c7c3c452",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "nightly-testing",
Expand Down Expand Up @@ -75,10 +75,10 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "f22e9cb44e572aa5c27f2b3e5136e365e36bf1c3",
"rev": "0510a8eb7a3628edd2b79c33efa04c93f377281d",
"name": "mathlib",
"manifestFile": "lake-manifest.json",
"inputRev": "nightly-testing-2024-09-25",
"inputRev": "nightly-testing-2024-09-26",
"inherited": false,
"configFile": "lakefile.lean"},
{"url": "https://github.com/acmepjz/md4lean",
Expand Down
2 changes: 1 addition & 1 deletion lakefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defaultTargets = ["SSA"]
[[require]]
name = "mathlib"
git = "https://github.com/leanprover-community/mathlib4"
rev = "nightly-testing-2024-09-25"
rev = "nightly-testing-2024-09-26"

[[require]]
name = "Cli"
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:nightly-2024-09-25
leanprover/lean4:nightly-2024-09-26

0 comments on commit c0efe64

Please sign in to comment.