Skip to content

Default [1..1] multiplicity on usages with explicit subsettings and redefinitions, unlike SysML 7.6.3 #819

Closed

Description

@vincemolnar

Version: 2026-08 (jupyter-sysml-kernel 0.62.0), measured; master at b924ce3b5 (after #815),
read from the code and its tests.

Minimal reproduction

package M {
    part def P;
    part x : P[0..3];
    part def C {
        part v : P;
        part u :> x;
        part w : P[2];
    }
    part def D :> C {
        part :>> w;
        part y :> w;
    }
}

Expected

SysML 7.6.3 Usages: "If a multiplicity is not declared for a usage, then the usage inherits the
multiplicity constraints of any other usages it subsets or redefines. If no tighter constraint is
inherited, the effective default is the most general multiplicity [0..*]. However, a tighter default
of [1..1] is implicitly declared for the usage if all of the following conditions hold: [...] 3. The
usage does not have any explicit owned subsettings or owned redefinitions."

So v gets [1..1], and u, D::w and D::y, which have explicit owned subsettings or
redefinitions, get no default. (7.6.3 is informative, and SYSML21-185 notes that Clause 8 has no
formal rule; 7.6.3 is the only statement of the rule.)

Actual

0.62.0, after transformAll(true):

M::C::v: Multiplicity owned by the usage, subsets Base::exactlyOne
M::C::u: Multiplicity owned by the usage, subsets Base::exactlyOne
M::C::w: MultiplicityRange owned by the usage, subsets Base::naturals
M::D::w: no multiplicity
M::D::y: no multiplicity

u gets the default although it subsets x explicitly: UsageAdapter.isAddDefaultMultiplicity()
suppresses it only when a subsetted feature has an owningType, the property condition 2 asks of the
usage itself, where condition 3 asks only whether explicit owned subsettings or redefinitions exist:

return target.isEnd() ||
       target.getOwningType() != null &&
       target.getOwnedSubsetting().stream().
            map(Subsetting::getSubsettedFeature).
            filter(f->f != null).
            map(FeatureUtil::getBasicFeatureOf).
            noneMatch(f->f != null && f.getOwningType() != null);

#815 describes this rule as "a modification to the third ('The usage does not have any explicit owned
subsettings or owned redefinitions that have no owning type')", which reads the opposite of the code
above, and removes condition 3, "presuming that the adopted resolution to [SYSML21-185] will insert
default multiplicities during parsing". Condition 3 as written can be checked during parsing: whether a
usage declares owned subsettings or redefinitions needs no name resolution, unlike the owning types of
their targets.

On master (ST6RI-947) the rule is in UsageParserPostProcessor.isAddDefaultMultiplicity(), now
target.isEnd() || target.getOwningType() != null, documented as "Subsettings and redefinitions do not
restrict this default (ST6RI-774)", and
MultiplicityPreparationTest.explicitSpecializationsReceiveDefaultMultiplicity expects the default on
attribute redefinedValues redefines values; with values[0..*]. By that code, D::w and D::y
above get [1..1] too. For D::w that conflicts with the redefined C::w[2]: a redefining feature
has the same values as the redefined one (KerML 7.3.4.5), so the two multiplicities cannot both hold
and D could have no instances.

Question

Is ST6RI-774 meant to change the rule of 7.6.3 (as a resolution of SYSML21-185)? If not, condition 3
asks for no default on a usage with an explicit owned subsetting or redefinition, both in 0.62.0 (for
subsettings of features without an owning type) and on master (for all of them), and it can be
checked during parsing as written.

The program printing the output above
import org.omg.sysml.interactive.SysMLInteractive;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.Multiplicity;
import org.omg.sysml.lang.sysml.Specialization;

/** For each usage: its multiplicity after the transformation, and what that multiplicity
 *  specializes. Arguments: the sysml.library directory, the directory holding m.sysml. */
public class DefaultMultiplicity {
    public static void main(String[] args) {
        SysMLInteractive si = SysMLInteractive.createInstance();
        si.setVerbose(false);
        si.loadLibrary(args[0]);
        si.readAll(args[1], true, ".sysml");
        si.resolveAllInputResources();
        si.transformAll(true);
        for (String name : new String[] {"M::C::v", "M::C::u", "M::C::w", "M::D::w", "M::D::y"}) {
            Feature f = (Feature) si.resolve(name);
            Multiplicity m = f.getMultiplicity();
            StringBuilder s = new StringBuilder(name + ": ");
            if (m == null) {
                s.append("no multiplicity");
            } else {
                s.append(m.eClass().getName()).append(m.getOwner() == f ? " owned by the usage" : " owned elsewhere");
                for (Specialization sp : m.getOwnedSpecialization()) {
                    s.append(", subsets ").append(sp.getGeneral().getQualifiedName());
                }
            }
            System.out.println(s);
        }
    }
}
javac -cp jupyter-sysml-kernel-0.62.0-all.jar DefaultMultiplicity.java
java -cp "jupyter-sysml-kernel-0.62.0-all.jar;." DefaultMultiplicity <sysml.library> <directory holding m.sysml>

Activity

  1. seidewitz commented on Oct 20, 2026

    @seidewitz
    Member

    Issue ST6RI-774 in the internal development Jira (which is not public) is entitled "Default multiplicity conditions are not per specification". It was created over two years ago and was planned to be resolved in the 2024-09 release. However, it was removed from the sprint and moved back to the backlog, with the comment:

    Actually, it may be desirable to update the specification to reflect the implementation (or maybe to remove condition 3 altogether). Package-level features have multiplicity 0..* by default. This means that a usage that specializes such a feature will also have multiplicity 0..* by default. But this leads to situations such as the following:

    attribute m1 : ISQ::MassValue; // Multiplicity 1..1
    attribute m2 :> ISQ::mass;     // Multiplicity 0..*
    

    This is likely to be unexpected by modelers.

    The current plan is to propose to the SysML RTF to formalize the rules for default multiplicity without the third condition.

  2. self-assigned this
    on Oct 20, 2026
  3. vincemolnar commented on Oct 20, 2026

    @vincemolnar
    ContributorAuthor

    Thanks, noted. I think we should keep the third condition, but only for redefinitions. Also, since there are implied redefinitions, it is dangerous to add the multiplicity at parse time. On a separate note, we also need checks for upper-bound conformance in case of subsettings (this becomes relevant here when, e.g., a default of [1] would violate a subsetted feature's [0] multiplicity).
    I'll take these to the RTF discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

wontfixThis will not be worked on

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions