Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Modules, interfaces and reference resolution

Modules organize the authorship and reuse of FormaSL programs. They gather declarations, establish which names become available to other modules and offer static interfaces through which types, relations, theories and operations can be used. Reference resolution connects the designators written in the program to the appropriate declarations and semantic referents.

That organization allows developing a domain in parts and composing them under identifiable contracts. One module can declare logistics relations, another can use those relations in risk evaluations and a third can publish operations destined for applications. The linkage between them keeps the identity of the declarations, their revisions and the guarantees exposed by the interfaces.

Source units, modules and packages

A source unit (SourceUnit) contains authored material of the language: FormaSL text or an equivalent representation. A module (LanguageModule) is a unit of binding, visibility, import, export and interface definition. A package gathers sources and modules for distribution, version selection and reproduction of a resolution basis.

On the H1 concrete surface, each .fsl source file contains a module declaration. That organization eases working with files, while the semantic identity of the module is determined by the language contract. The file name and its physical path are authorship and location information.

A module can declare types, relations, contents, theories, rules and semantic applications. The references those elements establish reach other modules through resolved bindings. The set of a module’s declarations can contribute to many regions of the metagraph, just as a semantic region can gather contributions from different modules.

Packages give those sources a unit of distribution. The project system uses forma.toml to declare the package, its sources, dependencies and targets. The resolved dependency basis can be fixed in forma.lock, including the selected versions and artifacts. That basis provides the coordinates needed to reproduce the resolution and the contracts used by a program.

Names, bindings, declarations and referents

When finding a name in an expression, FormaSL resolves a language binding under the applicable basis. The binding identifies the designation available in that scope. A declaration has its own identity; when it introduces or designates a semantic referent, that referent has another identity.

That difference appears in the use of aliases. A module can publish an alternative name for an existing type. The alias creates another way to reach the declaration, keeping the type’s identity. A re-export performs a similar operation at the boundary between interfaces: the name seen by the consumer can change while the referent remains the same.

A new declaration with its own meaning follows the corresponding introduction contract. Having the same name as an earlier declaration, including after a package revision, is a textual and resolution property; the succession between declarations or referents is determined by the appropriate identity and evolution relations.

Consider a shipment relation used by two modules. The logistics module can make it available under its original name, while an integration module publishes it under an alias adjusted to its consumers’ interface. The two designations can resolve to the same relation without creating two shipment instances. The identity of the concrete instances keeps belonging to the represented semantic domain.

Imports and exports

Imports make declarations of other modules accessible under resolution and visibility rules. Exports determine which bindings a module publishes to its consumers. The language admits qualified references and explicit renaming when the author wishes to select specific names in the interface.

A quality evaluation module can import the types and relations used to describe an inspection. That import makes available the relation’s contract, its roles and the guarantees needed for use. The evaluation operation can then query domain information and produce results under its own contract, without needing to redeclare the imported elements.

Importing a theory and adopting a theory are distinct actions. The import gives access to declarations through the module infrastructure; inclusion, extension, mapping and interpretation between theories establish semantic relations of their own. The same holds for policies: the availability of a declaration does not automatically establish its applicability or its authority in a determined judgment.

The order of files or imports is not used as a precedence criterion between competing declarations. When alternatives with the same specificity exist, resolution keeps the ambiguity so the program chooses a qualified designation or establishes an explicit binding.

Interfaces as static contracts

A module interface describes what consumers can use. For each exported binding, it makes available the information needed for static formation: the declaration’s category, the type or contract involved, its public guarantees, the visibility and the corresponding revision basis.

The interface contract can be presented by an explicit declaration or obtained by the formation rules applicable to the module. An InterfaceView represents the set of guarantees effectively exposed to the consumer at an import or export boundary.

The same declaration can be seen by different consumers through different interfaces. A module can publish the identity of an opaque type and operations using it, while another consumer has access to a more detailed interface. The type’s identity is preserved; the information each consumer can use depends on the selected interface view.

Compatibility between interfaces is directional. A module provides a required interface when it makes available the necessary bindings with compatible static guarantees. Additional elements published by the provider can remain outside the contract required by the consumer.

Verification is specific to each declaration’s category. Type compatibility considers type contracts and substitutability; that of relations takes into account relevant participation roles and guarantees; other categories use their own contracts. That discipline lets modules be composed preserving the meaning of the constructs crossing their interfaces.

Resolution under an identified basis

The resolution of a name depends on a resolution basis (ResolutionBasis). That basis gathers the revisions of modules and interfaces, the admitted imports and aliases, the visibility rules, the contracts expected for the target and the applicable scope path.

