Repository navigation
feat(language): a dimension lists its members - #1014
Draft
FabianHofmann wants to merge 13 commits into
Draft
FabianHofmann wants to merge 13 commits into
FabianHofmann wants to merge 13 commits into
Conversation
A dimension takes `over:`, a list of plain dimensions or a mapping of role to dimension, and `missing:`, absent or refused. Its label is the tuple of its members, and it is one plain dimension in every operator. The entry implies a relation of the same name, keyed by the dimension with one value column per member, so `at` and `sum` read a member as they read any relation column. mathspec refuses at load, with the rewrite: a member that has members, an order along the dimension, a role named after another dimension, a dimension listed twice, an operand that carries the dimension and a member in one call through it, and a label comparison. A sum over a member and an operand over a member that meets the dimension get the rewrite through the implied relation. All three typesetters print the dimension as a subset of the product of its members.
A sum through a relation that names a member in `over=`, where the operand is over the dimension that lists the member, is refused with the sum over the dimension itself.
The dimensions page has the `over` and `missing` keys, the relation the entry declares, what mathspec refuses and the data contract. The limits page lists member access and an order along such a dimension as constructs the language already has.
- An operand over a member meeting one over the dimension (+, -, *, /, comparison, condition comparison) is refused at the node, with the at() and sum() rewrites. sum(flow * capacity) and sum(flow * capacity, over=unit) no longer load as a cross product. - A named-expression body, a case value and a where name the at() rewrite; a named expression is suggested by its own name. - sum(u, over=unit, by=connection[port]) on an operand without connection suggests sum(at(u, by=connection[unit]), over=connection, by=...). - sos of type 1 runs along a dimension with members; type 2 is refused as unordered. The dead within= guard is gone. - never-an-axis ignores the implied relation; an entry over the dimension reaches its members. - Bare where: connection suggests connection[port] == '...'. - "member" means only a dimension under over:; an SOS has elements. - Program.relations documents the implied relation and where its rows come from.
- An operand over a member meeting one over the dimension loads where the entry's dims: lists both, as their cross product (rule 11 of #1011). Elsewhere it stays refused with the at() and sum() rewrites. - Inside a sum, a dim the sum adds up is not the entry's own, so sum(flow * capacity, over=unit) is refused even where dims: lists unit. - The objective and an assumption have no dims:, so the meeting stays refused there, and in a piecewise where:, which its assumptions repeat. - The frame is passed to constraints, variable and parameter where:, named expressions with their cases, and piecewise links. - A constraint over a member its dims: lack keeps its at() rewrite, now tested.
This was referenced Nov 16, 2026
A side named after a tuple dimension with a column reads its implied relation, so connection[unit] == assignment[unit] is the inner join of two tuple dimensions that share a member.
This was referenced Nov 18, 2026
This branch has not been deployed
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.
Note
The following content was generated by AI.
A dimension lists its members under
over:; its label is the tuple, and a member is read through the relation the entry implies.Supersedes #999. Part of #1011. Stacked on #1013 (which is on #1012).
Two relation columns now compare where
dims:lists both keys (before: keys over the same dimensions), flat too:Legend:
C ⊆ P × U(=undermissing: refused);limitprintsflow_{c,t} ≤ capacity_{connection.unit(c)}.Method, gate output, open decision, not done
Triage (limits.md): not an operator, not a macro. A key on
dimensions:that declares a relation; every read goes throughatandsumas they are.Rules of #1011 in this PR: 1, 2, 3, 4, 5, 7, 8, 10, 12, and the load half of 11 (a cross product loads;
checkadvice later). Rule 9 needed no code:where: "at(active, by=connection[unit])"loads, test added.How
DimensionSpec.over/.missing;Dimension.over/.missingon the program.Namespace.relations:key: connection,values:the members,missing: refused.Program.relationshas it; its docstring and reading.md say a tool takes its rows from the dimension's struct column, no table of its own.relations:. A declaredconnectionrelation is still refused (tested).+ - * /, constraint and condition comparisons), against the entry'sdims:passed down to the resolver.m(notT) meeting one overT(notm) is refused unless the frame lists bothTandm; then it is their cross product (rule 11).dims:: constraint (body andwhere:), variable and parameterwhere:, named expression (body, casewhen:, value,otherwise:), piecewise links.sum(...), frame = entrydims:minus what that sum adds up (over=names; all for a baresum). A summedunitinside is not the frame'sunit, so a cross product summed away is refused, as in rule 10; one the sum keeps loads.where:(copied into the curve's assumptions; framing it made the assumption crash at load)._dimensions.py: none duplicates the node check. Each catches an operand over a member that meets nothing (e.g.u <= 1over[connection]); guard removal below.merge: the existing "say different things about the dimension" refusal coversover:andmissing:.rename: members renamed insideover:; a role is refused like a relation column.never-an-axisadvice skips the implied relation; an entry over the dimension reaches its members.over:; SOS docs and messages say "element".Inner join (this revision; limit moved, limits.md
joinrow)T[m]of a two-column comparison was read as dimensionT, not its implied relation. Both sides now read as a relation where they name a column (_side_kind).connection[unit] == backup[spare](same key) loads too.dims:) carries both keys;RelationPairComparison.dimsis the union. Each relation read at its own key; no row in either → false. No tuple special case.where:): today's rule, same-key only.when:: exclusivity prover unchanged and sound. It models the pair as one boolean per cell plus both rows; keys do not enter. Tested:==/!=proved apart;==vs a label refused with witness.connection.unit(c) = assignment.unit(a),bus_of(u) = line_end(l)in md/tex/typst; no golden case added.test_tuple_dimensions.py3 load cases + 2 case-exclusivity + 3 typeset;test_validation.py4 load cases (variable/parameter/constraintwhere:, case), 3 refusal messages (key outside frame ×2, assumption).Refused at load, each with the rewrite (
tests/test_tuple_dimensions.py, 41 parametrized cases)over:ordered:,dtype:,one_of:besideover:;missing:withoutover:shift,sum_back,position,piecewise:,sos:oftype: 2along one;within=connection[...]keeps the existing "no key column over 'snapshot'" refusalconnectionand a member, in a call throughconnectionover=naming a member →sum(..., over=connection, by=connection[port]); operand withoutconnection→sum(at(u, by=connection[unit]), over=connection, by=connection[port])connectionwheredims:lacks one of the two (flow <= capacityover[connection, snapshot],sum(flow * capacity)in the objective,sum(flow * capacity, over=unit)even over[connection, unit, snapshot], an assumption, a piecewisewhere:) →at(capacity, by=connection[unit])orsum(flow, over=connection, by=connection[unit])upper: capacity,where: capacity > 0, a body or case value overunit→at(capacity, by=connection[unit]); a named expression is named itself (at(e, …))connection == 'a'→connection[port] == ...; barewhere: connection→connection[port] == '...'Loads:
sos:oftype: 1alongconnection(no order used); an entry over[connection, unit](both <= capacity); a meeting wheredims:lists both: constraintflow <= capacityand named expressionflow * capacityover[connection, unit, snapshot],sum(flow * capacity, over=snapshot)over[connection, unit], and the same in a variable, constraint or parameterwhere:, a case, a piecewise link (8 cases).Guard removal (this revision): frame exemption deleted → 4 load cases fail; sum not shrinking the frame → 2 refusals fail (
sum(..., over=unit)over a frame withunit, baresum); frame dropped at each call site (constraint body, constraintwhere:, variablewhere:, parameterwhere:, named body, casewhen:/value/otherwise:, piecewise link) → 1–2 load cases each; framing the piecewisewhere:→ assertion crash, 1 refusal fails. The constraint frame'sat()rewrite failed no test once the node check took its case; a case now covers it (u <= 1over[connection]).Earlier revisions: 11 + 12 guards, 1–2 failing tests each.
Gates
pixi run cipasses on b5d7afd (after merging feat/bound-at ad19bec, which brings main's docs(examples): TIMES examples and a sparse-set example #1021): lint, 4315 tests (1 skipped), docs-build--strict, compile-tex (62 documents).examples/times/*.yamlandexamples/sparse.yamlload.*.out(addscorridor_capovercorridor, so the golden model draws no advice),docs/reference/notation.md,tests/expand/*/after.yaml(SOS description "element"). Schema unchanged.Open decision
connectionand a member": refused for any call throughconnection(_dimensions.pyjoin_dims), also where the member is not joined on. Narrower is possible.Choices where #1011 is silent
dtype:andone_of:besideover:refused; a label comparison of the dimension refused. Rule 12 says the label is opaque.missing: refusedtypesets asC = P × U.[unit]vs{unit: unit}) differ inmerge, as relation columns do.override) may not changemissing:of a dimension; a relation'smissing:it may.Not done
atunstack) and rule 11 (checkadvice): later PRs.at(x, by=connection[unit, port])on an operand overconnectionkeeps today's refusal.in:, nomaps:, no linopy change. feat(language): a dimension may list combinations #999 untouched.Co-Authored-By, by the user's rule; AGENTS.md says otherwise.Generated by Claude Code