Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/acdeveloper-sci/forti4d/llms.txt

Use this file to discover all available pages before exploring further.

MI4D (4-Dimensional Integral Model) is the conceptual framework at the heart of Forti4D’s static analysis engine. Rather than treating a Fortran program as a flat sequence of text lines, MI4D proposes that every program is a topological hyper-object existing simultaneously across four orthogonal dimensions. A bug, a technical debt item, or a structural risk is defined as a topological inconsistency — an invalid intersection between these dimensions. By mapping each analysis script to a specific axis or projection, Forti4D produces findings that are precisely located in 4D space and traceable back to an exact file and line number where a developer must intervene.

The Four Axes

Each axis captures a distinct, irreducible property of a Fortran program. Together they form the coordinate system used to locate every symbol, statement, and structural unit in the corpus.

Axis X — Physical Dimension (Storage Topology)

Axis X describes the material existence of code on disk. It is organized as a strict containment hierarchy: Workspace → Path → Source File → Physical Line.
  • The atom of Axis X is the physical line (L_phys), identified by its local line number within a file.
  • Each physical line also receives a global coordinate (X_global) — unique across the entire Workspace — assigned at analysis time.
  • Axis X is static and immutable during analysis: it is agnostic to program logic, and two files are always disjoint sets of physical lines.
Forti4D coverage: reader_logical.py resolves physical lines into logical lines (handling continuation). inventory.py and profiler.py build the physical map of the corpus — files, line ranges per unit.
E1 limitation — C preprocessor directives: Directives such as #ifdef, #define, and #include (cpp) are treated as unrecognized physical lines and are never expanded. The Traceability Map (ℳ) is built from the literal source as written, not from the post-preprocessing view seen by the compiler. #include (cpp) is not followed; only native Fortran INCLUDE is tracked.

Axis Y — Logical Dimension (Executable Program Structure)

Axis Y is the transformation of the fragmented physical space (X) into a continuous logical flow. It processes physical lines into logical lines (L_log), resolves INCLUDE directives, and organizes the result into a containment tree of program units. The key structure is the Traceability Map (ℳ): for every logical line (Seq_log), ℳ records which physical lines compose it. This is the bridge between the abstract model and the concrete source file — the inverse ℳ⁻¹ translates any detected inconsistency back to the exact file and line number where a developer must intervene. Axis Y also defines the anatomy of a program unit: the Specification Zone (declarations), Execution Zone (executable statements), and Containment Zone (CONTAINS). The “Sandwich Rule” — every construct has an explicit open and close statement — governs structural integrity at this level. Forti4D coverage: inventory.py (unit tree, line ranges), dependencies.py (call graph = inter-unit Y relationships), profiler.py (statement classification within units), sloc.py (logical line counting per unit).

Axis Z — Scope Dimension (Semantic Depth)

Axis Z is a discrete ordinal scale measuring the visibility and isolation of symbols. It is not a metric but a depth level. Every Symbol — the persistent semantic entity behind a name — lives in Axis Z. Its identity is the pair (name, scoping unit), not the name alone. This is why two subroutines can each have a local variable I that are completely independent: same name, different Z coordinate.
Level (Z)NameDescriptionTypical entities
0UniversalVisible to the OS linkerExternal SUBROUTINEs, unnamed COMMON blocks
1InterfacePublic under contract (USE)PUBLIC entities in MODULEs
2Host (Owner)Private to the unit, visible to childrenLocal variables of PROGRAM or MODULE
3Contained (Inherited)Internal sub-scopeProcedures after CONTAINS
4Local (Ephemeral)Maximum temporal privacyVariables inside BLOCK…END BLOCK
The dynamics of Axis Z follow a fluid analogy:

Gravity — Host Association

Symbols naturally “fall” from Z=2 into child scopes. A variable declared in a host unit is visible to all procedures it contains.

Pumping — Use Association

A USE statement forces symbols from Z=1 (Interface) into Z=2 (Host). Modules push their public API into the consuming unit’s scope.

Walls — PRIVATE

