Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2022 Aaron Anderson. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: Aaron Anderson | |
-/ | |
import data.fintype.basic | |
import model_theory.substructures | |
/-! | |
# Elementary Maps Between First-Order Structures | |
## Main Definitions | |
* A `first_order.language.elementary_embedding` is an embedding that commutes with the | |
realizations of formulas. | |
* A `first_order.language.elementary_substructure` is a substructure where the realization of each | |
formula agrees with the realization in the larger model. | |
* The `first_order.language.elementary_diagram` of a structure is the set of all sentences with | |
parameters that the structure satisfies. | |
* `first_order.language.elementary_embedding.of_models_elementary_diagram` is the canonical | |
elementary embedding of any structure into a model of its elementary diagram. | |
## Main Results | |
* The Tarski-Vaught Test for embeddings: `first_order.language.embedding.is_elementary_of_exists` | |
gives a simple criterion for an embedding to be elementary. | |
* The Tarski-Vaught Test for substructures: `first_order.language.embedding.is_elementary_of_exists` | |
gives a simple criterion for a substructure to be elementary. | |
-/ | |
open_locale first_order | |
namespace first_order | |
namespace language | |
open Structure | |
variables (L : language) (M : Type*) (N : Type*) {P : Type*} {Q : Type*} | |
variables [L.Structure M] [L.Structure N] [L.Structure P] [L.Structure Q] | |
/-- An elementary embedding of first-order structures is an embedding that commutes with the | |
realizations of formulas. -/ | |
structure elementary_embedding := | |
(to_fun : M β N) | |
(map_formula' : β{n} (Ο : L.formula (fin n)) (x : fin n β M), | |
Ο.realize (to_fun β x) β Ο.realize x . obviously) | |
localized "notation A ` βͺβ[`:25 L `] ` B := first_order.language.elementary_embedding L A B" | |
in first_order | |
variables {L} {M} {N} | |
namespace elementary_embedding | |
instance fun_like : fun_like (M βͺβ[L] N) M (Ξ» _, N) := | |
{ coe := Ξ» f, f.to_fun, | |
coe_injective' := Ξ» f g h, begin | |
cases f, | |
cases g, | |
simp only, | |
ext x, | |
exact function.funext_iff.1 h x end } | |
instance : has_coe_to_fun (M βͺβ[L] N) (Ξ» _, M β N) := fun_like.has_coe_to_fun | |
@[simp] lemma map_bounded_formula (f : M βͺβ[L] N) {Ξ± : Type} {n : β} | |
(Ο : L.bounded_formula Ξ± n) (v : Ξ± β M) (xs : fin n β M) : | |
Ο.realize (f β v) (f β xs) β Ο.realize v xs := | |
begin | |
classical, | |
rw [β bounded_formula.realize_restrict_free_var set.subset.rfl, set.inclusion_eq_id, iff_eq_eq], | |
swap, { apply_instance }, | |
have h := f.map_formula' ((Ο.restrict_free_var id).to_formula.relabel (fintype.equiv_fin _)) | |
((sum.elim (v β coe) xs) β (fintype.equiv_fin _).symm), | |
simp only [formula.realize_relabel, bounded_formula.realize_to_formula, iff_eq_eq] at h, | |
rw [β function.comp.assoc _ _ ((fintype.equiv_fin _).symm), | |
function.comp.assoc _ ((fintype.equiv_fin _).symm) (fintype.equiv_fin _), | |
equiv.symm_comp_self, function.comp.right_id, function.comp.assoc, sum.elim_comp_inl, | |
function.comp.assoc _ _ sum.inr, sum.elim_comp_inr, | |
β function.comp.assoc] at h, | |
refine h.trans _, | |
rw [function.comp.assoc _ _ (fintype.equiv_fin _), equiv.symm_comp_self, | |
function.comp.right_id, sum.elim_comp_inl, sum.elim_comp_inr, β set.inclusion_eq_id, | |
bounded_formula.realize_restrict_free_var set.subset.rfl], | |
end | |
@[simp] lemma map_formula (f : M βͺβ[L] N) {Ξ± : Type} (Ο : L.formula Ξ±) (x : Ξ± β M) : | |
Ο.realize (f β x) β Ο.realize x := | |
by rw [formula.realize, formula.realize, β f.map_bounded_formula, unique.eq_default (f β default)] | |
lemma map_sentence (f : M βͺβ[L] N) (Ο : L.sentence) : | |
M β¨ Ο β N β¨ Ο := | |
by rw [sentence.realize, sentence.realize, β f.map_formula, unique.eq_default (f β default)] | |
lemma Theory_model_iff (f : M βͺβ[L] N) (T : L.Theory) : | |
M β¨ T β N β¨ T := | |
by simp only [Theory.model_iff, f.map_sentence] | |
lemma elementarily_equivalent (f : M βͺβ[L] N) : M β [L] N := | |
elementarily_equivalent_iff.2 f.map_sentence | |
@[simp] lemma injective (Ο : M βͺβ[L] N) : | |
function.injective Ο := | |
begin | |
intros x y, | |
have h := Ο.map_formula ((var 0).equal (var 1) : L.formula (fin 2)) (Ξ» i, if i = 0 then x else y), | |
rw [formula.realize_equal, formula.realize_equal] at h, | |
simp only [nat.one_ne_zero, term.realize, fin.one_eq_zero_iff, if_true, eq_self_iff_true, | |
function.comp_app, if_false] at h, | |
exact h.1, | |
end | |
instance embedding_like : embedding_like (M βͺβ[L] N) M N := | |
{ injective' := injective } | |
@[simp] lemma map_fun (Ο : M βͺβ[L] N) {n : β} (f : L.functions n) (x : fin n β M) : | |
Ο (fun_map f x) = fun_map f (Ο β x) := | |
begin | |
have h := Ο.map_formula (formula.graph f) (fin.cons (fun_map f x) x), | |
rw [formula.realize_graph, fin.comp_cons, formula.realize_graph] at h, | |
rw [eq_comm, h] | |
end | |
@[simp] lemma map_rel (Ο : M βͺβ[L] N) {n : β} (r : L.relations n) (x : fin n β M) : | |
rel_map r (Ο β x) β rel_map r x := | |
begin | |
have h := Ο.map_formula (r.formula var) x, | |
exact h | |
end | |
instance strong_hom_class : strong_hom_class L (M βͺβ[L] N) M N := | |
{ map_fun := map_fun, | |
map_rel := map_rel } | |
@[simp] lemma map_constants (Ο : M βͺβ[L] N) (c : L.constants) : Ο c = c := | |
hom_class.map_constants Ο c | |
/-- An elementary embedding is also a first-order embedding. -/ | |
def to_embedding (f : M βͺβ[L] N) : M βͺ[L] N := | |
{ to_fun := f, | |
inj' := f.injective, } | |
/-- An elementary embedding is also a first-order homomorphism. -/ | |
def to_hom (f : M βͺβ[L] N) : M β[L] N := | |
{ to_fun := f } | |
@[simp] lemma to_embedding_to_hom (f : M βͺβ[L] N) : f.to_embedding.to_hom = f.to_hom := rfl | |
@[simp] | |
lemma coe_to_hom {f : M βͺβ[L] N} : (f.to_hom : M β N) = (f : M β N) := rfl | |
@[simp] lemma coe_to_embedding (f : M βͺβ[L] N) : (f.to_embedding : M β N) = (f : M β N) := rfl | |
lemma coe_injective : @function.injective (M βͺβ[L] N) (M β N) coe_fn := | |
fun_like.coe_injective | |
@[ext] | |
lemma ext β¦f g : M βͺβ[L] Nβ¦ (h : β x, f x = g x) : f = g := | |
fun_like.ext f g h | |
lemma ext_iff {f g : M βͺβ[L] N} : f = g β β x, f x = g x := | |
fun_like.ext_iff | |
variables (L) (M) | |
/-- The identity elementary embedding from a structure to itself -/ | |
@[refl] def refl : M βͺβ[L] M := | |
{ to_fun := id } | |
variables {L} {M} | |
instance : inhabited (M βͺβ[L] M) := β¨refl L Mβ© | |
@[simp] lemma refl_apply (x : M) : | |
refl L M x = x := rfl | |
/-- Composition of elementary embeddings -/ | |
@[trans] def comp (hnp : N βͺβ[L] P) (hmn : M βͺβ[L] N) : M βͺβ[L] P := | |
{ to_fun := hnp β hmn } | |
@[simp] lemma comp_apply (g : N βͺβ[L] P) (f : M βͺβ[L] N) (x : M) : | |
g.comp f x = g (f x) := rfl | |
/-- Composition of elementary embeddings is associative. -/ | |
lemma comp_assoc (f : M βͺβ[L] N) (g : N βͺβ[L] P) (h : P βͺβ[L] Q) : | |
(h.comp g).comp f = h.comp (g.comp f) := rfl | |
end elementary_embedding | |
variables (L) (M) | |
/-- The elementary diagram of an `L`-structure is the set of all sentences with parameters it | |
satisfies. -/ | |
abbreviation elementary_diagram : L[[M]].Theory := L[[M]].complete_theory M | |
/-- The canonical elementary embedding of an `L`-structure into any model of its elementary diagram | |
-/ | |
@[simps] def elementary_embedding.of_models_elementary_diagram | |
(N : Type*) [L.Structure N] [L[[M]].Structure N] | |
[(Lhom_with_constants L M).is_expansion_on N] [N β¨ L.elementary_diagram M] : | |
M βͺβ[L] N := | |
β¨(coe : L[[M]].constants β N) β sum.inr, Ξ» n Ο x, begin | |
refine trans _ ((realize_iff_of_model_complete_theory M N (((L.Lhom_with_constants | |
M).on_bounded_formula Ο).subst (constants.term β sum.inr β x)).alls).trans _), | |
{ simp_rw [sentence.realize, bounded_formula.realize_alls, bounded_formula.realize_subst, | |
Lhom.realize_on_bounded_formula, formula.realize, unique.forall_iff, realize_constants] }, | |
{ simp_rw [sentence.realize, bounded_formula.realize_alls, bounded_formula.realize_subst, | |
Lhom.realize_on_bounded_formula, formula.realize, unique.forall_iff], | |
refl } | |
endβ© | |
variables {L M} | |
namespace embedding | |
/-- The Tarski-Vaught test for elementarity of an embedding. -/ | |
theorem is_elementary_of_exists (f : M βͺ[L] N) | |
(htv : β (n : β) (Ο : L.bounded_formula empty (n + 1)) (x : fin n β M) (a : N), | |
Ο.realize default (fin.snoc (f β x) a : _ β N) β | |
β b : M, Ο.realize default (fin.snoc (f β x) (f b) : _ β N)) : | |
β{n} (Ο : L.formula (fin n)) (x : fin n β M), Ο.realize (f β x) β Ο.realize x := | |
begin | |
suffices h : β (n : β) (Ο : L.bounded_formula empty n) (xs : fin n β M), | |
Ο.realize (f β default) (f β xs) β Ο.realize default xs, | |
{ intros n Ο x, | |
refine Ο.realize_relabel_sum_inr.symm.trans (trans (h n _ _) Ο.realize_relabel_sum_inr), }, | |
refine Ξ» n Ο, Ο.rec_on _ _ _ _ _, | |
{ exact Ξ» _ _, iff.rfl }, | |
{ intros, | |
simp [bounded_formula.realize, β sum.comp_elim, embedding.realize_term] }, | |
{ intros, | |
simp [bounded_formula.realize, β sum.comp_elim, embedding.realize_term] }, | |
{ intros _ _ _ ih1 ih2 _, | |
simp [ih1, ih2] }, | |
{ intros n Ο ih xs, | |
simp only [bounded_formula.realize_all], | |
refine β¨Ξ» h a, _, _β©, | |
{ rw [β ih, fin.comp_snoc], | |
exact h (f a) }, | |
{ contrapose!, | |
rintro β¨a, haβ©, | |
obtain β¨b, hbβ© := htv n Ο.not xs a _, | |
{ refine β¨b, Ξ» h, hb (eq.mp _ ((ih _).2 h))β©, | |
rw [unique.eq_default (f β default), fin.comp_snoc], }, | |
{ rw [bounded_formula.realize_not, β unique.eq_default (f β default)], | |
exact ha } } }, | |
end | |
/-- Bundles an embedding satisfying the Tarski-Vaught test as an elementary embedding. -/ | |
@[simps] def to_elementary_embedding (f : M βͺ[L] N) | |
(htv : β (n : β) (Ο : L.bounded_formula empty (n + 1)) (x : fin n β M) (a : N), | |
Ο.realize default (fin.snoc (f β x) a : _ β N) β | |
β b : M, Ο.realize default (fin.snoc (f β x) (f b) : _ β N)) : | |
M βͺβ[L] N := | |
β¨f, Ξ» _, f.is_elementary_of_exists htvβ© | |
end embedding | |
namespace equiv | |
/-- A first-order equivalence is also an elementary embedding. -/ | |
def to_elementary_embedding (f : M β[L] N) : M βͺβ[L] N := | |
{ to_fun := f } | |
@[simp] lemma to_elementary_embedding_to_embedding (f : M β[L] N) : | |
f.to_elementary_embedding.to_embedding = f.to_embedding := rfl | |
@[simp] lemma coe_to_elementary_embedding (f : M β[L] N) : | |
(f.to_elementary_embedding : M β N) = (f : M β N) := rfl | |
end equiv | |
@[simp] lemma realize_term_substructure {Ξ± : Type*} {S : L.substructure M} (v : Ξ± β S) | |
(t : L.term Ξ±) : | |
t.realize (coe β v) = (β(t.realize v) : M) := | |
S.subtype.realize_term t | |
namespace substructure | |
@[simp] lemma realize_bounded_formula_top {Ξ± : Type*} {n : β} {Ο : L.bounded_formula Ξ± n} | |
{v : Ξ± β (β€ : L.substructure M)} {xs : fin n β (β€ : L.substructure M)} : | |
Ο.realize v xs β Ο.realize ((coe : _ β M) β v) (coe β xs) := | |
begin | |
rw β substructure.top_equiv.realize_bounded_formula Ο, | |
simp, | |
end | |
@[simp] lemma realize_formula_top {Ξ± : Type*} {Ο : L.formula Ξ±} {v : Ξ± β (β€ : L.substructure M)} : | |
Ο.realize v β Ο.realize ((coe : (β€ : L.substructure M) β M) β v) := | |
begin | |
rw β substructure.top_equiv.realize_formula Ο, | |
simp, | |
end | |
/-- A substructure is elementary when every formula applied to a tuple in the subtructure | |
agrees with its value in the overall structure. -/ | |
def is_elementary (S : L.substructure M) : Prop := | |
β{n} (Ο : L.formula (fin n)) (x : fin n β S), Ο.realize ((coe : _ β M) β x) β Ο.realize x | |
end substructure | |
variables (L) (M) | |
/-- An elementary substructure is one in which every formula applied to a tuple in the subtructure | |
agrees with its value in the overall structure. -/ | |
structure elementary_substructure := | |
(to_substructure : L.substructure M) | |
(is_elementary' : to_substructure.is_elementary) | |
variables {L} {M} | |
namespace elementary_substructure | |
instance : has_coe (L.elementary_substructure M) (L.substructure M) := | |
β¨elementary_substructure.to_substructureβ© | |
instance : set_like (L.elementary_substructure M) M := | |
β¨Ξ» x, x.to_substructure.carrier, Ξ» β¨β¨s, hs1β©, hs2β© β¨β¨t, ht1β©, ht2β© h, begin | |
congr, | |
exact h, | |
endβ© | |
instance induced_Structure (S : L.elementary_substructure M) : L.Structure S := | |
substructure.induced_Structure | |
@[simp] lemma is_elementary (S : L.elementary_substructure M) : | |
(S : L.substructure M).is_elementary := S.is_elementary' | |
/-- The natural embedding of an `L.substructure` of `M` into `M`. -/ | |
def subtype (S : L.elementary_substructure M) : S βͺβ[L] M := | |
{ to_fun := coe, | |
map_formula' := Ξ» n, S.is_elementary } | |
@[simp] theorem coe_subtype {S : L.elementary_substructure M} : βS.subtype = coe := rfl | |
/-- The substructure `M` of the structure `M` is elementary. -/ | |
instance : has_top (L.elementary_substructure M) := | |
β¨β¨β€, Ξ» n Ο x, substructure.realize_formula_top.symmβ©β© | |
instance : inhabited (L.elementary_substructure M) := β¨β€β© | |
@[simp] lemma mem_top (x : M) : x β (β€ : L.elementary_substructure M) := set.mem_univ x | |
@[simp] lemma coe_top : ((β€ : L.elementary_substructure M) : set M) = set.univ := rfl | |
@[simp] lemma realize_sentence (S : L.elementary_substructure M) (Ο : L.sentence) : | |
S β¨ Ο β M β¨ Ο := | |
S.subtype.map_sentence Ο | |
@[simp] lemma Theory_model_iff (S : L.elementary_substructure M) (T : L.Theory) : | |
S β¨ T β M β¨ T := | |
by simp only [Theory.model_iff, realize_sentence] | |
instance Theory_model {T : L.Theory} [h : M β¨ T] {S : L.elementary_substructure M} : S β¨ T := | |
(Theory_model_iff S T).2 h | |
instance [h : nonempty M] {S : L.elementary_substructure M} : nonempty S := | |
(model_nonempty_theory_iff L).1 infer_instance | |
lemma elementarily_equivalent (S : L.elementary_substructure M) : S β [L] M := | |
S.subtype.elementarily_equivalent | |
end elementary_substructure | |
namespace substructure | |
/-- The Tarski-Vaught test for elementarity of a substructure. -/ | |
theorem is_elementary_of_exists (S : L.substructure M) | |
(htv : β (n : β) (Ο : L.bounded_formula empty (n + 1)) (x : fin n β S) (a : M), | |
Ο.realize default (fin.snoc (coe β x) a : _ β M) β | |
β b : S, Ο.realize default (fin.snoc (coe β x) b : _ β M)) : | |
S.is_elementary := | |
Ξ» n, S.subtype.is_elementary_of_exists htv | |
/-- Bundles a substructure satisfying the Tarski-Vaught test as an elementary substructure. -/ | |
@[simps] def to_elementary_substructure (S : L.substructure M) | |
(htv : β (n : β) (Ο : L.bounded_formula empty (n + 1)) (x : fin n β S) (a : M), | |
Ο.realize default (fin.snoc (coe β x) a : _ β M) β | |
β b : S, Ο.realize default (fin.snoc (coe β x) b : _ β M)) : | |
L.elementary_substructure M := | |
β¨S, Ξ» _, S.is_elementary_of_exists htvβ© | |
end substructure | |
end language | |
end first_order | |