Loop analysis: one proof-rule layer (obligations, rules, candidate sources; strategies as presets)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start with the design note and strategy matrix, then inspect prodigy/analysis/loops/, prodigy/distribution, and the referenced deciders in subinvariant.py, exact/strategies.py, exploration.py, unrolling.py, and bounds/egcalc.py. The first implementation target is the unified obligation chain and operator/rule layer, with existing strategies becoming presets. Done means the listed obligations, operators, Kleene iteration, loop-bound propagation, and certificate checks have single implementations, with golden behavior comparisons and documented justification for any remaining exceptions.
Written by the indexing model from the issue text.
Description
The ten loop strategies in prodigy/analysis/loops/ combine a few building blocks:
- four proof rules: Kleene (lower), Park (upper), lower induction with finite mass (lower), and both together (exact);
- two operators: the output transformer Φ and the EVT operator Ψ_g;
- five candidate sources: the user, template synthesis, LP, a language model, and extrapolation.
Each strategy, however, is implemented as a column of its own. It builds its own operator, checks its own side conditions, derives its own guarantee and prints its own output. Found while planning the complexity work of #512:
- Ψ is built in four places:
invariant_verification.evt_operator, inline insubinvariant.py, inline inexploration.py, and as a separate semantics of the fragment inbounds/egcalc.py. - Three non-negativity deciders cover different classes in a different order:
subinvariant.decide_nonneg,exact/strategies._positivityandGFCalculus.first_negative. The same function can be proven non-negative under one strategy and stay unknown under another. - Three or four finite-mass deciders:
exact/strategies.finite_mass,subinvariant.exact_mass/rational_mass,unrolling._finite_massandGFCalculus.mass. - Two arbiters for the same obligation ν ≤ Ψ(ν), |ν| < ∞:
evt_subinvariantchecks it with the engines.evt_sandwichchecks it withverify_certificate, that is, withegcalc's own semantics.- So the soundness of sandwich certificates rests on a second implementation of the semantics.
- Kleene iteration is implemented three times:
unrollandmass_thresholdare copies apart from the stopping rule;evt_iterateis the same iteration on Ψ. - Soundness arguments are scattered. Over-approximated bodies (
scope.kind), the series identity (#276, #393) andobserveare handled separately inpark,exact/strategies,subinvariantand throughrequires_unconditioned. - Three ways carry an upper bound past the loop:
LoopOutcome.upper,query_bounds, andauto._upper_query_bounds. In addition,bounds/has its own program split and its own evaluation of the queries after the loop. exact/heuristics/positivityholds proof rules under a misleading name. Its docstring says they are sound, yet they live inanalysisand are imported across packages.
Proposal
The proposal adds a layer between the engines and the strategies:
- Obligations in
prodigy/distribution.nonneg,finite_mass,leqandequal, each three-valued and with the reason, as one ordered chain of rules for classes.- The chain covers the product form,
nonneg_by_construction, exp and log polynomials, independent factors, Pringsheim, and the current positivity rules. - Engine hooks only for CAS operations.
- The operators in one place: Ψ_g, and the Park transformer shared with compare mode.
- The proof rules in
loops/rules/:kleene(with a stopping policy),park,lower_inductionandexact_fixed_point.- Each states its theorem and side conditions once.
- Each handles the approximated body, the series identity and
observein one place. - Each returns a
Guaranteeand the evidence.
- Candidate sources only propose. The LP becomes a proposal engine whose final certificates are checked by the shared rules through the engines.
egcalcandexplicitthen carry no soundness. - Strategies become presets (source × rule × stopping × presentation). Names,
delivers, CLI and GUI stay. - One path past the loop, through the upper track and the query handler.
query_boundsstays only where an upper bound has infinite mass, with that reason.
A design note comes first and must be approved before any code. It includes:
- the strategy matrix;
- the unified deciders with their classes;
- the rule signatures;
- a timing of the engine check of the final LP certificates on the looping examples (SymPy, GiNaC);
- the PR cut.
Done when
- Each obligation has exactly one decider chain, in
prodigy/distribution. No strategy keeps its own copy. - Ψ_g and the Park transformer are built in one place each.
- The four rules exist with their side conditions documented once. Every strategy derives its guarantee through them.
- Certificates of
evt_sandwichare accepted only by the shared rules, or a measured and approved reason is recorded for keepingverify_certificateas an arbiter. -
unroll,mass_thresholdandevt_iterateshare one Kleene implementation. - Upper bounds after a loop take one path. Every remaining exception is justified.
- Strategies print through the session, not to stdout.
- Results are behaviour-preserving on both engines (golden comparison). Every result that becomes stronger or weaker is listed and justified.
- The records and types of #512 that were planned for the calculus are either gone with the reason stated or done as classified there:
Exploration,VariableProfile,LoopProblem,TemplateLP,Certificate,SandwichResult,LoopStrategy, and the iteration, reporter and option types. - A leftover search for the moved and renamed modules is stated in the PR.
Part of the v0.7.0 architecture pass; #512 is closed only after this.
- Dominant language
- Python
- Stars
- 6
- Forks
- 2
- Avg merge
- 1h 52m
- Merged PRs (30d)
- 187
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LKlinke/Prodigy
-
area: engines bug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: gui bug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: gui bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
area: engines bug priority: medium
Maintainers usually reply within 1 day
-
area: maintenance priority: low
Maintainers usually reply within 1 day
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day