Skip to content

[Feature]: Function::isModelLevelEvaluable — generate the Kernel Functions Library membership set #364

Description

@antoineatstariongroup

Description

FunctionExtensions.ComputeIsModelLevelEvaluable(this IFunction) in
SysML2.NET/Extend/FunctionExtensions.cs:69 is a NotSupportedException stub. It has no OCL
derivation
— per KerML 1.0 §8.3.4.7.4 (normative) it is a Kernel Functions Library membership
test:

Certain Functions from the Kernel Functions Library are considered to have
isModelLevelEvaluable = true. For all other Functions it is false.

The set is KerML 1.0 Table 5 (§8.2.5.8.1) + Table 7 (§8.2.5.8.2) — 39 operator symbols, 3 of them
marked No
. Do not hardcode the names: 36 of the 39 rows are derivable from sources the code
generator already reads.

Derivation

  1. Operator symbols from the grammarResources/KerML-textual-bnf.kebnf, token rules
    ConditionalBinaryOperator, BinaryOperator, UnaryOperator, ClassificationTestOperator,
    CastOperator, MetaclassificationTestOperator, MetaCastOperator, plus the inline
    operator = 'if' | 'all' | '[' | ',' assignments. → 35 symbols.
  2. The 4 remaining operators from the XMIIndexExpression, FeatureChainExpression,
    CollectExpression and SelectExpression do not assign operator in the grammar; it is an OCL
    constraint body in Resources/KerML_only_xmi.uml: operator = '#' (:5937), '.' (:5761),
    'collect' (:5692), 'select' (:5633). → 39 total.
  3. Symbol → library function — from
    Resources/sysml.library.kpar/Kernel_Function_Library-1.0.0.kpar: the first package declaring a
    Function with that declaredName, probed in the order BaseFunctions, DataFunctions,
    ControlFunctions. That order is not invented — it is the OCL at
    Resources/KerML_only_xmi.uml:5671, already implemented at
    SysML2.NET/Extend/OperatorExpressionExtensions.cs:63. It resolves the == / === collision
    (both are declared in BaseFunctions and DataFunctions) to BaseFunctions, matching
    Table 5.
  4. Subtract the 3 curated exclusions — the only No rows: BaseFunctions::'all' (type extent),
    BaseFunctions::'[' and DataFunctions::'~' (abstract, no default definition in the library; see
    the notes at Resources/KerML-textual-bnf.kebnf:1178 and :1064). isAbstract does not
    discriminate — BaseFunctions::'==' is abstract and is evaluable — so these three must be an
    explicit list with a spec citation each.

This derivation is deliberately narrower than "every Function in the three packages": max, min,
reduce, forAll, selectOne, minimize etc. are declared there but are not operator terminals,
and fall out automatically.

Generator must validate (fail generation on mismatch)

  • Every derived qualified name resolves to a Function in the Kernel Function Library.
  • Steps 1–3 yield exactly 39 symbols — any other count means spec or library drift.
  • The exclusion list has 3 entries and every entry is present in the derived set.
  • '^' and '**' are separate Function declarations in DataFunctions even though Table 5
    collapses them into one row; both belong in the emitted set.

Output

A frozen set of qualified names in an AutoGen file (alongside
SysML2.NET/LexicalRules/AutoGenLexicalRules/), consumed by ComputeIsModelLevelEvaluable via
functionSubject.qualifiedName. Scope is the evaluable set only — the full operator → function map
is #365's concern.

Notes

SysML2.NET.CodeGenerator/Grammar/ already carries the KEBNF object model (TerminalElement,
Alternatives, TextualNotationRule) and GrammarLoader, and UmlCoreLexicalRulesGenerator
already emits from this rule shape. Reading .kermlx is the one new capability —
SysML2.NET.CodeGenerator references uml4net.xmi only, not SysML2.NET.Serializer.Xmi.

Impact

Completes the runtime behaviour of
InvocationExpressionExtensions.ComputeRedefinedModelLevelEvaluableOperation
(SysML2.NET/Extend/InvocationExpressionExtensions.cs:57), which compiles today but throws through
function.isModelLevelEvaluable.

Checklist

  • Generator: extract operator terminals from the KEBNF token rules
  • Generator: extract the 4 XMI operator = '…' constraint operators
  • Generator: read Kernel_Function_Library-1.0.0.kpar, map symbol → qualified name via the OCL probe order
  • Generator: curated 3-entry exclusion list + the drift validations above
  • Handlebars template + emitted AutoGen file
  • bool ComputeIsModelLevelEvaluable(this IFunction)
  • SysML2.NET.Tests/Extend/FunctionExtensionsTestFixture.cs

System Configuration

  • SysML2.NET version: 0.19.0
  • Source files:
    • SysML2.NET/Extend/FunctionExtensions.cs
    • SysML2.NET.CodeGenerator/Generators/UmlHandleBarsGenerators/

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions