Repository navigation
A sum of an Iverson bracket is counted in closed form - #1575
Merged
Merged
Conversation
The statement is read as conditions on the index. An equation linear in it fixes it at a point, and the sum is a bracket again -- the point whole, in the range, and satisfying the rest -- which a sum outside counts in turn. A comparison or a membership in an interval bounds the index; a divisibility of a linear function of it fixes a residue class, several combining by the Chinese remainder theorem; a statement that it is a perfect power is counted by the roots of the ends, two powers as the power of the least common multiple. A conjunct free of the index, or a linear function of it being whole, is a factor; a product of brackets is the bracket of the conjunction; not and or are counted by inclusion and exclusion. It comes before the expansion, so a long range is counted and not left as written: sum(iverson(2 divides k or 3 divides k), k, 1, 1000) is 667; Sullivan and Mackey's §8.7.4 Tries 1 and 2 are 40 and 960, Ex 8.7.5 is 962, and Ex 8.5.3's three pirates count binomial(22, 2). Part of #1409. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A sum of an Iverson bracket is a count, and it is now written in closed form however long the range is.
sum(iverson(2 divides k or 3 divides k), k, 1, 1000)is667, where the expansion stops at 100 terms and left it as written.What is read (
IversonSum, tried before the expansion):p, and the sum is then a bracket again:pis whole, in the range, and satisfies the other conditions. In a nested sum, that bracket is what the next sum out counts.exists m in ZZ+ : m^e = ksays the index is a perfecte-th power. Over a range from 1 it is counted by the integer roots of the ends, and two powers are the power of the least common multiple, so a square that is a cube is a sixth power.not Qcounts the range lessQ, andQ or RcountsQandRless both.What is left is the number of whole numbers from
LtoUin the classrmodulom, which isfloor((U - r)/m) - floor((L - 1 - r)/m), orU - L + 1with no class. It is never below zero, which is also the count of an empty range.Examples:
sum(iverson(not 2 divides k and not 5 divides k), k, 1, 99)is40. With a symbolicnit isn - floor(n/2) - floor(n/5) + floor(n/10), each term insidemax(0, ...).962. §8.7.4 Try 2, below 1000 and neither squares, cubes nor fifth powers:960.sum(sum(sum(iverson(a + b + c = 20), c, 0, 20), b, 0, 20), a, 0, 20)is231,binomial(22, 2). The two inner sums are counted in closed form, and the outer one is written out over its 21 values.A bound that is not a number is read as real, as a bound of the range that is not a number is read as whole. A comparison with a point off the real line has no truth value, and that sum is declined.
Suite: 13,505 passed, 0 failed on net10.0, and every target framework builds. Gate: passed, with allocation as the baseline says on all 19 gated benchmarks.
BREAKING-CHANGES.md: theiversonentry is extended, with rows measured on 2.5.0.Part of #1409.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura