Axiomatic Reasoning for LLMs

Visual Diagram as an Optimized Middle Layer for Deep Coding

1. Core Architecture

Deep Coding separates software construction into three layers:

Inserting a visual diagram as an explicit intermediate layer transforms the pipeline into four steps:

  1. Natural language intent → Visual diagram (AI‑generated)
  2. Visual diagram → Human verification
  3. Visual diagram → Structural specification (AI‑transformed)
  4. Structural specification → Implementation (AI‑generated)

The diagram layer uses text‑based diagram languages (Mermaid, PlantUML, UML, state charts) that are both human‑readable and machine‑processable.

2. Role of the Visual Diagram

The visual diagram serves three functions:

3. Transformation Pipeline

3.1 Intent → Diagram (AI)

Large language models generate diagram code (Mermaid, UML) from natural language descriptions. Current models achieve 61–68% completeness and correctness for UML diagrams, with sequence diagrams closest to human quality. Evaluation benchmarks (MermaidSeqBench) measure syntactic correctness, activation handling, error flow representation, and practical usability.

3.2 Diagram → Human Verification

Verification operates at two levels:

Humans verify diagrams more efficiently than text: eye‑tracking studies show shorter analysis time, fewer errors, and higher confidence with diagrams. The advantage increases with problem complexity.

3.3 Diagram → Structural Specification (AI)

The diagram is transformed into a formal structural specification (JSON Schema, TypeScript interfaces, OpenAPI). This transformation is deterministic: each diagram element maps to a specification constraint. Existing implementations include state‑chart‑to‑code generators and SysML requirement diagram transformers.

3.4 Structural Specification → Implementation (AI)

Implementation generation follows the original Deep Coding principle of generative conformance: code is produced only from the specification, and a validation gate rejects any non‑conforming output.

4. Human Role Compression

The pipeline reduces human involvement to two activities:

All intermediate transformations (intent→diagram, diagram→specification, specification→code) are automated. The human never writes diagram code manually nor edits the structural specification directly.

5. Operational Benefits

5.1 Version Control and CI/CD Integration

Diagram code (Mermaid, PlantUML) is stored in the same repository as source code. Git tracks changes, supports pull request reviews, and enables CI/CD pipelines that:

5.2 Traceability

Each diagram element carries traceability links (SysML satisfy/verify/trace relations). When the intent changes, the diagram is regenerated, and the structural specification updates automatically. Propagation of changes requires no manual intervention.

5.3 Elimination of Documentation Drift

Because diagrams are generated from intent and verified by humans, they never become stale. The diagram is always a faithful representation of the current intent and specification.

6. Empirical Grounding

7. Trade‑offs and Constraints

Constraint Mitigation
Diagram generation accuracy (61–68% for UML) Human verification catches errors before specification generation.
Learning curve for diagram syntax AI generates diagram code; humans only read rendered diagrams.
Reduced accessibility for non‑technical stakeholders Render diagrams to images for sharing; keep natural language summaries alongside.
Automatic layout may produce visually confusing diagrams Human verification includes layout adjustment requests; interactive refinement loops.
Optimal diagram type varies by task (flowchart, state chart, sequence) Select diagram type based on problem domain; use hybrid pipelines when needed.

8. Comparison with Existing Approaches

Approach Middle Layer Human Role Automation
Traditional MDD UML (proprietary tools) Manual modeling Partial code generation
IDD/SDD (Praxis, Spec Kit) Textual specification Write specifications Specification→code
Diagram‑as‑Code (CALM) Mermaid/PlantUML Write diagram code CI/CD automation
Deep Coding with visual diagram AI‑generated visual diagram Verify only Full pipeline automation

The key difference: the human never writes diagram code. The AI generates the diagram from intent, the human verifies it, and the pipeline proceeds automatically.

9. Conclusion

Inserting a visual diagram as an explicit intermediate layer between intent and structural specification in Deep Coding creates a pipeline where:

The approach is grounded in established cognitive science (diagram superiority for complex tasks), LLM capabilities (text‑to‑diagram generation at practical accuracy), and industry implementations (Morgan Stanley CALM, diagram‑as‑code tools). The pipeline does not replace existing development practices but provides a structured integration of visual modeling into AI‑driven software construction.