Class: ADSL::DS::DSRelation

Inherits:
DSNode show all
Includes:
FOL
Defined in:
lib/adsl/ds/data_store_spec.rb,
lib/adsl/spass/spass_ds_extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DSNode

#list_entity_classes_read, #list_entity_classes_written_to, #replace, #replace_var

Instance Attribute Details

Returns the value of attribute left_link.



166
167
168
# File 'lib/adsl/spass/spass_ds_extensions.rb', line 166

def left_link
  @left_link
end

Returns the value of attribute right_link.



166
167
168
# File 'lib/adsl/spass/spass_ds_extensions.rb', line 166

def right_link
  @right_link
end

#type_predObject (readonly)

Returns the value of attribute type_pred.



166
167
168
# File 'lib/adsl/spass/spass_ds_extensions.rb', line 166

def type_pred
  @type_pred
end

Instance Method Details

#[](variable) ⇒ Object



168
169
170
# File 'lib/adsl/spass/spass_ds_extensions.rb', line 168

def [](variable)
  @type_pred[variable]
end

#to_sObject



90
91
92
# File 'lib/adsl/ds/data_store_spec.rb', line 90

def to_s
  "#{from_class.name}.#{name}"
end

#translate(translation) ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/adsl/spass/spass_ds_extensions.rb', line 172

def translate(translation)
  if @inverse_of
    @type_pred = @inverse_of.type_pred
    @left_link = @inverse_of.right_link
    @right_link = @inverse_of.left_link
  else
    @type_pred = translation.create_predicate "of_#{@from_class.name}_#{@name}_type", 1
    @left_link = translation.create_predicate "left_link_#{@from_class.name}_#{@name}", 2
    @right_link = translation.create_predicate "right_link_#{@from_class.name}_#{@name}", 2
    translation.create_formula _for_all(:t, :o, _implies(@left_link[:t, :o], _and(@from_class[:o], @type_pred[:t])))
    translation.create_formula _for_all(:t, :o, _implies(@right_link[:t, :o], _and(@to_class[:o], @type_pred[:t])))
    translation.create_formula _for_all(:t, :o1, :o2, _and(
      _implies(_and(@left_link[:t, :o1], @left_link[:t, :o2]), _equal(:o1, :o2)),
      _implies(_and(@right_link[:t, :o1], @right_link[:t, :o2]), _equal(:o1, :o2))
    ))
    translation.create_formula _for_all(:t, _implies(
      @type_pred[:t],
      _exists(:o1, :o2, _and(@left_link[:t, :o1], @right_link[:t, :o2]))
    ))
  end

  if @cardinality[0] > 0
    translation.create_formula _for_all(:o, _implies(@from_class[:o], _exists(:t, @left_link[:t, :o])))
  end
  if @cardinality[1] == 1
    translation.create_formula _for_all(:o, :t1, :t2, _implies(
      _and(@left_link[:t1, :o], @left_link[:t2, :o]),
      _equal(:t1, :t2)
    ))  
  end
end