RERUM¶
Rewriting Expressions via Rules Using Morphisms
A pattern matching and term rewriting library for symbolic computation in Python.
Features¶
- Declarative Rules - Define rewrite rules in a simple DSL
- Pattern Matching - Match expressions with variables, constants, and rest patterns
- Conditional Guards - Rules with
whenconditions - Rule Priorities - Control which rules fire first
- Named Groups - Organize rules into selectable groups
- Multiple Strategies - exhaustive, once, bottomup, topdown
- CLI & REPL - Interactive exploration and scripting
- Extensible - Custom preludes for new operations
Quick Start¶
from rerum import RuleEngine, E
engine = RuleEngine.from_dsl('''
@add-zero: (+ ?x 0) => :x
@mul-one: (* ?x 1) => :x
''')
engine(E("(+ y 0)")) # => "y"
engine(E("(* x 1)")) # => "x"
Installation¶
Command Line¶
Next Steps¶
- Getting Started - Tutorial introduction
- DSL Reference - Complete syntax guide
- CLI - Command-line interface
- API Reference - Python API
- Examples - Real-world examples