# arminbiere/cadical architecture

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

- Interactive diagram: https://gitdiagram.com/arminbiere/cadical
- Repository: https://github.com/arminbiere/cadical

## Overview

##### Main Components

a) Core Solver Components:
- Algorithmic components:
- Propagation Engine (propagate.cpp)
- Decision Engine (decide.cpp)
- Clause Learning (analyze.cpp)
- Backtracking (backtrack.cpp)
- Variable Management (var.cpp)
- Clause Management (clause.cpp)

b) Preprocessing Layer:
- Preprocessing components:
- Elimination (elim.cpp)
- Subsumption (subsume.cpp)
- Vivification (vivify.cpp)
- Probing (probe.cpp)

c) Interface Layer:
- API Interfaces:
- C++ API (cadical.hpp)
- C API (ccadical.h)
- IPASIR Interface (ipasir.cpp)

d) Proof Generation:
- Multiple proof format support:
- DRAT Tracer
- FRAT Tracer
- LRAT Tracer
- VeriPB Tracer

##### Component Relationships

**[Input Layer (CNF/ICNF)] → [Preprocessing] → [Core Solver] → [Solution/Proof]**
- ↑↓               ↑↓
- [Clause Database] ← [Learnt Clauses]

##### Important Details

a) Data Structures:
- Clause storage (clause.hpp)
- Watch lists (watch.hpp)
- Variable heap (heap.hpp)
- Assignment queue (queue.hpp)

b) Utility Components:
- Memory management (arena.hpp)
- Configuration (config.hpp)
- Statistics (stats.hpp)
- Resource limits (limit.hpp)

##### Implementation Notes

Use these symbols:
- Rectangles: Major components
- Rounded rectangles: Interfaces
- Diamonds: Decision points

- Simplicity and maintainability
- Performance optimization
- Modular architecture
- Multiple interface support

Keep the abstraction level focused on the major architectural components while showing enough detail to understand the solver's operation flow and key features.

This architecture represents a modern CDCL SAT solver with a focus on clean design and high performance, suitable for both academic and industrial applications.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Component]:::core --- L2[/Interface/]:::interface
        L2 --- L3[(Database)]:::storage
        L3 --- L4([Preprocessing]):::preproc
        L4 --- L5{{Decision Point}}:::decision
    end

    subgraph Input
        CNF[/CNF Format/]:::interface
        ICNF[/Incremental CNF/]:::interface
    end

    subgraph "Interface Layer"
        CAPI[/C API/]:::interface
        CPPAPI[/C++ API/]:::interface
        IPASIR[/IPASIR Interface/]:::interface
    end

    subgraph "Preprocessing Layer"
        ELIM([Elimination]):::preproc
        SUBS([Subsumption]):::preproc
        VIV([Vivification]):::preproc
        PROB([Probing]):::preproc
    end

    subgraph "Core Solver"
        PROP[Propagation Engine]:::core
        DEC[Decision Engine]:::core
        LEARN[Clause Learning]:::core
        BACK[Backtracking]:::core
        VARMGMT[Variable Management]:::core
        CLAUSEMGMT[Clause Management]:::core
    end

    subgraph "Data Structures"
        WATCH[(Watch Lists)]:::storage
        HEAP[(Variable Heap)]:::storage
        QUEUE[(Assignment Queue)]:::storage
        CLAUSE[(Clause Storage)]:::storage
    end

    subgraph "Proof Generation"
        DRAT[DRAT Tracer]:::proof
        FRAT[FRAT Tracer]:::proof
        LRAT[LRAT Tracer]:::proof
        VPBT[VeriPB Tracer]:::proof
    end

    subgraph "Utilities"
        MEM[Memory Management]:::util
        CONF[Configuration]:::util
        STATS[Statistics]:::util
        LIMITS[Resource Limits]:::util
    end

    CNF & ICNF --> CAPI & CPPAPI & IPASIR
    CAPI & CPPAPI & IPASIR --> ELIM & SUBS & VIV & PROB
    ELIM & SUBS & VIV & PROB --> PROP
    PROP <--> DEC
    DEC --> LEARN
    LEARN --> BACK
    BACK --> VARMGMT
    VARMGMT <--> CLAUSEMGMT
    CLAUSEMGMT <--> CLAUSE
    PROP <--> WATCH
    DEC <--> HEAP
    PROP <--> QUEUE
    LEARN --> DRAT & FRAT & LRAT & VPBT

    MEM --> CLAUSE
    CONF --> DEC
    STATS --> LEARN
    LIMITS --> PROP

    classDef core fill:#a4c2f4
    classDef interface fill:#ffe599
    classDef preproc fill:#b6d7a8
    classDef storage fill:#d9d9d9
    classDef proof fill:#f9cb9c
    classDef util fill:#d5a6bd
    classDef decision fill:#cc4125

    click PROP "https://github.com/arminbiere/cadical/blob/master/src/propagate.cpp"
    click DEC "https://github.com/arminbiere/cadical/blob/master/src/decide.cpp"
    click LEARN "https://github.com/arminbiere/cadical/blob/master/src/analyze.cpp"
    click BACK "https://github.com/arminbiere/cadical/blob/master/src/backtrack.cpp"
    click VARMGMT "https://github.com/arminbiere/cadical/blob/master/src/var.cpp"
    click CLAUSEMGMT "https://github.com/arminbiere/cadical/blob/master/src/clause.cpp"
    click ELIM "https://github.com/arminbiere/cadical/blob/master/src/elim.cpp"
    click SUBS "https://github.com/arminbiere/cadical/blob/master/src/subsume.cpp"
    click VIV "https://github.com/arminbiere/cadical/blob/master/src/vivify.cpp"
    click PROB "https://github.com/arminbiere/cadical/blob/master/src/probe.cpp"
    click CPPAPI "https://github.com/arminbiere/cadical/blob/master/src/cadical.hpp"
    click CAPI "https://github.com/arminbiere/cadical/blob/master/src/ccadical.h"
    click IPASIR "https://github.com/arminbiere/cadical/blob/master/src/ipasir.cpp"
    click DRAT "https://github.com/arminbiere/cadical/blob/master/src/drattracer.cpp"
    click FRAT "https://github.com/arminbiere/cadical/blob/master/src/frattracer.cpp"
    click LRAT "https://github.com/arminbiere/cadical/blob/master/src/lrattracer.cpp"
    click VPBT "https://github.com/arminbiere/cadical/blob/master/src/veripbtracer.cpp"
    click WATCH "https://github.com/arminbiere/cadical/blob/master/src/watch.cpp"
    click HEAP "https://github.com/arminbiere/cadical/blob/master/src/heap.hpp"
    click QUEUE "https://github.com/arminbiere/cadical/blob/master/src/queue.cpp"
    click MEM "https://github.com/arminbiere/cadical/blob/master/src/arena.cpp"
    click CONF "https://github.com/arminbiere/cadical/blob/master/src/config.cpp"
    click STATS "https://github.com/arminbiere/cadical/blob/master/src/stats.cpp"
    click LIMITS "https://github.com/arminbiere/cadical/blob/master/src/limit.cpp"
```
