Skip to content

feat(lean): RLE pattern parser for Conway Life (Epic #1647 Phase 2)#1996

Merged
jsboige merged 1 commit into
mainfrom
feat/conway-rle-parser
Jun 1, 2026
Merged

feat(lean): RLE pattern parser for Conway Life (Epic #1647 Phase 2)#1996
jsboige merged 1 commit into
mainfrom
feat/conway-rle-parser

Conversation

@jsboige
Copy link
Copy Markdown
Owner

@jsboige jsboige commented Jun 1, 2026

Summary

Phase 2 of Conway Game-of-Life Epic #1647: RLE (Run Length Encoded) pattern parser.

New module

Module Lines sorry Description
Conway.Life.RLE 307 0 Character-by-character RLE parser + named pattern constants

Parser features

  • parseRLE : String → Except String Grid — handles comments (#...), header (x = W, y = H), digit run counts, payload chars b/o/$/!
  • parseRLE! — total wrapper returning [] on error
  • Output is sorted/deduplicated via existing sortDedup
  • Custom lTrim avoids String.trim deprecation

Named patterns (RLE + parsed grids)

Pattern RLE source Cells Cross-validated
glider_RLE / glider_parsed LifeWiki canonical 5 structure matches Conway.Life.glider
lwss_RLE / lwss_parsed LifeWiki 9 == Conway.Life.Spaceships.lwss
pulsar_RLE / pulsar_parsed LifeWiki 48 == Conway.Life.Oscillators.pulsar
gosper_gun_RLE / gosper_gun Bill Gosper 1970 36 First gun pattern in the project

Verification (lean-merge-discipline HARD gate)

lake build Conway.Life.RLE → SUCCESS
lake build Conway → SUCCESS (3332 jobs)
grep -c sorry RLE.lean = 0
#eval cross-validations all pass:
  lwss_parsed == lwss → true
  pulsar_parsed == pulsar → true
  isSpaceship lwss_parsed 4 (0, 2) → true
  isOscillator pulsar_parsed 3 → true
  gosper_gun.length = 36

No theorems (parser is pure computation; correctness via #eval).

Follows #1975 (Spaceships + Oscillators, merged). Companion to #1989 (MacroCell + Hashlife).

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Adds Conway/Life/RLE.lean: a total parser for the standard
Run Length Encoded pattern format used by LifeWiki / conwaylife.com.

- parseRLE : String -> Except String Grid (handles comments, header,
  whitespace, run counts, b/o/$/!).
- 4 flagship pattern constants with their RLE strings and parsed grids:
  glider, lwss, pulsar, gosper_gun (the 1970 Bill Gosper glider gun,
  36 cells, period 30, first known infinite-growth pattern).
- #eval sanity checks cross-verify lwss_parsed == lwss and
  pulsar_parsed == pulsar against the hand-written constants.
- No sorry, no theorem (the parser is a pure computation; behavioural
  correctness is exercised via #eval isSpaceship / isOscillator).

Verified locally: lake build Conway.Life.RLE SUCCESS, lake build Conway
SUCCESS (3332 jobs), no warnings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jsboige jsboige merged commit 6659e82 into main Jun 1, 2026
2 checks passed
@jsboige jsboige deleted the feat/conway-rle-parser branch June 1, 2026 01:09
jsboige added a commit that referenced this pull request Jun 1, 2026
…1996)

Adds Conway/Life/RLE.lean: a total parser for the standard
Run Length Encoded pattern format used by LifeWiki / conwaylife.com.

- parseRLE : String -> Except String Grid (handles comments, header,
  whitespace, run counts, b/o/$/!).
- 4 flagship pattern constants with their RLE strings and parsed grids:
  glider, lwss, pulsar, gosper_gun (the 1970 Bill Gosper glider gun,
  36 cells, period 30, first known infinite-growth pattern).
- #eval sanity checks cross-verify lwss_parsed == lwss and
  pulsar_parsed == pulsar against the hand-written constants.
- No sorry, no theorem (the parser is a pure computation; behavioural
  correctness is exercised via #eval isSpaceship / isOscillator).

Verified locally: lake build Conway.Life.RLE SUCCESS, lake build Conway
SUCCESS (3332 jobs), no warnings.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant