From b8a13ab755317e4af3a4a99bd92fae26aa6a75b2 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Mon, 18 Nov 2024 11:53:46 +1100 Subject: [PATCH] chore: fix naming of left/right injectivity lemmas (#6106) We've been internally inconsistent on the naming of these lemmas in Lean; this changes them to match Mathlib (which, moreover, I think is correct). --- src/Init/Data/BitVec/Bitblast.lean | 4 ++-- src/Init/Data/Bool.lean | 8 ++++---- src/Init/Data/Int/Lemmas.lean | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Init/Data/BitVec/Bitblast.lean b/src/Init/Data/BitVec/Bitblast.lean index ff916cf7d4..1fa7a3166d 100644 --- a/src/Init/Data/BitVec/Bitblast.lean +++ b/src/Init/Data/BitVec/Bitblast.lean @@ -403,7 +403,7 @@ theorem getLsbD_neg {i : Nat} {x : BitVec w} : rw [carry_succ_one _ _ (by omega), ← Bool.xor_not, ← decide_not] simp only [add_one_ne_zero, decide_false, getLsbD_not, and_eq_true, decide_eq_true_eq, not_eq_eq_eq_not, Bool.not_true, false_bne, not_exists, _root_.not_and, not_eq_true, - bne_left_inj, decide_eq_decide] + bne_right_inj, decide_eq_decide] constructor · rintro h j hj; exact And.right <| h j (by omega) · rintro h j hj; exact ⟨by omega, h j (by omega)⟩ @@ -419,7 +419,7 @@ theorem getMsbD_neg {i : Nat} {x : BitVec w} : simp [hi]; omega case pos => have h₁ : w - 1 - i < w := by omega - simp only [hi, decide_true, h₁, Bool.true_and, Bool.bne_left_inj, decide_eq_decide] + simp only [hi, decide_true, h₁, Bool.true_and, Bool.bne_right_inj, decide_eq_decide] constructor · rintro ⟨j, hj, h⟩ refine ⟨w - 1 - j, by omega, by omega, by omega, _root_.cast ?_ h⟩ diff --git a/src/Init/Data/Bool.lean b/src/Init/Data/Bool.lean index edfff1ac73..3a89f80d9e 100644 --- a/src/Init/Data/Bool.lean +++ b/src/Init/Data/Bool.lean @@ -238,8 +238,8 @@ theorem not_bne_not : ∀ (x y : Bool), ((!x) != (!y)) = (x != y) := by simp @[simp] theorem bne_assoc : ∀ (x y z : Bool), ((x != y) != z) = (x != (y != z)) := by decide instance : Std.Associative (· != ·) := ⟨bne_assoc⟩ -@[simp] theorem bne_left_inj : ∀ {x y z : Bool}, (x != y) = (x != z) ↔ y = z := by decide -@[simp] theorem bne_right_inj : ∀ {x y z : Bool}, (x != z) = (y != z) ↔ x = y := by decide +@[simp] theorem bne_right_inj : ∀ {x y z : Bool}, (x != y) = (x != z) ↔ y = z := by decide +@[simp] theorem bne_left_inj : ∀ {x y z : Bool}, (x != z) = (y != z) ↔ x = y := by decide theorem eq_not_of_ne : ∀ {x y : Bool}, x ≠ y → x = !y := by decide @@ -295,9 +295,9 @@ theorem xor_right_comm : ∀ (x y z : Bool), ((x ^^ y) ^^ z) = ((x ^^ z) ^^ y) : theorem xor_assoc : ∀ (x y z : Bool), ((x ^^ y) ^^ z) = (x ^^ (y ^^ z)) := bne_assoc -theorem xor_left_inj : ∀ {x y z : Bool}, (x ^^ y) = (x ^^ z) ↔ y = z := bne_left_inj +theorem xor_right_inj : ∀ {x y z : Bool}, (x ^^ y) = (x ^^ z) ↔ y = z := bne_right_inj -theorem xor_right_inj : ∀ {x y z : Bool}, (x ^^ z) = (y ^^ z) ↔ x = y := bne_right_inj +theorem xor_left_inj : ∀ {x y z : Bool}, (x ^^ z) = (y ^^ z) ↔ x = y := bne_left_inj /-! ### le/lt -/ diff --git a/src/Init/Data/Int/Lemmas.lean b/src/Init/Data/Int/Lemmas.lean index 4b0e560fb0..4903a3d3e2 100644 --- a/src/Init/Data/Int/Lemmas.lean +++ b/src/Init/Data/Int/Lemmas.lean @@ -329,22 +329,22 @@ theorem toNat_sub (m n : Nat) : toNat (m - n) = m - n := by /- ## add/sub injectivity -/ @[simp] -protected theorem add_right_inj {i j : Int} (k : Int) : (i + k = j + k) ↔ i = j := by +protected theorem add_left_inj {i j : Int} (k : Int) : (i + k = j + k) ↔ i = j := by apply Iff.intro · intro p rw [←Int.add_sub_cancel i k, ←Int.add_sub_cancel j k, p] · exact congrArg (· + k) @[simp] -protected theorem add_left_inj {i j : Int} (k : Int) : (k + i = k + j) ↔ i = j := by +protected theorem add_right_inj {i j : Int} (k : Int) : (k + i = k + j) ↔ i = j := by simp [Int.add_comm k] @[simp] -protected theorem sub_left_inj {i j : Int} (k : Int) : (k - i = k - j) ↔ i = j := by +protected theorem sub_right_inj {i j : Int} (k : Int) : (k - i = k - j) ↔ i = j := by simp [Int.sub_eq_add_neg, Int.neg_inj] @[simp] -protected theorem sub_right_inj {i j : Int} (k : Int) : (i - k = j - k) ↔ i = j := by +protected theorem sub_left_inj {i j : Int} (k : Int) : (i - k = j - k) ↔ i = j := by simp [Int.sub_eq_add_neg] /- ## Ring properties -/