feat: add De Bruijn indexed reduction engine #33

Closed
mvhutz wants to merge 2 commits from feat/debruijn-engine into main
Owner

Context

This PR implements issue #26, adding a De Bruijn indexed reduction engine as an alternative to the standard lambda calculus interpreter.

Summary

  • Add -i flag to select interpreter (lambda or debruijn)
  • Create debruijn package with Expression types:
    • Variable with integer index and optional label
    • Abstraction without named parameter (parameter is implicit)
    • Application same as lambda
  • Implement shift and substitute operations for De Bruijn indices
  • Add conversion functions between lambda and De Bruijn representations
  • Update CLI to support switching between interpreters
  • Add De Bruijn tests to verify all samples pass

Test Plan

  • All existing lambda interpreter tests pass
  • All De Bruijn interpreter tests pass with same expected output
  • Invalid interpreter flag returns appropriate error
  • Both interpreters produce identical results for all test samples

Closes #26

## Context This PR implements issue #26, adding a De Bruijn indexed reduction engine as an alternative to the standard lambda calculus interpreter. ## Summary - Add `-i` flag to select interpreter (`lambda` or `debruijn`) - Create `debruijn` package with Expression types: - `Variable` with integer index and optional label - `Abstraction` without named parameter (parameter is implicit) - `Application` same as lambda - Implement shift and substitute operations for De Bruijn indices - Add conversion functions between lambda and De Bruijn representations - Update CLI to support switching between interpreters - Add De Bruijn tests to verify all samples pass ## Test Plan - [x] All existing lambda interpreter tests pass - [x] All De Bruijn interpreter tests pass with same expected output - [x] Invalid interpreter flag returns appropriate error - [x] Both interpreters produce identical results for all test samples Closes #26
mvhutz added 1 commit 2026-01-17 00:36:30 +00:00
Add a new interpreter option (-i debruijn) that uses De Bruijn indices
for variable representation, eliminating the need for variable renaming
during substitution.

- Add -i flag to select interpreter (lambda or debruijn)
- Create debruijn package with Expression types (Variable with index,
  Abstraction without parameter, Application)
- Implement shift and substitute operations for De Bruijn indices
- Add conversion functions between lambda and De Bruijn representations
- Update CLI to support switching between interpreters
- Add De Bruijn tests to verify all samples pass

Closes #26
mvhutz added 1 commit 2026-01-17 19:53:10 +00:00
mvhutz closed this pull request 2026-01-17 19:53:15 +00:00

Pull request closed

Sign in to join this conversation.