# PebbleCDCL Solver

A from-scratch CDCL SAT solver specialized for pebbling formula families.

## Target Family

The solver targets three pebbling SAT benchmark subfamilies:
- **pbl** (pebbling linear): Mixed clause sizes (1-11), variable count ~4*N, clause count ~N^2
- **grid-pbl** (grid pebbling): Mostly size-4 clauses with binary constraints, variable count = N*(N+1), clause count ≈ 2N²
- **peb-pyrofpyr** (pyramid of pyramid pebbling): Almost entirely size-7 clauses, very dense

## Performance

### Train Split (44 instances)
- **All 44 solved** (100%)
- **PAR-2: ~6.8s** (vs Kissat SC2024 baseline: 24.9s, **3.67x faster**)
- Hardest instances: pyrofpyr-15 (19s local / 45s broker), grid-pbl-0300 (13s local / 37s broker)
- All UNSAT proofs verified by VeriPB

### vs Kissat Comparison
- **pyrofpyr**: 10-23x faster than Kissat (Kissat struggles with these hard UNSAT instances)
- **pbl**: Similar speed
- **grid-pbl**: 1-2x slower than Kissat (Kissat has BVE and other preprocessing we lack)

## Architecture

### Core CDCL Engine
- **Watched Literal Propagation** with blocker optimization for fast BCP
- **Arena-based clause storage** with compact header layout:
  - Original: `[header][lits...]`
  - Learnt: `[header][lbd|proofId_high16][proofId_low32][lits...]`
- **VSIDS** variable activity heuristic with decay factor 0.85
- **1-UIP conflict analysis** with recursive self-subsumption minimization
- **Phase saving** with Jeroslow-Wang initial phase (critical for grid-pbl UNSAT performance)

### Clause Management
- **LBD-based tiering**: Clauses with LBD ≤ 3 are protected from deletion
- **Glucose-style restarts** (K=0.8, window=20): restart when recent average LBD exceeds 80% of global average
- **reduceDB** every 1000 conflicts (+ scaling with database size): removes half of eligible clauses sorted by LBD

### Proof Generation
- VeriPB v2.0 RUP-based proofs with buffered I/O (1MB buffer)
- Clause deletion annotations in proof when reduceDB removes learned clauses
- Deletion annotations reduce VeriPB verification time from 300s+ to <40s on large instances

## Tuned Parameters

| Parameter | Value | Alternatives Tested |
|---|---|---|
| VSIDS decay | 0.85 | 0.80, 0.90, 0.95 |
| LBD keep threshold | 3 | 2, 4, 5 |
| reduceDB frequency | 1000 | 500, 2000 |
| Restart K | 0.8 | 0.6, 0.7, 0.9 |
| Restart window | 20 | 10, 25, 30, 50, 100 |
| Time limit | 540s | (10% safety margin below 600s) |

## What Didn't Help

- **Binary clause optimization**: Only 11 binary learned clauses out of 1.8M for pyrofpyr. Not impactful.
- **Failed literal probing**: Zero units found on all pebbling instances. The encoding lacks local inconsistencies.
- **Prefetching in BCP**: Added overhead outweighed cache benefit.
- **LBD update during analysis**: Overhead of computing LBD for every antecedent clause.
- **More aggressive restarts** (K=0.6-0.7): Worse performance across all instance types.
- **Zero/different initial activity**: VSIDS learning quickly dominates; initial activity barely matters.

## Known Limitations

- No preprocessing (BVE, subsumption elimination) → slower than Kissat on grid-pbl
- No in-processing (vivification, clause strengthening)
- No chronological backtracking
- No clause relocation/compaction (arena grows monotonically)

## Potential Future Improvements

1. Bounded Variable Elimination (BVE) for grid instances
2. Clause vivification as in-processing
3. On-the-fly self-subsumption during conflict analysis
4. Tier-based clause management (core/local/temporary)
5. Better cache locality through clause relocation

## Changelog

### v4.0 (current)
- Restart window reduced from 50 to 20 conflicts (18% faster on pyrofpyr, 22% faster on grid SAT)
- Submitted to broker

### v3.0
- VSIDS decay tuned to 0.85 (from 0.95)
- LBD keep threshold changed to 3 (from 2)
- reduceDB frequency set to 1000
- PAR-2: 6.8s (3.67x faster than Kissat baseline)

### v2.2
- Added Jeroslow-Wang initial phase selection
- 5x speedup on grid-pbl UNSAT instances
- PAR-2: 12.9s

### v2.1
- Added Glucose-style restarts (K=0.8)
- Added LBD-based clause management
- Added proof clause deletion annotations
- PAR-2: 15.7s

### v1.0
- Initial CDCL solver with watched literals, VSIDS, 1-UIP, VeriPB proofs
- PAR-2: ~40s
