Assert constraint
An assert constraint usage specifies that the result of a given constraint must always be true. If, at any point, the assert constraint evaluates to anything other than its asserted value, it indicates a logical inconsistency within the model.
There are two ways a constraint can be asserted:
- by referencing a constraint defined elsewhere in the model.
- The element symbol is displayed with the assert keyword (unnamed element) or the assert constraint keyword (named element).

- See the procedures:
- The element symbol is displayed with the assert keyword (unnamed element) or the assert constraint keyword (named element).
- by containing an owned assert constraint usage, i.e., the asserted constraint is the assert constraint usage itself.
- The element symbol is displayed with the assert constraint keyword.

- See the procedures:
- The element symbol is displayed with the assert constraint keyword.
Asserting a constraint by referencing a constraint defined elsewhere in the model
Asserting constraints via the Textual Editor
To assert constraints via the Textual Editor
- In the body of an element for which you want to reference a constraint, declare one of the following:
- For an unnamed assert constraint, declare the assert keyword, then follow with the name of the constraint you want to reference.
- For a named assert constraint, declare the assert constraint keyword, name the new usage, and then reference subset the constraint you want to reference.
To negate an assert constraint usage, specify the not keyword after the assert keyword, e.g., assert not constraint.
- Specify the constraint (expression, attributes, etc.) in the element's body.
- Click the Synchronize button.
constraint def MassLimit {
attribute mass : MassValue;
attribute massLimit : MassValue;
mass <= massLimit
}
assert constraint massIsPositive {
attribute mass : MassValue;
mass > 0 [kilogram]
}
part vehicle {
attribute massActual : MassValue;
attribute massRequired : MassValue;
assert massIsPositive { :>> mass = massRequired; } // step 1.a - unnamed usage reference subsets another constraint usage
assert constraint positiveMass ::> massIsPositive { :>> mass = massRequired; } // step 1.b - named usage reference subsets another constraint usage
assert not massIsPositive { :>> mass = massRequired; } // negated assert usage
}
Asserting constraints via the Drag and Drop handler in a view
To assert constraints via the Drag and Drop handler in a view
- Drag and drop an assert constraint element from the Containment tree or use its symbol's Drag and Drop handler on an element symbol executing the Create Assert Constraint command.
Asserting constraints via the Specification panel
To assert constraints via the Specification panel
- Drag and drop a constraint element from the Containment tree or use its symbol's Drag and Drop handler and drop it on the Asserted Constraint field in the Properties section of the Specification panel for the assert constraint usage.
The appropriate constraint is specified for the element.
Asserting a constraint via the owned assert constraint usage itself as the asserted constraint
Asserting constraints via the Textual Editor
To assert constraints via the Textual Editor
- In the Textual Editor, place the cursor where you want to create the element and declare the keyword assert constraint for an assert constraint usage.
To negate an assert constraint usage, specify the not keyword after the assert keyword, e.g., assert not constraint.
- Specify the element name.
- Specify the constraint (expression, attributes, etc.) in the element's body.
- Click the Synchronize button.
part vehicle {
attribute massActual : MassValue;
attribute massRequired : MassValue;
assert constraint massIsPositive { massActual <= massRequired } // named assert constraint usage
assert constraint { massActual <= massRequired } // unnamed assert constraint usage
assert not constraint massIsPositive { massActual <= massRequired } // named and negated assert constraint usage
}
Asserting constraints via the Create Element command
To assert constraints via the Create Element command
In the Containment tree, right-click an element, and in the shortcut menu, click Create Element.
- In the Create Element dialog, click assert constraint to create an assert constraint usage element.
- Name the element.
- Specify the constraint (expression, attributes, etc.).
Asserting constraints via the view palette
To assert constraints via the view palette
- In the view palette, under the Requirements/Constraints group, click the assert constraint button to create an assert constraint usage element.
- Click in the view pane where you want to create the constraint.
- Specify the constraint (expression, attributes, etc.).
Asserting constraints via the symbol compartment in a view
For more information, see the Compartments page.
To assert constraints via the symbol compartment in a view
- Do one of the following:
- Select an element symbol and click the Create Element button on it. In the dropdown menu, click the assert constraint element.
- Select an element symbol and on the right side of the assert constraints compartment, click the Create assert constraint button.
- Specify the constraint (expression, attributes, etc.).
The new element is created and displayed in the assert constraints compartment.
Asserting constraints via the Specification panel
To assert constraints via the Specification panel
- Open the Specification panel.
- Do one of the following:
- In the Properties section bar, click the Create Element
button. The shortcut menu appears. Click the assert constraint element in the shortcut menu. - In the assert constraints compartment section's bar, click the Create assert constraint
button.
- In the Properties section bar, click the Create Element
- Specify the constraint (expression, attributes, etc.).
The element is created in the assert constraints compartment.