An AI can perform every individual calculation correctly and still produce the wrong answer by changing their order. Rounding each amount before adding it can differ from rounding the final total. Squaring an average differs from averaging squared values. Filtering records before joining them can change which objects remain visible. Vocabulary Coding and Engineering proposes a Semantic Transformation Order Contract: preserve the sequence of operations, the conditions under which they may be reordered, and the evidence that the reordered result still answers the intended question.
The PostgreSQL 17 documentation on aggregate expressions distinguishes aggregate inputs, filtering and the ordering required by certain operations; its aggregate-function documentation specifies such details as the treatment of missing inputs. These established technical mechanisms illustrate why an operation’s position and scope matter. The proposed eduKateSG extension connects the Quantity Kind Contract, Stock–Flow Contract and earlier Join Contract. All new calculations are fictional or mathematical examples, not a claim of a new deployed optimizer or independently validated Meaning Lab outcome.
- Specify the operations and the grain at each stage.
- Distinguish equivalent reorderings from changes that alter the question.
- Check when a transform commutes with an aggregation under stated assumptions.
- Preserve rounding, filtering, missing-value and ordering conventions.
- Distinguish the order of input records from the order of transformations.
- Test candidate reorderings against invariants and independently reviewed counterexamples.
- Do not silently trade correctness, authorization or source completeness for efficiency.
Chapter index
- 1. The same operations are not necessarily the same method
- 2. Commutation has a precise scope
- 3. Linear scaling and summation
- 4. An offset changes the algebra
- 5. Nonlinearity changes the answer
- 6. Rounding at different stages
- 7. Averages of averages need weights
- 8. Filter before or after aggregation
- 9. Missing values change the input collection
- 10. Order of records is another issue
- 11. Deduplication is a semantic operation
- 12. The proposed transformation record
- 13. Zoom 0: algebra as the language of operations
- 14. Zoom 1: everyday decisions
- 15. Zoom 2: organisational reporting
- 16. Zoom 3: institutions and published statistics
- 17. Zoom 4: coordinated AI reasoning
- 18. Zoom 5: inheriting calculation methods
- 19. Invariance needs more than equal outputs
- 20. Parallel summaries and merging
- 21. Proposed fixtures for transformation order
- 22. A useful comparison receipt
- 23. Preserve authority across operations
- 24. A proposed four-week programme
- 25. Questions every reader should ask
- 26. The next engineering step
1. The same operations are not necessarily the same method
Suppose a report calculates a total, converts its unit and displays a rounded result. A second report rounds individual values, converts them and adds them. The operation names sound similar, but the resulting numbers can differ. A method is defined not only by the operations it includes but by their composition and the values on which each operates. A language system needs to preserve those dependencies rather than treat an unordered list of steps as a complete description of a calculation.
2. Commutation has a precise scope
Two transformations commute on a specified domain if applying them in either order produces the same result there. This is a mathematical property to establish under stated definitions. It is not a general permission to reorder instructions that appear independent. Some operations change the input type or the collection being considered, so reversing them may not even be meaningful. State the domain and intended result before claiming equivalence. A bounded test may find a counterexample without proving a general theorem.
3. Linear scaling and summation
Consider three fictional lengths of 2, 3 and 5 metres, representing consecutive segments. Adding them produces 10 metres, or 1,000 centimetres. Converting each to centimetres first produces 200, 300 and 500, whose sum is also 1,000. Exact multiplication by a constant distributes over addition. The equivalence depends on the same conversion factor, compatible measures and no intervening rounding or selection. It does not justify summing unrelated measurements of the same object or assuming every unit conversion is a simple scaling.
4. An offset changes the algebra
An absolute temperature in degrees Celsius can be converted to kelvins by adding 273.15. For readings of 10 and 20 degrees Celsius, their arithmetic mean is 15 degrees Celsius, corresponding to 288.15 kelvins. Converting first and averaging the two readings also produces 288.15 kelvins. This works because an arithmetic mean with weights summing to one preserves a common affine conversion. A raw sum does not preserve the offset in the same way. The Quantity Kind Contract must establish whether the operation itself has a legitimate physical interpretation.
5. Nonlinearity changes the answer
Take two positive values, 2 and 4, under a fictional unit convention. Their average is 3, whose square is 9. Squaring the original values gives 4 and 16; their average is 10. Neither calculation contains an arithmetic error. They answer different mathematical questions. A reviewer should not replace an average of squared quantities with the square of an average merely because the latter is easier to compute. This simple counterexample makes a difference in transformation order observable without requiring any empirical data.
6. Rounding at different stages
Suppose three fictional amounts are each 0.334 units. Rounding each to two decimal places produces 0.33, whose sum is 0.99. Adding the original values gives 1.002, which rounds to 1.00. The intended procedure determines the appropriate result. Actual financial or measurement conventions require their own authoritative rounding rules. Retain both the original precision and the operation at which rounding is applied. The Boundary Sensitivity Map can identify whether the resulting difference changes a later classification.
7. Averages of averages need weights
One group contains two observations with an average of 10, while a second contains eight with an average of 20. The unweighted average of the two group averages is 15. The average across all ten observations is 18, assuming both summaries refer to comparable observations with the stated counts. Both operations are meaningful for different questions. Preserve the group sizes and intended weighting. The Aggregation Integrity Map helps ensure that an optimization based on precomputed averages does not lose the original denominator.
8. Filter before or after aggregation
A fictional organisation wants the total of individual amounts greater than 50. It cannot ordinarily calculate the total of every amount first and then apply the same threshold to that total. The first condition is about individual records; the second is about a group result. PostgreSQL’s aggregate-expression syntax makes the set of selected inputs an explicit feature of an aggregate. A semantic specification must similarly identify what the filter applies to. A correct threshold with the wrong scope can transform a legitimate calculation into a different question.
9. Missing values change the input collection
The PostgreSQL documentation defines average over non-null inputs. In a fictional collection containing 10, 20 and one unknown value, that convention gives 15 from the two known values. Substituting zero before averaging gives 10 across three values. These are distinct calculations with distinct assumptions. An AI should not insert zero merely to make every row participate. Preserve unknown, not applicable and observed zero as separate meanings. The Missingness Ledger and Identification Envelope help describe what remains unresolved.
10. Order of records is another issue
Some operations depend on which item comes first, such as concatenating a sequence of words. PostgreSQL documents that certain aggregates can produce different outputs depending on input order. This is distinct from changing the order of transformations. A chronological list of corrections and an alphabetical list of corrections may both contain the same entries while answering different questions. Record the relevant sorting key and tie handling. A source’s order should not be changed without considering its intended meaning and any necessary dependencies.
11. Deduplication is a semantic operation
In a fictional list of readings, two equal values may belong to two different events. Removing duplicate numerical values before calculating a total could remove genuine observations. If two records represent repeated transmission of one event, deduplication by the appropriate event identity may be justified. Define what counts as the same observation and when the rule is applied. The Reconciliation Ledger and Reference Integrity Contract provide complementary distinctions. A smaller dataset is not necessarily a more accurate representation of the source.
12. The proposed transformation record
Record the input source and version, operation identifier, relevant input and output grain, quantity kind, parameter values, filtering and rounding conventions, missing-value treatment, ordering requirements and dependencies. Identify the intended invariant and any proposed alternative sequence. Preserve the method and evidence used to justify an equivalence claim. These fields are a proposed review interface. They do not guarantee that the underlying implementation follows the declaration or that the declared sequence answers the intended domain question.
13. Zoom 0: algebra as the language of operations
A learner can calculate the square of an average and the average of squares, then explain why the results differ. Introduce a scaling operation that does commute with summation under stated assumptions. The contrast builds the ability to inspect the structure of an expression rather than memorise that operations always follow a particular verbal order. The same idea helps students understand when an algebraic simplification is justified. A new reviewed example can investigate whether the learner transfers the distinction.
14. Zoom 1: everyday decisions
A household may calculate a total from several rounded estimates or first obtain a more precise combined amount. The appropriate procedure depends on the actual question and available precision. An assistant should label estimates and identify any additional assumptions. It should not present a rounded display as an exact bill or silently replace an agreed calculation method. The practical principle is that the sequence of calculation matters when the result supports a decision. Actual charges and payment obligations require their own evidence and authority.
15. Zoom 2: organisational reporting
A company may rearrange a reporting pipeline to make it faster. Moving a filter, rounding step or grouping operation can change the output population or measure. Before changing the process, specify the intended result and examine the proposed equivalence under the actual data model. Use appropriate technical and domain review for consequential reporting. An efficient implementation is valuable only if its relevant outputs preserve the required meaning. A passing performance benchmark does not establish semantic correctness.
16. Zoom 3: institutions and published statistics
Institutions may compare measures computed through several transformation stages. Reclassification, standardisation and aggregation can each introduce assumptions. Reordering those stages may alter the statistic’s meaning. Retain the documented methodology, population and reference definitions. An AI summarising a report should avoid substituting a superficially similar calculation without justification. Official statistical methods remain authoritative for their intended use. This proposal helps make the calculation interpretable, not certify a new statistical procedure.
17. Zoom 4: coordinated AI reasoning
One specialist agent may convert quantities, another aggregate them and another check a decision boundary. A coordinator should preserve the sequence and conditions required by the method. Independent operations may proceed in parallel when that is justified, but apparent independence is not proof. The Choreography and Assumption Closure contracts help expose dependencies among components. The Production Attestation can preserve the operations actually used. A portable intelligence pool needs the structure of a method, not just a list of capabilities that participated.
18. Zoom 5: inheriting calculation methods
Future researchers may inherit final tables without the procedures that produced them. Even if the original variables are well defined, several possible transformation sequences could lead to different interpretations. Preserve the method, source versions and relevant assumptions where appropriate. A future system can then investigate whether a different implementation preserves the intended result. Respect applicable privacy and retention limits. Portable civilisation needs to retain enough of the reasoning structure for knowledge to remain usable and open to correction.
19. Invariance needs more than equal outputs
Two alternative sequences may happen to produce equal results on a particular dataset. If both values in the square example were 3, squaring before or after averaging would give the same number. That does not establish equivalence for every admissible dataset. Test meaningful variations and review the mathematical conditions. A counterexample can defeat a universal claim. A finite collection of successes supports only a bounded empirical statement unless a suitable proof establishes a stronger property.
20. Parallel summaries and merging
A sum over disjoint groups can be reconstructed by adding their sums, under the same quantity definitions. A mean can be reconstructed from compatible sums and counts rather than by averaging unweighted group means. A median generally cannot be reconstructed from group medians alone. This matters when an agent divides work among several services. Specify which intermediate records must survive for the final calculation to be valid. The Stock–Flow and Quantity Kind contracts preserve relevant boundaries and units. Not every reduction supports the same merge operation.
21. Proposed fixtures for transformation order
Prepare reviewed synthetic cases for constant scaling and summation, affine conversion and averaging, squaring before or after averaging, rounding, missing-value substitution, and filtering at different grains. Include a case where a reordered operation is undefined. Record the expected results and the reasoning for each. These are proposed tests, not observed Meaning Lab performance. Independent reviewers should inspect the domain assumptions rather than judge only whether the final number matches an authored answer.
22. A useful comparison receipt
A report comparing two sequences should state the original and alternative operations, input domain, expected invariant, actual tested results and any counterexample. Where the equivalence depends on exact arithmetic or absence of rounding, identify that requirement. If the results differ, report which stage first changes the meaning or quantity. The Attribution Trace and Revalidation Cache can help locate affected checks. A proposal to optimise a calculation is not the same as an established safe substitution.
23. Preserve authority across operations
A rearranged workflow must not move a consequential effect ahead of a mandatory permission check merely because the data processing steps seem commutative. Mathematical equivalence does not establish operational equivalence when side effects, privacy or authorization differ. Apply the actual security and domain rules. Use authorized sources and synthetic fixtures for early experiments. Preserve what was calculated separately from what was executed. The Authority Epoch and Commit Boundary remain essential when transformations lead to external actions.
24. A proposed four-week programme
Week 1: define a bounded set of numerical and record transformations. Week 2: construct reviewed equivalence and counterexample fixtures with explicit assumptions. Week 3: if an implementation exists, compare actual intermediate and final states across alternative sequences. Week 4: report observed differences, failures and limitations. These are proposed stages, not completed work. A real optimizer or operational procedure needs appropriate engineering, verification and independent evidence.
25. Questions every reader should ask
Which operation comes first? What collection and quantity does it act upon? Is the proposed reordering mathematically justified on the actual domain? Does a filter, rounding step or missing value change the result? Are intermediate summaries sufficient for the intended final calculation? Are permission and side-effect boundaries preserved? These questions make the sequence of reasoning inspectable and help distinguish a useful simplification from a subtle change in the question being answered.
26. The next engineering step
Link the Transformation Order Contract to the Quantity Kind, Stock–Flow, Join, and Production Attestation records. Define small, reviewed equivalence claims and investigate their boundary conditions. The next companion problem concerns splitting information into smaller records and establishing whether the original relationships can be reconstructed. No new deployed transformation engine or independent empirical findings are claimed. The proposal advances vocabulary engineering by treating operation order as part of the meaning that must survive across a handover.
Technical references
Continue reading
- Semantic Quantity Kind Contract
- Semantic Stock–Flow Contract
- Semantic Join Contract
- Semantic Boundary Sensitivity Map
- Semantic Production Attestation
Research status: aggregate operations and mathematical composition are established concepts. The Semantic Transformation Order Contract is a proposed vocabulary-engineering extension. All new examples are illustrative. No new implementation, formal proof of a real pipeline or independent empirical outcome is claimed.
Continue the current series: Semantic Reconstruction Contract
