-
Key: KERML11-213
-
Status: open
-
Source: P-1 AI ( Ethan Lew)
-
Summary:
The result expression of VectorFunctions::'cartesian-' applies CartesianVectorOf twice, so it does not compute the difference of two vectors (or the negation of one).
Specification p. 394 and library model (SysML-v2-Release 2026-08, Kernel Libraries/Kernel Function Library/VectorFunctions.kerml, line 222):
function 'cartesian-' specializes '-' { in v: CartesianVectorValue[1]; in w: CartesianVectorValue[0..1]; inv precondition { w != null implies v.dimension == w.dimension } return u: CartesianVectorValue[1] = CartesianVectorOf( if w == null? CartesianVectorOf(v.elements->collect{in x : Real; -x}) else CartesianVectorOf( (1..v.dimension)->collect{in i : Positive; v#(i) - w#(i)} ) ); }Both branches of the if already construct a CartesianVectorValue. The outer CartesianVectorOf(...) then takes that vector as its components, which are declared Real[*], so the argument does not conform. Read literally, the result is a one-dimensional vector whose single element is the difference vector. Every v - w and -v on Cartesian vectors is affected. The neighbouring 'cartesian+' has no such outer wrapper.
Example:
package Repro { private import VectorFunctions::*; attribute d = CartesianVectorOf((1.0, 2.0)) - CartesianVectorOf((3.0, 5.0)); // expected: elements (-2.0, -3.0), dimension 2 // as defined: dimension 1, and the one element is a CartesianVectorValue, not a Real }Proposed resolution: remove the outer CartesianVectorOf:
return u: CartesianVectorValue[1] = if w == null? CartesianVectorOf(v.elements->collect{in x : Real; -x}) else CartesianVectorOf( (1..v.dimension)->collect{in i : Positive; v#(i) - w#(i)} ); -
Reported: KerML 1.0b4 — Sun, 18 Oct 2026 04:35 GMT
-
Updated: Tue, 20 Oct 2026 18:42 GMT
KERML11 — VectorFunctions::'cartesian-' wraps its result in a second CartesianVectorOf
- Key: KERML11-213
- OMG Task Force: Kernel Modeling Language (KerML) 1.1 RTF