Basics on First-Order Structures #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4. This file defines first-order languages and structures in the style of the Flypitch project, as well as several important maps between structures.
Main Definitions #
- A
first_order.language
defines a language as a pair of functions from the natural numbers toType l
. One sendsn
to the type ofn
-ary functions, and the other sendsn
to the type ofn
-ary relations. - A
first_order.language.Structure
interprets the symbols of a givenfirst_order.language
in the context of a given type. - A
first_order.language.hom
, denotedM →[L] N
, is a map from theL
-structureM
to theL
-structureN
that commutes with the interpretations of functions, and which preserves the interpretations of relations (although only in the forward direction). - A
first_order.language.embedding
, denotedM ↪[L] N
, is an embedding from theL
-structureM
to theL
-structureN
that commutes with the interpretations of functions, and which preserves the interpretations of relations in both directions. - A
first_order.language.elementary_embedding
, denotedM ↪ₑ[L] N
, is an embedding from theL
-structureM
to theL
-structureN
that commutes with the realizations of all formulas. - A
first_order.language.equiv
, denotedM ≃[L] N
, is an equivalence from theL
-structureM
to theL
-structureN
that commutes with the interpretations of functions, and which preserves the interpretations of relations in both directions.
TODO #
Use [countable L.symbols]
instead of [L.countable]
.
References #
For the Flypitch project:
Languages and Structures #
A first-order language consists of a type of functions of every natural-number arity and a type of relations of every natural-number arity.
Instances for first_order.language
- first_order.language.has_sizeof_inst
- first_order.language.inhabited
Used to define first_order.language₂
.
Equations
- first_order.sequence₂ a₀ a₁ a₂ _x = pempty
- first_order.sequence₂ a₀ a₁ a₂ 2 = a₂
- first_order.sequence₂ a₀ a₁ a₂ 1 = a₁
- first_order.sequence₂ a₀ a₁ a₂ 0 = a₀
Instances for first_order.sequence₂
Equations
- first_order.sequence₂.inhabited₀ a₀ a₁ a₂ = h
Equations
- first_order.sequence₂.inhabited₁ a₀ a₁ a₂ = h
Equations
- first_order.sequence₂.inhabited₂ a₀ a₁ a₂ = h
A constructor for languages with only constants, unary and binary functions, and unary and binary relations.
Equations
- first_order.language.mk₂ c f₁ f₂ r₁ r₂ = {functions := first_order.sequence₂ c f₁ f₂, relations := first_order.sequence₂ pempty r₁ r₂}
Instances for first_order.language.mk₂
The empty language has no symbols.
Equations
Instances for first_order.language.empty
Equations
The sum of two languages consists of the disjoint union of their symbols.
Equations
Instances for first_order.language.sum
The type of constants in a given language.
Instances for first_order.language.constants
The cardinality of a language is the cardinality of its type of symbols.
Equations
- L.card = cardinal.mk L.symbols
A language is relational when it has no function symbols.
Instances of this typeclass
- first_order.language.is_relational_of_empty_functions
- first_order.language.is_relational_empty
- first_order.language.is_relational_sum
- first_order.language.is_relational_mk₂
- first_order.language.is_relational_constants_on
- first_order.language.order.first_order.language.is_relational
- first_order.language.graph.first_order.language.is_relational
A language is algebraic when it has no relation symbols.
- fun_map : Π {n : ℕ}, L.functions n → (fin n → M) → M
- rel_map : Π {n : ℕ}, L.relations n → (fin n → M) → Prop
A first-order structure on a type M
consists of interpretations of all the symbols in a given
language. Each function of arity n
is interpreted as a function sending tuples of length n
(modeled as (fin n → M)
) to M
, and a relation of arity n
is a function from tuples of length
n
to Prop
.
Instances of this typeclass
- first_order.language.sum_Structure
- first_order.language.empty_Structure
- first_order.language.params_Structure
- first_order.language.constants_on_self_Structure
- first_order.language.with_constants_self_Structure
- first_order.language.with_constants_Structure
- first_order.language.substructure.induced_Structure
- first_order.language.quotient_structure
- first_order.language.direct_limit.Structure
- first_order.language.elementary_substructure.induced_Structure
- category_theory.bundled.Structure
- first_order.language.Theory.Model.struc
- first_order.language.Theory.Model.left_Structure
- first_order.language.Theory.Model.right_Structure
- first_order.language.ultraproduct.Structure
- first_order.language.skolem₁_Structure
- first_order.language.order_Structure
Instances of other typeclasses for first_order.language.Structure
- first_order.language.Structure.has_sizeof_inst
- first_order.language.Structure.unique
Used for defining first_order.language.Theory.Model.inhabited
.
Equations
Maps #
- to_fun : M → N
- map_fun' : (∀ {n : ℕ} (f : L.functions n) (x : fin n → M), self.to_fun (first_order.language.Structure.fun_map f x) = first_order.language.Structure.fun_map f (self.to_fun ∘ x)) . "obviously"
- map_rel' : (∀ {n : ℕ} (r : L.relations n) (x : fin n → M), first_order.language.Structure.rel_map r x → first_order.language.Structure.rel_map r (self.to_fun ∘ x)) . "obviously"
A homomorphism between first-order structures is a function that commutes with the interpretations of functions and maps tuples in one structure where a given relation is true to tuples in the second structure where that relation is still true.
Instances for first_order.language.hom
- to_embedding : M ↪ N
- map_fun' : (∀ {n : ℕ} (f : L.functions n) (x : fin n → M), self.to_embedding.to_fun (first_order.language.Structure.fun_map f x) = first_order.language.Structure.fun_map f (self.to_embedding.to_fun ∘ x)) . "obviously"
- map_rel' : (∀ {n : ℕ} (r : L.relations n) (x : fin n → M), first_order.language.Structure.rel_map r (self.to_embedding.to_fun ∘ x) ↔ first_order.language.Structure.rel_map r x) . "obviously"
An embedding of first-order structures is an embedding that commutes with the interpretations of functions and relations.
Instances for first_order.language.embedding
- first_order.language.embedding.has_sizeof_inst
- first_order.language.embedding.embedding_like
- first_order.language.embedding.strong_hom_class
- first_order.language.embedding.has_coe_to_fun
- first_order.language.embedding.inhabited
- to_equiv : M ≃ N
- map_fun' : (∀ {n : ℕ} (f : L.functions n) (x : fin n → M), self.to_equiv.to_fun (first_order.language.Structure.fun_map f x) = first_order.language.Structure.fun_map f (self.to_equiv.to_fun ∘ x)) . "obviously"
- map_rel' : (∀ {n : ℕ} (r : L.relations n) (x : fin n → M), first_order.language.Structure.rel_map r (self.to_equiv.to_fun ∘ x) ↔ first_order.language.Structure.rel_map r x) . "obviously"
An equivalence of first-order structures is an equivalence that commutes with the interpretations of functions and relations.
Instances for first_order.language.equiv
- first_order.language.equiv.has_sizeof_inst
- first_order.language.equiv.equiv_like
- first_order.language.equiv.first_order.language.strong_hom_class
- first_order.language.equiv.has_coe_to_fun
- first_order.language.equiv.inhabited
Equations
Given a language with a nonempty type of constants, any structure will be nonempty. This cannot
be a global instance, because L
becomes a metavariable.
The function map for first_order.language.Structure₂
.
Equations
- first_order.language.fun_map₂ c' f₁' f₂' f _x = pempty.elim f
- first_order.language.fun_map₂ c' f₁' f₂' f x = f₂' f (x 0) (x 1)
- first_order.language.fun_map₂ c' f₁' f₂' f x = f₁' f (x 0)
- first_order.language.fun_map₂ c' f₁' f₂' f _x = c' f
The relation map for first_order.language.Structure₂
.
Equations
- first_order.language.rel_map₂ r₁' r₂' r _x = pempty.elim r
- first_order.language.rel_map₂ r₁' r₂' r x = r₂' r (x 0) (x 1)
- first_order.language.rel_map₂ r₁' r₂' r x = (x 0 ∈ r₁' r)
- first_order.language.rel_map₂ r₁' r₂' r _x = pempty.elim r
A structure constructor to match first_order.language₂
.
Equations
- first_order.language.Structure.mk₂ c' f₁' f₂' r₁' r₂' = {fun_map := λ (_x : ℕ), first_order.language.fun_map₂ c' f₁' f₂', rel_map := λ (_x : ℕ), first_order.language.rel_map₂ r₁' r₂'}
- map_fun : ∀ (φ : F) {n : ℕ} (f : L.functions n) (x : fin n → M), ⇑φ (first_order.language.Structure.fun_map f x) = first_order.language.Structure.fun_map f (⇑φ ∘ x)
- map_rel : ∀ (φ : F) {n : ℕ} (r : L.relations n) (x : fin n → M), first_order.language.Structure.rel_map r x → first_order.language.Structure.rel_map r (⇑φ ∘ x)
hom_class L F M N
states that F
is a type of L
-homomorphisms. You should extend this
typeclass when you extend first_order.language.hom
.
Instances of this typeclass
Instances of other typeclasses for first_order.language.hom_class
- first_order.language.hom_class.has_sizeof_inst
- map_fun : ∀ (φ : F) {n : ℕ} (f : L.functions n) (x : fin n → M), ⇑φ (first_order.language.Structure.fun_map f x) = first_order.language.Structure.fun_map f (⇑φ ∘ x)
- map_rel : ∀ (φ : F) {n : ℕ} (r : L.relations n) (x : fin n → M), first_order.language.Structure.rel_map r (⇑φ ∘ x) ↔ first_order.language.Structure.rel_map r x
strong_hom_class L F M N
states that F
is a type of L
-homomorphisms which preserve
relations in both directions.
Instances of this typeclass
Instances of other typeclasses for first_order.language.strong_hom_class
- first_order.language.strong_hom_class.has_sizeof_inst
Equations
Not an instance to avoid a loop.
Equations
Equations
- first_order.language.hom.fun_like = {coe := first_order.language.hom.to_fun _inst_2, coe_injective' := _}
Equations
- first_order.language.hom.hom_class = {map_fun := _, map_rel := _}
The identity map from a structure to itself
Equations
- first_order.language.hom.inhabited = {default := first_order.language.hom.id L M _inst_1}
Any element of a hom_class
can be realized as a first_order homomorphism.
Equations
- first_order.language.embedding.embedding_like = {coe := λ (f : L.embedding M N), f.to_embedding.to_fun, coe_injective' := _, injective' := _}
Equations
A first-order embedding is also a first-order homomorphism.
In an algebraic language, any injective homomorphism is an embedding.
Equations
- first_order.language.embedding.of_injective hf = {to_embedding := {to_fun := f.to_fun, inj' := hf}, map_fun' := _, map_rel' := _}
The identity embedding from a structure to itself
Equations
- first_order.language.embedding.refl L M = {to_embedding := function.embedding.refl M, map_fun' := _, map_rel' := _}
Equations
Composition of first-order embeddings is associative.
Any element of an injective strong_hom_class
can be realized as a first_order embedding.
Equations
- first_order.language.strong_hom_class.to_embedding = λ (φ : F), {to_embedding := {to_fun := ⇑φ, inj' := _}, map_fun' := _, map_rel' := _}
Equations
The inverse of a first-order equivalence is a first-order equivalence.
A first-order equivalence is also a first-order embedding.
A first-order equivalence is also a first-order homomorphism.
The identity equivalence from a structure to itself
Equations
- first_order.language.equiv.refl L M = {to_equiv := equiv.refl M, map_fun' := _, map_rel' := _}
Equations
- first_order.language.equiv.inhabited = {default := first_order.language.equiv.refl L M _inst_1}
Composition of first-order homomorphisms is associative.
Any element of a bijective strong_hom_class
can be realized as a first_order isomorphism.
Equations
Equations
- first_order.language.empty_Structure = {fun_map := λ (_x : ℕ), empty.elim, rel_map := λ (_x : ℕ), empty.elim}
Makes a language.empty.hom
out of any function.
Makes a language.empty.embedding
out of any function.
Equations
- embedding.empty f = {to_embedding := f, map_fun' := _, map_rel' := _}
A structure induced by a bijection.
A bijection as a first-order isomorphism with the induced structure on the codomain.