A PRIVATE attribute blocks symbols from reaching Z=1. The unit’s internals are contained — they cannot be exported through a USE.
Forti4D coverage: symbols.py (variable/parameter/implicit declarations per unit, Z=2–4), derived_types.py (TYPE definitions = named scoping units), equivalences.py (EQUIVALENCE aliasing — a Z-level anomaly), common_blocks.py (Z=0 coupling via COMMON).

Axis T — State Dimension (Symbol Lifetime)

Axis T describes the evolution of each symbol’s validity along the execution trajectory (Control Flow Graph — CFG). It answers the question: at this point in the program, is this variable’s value trustworthy? Each symbol, at every point Seq_log, holds one of four states:
StateSymbolMeaning
UndefinedΩMemory allocated but value indeterminate. Reading here is a critical error.
DefinedΔThe symbol holds a valid, explicitly assigned value.
Static/SavedΣValue persists across calls (SAVE attribute or initialized in declaration).
Dead/DeallocatedOut of scope or explicitly freed (DEALLOCATE).
The trajectory of a symbol S is the function τ_S : Seq_log → {Ω, Δ, Σ, †}. A topological inconsistency is any 4D point (X_global, Seq_log, Z, τ_S) where the state is incompatible with the operation performed — for example, reading a symbol in state Ω, or writing to an INTENT(IN) argument. When a branch construct (IF, SELECT CASE) splits a trajectory, both paths may produce different states. If one branch leaves a symbol in Ω and another in Δ, the merge point produces an ambiguous state (Ω|Δ) — the basis for detecting Conditional Define errors. Forti4D coverage (partial): reachability.py detects the extreme case of Ω for entire units (dead code — units never reached from any entry point). complexity.py measures CFG branching depth (McCabe CC) without tracking symbol states.
Axis T is only partially implemented in the current release. Dead code detection (reachability.py) and CFG complexity measurement (complexity.py) are available, but full symbol-state tracking — Use Before Define, Conditional Define, and INTENT violation detection — is the primary scope of future development.

The Six Projection Planes

Two axes combined produce a projection plane — a 2D view that reveals a specific category of inconsistencies. The six planes form a complete map of all pairwise relationships in the model.
PlaneAxesWhat it revealsForti4D coverage
XYPhysical × LogicalINCLUDE chains, fragmentation, traceability mapprofiler.py (audit CSVs), reader_logical.py
YZLogical × ScopeShadowing, implicit typing (Phantom Scope), Privacy Leaksymbols.py (Implicit_None), cross_analysis.py
XZPhysical × ScopeOrphan modules, dead definitions at file levelreachability.py, structure_analysis.py
YTLogical × StateUse Before Define, Conditional Define, Post-Deallocationcomplexity.py (CFG structure only) — partial
XTPhysical × StateDead code, Spurious SAVEreachability.py — partial
ZTScope × StateSAVE violations, INTENT(IN/OUT) inconsistencies, global mutable statesymbols.py (attributes only) — partial

Implementation Status

Forti4D v0.7 implements Axes X, Y, and the foundational layer of Z. Axis T is partially addressed through dead-code detection and CFG complexity measurement.
AxisStatus in v0.7
X — PhysicalComplete
Y — StructuralComplete
Z — ScopeFoundational (declarations, visibility attributes, EQUIVALENCE, COMMON)
T — StatePartial (dead code + CFG depth; no symbol-state tracking)

Pipeline Stage Mapping

The MI4D specification defines five internal analysis stages (E1–E5). The Forti4D pipeline maps each stage to one or more analysis scripts:
MI4D StageComponentAxis builtForti4D scripts
E1PhysicalManagerXreader_logical.py, inventory.py
E2StructuralParserYinventory.py, dependencies.py, profiler.py
E3LexerDMLsub-plane (x′, y′)profiler.py (statement classification)
E4ScopeManagerZsymbols.py, derived_types.py, equivalences.py, common_blocks.py
E5FlowAnalyzerTreachability.py, complexity.py (partial)
Supporting and reporting scripts — sloc.py, clones.py, consolidate.py, cross_analysis.py, structure_analysis.py, prioritization.py, visual_graph.py, html_report.py — operate on the outputs of E1–E5 to produce structured reports and metrics. They do not extend the model axes directly but provide projections, aggregations, and risk scoring derived from the 4D geometry.

Build docs developers (and LLMs) love