Class: MiniKraken::Rela::BinaryRelation

Inherits:
Core::Relation show all
Defined in:
lib/mini_kraken/rela/binary_relation.rb

Overview

A binary relation between sets X and Y is a subset of the Cartesian product X × Y; that is, it is a set of ordered pairs (x, y) consisting of elements x in X and y in Y.

Direct Known Subclasses

Unify

Instance Attribute Summary

Attributes inherited from Core::Specification

#arity, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Relation

#solver_for

Methods inherited from Core::Specification

#check_arity, #inspect, #variadic?

Constructor Details

#initialize(aName) ⇒ BinaryRelation

Returns a new instance of BinaryRelation.

Parameters:

  • aName (String)

    Name of the relation.



12
13
14
15
# File 'lib/mini_kraken/rela/binary_relation.rb', line 12

def initialize(aName)
  super(aName, 2)
  freeze
end

Class Method Details

.symmetricObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mini_kraken/rela/binary_relation.rb', line 17

def self.symmetric
  define_method :commute_cond do |arg1, arg2, ctx|
    w1 = weight_arg(arg1, ctx)
    w2 = weight_arg(arg2, ctx)
    if w2 > w1
      [arg2, arg1]
    else
      [arg1, arg2]
    end
  end
end