## Summary
- Adds `-i` flag to select interpreter (lambda or debruijn)
- Implements De Bruijn index-based reduction engine that eliminates variable renaming
- Abstracts Engine into interface with LambdaEngine and DeBruijnEngine implementations
- Adds conversion functions between lambda calculus and De Bruijn representations
- All test samples pass with both engines
## Implementation Details
### De Bruijn Package
- **Variable**: Contains integer index and optional label string
- **Abstraction**: Contains only body (no parameter needed)
- **Application**: Similar structure to lambda version
- **Substitute**: Replaces variables by index with automatic shift operations
- **ReduceAll**: Mirrors lambda reduction without variable renaming overhead
### Engine Abstraction
- Created `Engine` interface with `Run()` and `GetResult()` methods
- `LambdaEngine`: Original named variable implementation
- `DeBruijnEngine`: New index-based implementation
- Both engines support all existing features (profiling, statistics, explanation, verbose mode)
### Conversion Functions
- `LambdaToDeBruijn`: Converts named lambda expressions to De Bruijn indices
- `DeBruijnToLambda`: Converts De Bruijn indices back to named expressions
- `SaccharineToDeBruijn`: Direct conversion from saccharine syntax to De Bruijn
### Testing
- Added comprehensive test suite comparing both engines
- All 6 test files pass (thunk, comments, church_5^5, church_6^6, list_2^30, fast_list_2^30)
- De Bruijn engine produces correct reductions without variable conflicts
## Test Plan
- [x] Build succeeds
- [x] All existing tests pass with lambda engine (default)
- [x] All existing tests pass with debruijn engine (`-i debruijn`)
- [x] Invalid interpreter flag returns error
- [x] Both engines produce equivalent reduced forms
- [x] Performance profiling works with both engines
- [x] Statistics tracking works with both engines
- [x] Verbose mode works with both engines
Closes #26
Closes#26
- Added -i flag to select interpreter (lambda or debruijn)
- Created debruijn package with Expression interface
- Variable contains index and optional label
- Abstraction contains only body (no parameter)
- Application structure remains similar
- Implemented De Bruijn reduction without variable renaming
- Shift operation handles index adjustments
- Substitute replaces by index instead of name
- Abstracted Engine into interface with two implementations
- LambdaEngine: original named variable engine
- DeBruijnEngine: new index-based engine
- Added conversion functions between representations
- LambdaToDeBruijn: converts named to indexed
- DeBruijnToLambda: converts indexed back to named
- SaccharineToDeBruijn: direct saccharine to De Bruijn
- Updated main to switch engines based on -i flag
- All test samples pass with both engines
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
-iflag to select interpreter (lambda or debruijn)Implementation Details
De Bruijn Package
Engine Abstraction
Engineinterface withRun()andGetResult()methodsLambdaEngine: Original named variable implementationDeBruijnEngine: New index-based implementationConversion Functions
LambdaToDeBruijn: Converts named lambda expressions to De Bruijn indicesDeBruijnToLambda: Converts De Bruijn indices back to named expressionsSaccharineToDeBruijn: Direct conversion from saccharine syntax to De BruijnTesting
Test Plan
-i debruijn)Closes #26
Pull request closed