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

Tidy proofs for pow256_slr and pow256_shr #27

Open
DavePearce opened this issue May 9, 2024 · 1 comment
Open

Tidy proofs for pow256_slr and pow256_shr #27

DavePearce opened this issue May 9, 2024 · 1 comment

Comments

@DavePearce
Copy link
Owner

DavePearce commented May 9, 2024

See these comments from stackoverflow for suggestions on using calc.

UPDATE: I had a crack at this already, though didn't end up getting the desired result.

@DavePearce
Copy link
Owner Author

DavePearce commented May 9, 2024

Ok, here's what I came up with:

def pow256_shr (n : Nat) (m : UInt8) (k : Nat) (p : n < 256^k) : (m.val * 256^k + n < 256^(k+1)) := by
  calc
    _ ≤ 255 * 256^k + n := by
              apply Nat.add_le_add_right
              apply Nat.mul_le_mul_right (256^k)
              exact Fin.is_le m.val
    _ < (255 + 1) * 256^k := by simp_arith; exact p
    _ = 256 * 256^k := by simp
    _ = 256^(k+1) := by exact Nat.pow_succ'.symm

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

No branches or pull requests

1 participant