elementary-row-operation-verifier 0.0.1

A tool to verify the correctness of elementary row operations on matrices
Documentation
# Architecture

## Crate Structure

```
src/
├── main.rs            # Binary entry
├── lib.rs             # Library entry (for tests)
├── cli.rs             # CLI argument parsing (clap)
├── error.rs           # Error types (thiserror)
├── matrix.rs          # Matrix type alias + nalgebra wrappers
├── verifier.rs        # Verification logic
├── math/              # Mathematical expression parsing
│   ├── mod.rs
│   ├── ast.rs         # Expression AST
│   ├── expr_parser.rs # nom-based expression parser
│   ├── token.rs       # Operand, Operator, RowOperation types
│   └── parser.rs      # Operation parser (+ 2 r[1], etc.)
├── parser/            # File parsing (shared utilities)
│   ├── mod.rs         # Entry: parse_file, parse_content
│   ├── common.rs      # Marker line → column positions
│   ├── matrix_parser.rs # Block collection
│   └── types.rs       # FileParseResult, Step, RawBlock
├── filetype/          # File type detection + parsing
│   ├── mod.rs         # Detection: row/col/mixed
│   ├── row.rs         # Row operation block parser
│   └── col.rs         # Column operation block parser
├── ops/               # Operation application
│   ├── mod.rs         # Dispatch to row/col
│   ├── row.rs         # Row operation application
│   └── col.rs         # Column operation application
├── tui/               # Terminal UI
│   ├── mod.rs         # TuiApp, event loop, layout
│   └── content.rs     # Matrix display + coloring
tests/
└── tui_tests.rs       # TUI rendering integration tests
```

## Data Flow

```
.lore file
  │
  ▼
parser::parse_file()
  │
  ├─ common::parse_marker()  → column positions
  ├─ matrix_parser           → block collection (empty lines)
  ├─ filetype::parse_block() → row or col block parsing
  │
  ▼
FileParseResult { ori, op_kind, steps }
  │
  ▼
Verifier::verify_file()
  │
  ├─ Start with ori
  ├─ For each step:
  │   ├─ parse_operation() → RowOperation
  │   ├─ ops::apply()     → new matrix
  │   └─ compare with expected
  └─ Continue with actual (even if wrong)
  │
  ▼
Vec<VerificationResult>
  │
  ▼
TUI or plain text output
```

## Key Design Decisions

### Character-position-based parsing

Matrix columns are aligned by character position, not whitespace splitting.
This preserves compatibility with external toolchains that produce
position-aligned output.

### 1-indexed row/column references

`r[1]` refers to the first row, `c[2]` to the second column. Internally
converted to 0-indexed before matrix operations.

### Sequential verification with error propagation

If a step computes a wrong result, subsequent steps are verified against
the **actual** (wrong) result — not the expected one. This prevents a
single error from cascading false positives.

### Simultaneous `<` replacement

Multiple `<` (replace) operations in one step are applied simultaneously
(swap semantics), not sequentially.

### Column-major nalgebra storage

`nalgebra::DMatrix::from_vec` uses column-major order. `matrix::from_rows()`
handles the row-major → column-major conversion.

## Dependencies

| Crate | Purpose |
|-------|---------|
| `nalgebra` | Matrix storage and operations |
| `nom` | Mathematical expression parsing |
| `num-rational` | Exact rational arithmetic |
| `ratatui` + `crossterm` | Terminal UI |
| `clap` | CLI argument parsing |
| `anyhow` + `thiserror` | Error handling |