Skip to content

feat(language): a divisor or a power over parameters may add, so a discount factor is written where it is used - #648

Closed
FBumann wants to merge 3 commits into
mainfrom
claude/loving-wozniak-qdycvl
Closed

FBumann wants to merge 3 commits into
mainfrom
claude/loving-wozniak-qdycvl

Conversation

@FBumann

@FBumann FBumann commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Prompt: Lets do 277

Note

The following content was generated by AI.

What this changes

x / (a + b) and (1 + rate) ** years load. Arithmetic over numbers and parameters is allowed under a divisor, a base and an exponent. A variable there is still refused. Closes #277.

Why

Before this change, the degree check refused a sum anywhere under / or **, so a discount factor had to ship as a prepared column. The program already carries these trees, and the typesetter already prints them.

Method, gate output, what moved, what was not done

The change. src/math_spec/degree.py loses _adds and its two refusals. Nothing else in src/ read a divisor's shape: lowering, dimensions, boundedness and the typesetter walk already take any variable-free subtree.

Where the refusal coverage moved. The four test_degree.py refusal cases (a-sum-as-a-base, a-sum-as-an-exponent, a-divisor-that-adds, an-addition-under-a-reduction-divisor) are now cases of test_an_affine_expression_passes_everywhere. The where refusal a-divisor-that-adds in test_validation.py is now a case of test_a_where_comparing_expressions_loads, beside a new a-base-that-adds. A new typesetting test, test_a_base_that_adds_is_bracketed_and_a_divisor_that_adds_is_not, runs in every format. On the old degree.py, 9 of these fail. With the change, they pass.

Typeset, all three formats:

  • LaTeX and Markdown: \left( 1 + \mathrm{cost}_{g} \right)^{2} and \frac{p_{t,g}}{\mathrm{cost}_{g} + \mathrm{p}^{\mathrm{max}}_{g}}
  • Typst: (1 + ...)^(2) and frac(p_(t,g), ... + ...)

Docs.

  • expressions.md replaces the single-factor paragraph with a whole model that divides by (1 + rate) ** years. The model was loaded with python -m math_spec check, and it is refused on main.
  • The PyPSA stochastic example gave "a divisor is one factor" as its reason to bind 1 / (1 - alpha) as data. It now binds CVaR_alpha and writes 1 / (1 - CVaR_alpha) in CVaR-def. The gallery page is regenerated with python -m tools.gallery. The typeset row is $\theta + \frac{1}{1-\alpha} \sum_s \pi_s a_s \le CVaR$, which is PyPSA's.
  • limits.md had no row for this refusal, so it does not change.

Gates.

  • pixi run lint: pass.
  • pixi run test: 1607 passed.
  • pixi run docs-build: fails in this container because the proxy blocks https://docs.python.org/3/objects.inv. The same mkdocs build --strict passes with that one inventory removed from a temporary copy of mkdocs.yml.
  • pixi run compile-tex: not run. Tectonic cannot fetch its bundle from relay.fullyjustified.net, so all 31 documents fail, changed or not. CI runs it.

Deliberately not done.

  • A dimension is still not a value (Using dimensions in math expressions and masks #14, declined). (1 + rate) ** period over the dimension period is refused, and period's coordinates ship as a parameter.
  • absence.md keeps "a divisor" among the positions where a missing parameter row has no value that contributes nothing. It now covers every parameter in a divisor, including the parameters of a sum.
  • Not checked: whether the engines in fluxopt/lpspec compute a sum in a divisor as one value before they divide.
  • Adjacent, not changed: examples/pypsa.yaml binds PyPSA's (1 - standing_loss) ** elapsed hours as data prep, which could now be derived. examples/pypsa_linearized_uc.yaml:116 says two parameters cannot be compared in a where, which the arithmetic comparison already made false.

🤖 Generated with Claude Code

https://claude.ai/code/session_01C8aNCHBtTstYhudLqHhafW


Generated by Claude Code

…scount factor is written where it is used

`x / (a + b)` and `(1 + rate) ** years` load. The degree check refused a
sum anywhere under a divisor, a base or an exponent. The program already
carries the tree, and the typesetter prints it in all three formats.

The PyPSA stochastic example reads `alpha` and divides by `1 - alpha`
in CVaR-def, instead of binding the inverted tail as data.

expressions.md: n 92, avg 15.4, median 14, over25 11 (was n 91, same).

Closes #277

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C8aNCHBtTstYhudLqHhafW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GpnFcQDuvt2bExGngb6MYk
@FBumann FBumann added the area: arithmetic Adding, subtracting, multiplying etc of variables, parameters etc. label Sep 25, 2026
@FBumann

FBumann commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Superseeded by #757

@FBumann FBumann closed this Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: arithmetic Adding, subtracting, multiplying etc of variables, parameters etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(1 + rate) ** period is refused, so a discount factor ships as a prepared column

3 participants