# imitator-model-checker/imitator architecture

> Architecture diagram of the GitHub repository imitator-model-checker/imitator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imitator-model-checker/imitator
- Repository: https://github.com/imitator-model-checker/imitator

## Overview

1. This repository is the IMITATOR model-checker: a command-line OCaml tool that reads a parametric timed automaton model plus a property, runs one of several synthesis/model-checking algorithms, and emits results such as parameter sets, witnesses, counterexamples, or exported artifacts.

2. The main execution path starts in `src/bin/IMITATOR.ml`, which pulls together option parsing, input loading, model/property parsing, algorithm selection, execution, and result printing. The build is managed with Dune, with legacy OASIS generation scripts still present for packaging variants.

3. The core domain model lives in `src/lib`. It is organized around typed structures for automata, states, values, expressions, constraints, and properties. These modules form the shared in-memory representation used by all algorithms, exporters, and tests.

4. Parsing is a distinct front-end layer. `ModelLexer.mll` / `ModelParser.mly` handle `.imi` model files, while `PropertyLexer.mll` / `PropertyParser.mly` handle `.imiprop` property files. Parsed syntax is then converted through model/property converter modules into typed structures and normalized expressions.

5. A substantial preprocessing/analysis layer sits between parsing and search. Modules such as `TypeConstraintResolver`, `ExpressionReducer`, `ClocksElimination`, `ModelConverter`, `ParsedValue`, and the discrete-expression utilities handle typing, simplification, parameter/clock handling, and structural normalization before any synthesis algorithm runs.

6. The algorithm layer is the largest subsystem and is split into many dedicated modules under `src/lib`: reachability and temporal-property checks (`AlgoEF`, `AlgoAG`, `AlgoEU`, `AlgoDeadlockFree`, `AlgoValid`, `AlgoNDFS`), synthesis variants (`AlgoIM`, `AlgoIMK`, `AlgoIMunion`, `AlgoBCCover`, `AlgoPRP`, `AlgoPTG`), optimization variants (`AlgoEFmin`, `AlgoEFmax`, `AlgoEFtminQueue`), and cycle/non-Zeno variants (`AlgoNZCUB`, `AlgoLoopSynth`, `AlgoAccLoopSynth`). Each algorithm works over the shared core model and returns a structured result.

7. Result handling is centralized through `Result`, `ResultProcessor`, `Statistics`, `Logger`, and formatter/export modules. The tool can render outcomes as text, JSON, LaTeX, GraphViz/dot, TikZ, and translations to external model formats such as Uppaal, Jani, and HyTech, which means the architecture has a clear “analysis engine → presentation/export” boundary.

8. There is a separate distributed execution stack in `src/lib_distr`, focused on PRPC/behavioral-cartography-style workloads. It introduces master/worker and collaborator/coordinator modules for load splitting and distributed search, plus `RunPaTATOR` and `DistributedUtilities` as the orchestration layer. This part depends on the core model and algorithm layers but adds cluster communication and work partitioning as an explicit boundary.

9. The repository also contains tool-support code outside the main engine: `comparator/` provides Python scripts and a small web UI for comparing results, and `scripts/` contains helper automation for queries and JSON processing. These are adjuncts for benchmarking and result analysis rather than part of the verification core.

10. `benchmarks/` is a large corpus of real models and properties used to exercise the engine across domains such as protocols, hardware, scheduling, security, and synthesis. File extensions indicate different roles: `.imi` for models, `.imiprop` for properties, `.pi0`/`.v0` for some legacy benchmark formats, and `.tsv` for source data used by generated models.

11. `tests/` is organized as a regression suite with focused cases for syntax, typing, expression semantics, updates, reachability, deadlock, cycle detection, timed properties, inclusions, and translation/export behavior. This suite mirrors the architecture of the engine: parser/type-checker tests, preprocessing tests, then algorithm-specific correctness cases.

12. The project has meaningful external-library boundaries: the presence of GMP, PPL, and MPI-related metadata and build patches indicates dependence on arbitrary-precision arithmetic/polyhedral reasoning and optional distributed execution support. That affects architecture because numerical domains and distributed PRPC execution are not incidental features; they are first-class execution modes.

13. Documentation and CI are treated as part of the product surface. `doc/` contains the user/developer manuals and generated diagrams, while `.github/workflows`, Docker support, and build scripts define reproducible builds and automated validation. The repository is therefore structured as a research-grade toolchain with a core verifier, exporters, distributed mode, benchmark corpus, and extensive regression infrastructure.

