Skip to content

Commit cbe86e0

Browse files
committed
feat(ModelTheory/Complexity): Preservation theorems for atomic and quantifier-free formulas (#16108)
Adds a bit of extra API for quantifier-free formulas Proves some preservation theorems of atomic and quantifier-free formulas with respect to certain classes of maps, including embeddings
1 parent b5f7e1c commit cbe86e0

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

Mathlib/ModelTheory/Complexity.lean

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,31 @@ theorem IsAtomic.isQF {φ : L.BoundedFormula α n} : IsAtomic φ → IsQF φ :=
7979
theorem isQF_bot : IsQF (⊥ : L.BoundedFormula α n) :=
8080
IsQF.falsum
8181

82-
theorem IsQF.not {φ : L.BoundedFormula α n} (h : IsQF φ) : IsQF φ.not :=
82+
namespace IsQF
83+
84+
theorem not {φ : L.BoundedFormula α n} (h : IsQF φ) : IsQF φ.not :=
8385
h.imp isQF_bot
8486

85-
theorem IsQF.relabel {m : ℕ} {φ : L.BoundedFormula α m} (h : φ.IsQF) (f : α → β ⊕ (Fin n)) :
87+
theorem top : IsQF (⊤ : L.BoundedFormula α n) := isQF_bot.not
88+
89+
theorem sup {φ ψ : L.BoundedFormula α n} (hφ : IsQF φ) (hψ : IsQF ψ) : IsQF (φ ⊔ ψ) :=
90+
hφ.not.imp hψ
91+
92+
theorem inf {φ ψ : L.BoundedFormula α n} (hφ : IsQF φ) (hψ : IsQF ψ) : IsQF (φ ⊓ ψ) :=
93+
(hφ.imp hψ.not).not
94+
95+
protected theorem relabel {m : ℕ} {φ : L.BoundedFormula α m} (h : φ.IsQF) (f : α → β ⊕ (Fin n)) :
8696
(φ.relabel f).IsQF :=
8797
IsQF.recOn h isQF_bot (fun h => (h.relabel f).isQF) fun _ _ h1 h2 => h1.imp h2
8898

89-
theorem IsQF.liftAt {k m : ℕ} (h : IsQF φ) : (φ.liftAt k m).IsQF :=
99+
protected theorem liftAt {k m : ℕ} (h : IsQF φ) : (φ.liftAt k m).IsQF :=
90100
IsQF.recOn h isQF_bot (fun ih => ih.liftAt.isQF) fun _ _ ih1 ih2 => ih1.imp ih2
91101

92-
theorem IsQF.castLE {h : l ≤ n} (hφ : IsQF φ) : (φ.castLE h).IsQF :=
102+
protected theorem castLE {h : l ≤ n} (hφ : IsQF φ) : (φ.castLE h).IsQF :=
93103
IsQF.recOn hφ isQF_bot (fun ih => ih.castLE.isQF) fun _ _ ih1 ih2 => ih1.imp ih2
94104

105+
end IsQF
106+
95107
theorem not_all_isQF (φ : L.BoundedFormula α (n + 1)) : ¬φ.all.IsQF := fun con => by
96108
cases' con with _ con
97109
exact φ.not_all_isAtomic con
@@ -315,6 +327,41 @@ theorem induction_on_exists_not {P : ∀ {m}, L.BoundedFormula α m → Prop} (
315327
(fun {_ φ} hφ => (hse φ.all_semanticallyEquivalent_not_ex_not).2 (hnot (hex (hnot hφ))))
316328
(fun {_ _} => hex) fun {_ _ _} => hse
317329

330+
section Preservation
331+
332+
variable {M : Type*} [L.Structure M] {N : Type*} [L.Structure N]
333+
variable {F : Type*} [FunLike F M N]
334+
335+
lemma IsAtomic.realize_comp_of_injective {φ : L.BoundedFormula α n} (hA : φ.IsAtomic)
336+
[L.HomClass F M N] {f : F} (hInj : Function.Injective f) {v : α → M} {xs : Fin n → M} :
337+
φ.Realize v xs → φ.Realize (f ∘ v) (f ∘ xs) := by
338+
induction hA with
339+
| equal t₁ t₂ => simp only [realize_bdEqual, ← Sum.comp_elim, HomClass.realize_term, hInj.eq_iff,
340+
imp_self]
341+
| rel R ts =>
342+
simp only [realize_rel, ← Sum.comp_elim, HomClass.realize_term]
343+
exact HomClass.map_rel f R (fun i => Term.realize (Sum.elim v xs) (ts i))
344+
345+
lemma IsAtomic.realize_comp {φ : L.BoundedFormula α n} (hA : φ.IsAtomic)
346+
[EmbeddingLike F M N] [L.HomClass F M N] (f : F) {v : α → M} {xs : Fin n → M} :
347+
φ.Realize v xs → φ.Realize (f ∘ v) (f ∘ xs) :=
348+
hA.realize_comp_of_injective (EmbeddingLike.injective f)
349+
350+
lemma IsQF.realize_embedding {φ : L.BoundedFormula α n} (hQF : φ.IsQF)
351+
[EmbeddingLike F M N] [L.StrongHomClass F M N] (f : F) {v : α → M} {xs : Fin n → M} :
352+
φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
353+
induction hQF with
354+
| falsum => rfl
355+
| of_isAtomic hA => induction hA with
356+
| equal t₁ t₂ => simp only [realize_bdEqual, ← Sum.comp_elim, HomClass.realize_term,
357+
(EmbeddingLike.injective f).eq_iff]
358+
| rel R ts =>
359+
simp only [realize_rel, ← Sum.comp_elim, HomClass.realize_term]
360+
exact StrongHomClass.map_rel f R (fun i => Term.realize (Sum.elim v xs) (ts i))
361+
| imp _ _ ihφ ihψ => simp only [realize_imp, ihφ, ihψ]
362+
363+
end Preservation
364+
318365
end BoundedFormula
319366

320367
theorem Formula.isAtomic_graph (f : L.Functions n) : (Formula.graph f).IsAtomic :=

0 commit comments

Comments
 (0)