Cores #
In this file, we define cores of fact sets. Namely, we define FactSet.isWeakCore and FactSet.isStrongCore.
FactSets that are models and cores are interesting since there are (intuitively speaking) the smallest possible models.
Under certain condition, the chase is able to produce a core directly, which is very desirable since the result of the chase is also always a universal model.
But this is discussed in other files. Here, we are only concerned with the definition of cores on FactSets and some of their properties.
Some Auxiliary Definitions and Theorems on Lists and Functions #
Before we can go into the actual definitions, we need a lot of machinery, mainly about functions to be able to state properties like injectivity and surjectivity possibly only about a list of set of elements and not the whole domain of the function.
Auxiliary Theorems on Lists #
If a list is duplicate free and the sublist of another list that has the same length, then both lists have exactly the same elements.
Injectivity and Surjectivity #
We define what it means for a function to be injective or surjective restricted to a given domain and image, given as either a list or set. Intuitively, results involving the list versions most likely have an implicit requirement for domain and image being finite whereas results stated for the set version do not have this requirement.
We found our more suitable than using Function.Injective and Function.Sufjective because this would require us to consider appropriate subtypes and also since there barely seem to be theorems in the standard library (outside Mathlib).
We might rework those definitions in the future though. I think a couple of (small) things can be cleaned up here but this is not the highest priprity.
Maybe this should even move to the BasicLeanDatastructures repo since there are really just general results over functions.
The image of a function for a given domain set.
Equations
- Function.image_set f A = A.map f
Instances For
A function is injective on a given domain set if for each two elements of the given domain, the mapping of both elements being the same implies the elements being the same.
Equations
Instances For
A function is surjective on a given domain set and image set if for each element of the image, there exists an element in the domain that maps to the desired image element.
Equations
Instances For
The image of a function for a given domain list.
Equations
- Function.image f l = (List.map f l).eraseDupsKeepRight
Instances For
A function is injective on a given domain list if for each two elements of the given domain, the mapping of both elements being the same implies the elements being the same.
Equations
Instances For
A function is surjective on a given domain list and image list if for each element of the image, there exists an element in the domain that maps to the desired image element.
Equations
Instances For
If the composition of two mappings is injective, then the first one must be injective.
If a mapping is surjective for a domain and image, then the same holds for any superset of the domain.
If the composition of two mappings is surjective for a domain and image, then the second one must be surjective on the same image and the domain that is the image of the first function.
The surjectivity definitions for set and list are interchangeable.
If a mapping is injective on a domain of the form hd::tl, then it is injective on tl.
The mapping of each domain element occurs in the image.
The image has no duplicates.
Every mapping is always surjective on its own image.
If a mapping is closed, then its image is fully contained in its domain.
Given a mapping and a domain list without duplicates, the mapping in injective on the domain if and only if the image contains the same number of elements as the domain.
A mapping is surjective on a given domain and image if and only if the given image is contained in the actual image of the mapping.
Given a single list without duplicates that represents both domain and image, if a mapping is surjective, then it is injective.
Given a single list without duplicates that represents both domain and image, if a mapping closed on the list, then the mapping is injective if and only if it is surjective.
Given a single list without duplicates that represents both domain and image, if a mapping both injective and surjective, then is must be closed on the list.
Strong GroundTermMappings (and Homomorphisms) #
Intuitively, a homomorphism is strong if it not only retains membership but also non-membership.
We define being strong as a standalone property for GroundTermMappings
without requiring any additional properties for the underlying GroundTermMapping.
A GroundTermMapping is strong for FactSets A and B if each element not in A, its mapping is not in B. However, we only demand this for elements that only feature terms from a given domain because we do not want to care about the mapping of terms outside the domain.
Equations
Instances For
If the composition of two mappings is strong from A to C and the second mapping is a homomorphism from B to C, then the first mapping is strong from A to B.
Repetition of GroundTermMappings (and Homomorphisms) #
In general, we can define what it means to apply a function a given number of times.
This is particularly useful for GroundTermMappings that are endomorphisms, i.e. homomorphisms from one structure into the same structure.
We can show some nice properties for such repetitions. For example, a repeated endomorphisms is still an endomorphisms.
Repetition of a GroundTermMapping defined in the obvious way. Repeating zero times is defined as the id function.
Equations
- h.repeat_hom Nat.zero = id
- h.repeat_hom j.succ = h ∘ h.repeat_hom j
Instances For
It does not mapper if we apply add one more repetition on the left or the right.
A (n+m)-times repetition can be split into the composition of an m-times repetition followed by an n-times repetition.
If some repetition maps a term to itself, then each multiple of the repetition count must also map the term to itself.
If some repetition maps a term to itself, then for each other term that is part of the loop, the same number of repetitions also maps that one to itself.
Consider a list of terms. If each term is reachable by some number of repetitions from some term, then for each term there is a number of repetition that maps the term to itself. Intuitively this holds by a pigeonhole principle: If for each term you need to pick a term from that you can reach it, but only finitely many terms are available, then eventually you need to complete a cycle.
If each term from a finite list is mapped to itself after some number of repetitions, then there is a global repetition number that maps each term to itself. Basically any common multiple of the individual repetition numbers works.
If a mapping is surjective for a given list of terms, then there exists a repetition count $k$ such that $k+1$ map each term from the list to itself. Note that we use $k+1$ repetitions as otherwise the result would be trivial for zero repetitions, which are the id by definition.
Repeating a mapping retains the isIdOnConstants property.
Repeating a mapping retains the isHomomorphism property at least for endomorphisms.
Cores Definitions and some of their Properties #
Here, we finally define isWeakCore and isStrongCore and show some of their relations and additional properties. This also involves some more theorems about homomorphisms.
A FactSet is a weak core if every endomorphisms on the fact set is strong and injective.
Equations
- fs.isWeakCore = ∀ (h : GroundTermMapping sig), h.isHomomorphism fs fs → h.strong fs.terms fs fs ∧ Function.injective_for_domain_set h fs.terms
Instances For
A FactSet is a strong core if every endomorphisms on the fact set is strong, injective, and surjective. (By definition, every strong core is a weak core.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
We say that a fact set $C$ is a homomorphic subset of another fact set $F$ if $C$ is a subset of $F$ and there is a homomorphism from $F$ to $C$.
Instances For
For a homomorphism on a finite fact set, injectivity implies surjectivity.
For a homomorphism on a finite fact set, injectivity implies that the homomorphisms is also strong.
For finite fact sets, isWeakCore implies isStrongCore. That means that isWeakCore and isStrongCore are equivalent on finite fact sets.
Given two fact sets A,B of which one is a weak and one is a strong core, if there are homomorphisms from A to B and B to A, then there exists an isomorphism from A to B, i.e. a strong homomorphisms that is injective and surjective.
Strong cores of fact sets are unique up to isomorphism. That is, consider a fact set $F$. A strong core $C$ for $F$ is a strong core that is also a homomorphic subset of $F$. Now every (other) homomorphic subset $C'$ of $F$ that is at least a weak core has an isomorphism into $C$.
Consider a KnowledgeBase and a universal model of the KB that is a strong core. Then every (other) universal model that is at least a weak core, is isomorphism to the strong core.
Given a model of a KnowledgeBase, every strong core of the model is also a model. In general, this does not hold for weak cores (in the infinite setting).
Building on top of the previous theorem, a strong core of a universal model is not only a model but also universal.