Basics on First-Order Structures #
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
FirstOrder.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
FirstOrder.Language.Structure
interprets the symbols of a givenFirstOrder.Language
in the context of a given type. - A
FirstOrder.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
FirstOrder.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
FirstOrder.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.
References #
For the Flypitch project:
- [J. Han, F. van Doorn, A formal proof of the independence of the continuum hypothesis] [flypitch_cpp]
- [J. Han, F. van Doorn, A formalization of forcing and the unprovability of the continuum hypothesis][flypitch_itp]
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.
For every arity, a
Type*
of functions of that arityFor every arity, a
Type*
of relations of that arity
Instances For
Used to define FirstOrder.Language₂
.
Equations
- FirstOrder.Sequence₂ a₀ a₁ a₂ x = match x with | 0 => a₀ | 1 => a₁ | 2 => a₂ | x => PEmpty.{u + 1}
Instances For
Equations
- FirstOrder.Sequence₂.inhabited₀ a₀ a₁ a₂ = h
Equations
- FirstOrder.Sequence₂.inhabited₁ a₀ a₁ a₂ = h
Equations
- FirstOrder.Sequence₂.inhabited₂ a₀ a₁ a₂ = h
Equations
- (_ : IsEmpty (FirstOrder.Sequence₂ a₀ a₁ a₂ (n + 3))) = (_ : IsEmpty PEmpty.{u + 1} )
A constructor for languages with only constants, unary and binary functions, and unary and binary relations.
Equations
- FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂ = { Functions := FirstOrder.Sequence₂ c f₁ f₂, Relations := FirstOrder.Sequence₂ PEmpty.{v + 1} r₁ r₂ }
Instances For
The empty language has no symbols.
Equations
Instances For
Equations
- FirstOrder.Language.instInhabitedLanguage = { default := FirstOrder.Language.empty }
The sum of two languages consists of the disjoint union of their symbols.
Equations
Instances For
The type of constants in a given language.
Equations
- FirstOrder.Language.Constants L = L.Functions 0
Instances For
The type of symbols in a given language.
Equations
- FirstOrder.Language.Symbols L = ((l : ℕ) × L.Functions l ⊕ (l : ℕ) × L.Relations l)
Instances For
The cardinality of a language is the cardinality of its type of symbols.
Equations
Instances For
A language is relational when it has no function symbols.
There are no function symbols in the language.
Instances
A language is algebraic when it has no relation symbols.
There are no relation symbols in the language.
Instances
Equations
- One or more equations did not get rendered due to their size.
Equations
- (_ : FirstOrder.Language.IsAlgebraic { Functions := symb, Relations := fun (x : ℕ) => Empty }) = (_ : FirstOrder.Language.IsAlgebraic { Functions := symb, Relations := fun (x : ℕ) => Empty })
Equations
- FirstOrder.Language.isRelational_empty = (_ : FirstOrder.Language.IsRelational { Functions := fun (x : ℕ) => Empty, Relations := fun (x : ℕ) => Empty })
Equations
- FirstOrder.Language.isAlgebraic_empty = (_ : FirstOrder.Language.IsAlgebraic { Functions := fun (x : ℕ) => Empty, Relations := fun (x : ℕ) => Empty })
Equations
- (_ : FirstOrder.Language.IsRelational (FirstOrder.Language.sum L L')) = (_ : FirstOrder.Language.IsRelational (FirstOrder.Language.sum L L'))
Equations
- (_ : FirstOrder.Language.IsAlgebraic (FirstOrder.Language.sum L L')) = (_ : FirstOrder.Language.IsAlgebraic (FirstOrder.Language.sum L L'))
Equations
- (_ : FirstOrder.Language.IsRelational (FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂)) = (_ : FirstOrder.Language.IsRelational (FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂))
Equations
- (_ : FirstOrder.Language.IsAlgebraic (FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂)) = (_ : FirstOrder.Language.IsAlgebraic (FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂))
Equations
- (_ : Subsingleton ((FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂).Functions n)) = (_ : Subsingleton ((FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂).Functions n))
Equations
- (_ : Subsingleton ((FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂).Relations n)) = (_ : Subsingleton ((FirstOrder.Language.mk₂ c f₁ f₂ r₁ r₂).Relations n))
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
.
Interpretation of the function symbols
Interpretation of the relation symbols
Instances
Used for defining FirstOrder.Language.Theory.ModelType.instInhabited
.
Equations
- FirstOrder.Language.Inhabited.trivialStructure L = { funMap := fun {n : ℕ} => default, RelMap := fun {n : ℕ} => default }
Instances For
Maps #
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.
- toFun : M → N
The underlying function of a homomorphism of structures
- map_fun' : ∀ {n : ℕ} (f : L.Functions n) (x : Fin n → M), self.toFun (FirstOrder.Language.Structure.funMap f x) = FirstOrder.Language.Structure.funMap f (self.toFun ∘ x)
The homomorphism commutes with the interpretations of the function symbols
- map_rel' : ∀ {n : ℕ} (r : L.Relations n) (x : Fin n → M), FirstOrder.Language.Structure.RelMap r x → FirstOrder.Language.Structure.RelMap r (self.toFun ∘ x)
The homomorphism sends related elements to related elements
Instances For
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
An embedding of first-order structures is an embedding that commutes with the interpretations of functions and relations.
- toFun : M → N
- inj' : Function.Injective self.toFun
- map_fun' : ∀ {n : ℕ} (f : L.Functions n) (x : Fin n → M), self.toEmbedding.toFun (FirstOrder.Language.Structure.funMap f x) = FirstOrder.Language.Structure.funMap f (self.toFun ∘ x)
The homomorphism commutes with the interpretations of the function symbols
- map_rel' : ∀ {n : ℕ} (r : L.Relations n) (x : Fin n → M), FirstOrder.Language.Structure.RelMap r (self.toFun ∘ x) ↔ FirstOrder.Language.Structure.RelMap r x
The homomorphism sends related elements to related elements
Instances For
An embedding of first-order structures is an embedding that commutes with the interpretations of functions and relations.
Equations
- One or more equations did not get rendered due to their size.
Instances For
An equivalence of first-order structures is an equivalence that commutes with the interpretations of functions and relations.
- toFun : M → N
- invFun : N → M
- left_inv : Function.LeftInverse self.invFun self.toFun
- right_inv : Function.RightInverse self.invFun self.toFun
- map_fun' : ∀ {n : ℕ} (f : L.Functions n) (x : Fin n → M), self.toEquiv.toFun (FirstOrder.Language.Structure.funMap f x) = FirstOrder.Language.Structure.funMap f (self.toFun ∘ x)
The homomorphism commutes with the interpretations of the function symbols
- map_rel' : ∀ {n : ℕ} (r : L.Relations n) (x : Fin n → M), FirstOrder.Language.Structure.RelMap r (self.toFun ∘ x) ↔ FirstOrder.Language.Structure.RelMap r x
The homomorphism sends related elements to related elements
Instances For
An equivalence of first-order structures is an equivalence that commutes with the interpretations of functions and relations.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Interpretation of a constant symbol
Equations
- ↑c = FirstOrder.Language.Structure.funMap c default
Instances For
Equations
- FirstOrder.Language.instCoeTCConstants = { coe := FirstOrder.Language.constantMap }
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 FirstOrder.Language.Structure₂
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The relation map for FirstOrder.Language.Structure₂
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A structure constructor to match FirstOrder.Language₂
.
Equations
- FirstOrder.Language.Structure.mk₂ c' f₁' f₂' r₁' r₂' = { funMap := fun {n : ℕ} => FirstOrder.Language.funMap₂ c' f₁' f₂', RelMap := fun {n : ℕ} => FirstOrder.Language.RelMap₂ r₁' r₂' }
Instances For
HomClass L F M N
states that F
is a type of L
-homomorphisms. You should extend this
typeclass when you extend FirstOrder.Language.Hom
.
- map_fun : ∀ (φ : F) {n : ℕ} (f : L.Functions n) (x : Fin n → M), φ (FirstOrder.Language.Structure.funMap f x) = FirstOrder.Language.Structure.funMap f (⇑φ ∘ x)
The homomorphism commutes with the interpretations of the function symbols
- map_rel : ∀ (φ : F) {n : ℕ} (r : L.Relations n) (x : Fin n → M), FirstOrder.Language.Structure.RelMap r x → FirstOrder.Language.Structure.RelMap r (⇑φ ∘ x)
The homomorphism sends related elements to related elements
Instances
StrongHomClass L F M N
states that F
is a type of L
-homomorphisms which preserve
relations in both directions.
- map_fun : ∀ (φ : F) {n : ℕ} (f : L.Functions n) (x : Fin n → M), φ (FirstOrder.Language.Structure.funMap f x) = FirstOrder.Language.Structure.funMap f (⇑φ ∘ x)
The homomorphism commutes with the interpretations of the function symbols
- map_rel : ∀ (φ : F) {n : ℕ} (r : L.Relations n) (x : Fin n → M), FirstOrder.Language.Structure.RelMap r (⇑φ ∘ x) ↔ FirstOrder.Language.Structure.RelMap r x
The homomorphism sends related elements to related elements
Instances
Equations
- (_ : FirstOrder.Language.HomClass L F M N) = (_ : FirstOrder.Language.HomClass L F M N)
Not an instance to avoid a loop.
Equations
- FirstOrder.Language.Hom.instFunLike = { coe := FirstOrder.Language.Hom.toFun, coe_injective' := (_ : ∀ (f g : FirstOrder.Language.Hom L M N), f.toFun = g.toFun → f = g) }
Equations
- (_ : FirstOrder.Language.HomClass L (FirstOrder.Language.Hom L M N) M N) = (_ : FirstOrder.Language.HomClass L (FirstOrder.Language.Hom L M N) M N)
Equations
- (_ : FirstOrder.Language.StrongHomClass L (FirstOrder.Language.Hom L M N) M N) = (_ : FirstOrder.Language.StrongHomClass L (FirstOrder.Language.Hom L M N) M N)
Equations
- FirstOrder.Language.Hom.hasCoeToFun = DFunLike.hasCoeToFun
The identity map from a structure to itself.
Equations
- FirstOrder.Language.Hom.id L M = FirstOrder.Language.Hom.mk fun (m : M) => m
Instances For
Equations
- FirstOrder.Language.Hom.instInhabitedHom = { default := FirstOrder.Language.Hom.id L M }
Composition of first-order homomorphisms.
Equations
- FirstOrder.Language.Hom.comp hnp hmn = FirstOrder.Language.Hom.mk (⇑hnp ∘ ⇑hmn)
Instances For
Composition of first-order homomorphisms is associative.
Any element of a HomClass
can be realized as a first_order homomorphism.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- (_ : EmbeddingLike (FirstOrder.Language.Embedding L M N) M N) = (_ : EmbeddingLike (FirstOrder.Language.Embedding L M N) M N)
Equations
- (_ : FirstOrder.Language.StrongHomClass L (FirstOrder.Language.Embedding L M N) M N) = (_ : FirstOrder.Language.StrongHomClass L (FirstOrder.Language.Embedding L M N) M N)
A first-order embedding is also a first-order homomorphism.
Equations
- FirstOrder.Language.Embedding.toHom = FirstOrder.Language.HomClass.toHom
Instances For
In an algebraic language, any injective homomorphism is an embedding.
Equations
- FirstOrder.Language.Embedding.ofInjective hf = FirstOrder.Language.Embedding.mk { toFun := f.toFun, inj' := hf }
Instances For
The identity embedding from a structure to itself.
Equations
Instances For
Equations
- FirstOrder.Language.Embedding.instInhabitedEmbedding = { default := FirstOrder.Language.Embedding.refl L M }
Composition of first-order embeddings.
Equations
- FirstOrder.Language.Embedding.comp hnp hmn = FirstOrder.Language.Embedding.mk { toFun := ⇑hnp ∘ ⇑hmn, inj' := (_ : Function.Injective (⇑hnp ∘ ⇑hmn)) }
Instances For
Composition of first-order embeddings is associative.
Any element of an injective StrongHomClass
can be realized as a first_order embedding.
Equations
- FirstOrder.Language.StrongHomClass.toEmbedding φ = FirstOrder.Language.Embedding.mk { toFun := ⇑φ, inj' := (_ : Function.Injective ⇑φ) }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- (_ : FirstOrder.Language.StrongHomClass L (FirstOrder.Language.Equiv L M N) M N) = (_ : FirstOrder.Language.StrongHomClass L (FirstOrder.Language.Equiv L M N) M N)
The inverse of a first-order equivalence is a first-order equivalence.
Equations
- FirstOrder.Language.Equiv.symm f = let src := f.symm; FirstOrder.Language.Equiv.mk src
Instances For
Equations
- FirstOrder.Language.Equiv.hasCoeToFun = DFunLike.hasCoeToFun
A first-order equivalence is also a first-order embedding.
Equations
- FirstOrder.Language.Equiv.toEmbedding = FirstOrder.Language.StrongHomClass.toEmbedding
Instances For
A first-order equivalence is also a first-order homomorphism.
Equations
- FirstOrder.Language.Equiv.toHom = FirstOrder.Language.HomClass.toHom
Instances For
The identity equivalence from a structure to itself.
Equations
Instances For
Equations
- FirstOrder.Language.Equiv.instInhabitedEquiv = { default := FirstOrder.Language.Equiv.refl L M }
Composition of first-order equivalences.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Composition of first-order homomorphisms is associative.
Any element of a bijective StrongHomClass
can be realized as a first_order isomorphism.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
Makes a Language.empty.Hom
out of any function.
Equations
Instances For
Makes a Language.empty.Embedding
out of any function.
Equations
Instances For
Makes a Language.empty.Equiv
out of any function.
Equations
Instances For
A structure induced by a bijection.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A bijection as a first-order isomorphism with the induced structure on the codomain.