# correcthorsebatterystaple/hoare-z3 architecture

> Architecture diagram of the GitHub repository correcthorsebatterystaple/hoare-z3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/correcthorsebatterystaple/hoare-z3
- Repository: https://github.com/correcthorsebatterystaple/hoare-z3

## Overview

##### Input Processing Layer
- Entry point (src/index.ts)
- Tokenizer (src/tokenizer.ts)
- Grammar parser (grammar.ne and src/grammar.js)

##### Core Processing Pipeline
- Verification Condition Generation (src/getVerificationConditions.ts)
- Hoare Logic Transformation (src/hoareTransformers.ts)
- Infix to Prefix Conversion (src/infixToPrefix.ts)
- SMT Generation (src/smtGenerator.ts)

##### Supporting Components
- Built-in Functions/Operations (src/builtin.ts)
- Type Definitions and Interfaces
- Enums for Tokens and Parser Nodes

##### Component Representation
- Use rectangles for major processing components
- Blue: Input/Output
- Green: Processing Components
- Yellow: Supporting Utilities
- Gray: Configuration/Definition Files

**[TypeScript Program + Specifications] →**
- [Lexical Analysis (tokenizer.ts)] →
- [Parsing (grammar.ne)] →
- [Verification Condition Generation] →
- [Hoare Logic Transformation] →
- [SMT Generation] →
- [SMT Conditions]

##### Supporting Components
- How built-in functions interface with the main pipeline
- Demonstrate how type definitions and enums support the system
- Relationship between different interfaces and their usage

##### Parser Dependencies
- How LexerTokenType and ParserNodeType enums support the parsing process
- How grammar.ne generates the parser

##### Transformation Pipeline
- Step-by-step transformation from TypeScript to SMT
- How each component feeds into the next

##### Support System
- Demonstrate how built-in functions are integrated
- Interface implementations and their relationships

Level of Detail Guidelines:

##### Testing: Indicate test points but don't detail individual test cases

Remember to:
- Keep the main transformation pipeline clear and central
- Use consistent notation throughout
- Bidirectional relationships where they exist
- Annotations for critical transformations
- Error handling paths
- Validation checkpoints

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        TS[TypeScript Program + Specifications]
    end

    subgraph "Lexical Analysis"
        TOK[Tokenizer]:::processor
        LEX_TOKEN[LexerTokenType]:::enum
        LEX_INT[Lexer Interfaces]:::interface
    end

    subgraph "Parsing Layer"
        GRAM[Grammar Parser]:::processor
        PARSE_NODE[Parser Node Types]:::enum
        PARSE_INT[Parser Interfaces]:::interface
        PARSE_HELP[Parser Helpers]:::utility
    end

    subgraph "Transformation Pipeline"
        VCG[Verification Condition Generator]:::processor
        HLT[Hoare Logic Transformer]:::processor
        ITP[Infix to Prefix Converter]:::processor
        SMTG[SMT Generator]:::processor
    end

    subgraph "Support System"
        BUILT[Built-in Functions]:::utility
        SAMPLE[Sample Programs]:::examples
    end

    subgraph Output
        SMT[SMT Conditions]
    end

    %% Main Flow
    TS --> TOK
    TOK --> GRAM
    GRAM --> VCG
    VCG --> HLT
    HLT --> ITP
    ITP --> SMTG
    SMTG --> SMT

    %% Supporting Relationships
    LEX_TOKEN --> TOK
    LEX_INT --> TOK
    PARSE_NODE --> GRAM
    PARSE_INT --> GRAM
    PARSE_HELP --> GRAM
    BUILT --> VCG
    BUILT --> HLT
    SAMPLE -.-> TS

    %% Styling
    classDef processor fill:#90EE90
    classDef enum fill:#FFD700
    classDef interface fill:#ADD8E6
    classDef utility fill:#D3D3D3
    classDef examples fill:#FFA07A

    %% Click Events
    click TOK "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/tokenizer.ts"
    click GRAM "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/grammar.ne"
    click VCG "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/getVerificationConditions.ts"
    click HLT "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/hoareTransformers.ts"
    click ITP "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/infixToPrefix.ts"
    click SMTG "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/smtGenerator.ts"
    click BUILT "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/builtin.ts"
    click LEX_TOKEN "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/enums/LexerTokenType.ts"
    click PARSE_NODE "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/enums/ParserNodeType.ts"
    click LEX_INT "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/interfaces/LexerToken.ts"
    click PARSE_INT "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/interfaces/ParserNode.ts"
    click PARSE_HELP "https://github.com/correcthorsebatterystaple/hoare-z3/blob/master/src/helpers/parserHelpers.ts"
    click SAMPLE "https://github.com/correcthorsebatterystaple/hoare-z3/tree/master/sample-programs/"
```
