Sha256: 847fa3e54234cf4eb78c37c618e64403326849c8537b5ee3609ac70cfec34287
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
class Predicate module In include Expr def priority 80 end def identifier self[1] end def values self[2] end def &(other) case other when In fv = free_variables if fv.size == 1 && fv == other.free_variables intersection = values & other.values if intersection.empty? Factory.contradiction elsif intersection.size == 1 Factory.eq(fv.first, [:literal, intersection.first]) else Factory.in(fv.first, intersection) end else super end else super end end def free_variables @free_variables ||= identifier.free_variables end def constant_variables values.size == 1 ? free_variables : [] end def constants values.size == 1 ? { identifier.name => values.first } : {} end def dyadic_priority 800 end def evaluate(tuple) values.include?(identifier.evaluate(tuple)) end end end
Version data entries
5 entries across 5 versions & 1 rubygems