fca :: FormalConcept :: defaultinit
# Formal Concept
#
# A pair *(A,B)* is a formal concept of a FormalContext *(G, M, I)* provided that:
#
# * *A ⊆ G*,
# * *B ⊆ M*,
# * *A′ = B*, and
# * *B′ = A*.
#
# Equivalently and more intuitively, *(A,B)* is a formal concept precisely when:
#
# * every object in *A* has every attribute in *B*,
# * for every object in *G* that is not in *A*, there is some attribute in *B* that
# the object does not have,
# * for every attribute in *M* that is not in *B*, there is some object in *A*
# that does not have that attribute.
class FormalConcept[O: Object, A: Object]
# Concept attributes
var attributes = new HashSet[A]
# Concept objects
var objects = new HashSet[O]
# Is `self` a subconcept of `super_concept`?
#
# A concept C1 is a subconcept of C2 if C2 has all the objects of C1.
fun is_subconcept(super_concept: FormalConcept[O, A]): Bool do
if self == super_concept then return false
if objects.length > super_concept.objects.length then return false
return super_concept.objects.has_all(objects)
end
redef fun to_s do return "{attributes}\n{objects}"
end
lib/fca/fca.nit:182,1--216,3