Main entry points: [`src/bin/IMITATOR.ml`](https://github.com/imitator-model-checker/imitator/blob/master/src/bin/IMITATOR.ml) (IMITATOR), [`src/lib/AbstractAlgorithm.ml`](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AbstractAlgorithm.ml) (Algo core), [`src/lib/Result.mli`](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/Result.mli) (Results), [`src/lib/TypedStructure.mli`](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/TypedStructure.mli) (Typed model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["IMITATOR<br/>cli entry<br/>[IMITATOR.ml]"]
  node_dune["Dune build<br/>build config"]
  node_oasis["Packaging<br/>legacy build<br/>[gen_oasis.py]"]
end

subgraph group_front["Front-end"]
  node_model_parse["Model parse<br/>parser/lexer<br/>[ModelParser.mly]"]
  node_prop_parse["Property parse<br/>parser/lexer<br/>[PropertyParser.mly]"]
  node_converters["Converters<br/>frontend transform<br/>[ModelConverter.ml]"]
end

subgraph group_core["Core model"]
  node_core_model["Typed model<br/>domain model<br/>[TypedStructure.mli]"]
  node_state_space["State space<br/>state domain<br/>[StateSpace.ml]"]
  node_exprs["Expressions<br/>semantic core"]
end

subgraph group_analysis["Normalization"]
  node_typecheck["Typing<br/>analysis pass"]
  node_reduce["Reduce<br/>analysis pass"]
  node_elim["Eliminate<br/>analysis pass"]
end

subgraph group_algos["Algorithms"]
  node_algo_base["Algo core<br/>algorithm framework"]
  node_reach["Reachability<br/>verification algos<br/>[AlgoEF.ml]"]
  node_synth["Synthesis<br/>[AlgoIM.ml]"]
  node_opt["Optimization<br/>[AlgoEFmin.ml]"]
  node_cycle["Cycle search<br/>cycle algos<br/>[AlgoNZCUB.ml]"]
end

subgraph group_output["Results"]
  node_results["Results<br/>result model<br/>[Result.mli]"]
  node_present["Presenters<br/>result processing<br/>[ResultProcessor.ml]"]
  node_exporters["Exporters<br/>output adapters<br/>[PTA2JaniSpec.ml]"]
end

subgraph group_distr["Distributed"]
  node_dist_run["Distributed run<br/>distributed engine<br/>[RunPaTATOR.ml]"]
  node_dist_workers["Workers<br/>distributed roles"]
end

subgraph group_support["Support"]
  node_bench["Benchmarks<br/>model corpus<br/>[README.md]"]
  node_tests["Regression tests<br/>test suite<br/>[test.py]"]
  node_docs["Docs<br/>documentation"]
  node_tooling["Tooling<br/>aux scripts<br/>[comparator.py]"]
end

node_cli -->|"loads model"| node_model_parse
node_cli -->|"loads property"| node_prop_parse
node_cli -->|"prepares input"| node_converters
node_cli -->|"selects algo"| node_algo_base
node_cli -->|"prints outcome"| node_results
node_model_parse -->|"syntax tree"| node_converters
node_prop_parse -->|"property tree"| node_converters
node_converters -->|"builds"| node_core_model
node_core_model -->|"contains"| node_state_space
node_core_model -->|"uses"| node_exprs
node_core_model -->|"validated by"| node_typecheck
node_exprs -->|"simplified by"| node_reduce
node_typecheck -->|"feeds"| node_reduce
node_reduce -->|"normalizes"| node_elim
node_elim -->|"prepares"| node_algo_base
node_algo_base -->|"dispatches"| node_reach
node_algo_base -->|"dispatches"| node_synth
node_algo_base -->|"dispatches"| node_opt
node_algo_base -->|"dispatches"| node_cycle
node_reach -->|"returns"| node_results
node_synth -->|"returns"| node_results
node_opt -->|"returns"| node_results
node_cycle -->|"returns"| node_results
node_results -->|"processed by"| node_present
node_present -->|"renders"| node_exporters
node_cli -.->|"distributed mode"| node_dist_run
node_dist_run -->|"coordinates"| node_dist_workers
node_dist_run -->|"shares model"| node_core_model
node_dist_run -->|"uses algorithms"| node_algo_base
node_bench -.->|"drives runs"| node_cli
node_tests -.->|"regresses"| node_cli
node_docs -.->|"documents"| node_cli
node_tooling -.->|"analyzes"| node_results

click node_cli "https://github.com/imitator-model-checker/imitator/blob/master/src/bin/IMITATOR.ml"
click node_dune "https://github.com/imitator-model-checker/imitator/tree/master/dune-project"
click node_oasis "https://github.com/imitator-model-checker/imitator/blob/master/gen_oasis.py"
click node_model_parse "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ModelParser.mly"
click node_prop_parse "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/PropertyParser.mly"
click node_converters "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ModelConverter.ml"
click node_core_model "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/TypedStructure.mli"
click node_state_space "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/StateSpace.ml"
click node_exprs "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/DiscreteExpressions.ml"
click node_typecheck "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/TypeConstraintResolver.ml"
click node_reduce "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ExpressionReducer.ml"
click node_elim "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ClocksElimination.ml"
click node_algo_base "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AbstractAlgorithm.ml"
click node_reach "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoEF.ml"
click node_synth "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoIM.ml"
click node_opt "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoEFmin.ml"
click node_cycle "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoNZCUB.ml"
click node_results "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/Result.mli"
click node_present "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ResultProcessor.ml"
click node_exporters "https://github.com/imitator-model-checker/imitator/blob/master/src/lib/PTA2JaniSpec.ml"
click node_dist_run "https://github.com/imitator-model-checker/imitator/blob/master/src/lib_distr/RunPaTATOR.ml"
click node_dist_workers "https://github.com/imitator-model-checker/imitator/blob/master/src/lib_distr/AlgoBCCoverDistributedMSSeqMaster.ml"
click node_bench "https://github.com/imitator-model-checker/imitator/blob/master/benchmarks/README.md"
click node_tests "https://github.com/imitator-model-checker/imitator/blob/master/tests/test.py"
click node_docs "https://github.com/imitator-model-checker/imitator/blob/master/doc/IMITATOR-developer-manual.md"
click node_tooling "https://github.com/imitator-model-checker/imitator/blob/master/comparator/comparator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_dune,node_oasis,node_dist_run,node_dist_workers toneBlue
class node_model_parse,node_prop_parse,node_converters,node_bench,node_tests,node_docs,node_tooling toneAmber
class node_core_model,node_state_space,node_exprs toneMint
class node_typecheck,node_reduce,node_elim toneRose
class node_algo_base,node_reach,node_synth,node_opt,node_cycle toneIndigo
class node_results,node_present,node_exporters toneTeal
```

## Components

### Entry points

Command-line launch and build orchestration

- [IMITATOR](https://github.com/imitator-model-checker/imitator/blob/master/src/bin/IMITATOR.ml): cli entry · Main command-line executable and orchestration flow · `src/bin/IMITATOR.ml`
- [Dune build](https://github.com/imitator-model-checker/imitator/tree/master/dune-project): build config · Primary build definition for the OCaml project · `dune-project`
- [Packaging](https://github.com/imitator-model-checker/imitator/blob/master/gen_oasis.py): legacy build · Legacy OASIS and generation scripts for packaging variants · `gen_oasis.py`

### Front-end

Input parsing and syntax conversion

- [Model parse](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ModelParser.mly): parser/lexer · Lexer and parser for .imi model files · `src/lib/ModelParser.mly`
- [Property parse](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/PropertyParser.mly): parser/lexer · Lexer and parser for .imiprop property files · `src/lib/PropertyParser.mly`
- [Converters](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ModelConverter.ml): frontend transform · Conversion from parsed syntax to typed and normalized structures · `src/lib/ModelConverter.ml`

### Core model

Shared typed representation

- [Typed model](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/TypedStructure.mli): domain model · Automata, states, values, expressions, constraints, and properties · `src/lib/TypedStructure.mli`
- [State space](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/StateSpace.ml): state domain · State and state-space abstractions shared by algorithms · `src/lib/StateSpace.ml`
- [Expressions](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/DiscreteExpressions.ml): semantic core · Expression, constraint, and discrete-domain semantics · `src/lib/DiscreteExpressions.ml`

### Normalization

Typing, simplification, and structural preprocessing

- [Typing](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/TypeConstraintResolver.ml): analysis pass · Type-constraint resolution and semantic validation · `src/lib/TypeConstraintResolver.ml`
- [Reduce](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ExpressionReducer.ml): analysis pass · Expression reduction and normalization before search · `src/lib/ExpressionReducer.ml`
- [Eliminate](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ClocksElimination.ml): analysis pass · Clock and structural elimination / simplification · `src/lib/ClocksElimination.ml`

### Algorithms

Main verification and synthesis engines

- [Algo core](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AbstractAlgorithm.ml): algorithm framework · Shared algorithm interfaces and generic execution helpers · `src/lib/AbstractAlgorithm.ml`
- [Reachability](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoEF.ml): verification algos · EF, AG, EU, deadlock, validity, and NDFS-style checks · `src/lib/AlgoEF.ml`
- [Synthesis](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoIM.ml): synthesis algos · IM, IMK, IMunion, BCcover, PRP, PTG-style synthesis · `src/lib/AlgoIM.ml`
- [Optimization](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoEFmin.ml): optimization algos · Min/max and timed optimization variants · `src/lib/AlgoEFmin.ml`
- [Cycle search](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/AlgoNZCUB.ml): cycle algos · Non-Zeno, loop synthesis, and accepting-cycle variants · `src/lib/AlgoNZCUB.ml`

### Results

Result handling, statistics, and exports

- [Results](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/Result.mli): result model · Structured outcomes returned by algorithms · `src/lib/Result.mli`
- [Presenters](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/ResultProcessor.ml): result processing · Formatting, logging, statistics, and export processing · `src/lib/ResultProcessor.ml`
- [Exporters](https://github.com/imitator-model-checker/imitator/blob/master/src/lib/PTA2JaniSpec.ml): output adapters · Text, JSON, LaTeX, dot, TikZ, Uppaal, Jani, and HyTech export · `src/lib/PTA2JaniSpec.ml`

### Distributed

Cluster execution and partitioned search

- [Distributed run](https://github.com/imitator-model-checker/imitator/blob/master/src/lib_distr/RunPaTATOR.ml): distributed engine · Distributed PRPC / behavioral-cartography execution orchestration · `src/lib_distr/RunPaTATOR.ml`
- [Workers](https://github.com/imitator-model-checker/imitator/blob/master/src/lib_distr/AlgoBCCoverDistributedMSSeqMaster.ml): distributed roles · Master/worker and collaborator/coordinator search roles · `src/lib_distr/AlgoBCCoverDistributedMSSeqMaster.ml`

### Support

Benchmarks, tests, docs, and tooling

- [Benchmarks](https://github.com/imitator-model-checker/imitator/blob/master/benchmarks/README.md): model corpus · Large suite of benchmark models, properties, and generated inputs · `benchmarks/README.md`
- [Regression tests](https://github.com/imitator-model-checker/imitator/blob/master/tests/test.py): test suite · Parser, typing, preprocessing, algorithm, and translation regressions · `tests/test.py`
- [Docs](https://github.com/imitator-model-checker/imitator/blob/master/doc/IMITATOR-developer-manual.md): documentation · User/developer manuals, diagrams, and examples · `doc/IMITATOR-developer-manual.md`
- [Tooling](https://github.com/imitator-model-checker/imitator/blob/master/comparator/comparator.py): aux scripts · Comparator UI and helper scripts for experiments and data processing · `comparator/comparator.py`

## Connections

- IMITATOR → Model parse: loads model · Entry point invokes model parsing
- IMITATOR → Property parse: loads property · Entry point invokes property parsing
- IMITATOR → Converters: prepares input · CLI hands parsed input to conversion pipeline
- IMITATOR → Algo core: selects algo · Command-line options determine algorithm selection and execution mode
- IMITATOR → Results: prints outcome · Main program formats and emits final results
- Model parse → Converters: syntax tree · Parsed models are converted into typed structures
- Property parse → Converters: property tree · Parsed properties are converted into typed structures
- Converters → Typed model: builds · Front-end conversion constructs the shared in-memory model
- Typed model → State space: contains · Model includes state and state-space abstractions
- Typed model → Expressions: uses · Typed model depends on expression and constraint semantics
- Typed model → Typing: validated by · Typed structure is checked and resolved during preprocessing
- Expressions → Reduce: simplified by · Expression layer is normalized before search
- Typing → Reduce: feeds · Typing produces cleaned inputs for reduction
- Reduce → Eliminate: normalizes · Reduction feeds elimination and structural cleanup
- Eliminate → Algo core: prepares · Preprocessing produces algorithm-ready models
- Algo core → Reachability: dispatches · Generic framework runs reachability and property-checking variants
- Algo core → Synthesis: dispatches · Generic framework runs synthesis variants
- Algo core → Optimization: dispatches · Generic framework runs optimization variants
- Algo core → Cycle search: dispatches · Generic framework runs cycle and non-Zeno variants
- Reachability → Results: returns · Reachability algorithms produce structured results
- Synthesis → Results: returns · Synthesis algorithms produce witnesses or parameter sets
- Optimization → Results: returns · Optimization algorithms produce extremal results
- Cycle search → Results: returns · Cycle algorithms produce loop and acceptance evidence
- Results → Presenters: processed by · Result objects flow into logging and formatting
- Presenters → Exporters: renders · Presentation layer emits text and export artifacts
- IMITATOR → Distributed run: distributed mode · CLI can invoke distributed execution stack
- Distributed run → Workers: coordinates · Distributed runtime splits work across roles
- Distributed run → Typed model: shares model · Distributed execution reuses the core typed model
- Distributed run → Algo core: uses algorithms · Distributed runtime delegates to core algorithms
- Benchmarks → IMITATOR: drives runs · Benchmark corpus is used to exercise the executable
- Regression tests → IMITATOR: regresses · Test suite validates parser, analysis, algorithms, and exports
- Docs → IMITATOR: documents · Manuals and examples describe the public tool surface
- Tooling → Results: analyzes · Auxiliary scripts compare and process verification outputs
