Module: Musa::Rules
- Included in:
- All
- Defined in:
- lib/musa-dsl/generative/rules.rb
Overview
Rule-based production system with growth and pruning.
Rules implements a production system that generates tree structures by applying growth rules to produce branches and pruning rules to eliminate invalid paths. Similar to L-systems and production systems in formal grammars, but with validation and constraint satisfaction.
Core Concepts
- Grow Rules: Transform objects into new possibilities (branches)
- Cut Rules: Prune branches that violate constraints
- End Condition: Mark branches as complete
- Tree: Hierarchical structure of all valid possibilities
- History: Path from root to current node
- Combinations: All valid complete paths through tree
Generation Process
- Seed: Start with initial object(s)
- Grow: Apply grow rules sequentially to create branches
- Validate: Apply cut rules to prune invalid branches
- Check End: Mark branches meeting end condition
- Recurse: Continue growing non-ended branches
- Collect: Gather all valid complete paths
Rule Application
Rules are applied in definition order. Each grow rule can produce
multiple branches via branch. Cut rules can prune with prune.
The system tracks history (path to current node) for context-aware
rule application.
Musical Applications
- Generate harmonic progressions with voice leading rules
- Create melodic variations with contour constraints
- Produce rhythmic patterns following metric rules
- Build counterpoint with species rules
- Generate chord voicings with spacing constraints
Defined Under Namespace
Classes: Rules