Class: Kumi::Core::Analyzer::Passes::FormalConstraintPropagator
- Inherits:
-
Object
- Object
- Kumi::Core::Analyzer::Passes::FormalConstraintPropagator
- Defined in:
- lib/kumi/core/analyzer/passes/formal_constraint_propagator.rb
Overview
RESPONSIBILITY: Propagate constraints forward and backward through operations DEPENDENCIES: :registry (function registry), constraint metadata from function specs INTERFACE: propagate_forward(constraint), propagate_reverse_through_operation(…)
Implements formal constraint propagation rules based on function semantics. Forward: x == 5, y = x + 10 => y == 15 Reverse: y == 15, y = x + 10 => x == 5
Instance Method Summary collapse
-
#initialize(schema, state) ⇒ FormalConstraintPropagator
constructor
A new instance of FormalConstraintPropagator.
-
#propagate_forward_through_operation(constraint, operation_spec, operand_map) ⇒ Object
Forward propagate a constraint through a single operation.
-
#propagate_reverse_through_operation(constraint, operation_spec, operand_map) ⇒ Object
Reverse propagate: derive input constraints from output constraints.
Constructor Details
#initialize(schema, state) ⇒ FormalConstraintPropagator
Returns a new instance of FormalConstraintPropagator.
15 16 17 18 19 |
# File 'lib/kumi/core/analyzer/passes/formal_constraint_propagator.rb', line 15 def initialize(schema, state) @schema = schema @state = state @registry = state[:registry] end |
Instance Method Details
#propagate_forward_through_operation(constraint, operation_spec, operand_map) ⇒ Object
Forward propagate a constraint through a single operation
22 23 24 25 26 27 28 29 |
# File 'lib/kumi/core/analyzer/passes/formal_constraint_propagator.rb', line 22 def propagate_forward_through_operation(constraint, operation_spec, operand_map) case constraint[:op] when :== propagate_equality_forward(constraint, operation_spec, operand_map) when :range propagate_range_forward(constraint, operation_spec, operand_map) end end |
#propagate_reverse_through_operation(constraint, operation_spec, operand_map) ⇒ Object
Reverse propagate: derive input constraints from output constraints
32 33 34 35 36 37 38 39 |
# File 'lib/kumi/core/analyzer/passes/formal_constraint_propagator.rb', line 32 def propagate_reverse_through_operation(constraint, operation_spec, operand_map) case constraint[:op] when :== propagate_equality_reverse(constraint, operation_spec, operand_map) when :range propagate_range_reverse(constraint, operation_spec, operand_map) end end |