Documentation

Mathlib.Order.Concept

Formal concept analysis #

This file defines concept lattices. A concept of a relation r : α → β → Prop is a pair of sets s : Set α and t : Set β such that s is the set of all a : α that are related to all elements of t, and t is the set of all b : β that are related to all elements of s.

Ordering the concepts of a relation r by inclusion on the first component gives rise to a concept lattice. Every concept lattice is complete and in fact every complete lattice arises as the concept lattice of its .

Implementation notes #

Concept lattices are usually defined from a context, that is the triple (α, β, r), but the type of r determines α and β already, so we do not define contexts as a separate object.

TODO #

Prove the fundamental theorem of concept lattices.

References #

Tags #

concept, formal concept analysis, intent, extend, attribute

Lower and upper polars #

def upperPolar {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) :
Set β

The upper polar of s : Set α along a relation r : α → β → Prop is the set of all elements which r relates to all elements of s.

Equations
Instances For
    def lowerPolar {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) :
    Set α

    The lower polar of t : Set β along a relation r : α → β → Prop is the set of all elements which r relates to all elements of t.

    Equations
    Instances For
      theorem mem_upperPolar_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {s : Set α} {b : β} :
      b upperPolar r s ∀ ⦃a : α⦄, a sr a b
      theorem mem_lowerPolar_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {t : Set β} {a : α} :
      a lowerPolar r t ∀ ⦃b : β⦄, b tr a b
      theorem subset_upperPolar_iff_subset_lowerPolar {α : Type u_2} {β : Type u_3} {r : αβProp} {s : Set α} {t : Set β} :
      theorem upperPolar_swap {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) :
      theorem lowerPolar_swap {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) :
      @[simp]
      theorem upperPolar_empty {α : Type u_2} {β : Type u_3} (r : αβProp) :
      @[simp]
      theorem lowerPolar_empty {α : Type u_2} {β : Type u_3} (r : αβProp) :
      @[simp]
      theorem mem_upperPolar_singleton {α : Type u_2} {β : Type u_3} (r : αβProp) {a : α} {b : β} :
      b upperPolar r {a} r a b
      @[simp]
      theorem mem_lowerPolar_singleton {α : Type u_2} {β : Type u_3} (r : αβProp) {a : α} {b : β} :
      a lowerPolar r {b} r a b
      @[simp]
      theorem upperPolar_union {α : Type u_2} {β : Type u_3} (r : αβProp) (s₁ s₂ : Set α) :
      upperPolar r (s₁ s₂) = upperPolar r s₁ upperPolar r s₂
      @[simp]
      theorem lowerPolar_union {α : Type u_2} {β : Type u_3} (r : αβProp) (t₁ t₂ : Set β) :
      lowerPolar r (t₁ t₂) = lowerPolar r t₁ lowerPolar r t₂
      @[simp]
      theorem upperPolar_iUnion {ι : Sort u_1} {α : Type u_2} {β : Type u_3} (r : αβProp) (f : ιSet α) :
      upperPolar r (⋃ (i : ι), f i) = ⋂ (i : ι), upperPolar r (f i)
      @[simp]
      theorem lowerPolar_iUnion {ι : Sort u_1} {α : Type u_2} {β : Type u_3} (r : αβProp) (f : ιSet β) :
      lowerPolar r (⋃ (i : ι), f i) = ⋂ (i : ι), lowerPolar r (f i)
      theorem upperPolar_iUnion₂ {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {κ : ιSort u_5} (r : αβProp) (f : (i : ι) → κ iSet α) :
      upperPolar r (⋃ (i : ι), ⋃ (j : κ i), f i j) = ⋂ (i : ι), ⋂ (j : κ i), upperPolar r (f i j)
      theorem lowerPolar_iUnion₂ {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {κ : ιSort u_5} (r : αβProp) (f : (i : ι) → κ iSet β) :
      lowerPolar r (⋃ (i : ι), ⋃ (j : κ i), f i j) = ⋂ (i : ι), ⋂ (j : κ i), lowerPolar r (f i j)
      theorem subset_lowerPolar_upperPolar {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) :
      theorem subset_upperPolar_lowerPolar {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) :
      @[simp]
      theorem upperPolar_lowerPolar_upperPolar {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) :
      @[simp]
      theorem lowerPolar_upperPolar_lowerPolar {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) :
      theorem upperPolar_anti {α : Type u_2} {β : Type u_3} (r : αβProp) :
      theorem lowerPolar_anti {α : Type u_2} {β : Type u_3} (r : αβProp) :

      Intent and extent #

      def Order.IsExtent {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) :

      A set is an extent when either of the following equivalent definitions holds:

      The latter is used as a definition, but one can rewrite using the former via IsExtent.eq.

      Equations
      Instances For
        @[simp]
        theorem Order.isExtent_lowerPolar {α : Type u_2} {β : Type u_3} {r : αβProp} {t : Set β} :
        theorem Order.isExtent_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {s : Set α} :
        theorem Order.IsExtent.eq {α : Type u_2} {β : Type u_3} {r : αβProp} {s : Set α} :
        IsExtent r slowerPolar r (upperPolar r s) = s

        Alias of the forward direction of Order.isExtent_iff.

        @[simp]
        theorem Order.IsExtent.univ {α : Type u_2} {β : Type u_3} {r : αβProp} :
        theorem Order.IsExtent.inter {α : Type u_2} {β : Type u_3} {r : αβProp} {s s' : Set α} :
        IsExtent r sIsExtent r s'IsExtent r (s s')
        theorem Order.IsExtent.iInter {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {r : αβProp} (f : ιSet α) (hf : ∀ (i : ι), IsExtent r (f i)) :
        IsExtent r (⋂ (i : ι), f i)
        theorem Order.IsExtent.iInter₂ {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {κ : ιSort u_5} {r : αβProp} (f : (i : ι) → κ iSet α) (hf : ∀ (i : ι) (j : κ i), IsExtent r (f i j)) :
        IsExtent r (⋂ (i : ι), ⋂ (j : κ i), f i j)
        def Order.IsIntent {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) :

        A set is an intent when either of the following equivalent definitions holds:

        The latter is used as a definition, but one can rewrite using the former via IsIntent.eq.

        Equations
        Instances For
          @[simp]
          theorem Order.isIntent_upperPolar {α : Type u_2} {β : Type u_3} {r : αβProp} {s : Set α} :
          theorem Order.isIntent_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {t : Set β} :
          theorem Order.IsIntent.eq {α : Type u_2} {β : Type u_3} {r : αβProp} {t : Set β} :
          IsIntent r tupperPolar r (lowerPolar r t) = t

          Alias of the forward direction of Order.isIntent_iff.

          @[simp]
          theorem Order.IsIntent.univ {α : Type u_2} {β : Type u_3} {r : αβProp} :
          theorem Order.IsIntent.inter {α : Type u_2} {β : Type u_3} {r : αβProp} {t t' : Set β} :
          IsIntent r tIsIntent r t'IsIntent r (t t')
          theorem Order.IsIntent.iInter {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {r : αβProp} (f : ιSet β) (hf : ∀ (i : ι), IsIntent r (f i)) :
          IsIntent r (⋂ (i : ι), f i)
          theorem Order.IsIntent.iInter₂ {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {κ : ιSort u_5} {r : αβProp} (f : (i : ι) → κ iSet β) (hf : ∀ (i : ι) (j : κ i), IsIntent r (f i j)) :
          IsIntent r (⋂ (i : ι), ⋂ (j : κ i), f i j)

          Concepts #

          structure Concept (α : Type u_2) (β : Type u_3) (r : αβProp) :
          Type (max u_2 u_3)

          The formal concepts of a relation. A concept of r : α → β → Prop is a pair of sets s, t such that s is the set of all elements that are r-related to all of t and t is the set of all elements that are r-related to all of s.

          • extent : Set α

            The extent of a concept.

          • intent : Set β

            The intent of a concept.

          • upperPolar_extent : upperPolar r self.extent = self.intent

            The intent consists of all elements related to all elements of the extent.

          • lowerPolar_intent : lowerPolar r self.intent = self.extent

            The extent consists of all elements related to all elements of the intent.

          Instances For
            theorem Concept.ext {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} (h : c.extent = d.extent) :
            c = d

            See Concept.ext' for a version using the intent.

            theorem Concept.ext_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} :
            c = d c.extent = d.extent
            theorem Concept.ext' {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} (h : c.intent = d.intent) :
            c = d

            See Concept.ext for a version using the extent.

            theorem Concept.extent_injective {α : Type u_2} {β : Type u_3} {r : αβProp} :
            theorem Concept.intent_injective {α : Type u_2} {β : Type u_3} {r : αβProp} :
            def Concept.copy {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) (e : Set α) (i : Set β) (he : e = c.extent) (hi : i = c.intent) :
            Concept α β r

            Copy a concept, adjusting definitional equalities.

            Equations
            • c.copy e i he hi = { extent := e, intent := i, upperPolar_extent := , lowerPolar_intent := }
            Instances For
              @[simp]
              theorem Concept.intent_copy {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) (e : Set α) (i : Set β) (he : e = c.extent) (hi : i = c.intent) :
              (c.copy e i he hi).intent = i
              @[simp]
              theorem Concept.extent_copy {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) (e : Set α) (i : Set β) (he : e = c.extent) (hi : i = c.intent) :
              (c.copy e i he hi).extent = e
              theorem Concept.copy_eq {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) (e : Set α) (i : Set β) (he : e = c.extent) (hi : i = c.intent) :
              c.copy e i he hi = c
              def Concept.ofIsExtent {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) (hs : Order.IsExtent r s) :
              Concept α β r

              Define a concept from an extent, by setting the intent to its upper polar.

              Equations
              Instances For
                @[simp]
                theorem Concept.intent_ofIsExtent {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) (hs : Order.IsExtent r s) :
                @[simp]
                theorem Concept.extent_ofIsExtent {α : Type u_2} {β : Type u_3} (r : αβProp) (s : Set α) (hs : Order.IsExtent r s) :
                (ofIsExtent r s hs).extent = s
                @[simp]
                theorem Concept.isExtent_extent {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) :
                theorem Concept.isExtent_iff_exists_concept {α : Type u_2} {β : Type u_3} {r : αβProp} {s : Set α} :
                Order.IsExtent r s ∃ (c : Concept α β r), c.extent = s
                def Concept.ofIsIntent {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) (ht : Order.IsIntent r t) :
                Concept α β r

                Define a concept from an intent, by setting the extent to its lower polar.

                Equations
                Instances For
                  @[simp]
                  theorem Concept.extent_ofIsIntent {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) (ht : Order.IsIntent r t) :
                  @[simp]
                  theorem Concept.intent_ofIsIntent {α : Type u_2} {β : Type u_3} (r : αβProp) (t : Set β) (ht : Order.IsIntent r t) :
                  (ofIsIntent r t ht).intent = t
                  @[simp]
                  theorem Concept.isIntent_intent {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) :
                  theorem Concept.isIntent_iff_exists_concept {α : Type u_2} {β : Type u_3} {r : αβProp} {t : Set β} :
                  Order.IsIntent r t ∃ (c : Concept α β r), c.intent = t
                  theorem Concept.rel_extent_intent {α : Type u_2} {β : Type u_3} {r : αβProp} {c : Concept α β r} {x : α} {y : β} (hx : x c.extent) (hy : y c.intent) :
                  r x y
                  theorem Concept.disjoint_extent_intent {α : Type u_2} {r' : ααProp} {c' : Concept α α r'} [Std.Irrefl r'] :

                  Note that if r' is the relation, this theorem will often not be true!

                  theorem Concept.mem_extent_of_rel_extent {α : Type u_2} {r' : ααProp} {c' : Concept α α r'} [IsTrans α r'] {x y : α} (hy : r' y x) (hx : x c'.extent) :
                  y c'.extent
                  theorem Concept.mem_intent_of_intent_rel {α : Type u_2} {r' : ααProp} {c' : Concept α α r'} [IsTrans α r'] {x y : α} (hy : r' x y) (hx : x c'.intent) :
                  y c'.intent
                  theorem Concept.codisjoint_extent_intent {α : Type u_2} {r' : ααProp} {c' : Concept α α r'} [Std.Trichotomous r'] [IsTrans α r'] :
                  @[implicit_reducible]
                  instance Concept.instPartialOrder {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Equations
                  theorem Concept.isCompl_extent_intent {α : Type u_2} {r' : ααProp} [IsStrictTotalOrder α r'] (c' : Concept α α r') :
                  @[simp]
                  theorem Concept.compl_extent {α : Type u_2} {r' : ααProp} [IsStrictTotalOrder α r'] (c' : Concept α α r') :
                  @[simp]
                  theorem Concept.compl_intent {α : Type u_2} {r' : ααProp} [IsStrictTotalOrder α r'] (c' : Concept α α r') :
                  @[simp]
                  theorem Concept.extent_subset_extent_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} :
                  @[simp]
                  theorem Concept.extent_ssubset_extent_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} :
                  @[simp]
                  theorem Concept.intent_subset_intent_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} :
                  @[simp]
                  theorem Concept.intent_ssubset_intent_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} :
                  theorem Concept.strictMono_extent {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  theorem Concept.strictAnti_intent {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  @[implicit_reducible]
                  instance Concept.instMax {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Max (Concept α β r)
                  Equations
                  @[simp]
                  theorem Concept.intent_max {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).intent = c.intent d.intent
                  @[simp]
                  theorem Concept.extent_max {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).extent = lowerPolar r (c.intent d.intent)
                  theorem Concept.extent_sup {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).extent = lowerPolar r (c.intent d.intent)

                  Alias of Concept.extent_max.

                  theorem Concept.intent_sup {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).intent = c.intent d.intent

                  Alias of Concept.intent_max.

                  @[implicit_reducible]
                  instance Concept.instMin {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Min (Concept α β r)
                  Equations
                  @[simp]
                  theorem Concept.intent_min {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).intent = upperPolar r (c.extent d.extent)
                  @[simp]
                  theorem Concept.extent_min {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).extent = c.extent d.extent
                  theorem Concept.extent_inf {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).extent = c.extent d.extent

                  Alias of Concept.extent_min.

                  theorem Concept.intent_inf {α : Type u_2} {β : Type u_3} {r : αβProp} (c d : Concept α β r) :
                  (cd).intent = upperPolar r (c.extent d.extent)

                  Alias of Concept.intent_min.

                  @[implicit_reducible]
                  instance Concept.instSemilatticeInf {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Equations
                  @[implicit_reducible]
                  instance Concept.instSemilatticeSup {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Equations
                  @[implicit_reducible]
                  instance Concept.instLattice {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Lattice (Concept α β r)
                  Equations
                  @[implicit_reducible]
                  instance Concept.instBoundedOrderConcept {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Equations
                  @[simp]
                  theorem Concept.extent_top {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  @[simp]
                  theorem Concept.intent_bot {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  @[simp]
                  theorem Concept.extent_bot {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  @[simp]
                  theorem Concept.intent_top {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  @[implicit_reducible]
                  instance Concept.instInfSet {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  InfSet (Concept α β r)
                  Equations
                  @[simp]
                  theorem Concept.intent_sInf {α : Type u_2} {β : Type u_3} {r : αβProp} (S : Set (Concept α β r)) :
                  (sInf S).intent = upperPolar r (⋂ iS, i.extent)
                  @[simp]
                  theorem Concept.extent_sInf {α : Type u_2} {β : Type u_3} {r : αβProp} (S : Set (Concept α β r)) :
                  (sInf S).extent = iS, i.extent
                  @[implicit_reducible]
                  instance Concept.instSupSet {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  SupSet (Concept α β r)
                  Equations
                  @[simp]
                  theorem Concept.intent_sSup {α : Type u_2} {β : Type u_3} {r : αβProp} (S : Set (Concept α β r)) :
                  (sSup S).intent = iS, i.intent
                  @[simp]
                  theorem Concept.extent_sSup {α : Type u_2} {β : Type u_3} {r : αβProp} (S : Set (Concept α β r)) :
                  (sSup S).extent = lowerPolar r (⋂ iS, i.intent)
                  @[implicit_reducible]
                  instance Concept.instCompleteLattice {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Equations
                  • One or more equations did not get rendered due to their size.
                  @[simp]
                  theorem Concept.extent_iSup {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {r : αβProp} (f : ιConcept α β r) :
                  (⨆ (i : ι), f i).extent = lowerPolar r (⋂ (i : ι), (f i).intent)
                  @[simp]
                  theorem Concept.intent_iSup {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {r : αβProp} (f : ιConcept α β r) :
                  (⨆ (i : ι), f i).intent = ⋂ (i : ι), (f i).intent
                  @[simp]
                  theorem Concept.extent_iInf {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {r : αβProp} (f : ιConcept α β r) :
                  (⨅ (i : ι), f i).extent = ⋂ (i : ι), (f i).extent
                  @[simp]
                  theorem Concept.intent_iInf {ι : Sort u_1} {α : Type u_2} {β : Type u_3} {r : αβProp} (f : ιConcept α β r) :
                  (⨅ (i : ι), f i).intent = upperPolar r (⋂ (i : ι), (f i).extent)
                  @[implicit_reducible]
                  instance Concept.instInhabited {α : Type u_2} {β : Type u_3} {r : αβProp} :
                  Inhabited (Concept α β r)
                  Equations
                  def Concept.swap {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) :

                  Swap the sets of a concept to make it a concept of the dual context.

                  Equations
                  • c.swap = { extent := c.intent, intent := c.extent, upperPolar_extent := , lowerPolar_intent := }
                  Instances For
                    @[simp]
                    theorem Concept.intent_swap {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) :
                    @[simp]
                    theorem Concept.extent_swap {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) :
                    @[simp]
                    theorem Concept.swap_swap {α : Type u_2} {β : Type u_3} {r : αβProp} (c : Concept α β r) :
                    c.swap.swap = c
                    @[simp]
                    theorem Concept.swap_le_swap_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} :
                    c.swap d.swap d c
                    @[simp]
                    theorem Concept.swap_lt_swap_iff {α : Type u_2} {β : Type u_3} {r : αβProp} {c d : Concept α β r} :
                    c.swap < d.swap d < c
                    def Concept.swapEquiv {α : Type u_2} {β : Type u_3} {r : αβProp} :

                    The dual of a concept lattice is isomorphic to the concept lattice of the dual context.

                    Equations
                    Instances For
                      @[simp]
                      theorem Concept.swapEquiv_apply {α : Type u_2} {β : Type u_3} {r : αβProp} (a✝ : (Concept α β r)ᵒᵈ) :
                      @[simp]
                      theorem Concept.swapEquiv_symm_apply {α : Type u_2} {β : Type u_3} {r : αβProp} (a✝ : Concept β α (Function.swap r)) :