Skip to content

feat(Foundations): define polynomial growth and relate it to big-O - #1067

Open
SamuelSchlesinger wants to merge 3 commits into
mainfrom
samschles/crypto-pr-05-polynomial-bound
Open

SamuelSchlesinger wants to merge 3 commits into
mainfrom
samschles/crypto-pr-05-polynomial-bound

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Following @thomaskwaring's suggestion, defines PolynomiallyBounded f for natural-valued functions by eventual domination by a fixed power n ^ d. Proves equivalence with Mathlib's Asymptotics.IsBigO after casting to the reals, and with a bound c * (n + 1) ^ d valid at every input.

This supplies the growth condition used for polynomial losses and hybrid lengths in the crypto stack. It makes no computability claim.

Originally composed with Claude Code; reworked with Codex to use eventual bounds and Mathlib's asymptotics API.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to stack #1064 October 4, 2026 22:12
@SamuelSchlesinger SamuelSchlesinger changed the title feat(Foundations): add polynomially bounded functions feat(Foundations): add polynomially bounded functions and use them for polynomial time Oct 4, 2026
@SamuelSchlesinger
SamuelSchlesinger force-pushed the samschles/crypto-pr-05-polynomial-bound branch from 2571822 to 43316c1 Compare October 4, 2026 23:03
@SamuelSchlesinger
SamuelSchlesinger force-pushed the samschles/crypto-pr-05-polynomial-bound branch from 43316c1 to 93344e7 Compare October 4, 2026 23:33
@thomaskwaring

Copy link
Copy Markdown
Collaborator

There's clearly other review work that needs to be done, but as a first thought is there a reason you didn't use Asymptotics.IsBigO? There's no Norm instance on Nat so you'd need some plumbing, but it's equivalent and you might be able to use the existing lemmas.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

is there a reason you didn't use Asymptotics.IsBigO?

No, I can change it to that and see if that is an improvement.

@thomaskwaring

Copy link
Copy Markdown
Collaborator

actually ∃ d, f ≤[atTop] n ^ d would probably be simpler (i think we should at least have lemmas connecting each version)

@SamuelSchlesinger
SamuelSchlesinger removed this pull request from stack #1064 October 5, 2026 20:06
@SamuelSchlesinger
SamuelSchlesinger added this pull request to stack #1077 October 5, 2026 20:07
@SamuelSchlesinger
SamuelSchlesinger force-pushed the samschles/crypto-pr-05-polynomial-bound branch from 93344e7 to d09d87d Compare October 5, 2026 20:19
@SamuelSchlesinger
SamuelSchlesinger removed this pull request from stack #1077 October 5, 2026 20:20
@SamuelSchlesinger
SamuelSchlesinger changed the base branch from samschles/crypto-pr-04-statistical-distance-lemmas to samschles/crypto-stack-review-base October 5, 2026 20:20
@SamuelSchlesinger
SamuelSchlesinger added this pull request to stack #1080 October 5, 2026 20:20
@SamuelSchlesinger
SamuelSchlesinger force-pushed the samschles/crypto-pr-05-polynomial-bound branch from d09d87d to 14146b0 Compare October 5, 2026 20:43
@SamuelSchlesinger
SamuelSchlesinger removed this pull request from stack #1080 October 5, 2026 20:43
@SamuelSchlesinger SamuelSchlesinger changed the title feat(Foundations): add polynomially bounded functions and use them for polynomial time feat(Foundations): define polynomial growth and relate it to big-O Oct 5, 2026
@SamuelSchlesinger
SamuelSchlesinger changed the base branch from samschles/crypto-stack-review-base to main October 5, 2026 20:43
@SamuelSchlesinger
SamuelSchlesinger added this pull request to stack #1084 October 5, 2026 20:57
@SamuelSchlesinger
SamuelSchlesinger removed this pull request from stack #1084 October 5, 2026 21:02
@SamuelSchlesinger
SamuelSchlesinger added this pull request to stack #1085 October 5, 2026 21:03

@thomaskwaring thomaskwaring left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this all looks good to me — i've suggested a few places where i think proofs can be simplified, particularly using grw and looser bounds (since the statement is existential it makes no difference)

also, i don't have a strong opinion either way, but perhaps you could define a trivial norm on Nat which might be fractionally easier than working with the casts


/-- A function is polynomially bounded if a fixed power eventually bounds its values. -/
def PolynomiallyBounded (f : ℕ → ℕ) : Prop :=
∃ d : ℕ, ∀ᶠ n in atTop, f n ≤ n ^ d

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think the idiomatic spelling is

Suggested change
∃ d : ℕ, ∀ᶠ n in atTop, f n ≤ n ^ d
∃ d : ℕ, f ≤ᶠ[atTop] (· ^ d)

which is defeq

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yuck :)

Comment thread Cslib/Foundations/Data/Nat/PolynomialBound.lean Outdated
Comment thread Cslib/Foundations/Data/Nat/PolynomialBound.lean Outdated
SamuelSchlesinger and others added 2 commits October 5, 2026 18:50
Co-authored-by: Thomas Krishna Waring <51426330+thomaskwaring@users.noreply.github.com>
Co-authored-by: Thomas Krishna Waring <51426330+thomaskwaring@users.noreply.github.com>
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Applied your changes.

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