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

Add UInt256.top and related lemmas #9

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Clear/UInt256.lean
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ instance : NatCast UInt256 := ⟨Fin.ofNat⟩
abbrev Nat.toUInt256 : ℕ → UInt256 := Fin.ofNat
abbrev UInt8.toUInt256 (a : UInt8) : UInt256 := a.toNat.toUInt256

def UInt256.top : ℕ := (⊤ : UInt256).val

lemma UInt256.top_def : UInt256.top = 2 ^ 256 - 1 := by
unfold top
rw [Fin.top_eq_last]
simp

lemma UInt256.top_def'
: UInt256.top = 115792089237316195423570985008687907853269984665640564039457584007913129639935 := by
rw [UInt256.top_def]; simp

lemma UInt256.size_def
: UInt256.size = 115792089237316195423570985008687907853269984665640564039457584007913129639936 := by
unfold size; simp

def Bool.toUInt256 (b : Bool) : UInt256 := if b then 1 else 0

@[simp]
Expand Down