-
Notifications
You must be signed in to change notification settings - Fork 409
chore: redefine Nat.div2
Nat.bodd
#13649
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
base: master
Are you sure you want to change the base?
Conversation
Nat.binaryRec
Nat.div2
Nat.bodd
PR summary 60c51c067a
|
File | Base Count | Head Count | Change |
---|---|---|---|
Mathlib.Data.Nat.Bits | 123 | 103 | -20 (-16.26%) |
Mathlib.Data.Nat.Size | 155 | 150 | -5 (-3.23%) |
Mathlib.Logic.Equiv.Nat | 293 | 292 | -1 (-0.34%) |
Import changes for all files
Files | Import difference |
---|---|
Mathlib.Data.Nat.Bits |
-20 |
Mathlib.Data.Nat.Size |
-5 |
Mathlib.Data.FP.Basic Mathlib.Logic.Equiv.Nat |
-1 |
Declarations diff
+ div2_lt_self
You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>
The doc-module for script/declarations_diff.sh
contains some details about this script.
No changes to technical debt.
You can run this locally as
./scripts/technical-debt-metrics.sh pr_summary
- The
relative
value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolute
value is therelative
value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
Please describe how and why did you change the definition(s) in the commit message. |
Nat.bit
Nat.div2
Nat.bodd
Nat.div2
Nat.bodd
This PR/issue depends on: |
|
||
/-- `bodd n` returns `true` if `n` is odd -/ | ||
def bodd (n : ℕ) : Bool := (boddDiv2 n).1 | ||
def bodd (n : ℕ) : Bool := 1 &&& n != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any advantage to this order vs
def bodd (n : ℕ) : Bool := 1 &&& n != 0 | |
def bodd (n : ℕ) : Bool := n &&& 1 != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 &&& n != 0
is defeq to n.testBit 0
.
The new definitions are faster than the old ones.
Nat.binaryRec
will be moved to batteries (leanprover-community/batteries#799) or core (leanprover/lean4#3756), so relevant contents are moved to a new file temporarily.Nat
into a new file #15567Nat.bit
#19666