The language can determine a binding uniquely, identify several admissible candidates or conclude that the reference was not resolved. It also distinguishes an absent reference, a reference of incompatible category, a visibility conflict and a cycle of aliases without an origin declaration.

Explicit qualification restricts the search path. In nested lexical scopes, a nearer admissible local binding has precedence over more distant lexical bindings. An explicit declaration or alias in the current module is also more specific than bindings reached only through unqualified import. Among competing imports with equal priority, the author resolves the choice through qualification, alias or interface selection.

The category expected by the consumer participates in resolution. A position requiring a theory reference is evaluated according to that contract, just as a relation role needs an admissible participant. The spelling coincidence between two declarations of different categories does not turn one into the other.

A resolved reference stays bound to the basis that determined its meaning. Updating a package, changing an alias or revising a module’s interface can produce a new resolution for later programs. Historical bindings keep the reference and the revision under which they were interpreted.

Language resolution and domain identity

Name resolution is an operation of the language. The identity of the represented entities can, in turn, be discussed, evaluated or contested within the semantic domain.

A Claim can assert that two external designations refer to the same organization. An evaluation can accept that correspondence in a determined context. Those positions have value for the operations admitting them, while the program’s constitutive name resolution keeps its own grounding.

In the composition of the metagraph, a same-referent correspondence recognizes that resolved references point to a shared semantic element. The reconciliation of previously distinct identities, in turn, requires a semantic relation of identity or co-reference with its specific contract.

It is also important to distinguish the resolution basis from an ontological scope or a context frame. The first determines the interpretation of the language’s designators; the ontological scope establishes conceptual commitments; the frame situates information under its own interpretation conditions. An operation can depend on the three, preserving each one’s function.

Resolution, types and relation contracts

The type system uses the resolved references to verify the formation of expressions and declarations. A type reference must identify an admissible declaration and the revision of its contract; parameters and bounds must be satisfied under the applicable static rules.

In relation contracts, resolution identifies roles and admissible participants. When the contract distinguishes multiplicity, ordering, participation identity or semantic keys, that information accompanies the declaration’s meaning. The module infrastructure preserves the guarantees needed for consumer applications to use the relation correctly.

Resolution also reaches higher-order elements: theories, ontologies, policies, rules and operations are referenced according to their declarative category. The sharing of the name infrastructure allows using all those declarations in the same program, keeping their own semantic contracts.

Module composition and semantic composition

A program can combine modules to make declarations available, form applications and establish reusable interfaces. That composition happens in the authorship and resolution plane. The metagraph’s semantic composition works with the structures and referents defined or used by those modules.

Consider three modules: one describes relations between equipments and inspections; another declares evaluation operations; a third composes queries, judgments and decisions. The first provides typed references, the second publishes operation contracts and the third uses those contracts in applications. The interfaces determine what each consumer knows and which guarantees it can use.

When the operations reference the same equipment or the same inspection, the shared identity follows from the resolved referents and the established semantic correspondences. That identity can cross several documentary contributions, without depending on the number of files participating in the composition.

The composition of applications adds other obligations: compatibility of inputs and results, historical bases, data dependencies and authority conditions. They are governed by the operations’ contracts and by the composition contract, complementing module formation and resolution.

Revisions, dependencies and reproducibility

Modules, interfaces and packages can evolve at different rhythms. A new revision can add a declaration, modify an interface or change a type’s contract. The resolved basis of the program identifies the revisions that effectively participated in its formation.

The historical binding keeps the identity of the consulted declaration, the exposed interface view and the contract used. A later change of name, physical location or published version does not retroactively redefine the meaning of the already resolved program.

FormaSL projects can fix their dependencies through the manifest and the lock file. The exact selection of sources and their revisions provides the basis for repeating verifications and executions according to the pertinent contracts. The distribution of a package and the semantic authority of an assertion remain different responsibilities.

From source to the explicit semantic program

FormaSL starts from source units, resolves the declarations and verifies their static formation. An admitted and resolved program goes through elaboration, which makes explicit or reconstructible the bindings, identities and contracts needed by the later stages.

In that passage remain the correspondence with the source, the identity of declarations and referents, the revisions of types and relations and the relevant static dependencies. The execution mechanisms receive a program whose meaning was determined by the language’s rules.

Realization, specified in .fsp, binds semantic requirements to capabilities and resources. Planning and the runtime can select mechanisms appropriate to the elaborated program, preserving the contracts they receive. Thus the module organizes authorship, the interface governs sharing and resolution establishes the referents over which computation will act.

Types, contracts and substitutability details the static judgments used by interfaces. Logical architecture and metagraph describes the identities and semantic relations modules reference. Ontologies and semantic theories presents the domain artifacts that can be made available and related across modules. Semantic operations and transitions develops the applications consuming those structures.