sysmlpy 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sysmlpy/__init__.py +226 -0
- sysmlpy/__main__.py +75 -0
- sysmlpy/antlr/README.md +146 -0
- sysmlpy/antlr/SysMLv2Lexer.interp +695 -0
- sysmlpy/antlr/SysMLv2Lexer.py +1123 -0
- sysmlpy/antlr/SysMLv2Lexer.tokens +444 -0
- sysmlpy/antlr/SysMLv2Parser.interp +960 -0
- sysmlpy/antlr/SysMLv2Parser.py +40750 -0
- sysmlpy/antlr/SysMLv2Parser.tokens +444 -0
- sysmlpy/antlr/SysMLv2ParserListener.py +4485 -0
- sysmlpy/antlr/SysMLv2ParserVisitor.py +2498 -0
- sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
- sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
- sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
- sysmlpy/antlr_parser.py +185 -0
- sysmlpy/antlr_visitor.py +10864 -0
- sysmlpy/definition.py +1115 -0
- sysmlpy/examples/attribute_values.py +161 -0
- sysmlpy/examples/part_attributes.py +139 -0
- sysmlpy/examples/tuples_sequences.py +231 -0
- sysmlpy/formatting.py +47 -0
- sysmlpy/grammar/antlr4/README.md +30 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.g4 +931 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.g4 +2432 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.interp +960 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.py +40750 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.tokens +444 -0
- sysmlpy/grammar/antlr4/SysMLv2ParserListener.py +4485 -0
- sysmlpy/grammar/antlr4/SysMLv2ParserVisitor.py +2498 -0
- sysmlpy/grammar/antlr4/desc.xml +7 -0
- sysmlpy/grammar/antlr4/examples/camera.sysml +14 -0
- sysmlpy/grammar/antlr4/examples/toaster-system.sysml +193 -0
- sysmlpy/grammar/antlr4/examples/vehicle-model.sysml +118 -0
- sysmlpy/grammar/antlr4/pom.xml +59 -0
- sysmlpy/grammar/classes.py +8610 -0
- sysmlpy/library/LICENSE +165 -0
- sysmlpy/library/README.md +52 -0
- sysmlpy/library/__init__.py +0 -0
- sysmlpy/library/domain/Analysis/AnalysisTooling.sysml +34 -0
- sysmlpy/library/domain/Analysis/SampledFunctions.sysml +119 -0
- sysmlpy/library/domain/Analysis/StateSpaceRepresentation.sysml +143 -0
- sysmlpy/library/domain/Analysis/TradeStudies.sysml +171 -0
- sysmlpy/library/domain/Cause and Effect/CausationConnections.sysml +83 -0
- sysmlpy/library/domain/Cause and Effect/CauseAndEffect.sysml +81 -0
- sysmlpy/library/domain/Geometry/ShapeItems.sysml +899 -0
- sysmlpy/library/domain/Geometry/SpatialItems.sysml +168 -0
- sysmlpy/library/domain/Metadata/ImageMetadata.sysml +78 -0
- sysmlpy/library/domain/Metadata/ModelingMetadata.sysml +143 -0
- sysmlpy/library/domain/Metadata/ParametersOfInterestMetadata.sysml +39 -0
- sysmlpy/library/domain/Metadata/RiskMetadata.sysml +100 -0
- sysmlpy/library/domain/Quantities and Units/ISQ.sysml +42 -0
- sysmlpy/library/domain/Quantities and Units/ISQAcoustics.sysml +439 -0
- sysmlpy/library/domain/Quantities and Units/ISQAtomicNuclear.sysml +2726 -0
- sysmlpy/library/domain/Quantities and Units/ISQBase.sysml +206 -0
- sysmlpy/library/domain/Quantities and Units/ISQCharacteristicNumbers.sysml +1991 -0
- sysmlpy/library/domain/Quantities and Units/ISQChemistryMolecular.sysml +1353 -0
- sysmlpy/library/domain/Quantities and Units/ISQCondensedMatter.sysml +1223 -0
- sysmlpy/library/domain/Quantities and Units/ISQElectromagnetism.sysml +2333 -0
- sysmlpy/library/domain/Quantities and Units/ISQInformation.sysml +958 -0
- sysmlpy/library/domain/Quantities and Units/ISQLight.sysml +1537 -0
- sysmlpy/library/domain/Quantities and Units/ISQMechanics.sysml +1564 -0
- sysmlpy/library/domain/Quantities and Units/ISQSpaceTime.sysml +1169 -0
- sysmlpy/library/domain/Quantities and Units/ISQThermodynamics.sysml +1256 -0
- sysmlpy/library/domain/Quantities and Units/MeasurementRefCalculations.sysml +30 -0
- sysmlpy/library/domain/Quantities and Units/MeasurementReferences.sysml +526 -0
- sysmlpy/library/domain/Quantities and Units/Quantities.sysml +107 -0
- sysmlpy/library/domain/Quantities and Units/QuantityCalculations.sysml +70 -0
- sysmlpy/library/domain/Quantities and Units/SI.sysml +378 -0
- sysmlpy/library/domain/Quantities and Units/SIPrefixes.sysml +48 -0
- sysmlpy/library/domain/Quantities and Units/TensorCalculations.sysml +50 -0
- sysmlpy/library/domain/Quantities and Units/Time.sysml +274 -0
- sysmlpy/library/domain/Quantities and Units/USCustomaryUnits.sysml +260 -0
- sysmlpy/library/domain/Quantities and Units/VectorCalculations.sysml +62 -0
- sysmlpy/library/domain/Requirement Derivation/DerivationConnections.sysml +63 -0
- sysmlpy/library/domain/Requirement Derivation/RequirementDerivation.sysml +39 -0
- sysmlpy/library/kernel/Base.kerml +95 -0
- sysmlpy/library/kernel/BaseFunctions.kerml +80 -0
- sysmlpy/library/kernel/BooleanFunctions.kerml +22 -0
- sysmlpy/library/kernel/Clocks.kerml +156 -0
- sysmlpy/library/kernel/CollectionFunctions.kerml +68 -0
- sysmlpy/library/kernel/Collections.kerml +147 -0
- sysmlpy/library/kernel/ComplexFunctions.kerml +47 -0
- sysmlpy/library/kernel/ControlFunctions.kerml +117 -0
- sysmlpy/library/kernel/ControlPerformances.kerml +135 -0
- sysmlpy/library/kernel/DataFunctions.kerml +43 -0
- sysmlpy/library/kernel/FeatureReferencingPerformances.kerml +190 -0
- sysmlpy/library/kernel/IntegerFunctions.kerml +43 -0
- sysmlpy/library/kernel/KerML.kerml +483 -0
- sysmlpy/library/kernel/Links.kerml +67 -0
- sysmlpy/library/kernel/Metaobjects.kerml +58 -0
- sysmlpy/library/kernel/NaturalFunctions.kerml +27 -0
- sysmlpy/library/kernel/NumericalFunctions.kerml +43 -0
- sysmlpy/library/kernel/Objects.kerml +212 -0
- sysmlpy/library/kernel/Observation.kerml +161 -0
- sysmlpy/library/kernel/OccurrenceFunctions.kerml +154 -0
- sysmlpy/library/kernel/Occurrences.kerml +992 -0
- sysmlpy/library/kernel/Performances.kerml +293 -0
- sysmlpy/library/kernel/RationalFunctions.kerml +49 -0
- sysmlpy/library/kernel/RealFunctions.kerml +56 -0
- sysmlpy/library/kernel/ScalarFunctions.kerml +33 -0
- sysmlpy/library/kernel/ScalarValues.kerml +23 -0
- sysmlpy/library/kernel/SequenceFunctions.kerml +111 -0
- sysmlpy/library/kernel/SpatialFrames.kerml +197 -0
- sysmlpy/library/kernel/StatePerformances.kerml +145 -0
- sysmlpy/library/kernel/StringFunctions.kerml +25 -0
- sysmlpy/library/kernel/Transfers.kerml +281 -0
- sysmlpy/library/kernel/TransitionPerformances.kerml +66 -0
- sysmlpy/library/kernel/TrigFunctions.kerml +35 -0
- sysmlpy/library/kernel/Triggers.kerml +188 -0
- sysmlpy/library/kernel/VectorFunctions.kerml +273 -0
- sysmlpy/library/kernel/VectorValues.kerml +64 -0
- sysmlpy/library/systems/Actions.sysml +552 -0
- sysmlpy/library/systems/Allocations.sysml +29 -0
- sysmlpy/library/systems/AnalysisCases.sysml +38 -0
- sysmlpy/library/systems/Attributes.sysml +25 -0
- sysmlpy/library/systems/Calculations.sysml +37 -0
- sysmlpy/library/systems/Cases.sysml +71 -0
- sysmlpy/library/systems/Connections.sysml +60 -0
- sysmlpy/library/systems/Constraints.sysml +44 -0
- sysmlpy/library/systems/Flows.sysml +126 -0
- sysmlpy/library/systems/Interfaces.sysml +89 -0
- sysmlpy/library/systems/Items.sysml +153 -0
- sysmlpy/library/systems/Metadata.sysml +32 -0
- sysmlpy/library/systems/Parts.sysml +81 -0
- sysmlpy/library/systems/Ports.sysml +54 -0
- sysmlpy/library/systems/Requirements.sysml +194 -0
- sysmlpy/library/systems/StandardViewDefinitions.sysml +123 -0
- sysmlpy/library/systems/States.sysml +103 -0
- sysmlpy/library/systems/SysML.sysml +539 -0
- sysmlpy/library/systems/UseCases.sysml +57 -0
- sysmlpy/library/systems/VerificationCases.sysml +103 -0
- sysmlpy/library/systems/Views.sysml +164 -0
- sysmlpy/navigate.py +272 -0
- sysmlpy/store.py +547 -0
- sysmlpy/usage.py +2978 -0
- sysmlpy-0.1.0.dist-info/METADATA +230 -0
- sysmlpy-0.1.0.dist-info/RECORD +143 -0
- sysmlpy-0.1.0.dist-info/WHEEL +4 -0
- sysmlpy-0.1.0.dist-info/entry_points.txt +3 -0
- sysmlpy-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
standard library package DerivationConnections {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package provides a library model for derivation connections between requirements.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
private import SequenceFunctions::excludes;
|
|
8
|
+
private import ControlFunctions::allTrue;
|
|
9
|
+
|
|
10
|
+
requirement originalRequirements[*] {
|
|
11
|
+
doc /* originalRequirements are the original requirements in Derivation connections. */
|
|
12
|
+
}
|
|
13
|
+
requirement derivedRequirements[*] {
|
|
14
|
+
doc /* derivedRequirements are the derived requirments in Derivation connections. */
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
abstract connection def Derivation {
|
|
18
|
+
doc
|
|
19
|
+
/*
|
|
20
|
+
* A Derivation connection asserts that one or more derivedRequirements are derived from
|
|
21
|
+
* a single originalRequirement. This means that any subject that satisfies the
|
|
22
|
+
* originalRequirement should, in itself or though other things related to it, satisfy
|
|
23
|
+
* each of the derivedRequirements.
|
|
24
|
+
*
|
|
25
|
+
* A connection usage typed by Derivation must have requirement usages for all its ends.
|
|
26
|
+
* The single end for the originalRequirement should subset originalRequirement, while
|
|
27
|
+
* the rest of the ends should subset derivedRequirements.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
// Note: This redefinition causes a distinguishibility problem for binary connections, becuse
|
|
31
|
+
// participant is already redefined for them to limit the multiplicity to 2.
|
|
32
|
+
// ref requirement :>> participant {
|
|
33
|
+
// doc /* All the participants in a Derivation must be requirements. */
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
ref requirement originalRequirement[1] :>> originalRequirements :> participant {
|
|
37
|
+
doc /* The single original requirement. */
|
|
38
|
+
}
|
|
39
|
+
ref requirement :>> derivedRequirements[1..*] :> participant {
|
|
40
|
+
doc /* The one or more requirements that are derived from the original requirement. */
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private assert constraint originalNotDerived {
|
|
44
|
+
doc /* The original requirement must not be a derived requirement. */
|
|
45
|
+
|
|
46
|
+
derivedRequirements->excludes(originalRequirement)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private assert constraint originalImpliesDerived {
|
|
50
|
+
doc
|
|
51
|
+
/*
|
|
52
|
+
* Whenever the originalRequirement is satisfied, all of the derivedRequirements must also
|
|
53
|
+
* be satisfied.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
originalRequirement.result implies allTrue(derivedRequirements.result)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
abstract connection derivations : Derivation[*] {
|
|
61
|
+
doc /* derivations is the base feature for Derivation connection usages. */
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
standard library package RequirementDerivation {
|
|
2
|
+
doc /* This package provides language-extension metadata for modeling requirement derivation. */
|
|
3
|
+
|
|
4
|
+
public import DerivationConnections::*;
|
|
5
|
+
private import Metaobjects::SemanticMetadata;
|
|
6
|
+
|
|
7
|
+
metadata def <original> OriginalRequirementMetadata :> SemanticMetadata {
|
|
8
|
+
doc
|
|
9
|
+
/*
|
|
10
|
+
* OriginalRequirementMetadata identifies a usage as an original requirement.
|
|
11
|
+
* It is intended to be used to tag the original requirement end of a Derivation.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
:> annotatedElement : SysML::Usage;
|
|
15
|
+
:>> baseType = originalRequirements meta SysML::Usage;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
metadata def <derive> DerivedRequirementMetadata :> SemanticMetadata {
|
|
19
|
+
doc
|
|
20
|
+
/*
|
|
21
|
+
* DerivedRequirementMetadata identifies a usage as a derived requirement.
|
|
22
|
+
* It is intended to be used to tag the derived requirement ends of a Derivation.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
:> annotatedElement : SysML::Usage;
|
|
26
|
+
:>> baseType = derivedRequirements meta SysML::Usage;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
metadata def <derivation> DerivationMetadata :> SemanticMetadata {
|
|
30
|
+
doc
|
|
31
|
+
/*
|
|
32
|
+
* DerivationMetadata is SemanticMetadata for a Derivation connection.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
:> annotatedElement : SysML::ConnectionDefinition;
|
|
36
|
+
:> annotatedElement : SysML::ConnectionUsage;
|
|
37
|
+
:>> baseType = derivations meta SysML::Usage;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
standard library package Base {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package defines the classifiers and features that provide the bases for the typing
|
|
5
|
+
* of all elements in the language.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
abstract classifier Anything {
|
|
9
|
+
doc
|
|
10
|
+
/*
|
|
11
|
+
* Anything is the top level generalized type in the language.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
feature self: Anything[1] subsets things chains things.that {
|
|
15
|
+
doc
|
|
16
|
+
/*
|
|
17
|
+
* The source of a SelfLink of this thing to itself. self is thus a feature that
|
|
18
|
+
* relates everything to itself. It is also the value of the nested "that" feature
|
|
19
|
+
* of all other things featured by this thing.
|
|
20
|
+
*/
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
abstract datatype DataValue specializes Anything {
|
|
25
|
+
doc
|
|
26
|
+
/*
|
|
27
|
+
* Value is the most general classifier of entities that are values that do not change
|
|
28
|
+
* over time.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
feature self: DataValue redefines Anything::self;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
abstract feature things: Anything [1..*] nonunique {
|
|
35
|
+
doc
|
|
36
|
+
/*
|
|
37
|
+
* things is the top-level feature in the language.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
feature that : Anything[1] {
|
|
41
|
+
doc
|
|
42
|
+
/*
|
|
43
|
+
* For each value of things, the "featuring instance" of that value.
|
|
44
|
+
* This is enforced by declaring Anything::self to be the chaining of things.that,
|
|
45
|
+
* restricting it the single value of self.
|
|
46
|
+
*/
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
abstract feature dataValues: DataValue[0..*] nonunique subsets things {
|
|
51
|
+
doc
|
|
52
|
+
/*
|
|
53
|
+
* dataValues is a specialization of things restricted to type DataValue.
|
|
54
|
+
*/
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
abstract feature naturals: ScalarValues::Natural[0..*] subsets dataValues {
|
|
58
|
+
doc
|
|
59
|
+
/*
|
|
60
|
+
* naturals is a specialization of dataValues restricted to type Natural.
|
|
61
|
+
* It is the root feature of all multiplicities, which map from a feature to
|
|
62
|
+
* the set of Natural numbers representing allowable cardinalities of the feature.
|
|
63
|
+
*/
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
multiplicity exactlyOne [1..1] {
|
|
67
|
+
doc
|
|
68
|
+
/*
|
|
69
|
+
* exactlyOne is a multiplicity range requiring a cardinality of exactly one.
|
|
70
|
+
*/
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
multiplicity zeroOrOne [0..1] {
|
|
74
|
+
doc
|
|
75
|
+
/*
|
|
76
|
+
* zeroOrOne is a multiplicity range requiring a cardinality of zero or one.
|
|
77
|
+
*/
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
multiplicity oneToMany [1..*] {
|
|
81
|
+
doc
|
|
82
|
+
/*
|
|
83
|
+
* oneToMany is a multiplicity range allowing any cardinality of one or more.
|
|
84
|
+
*/
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
multiplicity zeroToMany [0..*] {
|
|
88
|
+
doc
|
|
89
|
+
/*
|
|
90
|
+
* zeroToMany is a multiplicity range allowing any cardinality of zero or more
|
|
91
|
+
* (that is, no restriction).
|
|
92
|
+
*/
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
standard library package BaseFunctions {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package defines a basic set of functions defined on all kinds of values.
|
|
5
|
+
* Most correspond to similarly named operators in the KerML expression syntax.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
private import Base::Anything;
|
|
9
|
+
private import Objects::Object;
|
|
10
|
+
private import Metaobjects::Metaobject;
|
|
11
|
+
private import KerML::Metaclass;
|
|
12
|
+
private import ScalarValues::*;
|
|
13
|
+
|
|
14
|
+
abstract function '=='{ in x: Anything[0..1]; in y: Anything[0..1];
|
|
15
|
+
return : Boolean[1];
|
|
16
|
+
}
|
|
17
|
+
function '!='{ in x: Anything[0..1]; in y: Anything[0..1];
|
|
18
|
+
return : Boolean[1] = not (x == y);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
abstract function '==='{ in x: Anything[0..1]; in y: Anything[0..1];
|
|
22
|
+
return : Boolean[1];
|
|
23
|
+
}
|
|
24
|
+
function '!=='{ in x: Anything[0..1]; in y: Anything[0..1];
|
|
25
|
+
return : Boolean[1] = not (x === y);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
abstract function ToString{ in x: Anything[0..1];
|
|
29
|
+
return : String;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
abstract function '['{ in x: Anything[0..*] nonunique; in y: Anything[0..*] nonunique;
|
|
33
|
+
return : Anything[0..*] nonunique;
|
|
34
|
+
}
|
|
35
|
+
abstract function '#'{ in seq: Anything[0..*] ordered nonunique; in index: Positive[1..*] ordered nonunique;
|
|
36
|
+
return : Anything[0..1];
|
|
37
|
+
}
|
|
38
|
+
abstract function ','{ in seq1: Anything[0..*] ordered nonunique; in seq2: Anything[0..*] ordered nonunique;
|
|
39
|
+
return : Anything[0..*] ordered nonunique;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
abstract function 'all'{
|
|
43
|
+
return : Object[0..*];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
abstract function 'istype'{
|
|
47
|
+
in seq: Anything[0..*];
|
|
48
|
+
in 'type': Anything;
|
|
49
|
+
return : Boolean[1];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
abstract function 'hastype'{
|
|
53
|
+
in seq: Anything[0..*];
|
|
54
|
+
in 'type': Anything;
|
|
55
|
+
return : Boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
abstract function '@'{
|
|
59
|
+
in seq: Anything[0..*];
|
|
60
|
+
in 'type': Anything;
|
|
61
|
+
return : Boolean[1];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
abstract function '@@'{
|
|
65
|
+
in seq: Metaobject[0..*];
|
|
66
|
+
in 'type': Metaobject;
|
|
67
|
+
return : Boolean[1];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
abstract function 'as'{
|
|
71
|
+
in seq: Anything[0..*] ordered nonunique;
|
|
72
|
+
return : Anything[0..*] ordered nonunique;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
abstract function 'meta'{
|
|
76
|
+
in seq: Metaobject[0..*] ordered nonunique;
|
|
77
|
+
return : Metaobject[0..*] ordered nonunique;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
standard library package BooleanFunctions {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package defines functions on Boolean values, including those corresponding to
|
|
5
|
+
* (non-conditional) logical operators in the KerML expression notation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
public import ScalarValues::*;
|
|
9
|
+
|
|
10
|
+
function 'not' specializes ScalarFunctions::'not' { in x: Boolean[1]; return : Boolean[1]; }
|
|
11
|
+
function 'xor' specializes ScalarFunctions::'xor' { in x: Boolean[1]; in y: Boolean[1]; return : Boolean[1]; }
|
|
12
|
+
|
|
13
|
+
function '|' specializes ScalarFunctions::'|' { in x: Boolean[1]; in y: Boolean[1]; return : Boolean[1]; }
|
|
14
|
+
function '&' specializes ScalarFunctions::'&' { in x: Boolean[1]; in y: Boolean[1]; return : Boolean[1]; }
|
|
15
|
+
|
|
16
|
+
function '==' specializes DataFunctions::'==' { in x: Boolean[0..1]; in y: Boolean[0..1]; return : Boolean[1]; }
|
|
17
|
+
|
|
18
|
+
function ToString specializes BaseFunctions::ToString { in x: Boolean[1]; return : String[1]; }
|
|
19
|
+
function ToBoolean { in x: String[1]; return : Boolean[1]; }
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
standard library package Clocks {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package models Clocks that provide an advancing numerical reference
|
|
5
|
+
* usable for quantifying the time of an Occurrence.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
private import ScalarValues::NumericalValue;
|
|
9
|
+
private import ScalarValues::Real;
|
|
10
|
+
private import Occurrences::Occurrence;
|
|
11
|
+
private import Occurrences::Life;
|
|
12
|
+
private import ControlFunctions::forAll;
|
|
13
|
+
|
|
14
|
+
private struct UniversalClockLife[1] :> Clock, Life {
|
|
15
|
+
doc
|
|
16
|
+
/*
|
|
17
|
+
* UniversalClockLife is the classifier of the singleton Life of the universalClock.
|
|
18
|
+
*/
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
feature universalClock : UniversalClockLife[1] {
|
|
22
|
+
doc
|
|
23
|
+
/*
|
|
24
|
+
* universalClock is a single Clock that can be used as a default universal
|
|
25
|
+
* time reference.
|
|
26
|
+
*/
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
abstract struct Clock {
|
|
30
|
+
doc
|
|
31
|
+
/*
|
|
32
|
+
* A Clock provides a numerical currentTime that advances montonically
|
|
33
|
+
* over its lifetime. Clock is an abstract base Structure that can be
|
|
34
|
+
* specialized for different kinds of time quantification (e.g., discrete
|
|
35
|
+
* time, continuous time, time with units, etc.).
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
private thisClock : Clock :>> self;
|
|
39
|
+
|
|
40
|
+
var feature currentTime : NumericalValue[1] {
|
|
41
|
+
doc
|
|
42
|
+
/*
|
|
43
|
+
* A scalar time reference that advances over the lifetime of the Clock.
|
|
44
|
+
*/
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
inv timeFlowConstraint {
|
|
48
|
+
doc
|
|
49
|
+
/*
|
|
50
|
+
* The currentTime of a snapshot of a Clock is equal to
|
|
51
|
+
* the TimeOf the snapshot relative to that Clock.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
snapshots->forAll{in s : Clock;
|
|
55
|
+
TimeOf(s, thisClock) == s.currentTime
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
abstract function TimeOf {
|
|
61
|
+
doc
|
|
62
|
+
/*
|
|
63
|
+
* TimeOf returns a numerical timeInstant for a given Occurrence relative to
|
|
64
|
+
* a given Clock. The timeInstant is the time of the start of the Occurrence,
|
|
65
|
+
* which is considered to be synchronized with the snapshot of the Clock
|
|
66
|
+
* with a currentTime equal to the returned timeInstant.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
in o : Occurrence[1];
|
|
70
|
+
in clock : Clock[1] default localClock;
|
|
71
|
+
return timeInstant : NumericalValue[1];
|
|
72
|
+
|
|
73
|
+
inv startTimeConstraint {
|
|
74
|
+
doc
|
|
75
|
+
/*
|
|
76
|
+
* The TimeOf an Occurrence is equal to the time of its start snapshot.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
timeInstant == TimeOf(o.startShot, clock)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
inv timeOrderingConstraint {
|
|
83
|
+
doc
|
|
84
|
+
/*
|
|
85
|
+
* If one Occurrence happens before another, then the TimeOf the end
|
|
86
|
+
* snapshot of the first Occurrence is no greater than the TimeOf the
|
|
87
|
+
* second Occurrence.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
o.predecessors->forAll{in p : Occurrence;
|
|
91
|
+
TimeOf(p.endShot, clock) <= timeInstant
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
inv timeContinuityConstraint {
|
|
96
|
+
doc
|
|
97
|
+
/*
|
|
98
|
+
* If one Occurrence happens immediately before another, then the TimeOf
|
|
99
|
+
* the end snapshot of the first Occurrence equals the TimeOf the second
|
|
100
|
+
* Occurrence.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
o.immediatePredecessors->forAll{in p : Occurrence;
|
|
104
|
+
TimeOf(p.endShot, clock) == timeInstant
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function DurationOf {
|
|
110
|
+
doc
|
|
111
|
+
/*
|
|
112
|
+
* DurationOf returns the duration of a given Occurrence relative to a
|
|
113
|
+
* given Clock, which is equal to the TimeOf the end snapshot of the
|
|
114
|
+
* Occurrence minus the TimeOf its start snapshot.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
in o : Occurrence[1];
|
|
118
|
+
in clock : Clock[1] default localClock;
|
|
119
|
+
return duration : NumericalValue =
|
|
120
|
+
TimeOf(o.endShot, clock) - TimeOf(o.startShot, clock);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
struct BasicClock :> Clock {
|
|
124
|
+
doc
|
|
125
|
+
/*
|
|
126
|
+
* A BasicClock is a Clock whose currentTime is a Real number.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
var feature :>> currentTime : Real;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function BasicTimeOf :> TimeOf {
|
|
133
|
+
doc
|
|
134
|
+
/*
|
|
135
|
+
* BasicTimeOf returns the TimeOf an Occurrence as a Real number relative
|
|
136
|
+
* to a BasicClock.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
in o : Occurrence[1];
|
|
140
|
+
in clock : BasicClock[1];
|
|
141
|
+
return : Real[1];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function BasicDurationOf :> DurationOf {
|
|
145
|
+
doc
|
|
146
|
+
/*
|
|
147
|
+
* BasicDurationOf returns the DurationOf an Occurrence as a Real number relative
|
|
148
|
+
* to a BasicClock.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
in o : Occurrence[1];
|
|
152
|
+
in clock : BasicClock[1];
|
|
153
|
+
return : Real[1];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
standard library package CollectionFunctions {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package defines functions on Collections (as defined in the Collections package).
|
|
5
|
+
* For functions on general sequences of values, see the SequenceFunctions package.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
private import Base::Anything;
|
|
9
|
+
private import ScalarValues::*;
|
|
10
|
+
private import SequenceFunctions::equals;
|
|
11
|
+
private import SequenceFunctions::includes;
|
|
12
|
+
private import ControlFunctions::exists;
|
|
13
|
+
public import Collections::*;
|
|
14
|
+
|
|
15
|
+
function '==' specializes BaseFunctions::'==' { in col1: Collection[0..1]; in col2: Collection[0..1];
|
|
16
|
+
return : Boolean[1] = col1.elements->equals(col2.elements);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function size { in col: Collection[1];
|
|
20
|
+
return : Natural[1] = SequenceFunctions::size(col.elements);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isEmpty { in col: Collection[1];
|
|
24
|
+
return : Boolean[1] = SequenceFunctions::isEmpty(col.elements);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function notEmpty { in col: Collection[1];
|
|
28
|
+
return : Boolean[1] = SequenceFunctions::notEmpty(col.elements);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function contains { in col: Collection[1]; in values: Anything[*];
|
|
32
|
+
return : Boolean[1] = col.elements->includes(values);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function containsAll { in col1: Collection[1]; in col2: Collection[2];
|
|
36
|
+
return : Boolean[1] = contains(col1, col2.elements);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function head { in col: OrderedCollection[1];
|
|
40
|
+
return : Anything[0..1] = SequenceFunctions::head(col.elements);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function tail { in col: OrderedCollection[1];
|
|
44
|
+
return : Anything[0..*] ordered nonunique = SequenceFunctions::tail(col.elements);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function last { in col: OrderedCollection[1];
|
|
48
|
+
return : Anything[0..1] = SequenceFunctions::last(col.elements);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function '#' specializes BaseFunctions::'#' { in col: OrderedCollection[1]; in index: Positive[1];
|
|
52
|
+
// Cast ensures this function is not called recursively if the elements of col are OrderedCollections.
|
|
53
|
+
return : Anything[0..1] = (col.elements as Anything)#(index);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function 'array#' specializes BaseFunctions::'#' { in arr: Array[1]; in indexes: Positive[n] ordered nonunique;
|
|
57
|
+
private feature n : Natural[1] = arr.rank;
|
|
58
|
+
|
|
59
|
+
// Assumes row-major ordering for elements.
|
|
60
|
+
private function index { in arr: Array[1]; in i : Natural; in indexes : Positive[1..*];
|
|
61
|
+
if i <= 1? indexes#(1) else arr.dimensions#(i) * (index(arr, i-1, indexes) - 1) + indexes#(i)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return : Anything[0..1] =
|
|
65
|
+
if n == 0 or (1..n)->exists {in i; indexes#(i) > arr.dimensions#(i)}? null
|
|
66
|
+
else arr.elements#(index(arr, n, indexes));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
standard library package Collections {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package defines a standard set of Collection data types. Unlike sequences of values
|
|
5
|
+
* defined directly using multiplicity, these data types allow for the possibility of collections
|
|
6
|
+
* as elements of collections.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
private import Base::*;
|
|
10
|
+
private import ScalarValues::*;
|
|
11
|
+
private import SequenceFunctions::size;
|
|
12
|
+
private import IntegerFunctions::*;
|
|
13
|
+
private import ControlFunctions::*;
|
|
14
|
+
|
|
15
|
+
abstract datatype Collection {
|
|
16
|
+
doc
|
|
17
|
+
/*
|
|
18
|
+
* Collection is the top level abstract supertype of all collection types.
|
|
19
|
+
* The name elements is used to denote the members or contents of the collection.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
feature elements[0..*] nonunique;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
abstract datatype OrderedCollection :> Collection {
|
|
26
|
+
doc
|
|
27
|
+
/*
|
|
28
|
+
* OrderedCollection is the abstract supertype for all ordered collection types.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
feature elements[0..*] ordered nonunique :>> Collection::elements;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
abstract datatype UniqueCollection :> Collection {
|
|
35
|
+
doc
|
|
36
|
+
/*
|
|
37
|
+
* UniqueCollection is the abstract supertype for all collection types with unique elements.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
feature elements[0..*] :>> Collection::elements {
|
|
41
|
+
/* Note: Redefinition of 'elements' is unique by default. */
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
datatype Array :> OrderedCollection {
|
|
46
|
+
doc
|
|
47
|
+
/*
|
|
48
|
+
* An Array is a fixed size, multi-dimensional Collection of which the elements are nonunique and ordered.
|
|
49
|
+
* Its dimensions specify how many dimensions the array has, and how many elements there are in each dimension.
|
|
50
|
+
* The rank is equal to the number of dimensions. The flattenedSize is equal to the total number of elements
|
|
51
|
+
* in the array.
|
|
52
|
+
*
|
|
53
|
+
* Feature elements is a flattened sequence of all elements of an Array and can be accessed by a tuple of indices.
|
|
54
|
+
* The number of indices is equal to rank. The elements are packed according to row-major convention, as in the C programming language.
|
|
55
|
+
*
|
|
56
|
+
* The elements of an Array can be assessed by a tuple of indices. The number of indices in such tuple is equal to rank.
|
|
57
|
+
* The packing of the elements, i.e. the flattened representation, follows the row-major convention,
|
|
58
|
+
* as in the C programming language.
|
|
59
|
+
*
|
|
60
|
+
* Note 1. Feature dimensions may be empty, which denotes a zero dimensional array, allowing an Array to collapse to a single element.
|
|
61
|
+
* This is useful to allow for specialization of an Array into a type restricted to represent a scalar.
|
|
62
|
+
* The flattenedSize of a zero dimensional array is 1.
|
|
63
|
+
*
|
|
64
|
+
* Note 2: An Array can represent the generalized mathematical concept of an infinite matrix of any rank, i.e. not limited to rank two.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
feature dimensions: Positive[0..*] ordered nonunique {
|
|
68
|
+
doc
|
|
69
|
+
/* Feature `dimensions` defines the N-dimensional shape of the Array
|
|
70
|
+
* The alternative name `shape` (as used in many programming languages) is not used as it would interfere with a geometric shape feature.
|
|
71
|
+
*/
|
|
72
|
+
}
|
|
73
|
+
feature rank: Natural[1] = size(dimensions);
|
|
74
|
+
feature flattenedSize: Positive[1] = dimensions->reduce '*' ?? 1;
|
|
75
|
+
inv { flattenedSize == size(elements) }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
datatype Bag :> Collection {
|
|
79
|
+
doc
|
|
80
|
+
/*
|
|
81
|
+
* Bag is a variable-size, unordered collection of nonunique elements.
|
|
82
|
+
*/
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
datatype Set :> UniqueCollection {
|
|
86
|
+
doc
|
|
87
|
+
/*
|
|
88
|
+
* Set is a variable-size, unordered collection of unique elements.
|
|
89
|
+
*/
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
datatype OrderedSet :> OrderedCollection, UniqueCollection
|
|
93
|
+
intersects OrderedCollection, UniqueCollection {
|
|
94
|
+
doc
|
|
95
|
+
/*
|
|
96
|
+
* OrderedSet is a variable-size, ordered collection of unique elements.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
feature elements[0..*] ordered :>> OrderedCollection::elements, UniqueCollection::elements {
|
|
100
|
+
/* Note: Redefinition of `elements` is unique by default. */
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
datatype List :> OrderedCollection {
|
|
105
|
+
doc
|
|
106
|
+
/*
|
|
107
|
+
* List is a variable-size, ordered collection of nonunique elements.
|
|
108
|
+
*/
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
datatype KeyValuePair {
|
|
112
|
+
doc
|
|
113
|
+
/*
|
|
114
|
+
* KeyValuePair is a tuple of a key and a value for use in Map collections.
|
|
115
|
+
* The key must be immutable.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
feature key: Anything[0..*] ordered nonunique;
|
|
119
|
+
feature val: Anything[0..*] ordered nonunique;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
datatype Map :> Collection {
|
|
123
|
+
doc
|
|
124
|
+
/*
|
|
125
|
+
* Map is a variable-size, unordered collection of elements that are key-value pairs.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
feature elements: KeyValuePair[0..*] :>> Collection::elements {
|
|
129
|
+
/* Note: Redefinition of `elements` is unique by default.
|
|
130
|
+
* The `key` of any `KeyValuePair` must be unique over the collection of `KeyValuePair`.
|
|
131
|
+
* The `val` does not need to be unique.
|
|
132
|
+
*/
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
datatype OrderedMap :> Map {
|
|
137
|
+
doc
|
|
138
|
+
/*
|
|
139
|
+
* OrderedMap is a variable-size, ordered collection of elements that are key-value pairs.
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
feature elements: KeyValuePair[0..*] ordered :>> Map::elements {
|
|
143
|
+
/* Note: Redefinition of `elements` is unique by default. */
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|