How parthganeriwala/soartoprismtranslator works
1. Purpose and top-level shape
- This is a Java 17 / Maven command-line translator that converts Soar production-rule models into PRISM model files.
- The architecture is a pipeline: Soar source + optional JSON config → ANTLR parse tree → internal rule model → PRISM text output.
2. Entry point and orchestration
- The runtime entry point is edu.fit.assist.translator.soar.main.
- It coordinates reading the Soar input, loading optional configuration, deciding which translation path to use, and writing the generated PRISM model to output1.pm and stdout.
3. Parsing boundary: Soar grammar
- The parser is defined in src/main/antlr4/.../Soar.g4.
- Maven generates the ANTLR runtime classes under src/main/java/.../translator/gen/:
- lexer/parser
- listener/visitor interfaces
- generated tokens/interp metadata
- This is the hard boundary between textual Soar syntax and the tool’s internal representation.
4. Rule extraction layer
- The soar package contains the domain objects used after parsing:
- Rule, Variable, Input, Output, SoarRules, MergedTransition
- These classes act as the translator’s intermediate model: they normalize parsed Soar productions into rule/variable structures that can be analyzed independently from the grammar.
5. Parse-tree walking and semantic collection
- Visitor.java is the main semantic extractor over the ANTLR parse tree.
- Its role is to populate the internal Soar rule structures from production rules and state/operator/goal patterns.
- TranslatorUtils.java likely supports helper logic for pattern handling, normalization, and value inference across rules.
6. Translation subsystem split
- There are two translator paths:
- Translate.java for the general Soar-to-PRISM translation path
- TimeBasedTranslator.java for the time-based path
- The README states the general translator is currently not functional, so the effective architecture today is centered on the time-based translator.
7. Time-based model specialization
- The tool detects models with time-related state such as time-counter or total-time.
- TimeBasedTranslator is the working implementation and is responsible for emitting PRISM modules that represent time progression and state transitions.
- This creates an important architectural constraint: supported models are not arbitrary Soar programs, but those that fit the translator’s time-centric assumptions.
8. Configuration and external parameters
- PrismConfig.java and test_config.json indicate support for external model parameters.
- The README and CONFIG_GUIDE.md show that the config file is used for things like:
- probability distributions
- response-time distributions
- error rates
- sickness/probability tables
- This is an input boundary separate from the Soar source itself, used to enrich the translation with numeric semantics.
9. Outputs and generated artifacts
- The translated PRISM model is emitted as plain .pm text.
- output.pm / output1.pm are repository-level output artifacts, showing the translator’s expected product format.
- The output target is PRISM DTMC/MDP syntax, with the current examples emphasizing deterministic/time-stepped DTMC-style generation.
10. Example and validation corpus
- The models/ directory is not core runtime code; it is a collection of sample and reference models used to exercise and validate translation behavior.
- Subfolders like attention, physiology, and translated soar models suggest multiple model families used to test coverage and compare against manual translations.
11. Build-time tooling
- Maven manages compilation and ANTLR code generation.
- The generated parser code is checked into the tree under gen, so the architecture includes both source grammar and generated parser artifacts as first-class components.
12. Key architectural constraint
- The most important boundary for diagramming is:
- Soar input parsing and rule normalization on one side
- PRISM model emission on the other
- In the current repo state, only the time-based translation pipeline should be shown as operational; the general translation path should be shown as present but not currently reliable.
Main entry points: SoarRules.java Rule model · main.java CLI entry · TimeBasedTranslator.java Time-based · Visitor.java Parse visitor
Components 16
Runtime
Command-line translation pipeline and semantic model
- CLI entry · Java main program that coordinates loading input, config, translation, and output
src/main/java/edu/fit/assist/translator/soar/main.java - Parse visitor · Walks the ANTLR parse tree and builds internal Soar rule structures
src/main/java/edu/fit/assist/translator/soar/Visitor.java - Utils · Shared normalization and pattern-handling helpers used during translation
src/main/java/edu/fit/assist/translator/soar/TranslatorUtils.java - Rule model · Normalizes Soar productions into rule, variable, input, and output structures
src/main/java/edu/fit/assist/translator/soar/SoarRules.java - Rule · Represents a translated Soar production rule
src/main/java/edu/fit/assist/translator/soar/Rule.java - Variable · Represents a variable used in extracted Soar rules
src/main/java/edu/fit/assist/translator/soar/Variable.java - Input · Represents input-side facts or conditions from parsed Soar structures
src/main/java/edu/fit/assist/translator/soar/Input.java - Output · Represents output-side effects or actions from parsed Soar structures
src/main/java/edu/fit/assist/translator/soar/Output.java - Merged trans. · Combines related transitions for downstream PRISM emission
src/main/java/edu/fit/assist/translator/soar/MergedTransition.java - PRISM config · Loads probability and timing parameters used to enrich translation
src/main/java/edu/fit/assist/translator/soar/PrismConfig.java - Time-based · Operational translation path that emits time-centric PRISM models
src/main/java/edu/fit/assist/translator/soar/TimeBasedTranslator.java - General path · Alternative Soar-to-PRISM path present in the repo but not currently reliable
src/main/java/edu/fit/assist/translator/soar/Translate.java
Grammar
Soar ANTLR grammar and generated parser artifacts
- Soar grammar · ANTLR grammar defining the textual Soar syntax boundary
src/main/antlr4/edu/fit/assist/soar/Soar.g4 - Generated parser · Checked-in lexer, parser, visitor, and token artifacts generated from the grammar
src/main/java/edu/fit/assist/translator/gen/SoarParser.java
Examples
Sample models and reference PRISM outputs
- Models · Sample Soar/PRISM models used for validation and reference
models - PM outputs · Example generated PRISM model files at the repository root
output1.pm
Connections 19
- CLI entry → Soar grammar: parse input · Reads Soar source through the grammar boundary
- Soar grammar → Generated parser: generate · ANTLR grammar produces lexer/parser artifacts
- CLI entry → Parse visitor: walk parse tree · Uses the visitor to extract semantic rule data
- Parse visitor → Rule model: build model · Populates the internal Soar rule representation
- Rule model → Rule: contains · Stores normalized production rules
- Rule model → Variable: contains · Stores rule variables and state references
- Rule model → Input: contains · Stores parsed input conditions
- Rule model → Output: contains · Stores parsed outputs/actions
- Rule model → Merged trans.: derives · Collapses related rule behavior into merged transitions
- Parse visitor → Utils: uses · Applies helper normalization during extraction
- CLI entry → PRISM config: load config · Optionally loads external numeric parameters
- CLI entry → Time-based: translate · Primary operational translation path
- CLI entry → General path: translate · Alternative path kept in the codebase
- Time-based → PRISM config: reads params · Uses config values for probabilities and timing
- Time-based → Merged trans.: emit from · Generates PRISM transitions from normalized rule structure
- General path → Rule model: consumes · Uses the internal rule model when invoked
- Time-based → PM outputs: writes · Produces PRISM .pm model text
- CLI entry → PM outputs: save output · Writes the translated model to output file and stdout
- Models → PM outputs: reference · Sample models and translated outputs for validation