Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add BitVec.neg_neg #14

Closed
wants to merge 5 commits into from
Closed

feat: add BitVec.neg_neg #14

wants to merge 5 commits into from

Conversation

tobiasgrosser
Copy link

... as well as neg_neq_iff_neq_neg.

@tobiasgrosser tobiasgrosser force-pushed the bitvec_neg_neg branch 2 times, most recently from 1a90574 to b001fcb Compare August 9, 2024 02:31
Copy link

@AtticusKuhn AtticusKuhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Comment on lines 1251 to 1259
@[simp]
theorem neg_neg {x : BitVec w} : - - x = x := by
by_cases h : x = 0
· subst h
simp
· simp only [toNat_eq, toNat_neg]
rw [toNat_eq] at h
simp only [ofNat_eq_ofNat, toNat_ofNat, Nat.zero_mod] at h
rw [Nat.mod_eq_of_lt (a := 2 ^ w - x.toNat) (by omega)]
rw [Nat.mod_eq_of_lt (by omega)]
omega

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this theorem could be made simpler?

@[simp]
theorem neg_neg2 {x : BitVec w} : - - x = x := by
  have p :  (- x) + (- -x)  = x - x := by
    simp [BitVec.sub_self, ← BitVec.sub_toAdd]
  rw [BitVec.eq_sub_iff_add_eq , BitVec.add_comm, ← BitVec.add_assoc , ← BitVec.sub_toAdd x x , BitVec.sub_self  x, BitVec.zero_add] at p
  assumption

.. as well as neg_neq_iff_neq_neg.
@tobiasgrosser tobiasgrosser force-pushed the bitvec_neg_neg branch 2 times, most recently from 3b8cdcf to ca08674 Compare August 10, 2024 05:51
@tobiasgrosser
Copy link
Author

Merged with leanprover#4951 into lean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants