What counts as language#
Several tools read the same spec file. An engine attaches data, builds the model and hands it to a solver. A renderer prints the spec as equations. A checker reads the spec in CI with no data. The language makes some decisions for all of them, and each tool makes the rest for itself. One question tells the two apart:
If two tools answered this differently, would the file have two meanings?
Suppose the engine sums p over generator and the renderer prints a sum over
snapshot. The file now means two things, and that is a bug. So the language
decides what sum(p, over=generator) means, and both tools read the answer
instead of working it out.
Suppose instead that the engine writes the model in one solver's file format and the renderer sets the page width to 80 characters. They disagree, and nothing is wrong, because each tool decides those things for itself.
Four rules follow from that question:
- A name means one thing, so
pcannot be a variable in the engine and a parameter in the renderer. - The set of operators is fixed, so a tool cannot add a
rollthat the others do not know. - Each operator has one rule for the dimensions of its result.
sum(p, over=generator, by=gen_bus[bus])groups bybusfor every program. - Degree is decided when the file loads. Whether
x * yis allowed does not depend on which engine builds the model.
A piecewise: entry and an sos: entry each state ordinary variables and
constraints, so the language decides what they state, and
spec.expand()
writes it out the same way for every tool.
What each tool decides for itself#
A tool can refuse a spec for a reason of its own. For example, one engine can
only take a literal offset in shift. Another has no concept of a special-ordered set
(SOS). A file format has no way to write a quadratic constraint. None of these
is a disagreement about what the file means, so the language does not settle
any of them. If the language refused everything one tool cannot build, every
other tool would inherit that limit.
So the rule holds in both directions:
- A tool must not invent a rule about what the file means. If it needs one, the rule goes into the language, once.
- The language must not state a rule about what one tool can build.
The limits say which operators and sections may be added to the language at all.