Sha256: 320d132e213a3a606154cba6e0aef65a087778e5807fd2385b3d74fb32530046

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

# encoding: utf-8

module Veritas
  class Optimizer
    module Function

      # Abstract base class representing Predicate optimizations
      class Predicate < Optimizer
        include AbstractClass, Binary

        # Optimize when the operands are constants
        class ConstantOperands < self
          include Binary::ConstantOperands

          # A Predicate with constant values is equivalent to a Proposition
          #
          # @return [Proposition]
          #
          # @api private
          def optimize
            Veritas::Function::Proposition.new(super)
          end

        end # class ConstantOperands

        # Optimize when the operands are unoptimized
        class UnoptimizedOperands < self
          include Binary::UnoptimizedOperands
        end # class UnoptimizedOperands

        # Optimize when the operands are a contradiction
        module Contradiction

          # Return a contradiction
          #
          # @return [Contradiction]
          #
          # @api private
          def optimize
            Veritas::Function::Proposition::Contradiction.instance
          end

        end # module Contradiction

        # Optimize when the operands are a tautology
        module Tautology

          # Return a tautology
          #
          # @return [Tautology]
          #
          # @api private
          def optimize
            Veritas::Function::Proposition::Tautology.instance
          end

        end # module Tautology
      end # class Predicate
    end # module Function
  end # class Optimizer
end # module Veritas

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 lib/veritas/optimizer/function/predicate.rb
veritas-optimizer-0.0.6 lib/veritas/optimizer/function/predicate.rb
veritas-optimizer-0.0.5 lib/veritas/optimizer/function/predicate.rb
veritas-optimizer-0.0.4 lib/veritas/optimizer/function/predicate.rb