Skip to main content

Module gen

Module gen 

Source
Expand description

Expression generation

Generates valid postfix expressions by enumerating “forms” (stack effect patterns).

§Streaming Architecture

For high complexity levels, the traditional approach of generating ALL expressions into memory before matching can cause memory exhaustion. This module provides both:

  • Batch generation: generate_all() returns all expressions (backward compatible)
  • Streaming generation: generate_streaming() processes expressions via callbacks

Streaming reduces memory from O(expressions) to O(depth) by processing expressions as they’re generated rather than accumulating them.

Structs§

ExpressionConstraintOptions
Options for additional expression constraints
GenConfig
Configuration for expression generation
GeneratedExprs
Result of expression generation
StreamingCallbacks
Callbacks for streaming expression generation

Functions§

expression_respects_constraints
Check if an expression respects the configured structural and numeric constraints.
generate_all
Generate all valid expressions up to the configured limits
generate_all_parallel
Generate expressions in parallel using Rayon
generate_all_parallel_with_context
Generate expressions in parallel using Rayon with an explicit evaluation context.
generate_all_with_context
Generate all valid expressions up to the configured limits using an explicit evaluation context.
generate_all_with_limit
Generate expressions with an early-abort limit on total count.
generate_all_with_limit_and_context
Generate expressions with an early-abort limit using an explicit evaluation context.
generate_streaming
Generate expressions with streaming callbacks for memory-efficient processing
generate_streaming_with_context
Generate expressions with streaming callbacks using an explicit evaluation context.
quantize_value
Uses ~8 significant digits for deduplication

Type Aliases§

LhsKey
Quantize a value to reduce floating-point noise Key for LHS deduplication: (quantized value, quantized derivative)