Datasets:
AI4M
/

text
stringlengths
0
3.34M
/- Copyright (c) 2022 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jesse Michael Han, Floris van Doorn -/ import model_theory.basic /-! #Elementary Maps Between First-Order Structures ## Main Definitions * A `first_order.language.elementary_embedding` is an embedding that commutes with the realizations of formulas. * -/ 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_formula N φ (to_fun ∘ x) ↔ realize_formula M φ x . obviously) localized "notation A ` ↪ₑ[`:25 L `] ` B := L.elementary_embedding A B" in first_order variables {L} {M} {N} namespace elementary_embedding instance has_coe_to_fun : has_coe_to_fun (M ↪ₑ[L] N) (λ _, M → N) := ⟨λ f, f.to_fun⟩ @[simp] lemma map_formula (f : M ↪ₑ[L] N) {α : Type} [fintype α] (φ : L.formula α) (x : α → M) : realize_formula N φ (f ∘ x) ↔ realize_formula M φ x := begin have g := fintype.equiv_fin α, have h := f.map_formula' (φ.relabel g) (x ∘ g.symm), rw [realize_formula_relabel, realize_formula_relabel, function.comp.assoc x g.symm g, g.symm_comp_self, function.comp.right_id] at h, rw [← h, iff_eq_eq], congr, ext y, simp, end @[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.snoc x (fun_map f x)), rw [realize_graph, fin.comp_snoc, realize_graph] at h, rw [eq_comm, h] end @[simp] lemma map_const (φ : M ↪ₑ[L] N) (c : L.const) : φ c = c := (φ.map_fun c fin.elim0).trans (congr rfl (funext fin.elim0)) @[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 (bd_rel r (var ∘ sum.inl)) x, exact h end @[simp] lemma injective (φ : M ↪ₑ[L] N) : function.injective φ := begin intros x y, have h := φ.map_formula (formula.equal (var 0) (var 1) : L.formula (fin 2)) (λ i, if i = 0 then x else y), rw [realize_equal, realize_equal] at h, simp only [nat.one_ne_zero, realize_term, fin.one_eq_zero_iff, if_true, eq_self_iff_true, function.comp_app, if_false] at h, exact h.1, end /-- 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 | f g h := begin cases f, cases g, simp only, ext x, exact function.funext_iff.1 h x, end @[ext] lemma ext ⦃f g : M ↪ₑ[L] N⦄ (h : ∀ x, f x = g x) : f = g := coe_injective (funext h) lemma ext_iff {f g : M ↪ₑ[L] N} : f = g ↔ ∀ x, f x = g x := ⟨λ h x, h ▸ rfl, λ h, ext h⟩ 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 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 namespace substructure /-- 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_formula M φ (coe ∘ x) ↔ realize_formula S φ 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⟩ @[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, begin rw formula at φ, rw [realize_formula, realize_formula, realize_bounded_formula_top, iff_eq_eq], exact congr rfl (funext fin_zero_elim), end⟩⟩ 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 end elementary_substructure end language end first_order
module Database import Schema import Decidable.Equality public export data DB : String -> Type where MkDB : (dbFile : String) -> (dbTables : List (String, Schema)) -> DB dbFile %name DB db public export data HasTable : List (String, Schema) -> String -> Schema -> Type where Here : HasTable ((name, s)::ts) name s There : HasTable ts name s -> HasTable ((name',s')::ts) name s
Set Implicit Arguments. Require Import List. Section NEList. Variable A:Type. Definition nelist := (A * list A)%type. Definition single x : nelist := (x, nil). Definition append (l1 l2: nelist) : nelist := let (x, xs) := l1 in let (y, ys) := l2 in (x, xs ++ cons y ys). Definition hd (l:nelist) : A := let (x, _) := l in x. Definition tl (l:nelist) : list A := let (_, xs) := l in xs. End NEList.
lemma uniformly_continuous_on_closure: fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" assumes ucont: "uniformly_continuous_on S f" and cont: "continuous_on (closure S) f" shows "uniformly_continuous_on (closure S) f"
Formal statement is: lemma Lim_null: fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" shows "(f \<longlongrightarrow> l) net \<longleftrightarrow> ((\<lambda>x. f(x) - l) \<longlongrightarrow> 0) net" Informal statement is: A net $f$ converges to $l$ if and only if the net $f - l$ converges to $0$.
Formal statement is: lemma complete_closed_subset: fixes S :: "'a::metric_space set" assumes "closed S" and "S \<subseteq> t" and "complete t" shows "complete S" Informal statement is: If $S$ is a closed subset of a complete metric space $t$, then $S$ is complete.
[STATEMENT] lemma mem_cnb_minus: "x \<in> set l ==> cnb l = crypt_nb x + (cnb l - crypt_nb x)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. x \<in> set l \<Longrightarrow> cnb l = crypt_nb x + (cnb l - crypt_nb x) [PROOF STEP] by (induct l, auto)
import basic_defs_world.level1 -- hide /- Axiom : A set A is the neighborhood of a point x if there is an open U such that x ∈ U ⊆ A. is_neighborhood : ∃ U, is_open U ∧ x ∈ U ∧ U ⊆ A -/ /- Axiom : A point x is an interior point of A if A is a neighborhood of x. is_interior_point : is_neighborhood x A -/ /- Axiom : The interior of a set A is the set of all its interior points. interior := { x : X | is_interior_point x A } -/ /- In this world we will end up having three alternative definitions of the interior of a set. This will be very useful, because at any point we will be able to choose the one that better fits our needs. First of all we need to figure out what properties does the interior of an arbitrary set have... So we start with an easy one: # Level 1: The interior is contained in the original set -/ variables {X : Type} -- hide variables [topological_space X] (x : X) (A : set X) -- hide namespace topological_space -- hide @[simp] -- hide /- Lemma The interior of any set A is contained in the set A. -/ lemma interior_is_subset: interior A ⊆ A := begin rintros x ⟨_, _⟩, tauto, end end topological_space -- hide
/- various properties about pfun and roption -/ import basic data.pfun open set universes u v w variables {α : Type u} {β : Type v} {γ : Type w} {n : ℕ} namespace roption def compatible (o₁ o₂ : roption α) : Prop := ∀{{x y}}, x ∈ o₁ → y ∈ o₂ → x = y namespace compatible variables {o₁ o₂ o₃ : roption α} infix ` =. `:50 := roption.compatible protected lemma compatible_of_eq {x y : α} (h : x = y) : compatible (roption.some x) (roption.some y) := omitted protected lemma symm (h : o₁ =. o₂) : o₂ =. o₁ := λx y hx hy, (h hy hx).symm -- note: it is not transitive, probably good to use different notation end compatible end roption namespace pfun protected def empty (α β : Type*) : α →. β := λx, roption.none protected def id : α →. α := pfun.lift id protected def comp (g : β →. γ) (f : α →. β) : α →. γ := λx, roption.bind (f x) g infix ` ∘. `:90 := pfun.comp def to_subtype (p : α → Prop) : α →. subtype p := λx, ⟨p x, λ h, ⟨x, h⟩⟩ def compatible (f g : α →. β) : Prop := ∀x, f x =. g x namespace compatible variables {f g h : α →. β} infix ` ~. `:50 := pfun.compatible protected lemma symm (h : f ~. g) : g ~. f := λx, (h x).symm -- note: it is not transitive, probably good to use different notation end compatible def restrict' (f : α →. β) (p : set α) : α →. β := pfun.restrict f (inter_subset_right p (dom f)) end pfun /- a partial equivalence -/ open pfun structure pequiv (α : Type*) (β : Type*) := (to_fun : α →. β) (inv_fun : β →. α) (dom_inv_fun : ∀{{x}} (hx : x ∈ dom to_fun), to_fun.fn x hx ∈ dom inv_fun) (dom_to_fun : ∀{{y}} (hy : y ∈ dom inv_fun), inv_fun.fn y hy ∈ dom to_fun) (left_inv : inv_fun ∘. to_fun ~. pfun.id) (right_inv : to_fun ∘. inv_fun ~. pfun.id) infixr ` ≃. `:25 := pequiv namespace equiv def to_pequiv (e : α ≃ β) : α ≃. β := ⟨e.to_fun, e.inv_fun, λx hx, trivial, λy hy, trivial, omitted, omitted⟩ def rfl : α ≃ α := equiv.refl α end equiv namespace pequiv instance : has_coe (α ≃. β) (α →. β) := ⟨pequiv.to_fun⟩ protected def rfl : α ≃. α := equiv.rfl.to_pequiv protected def refl (α) : α ≃. α := pequiv.rfl protected def symm (e : α ≃. β) : β ≃. α := ⟨e.inv_fun, e.to_fun, e.dom_to_fun, e.dom_inv_fun, e.right_inv, e.left_inv⟩ protected def trans (e₁ : α ≃. β) (e₂ : β ≃. γ) : α ≃. γ := ⟨e₂.to_fun ∘. e₁.to_fun, e₁.inv_fun ∘. e₂.inv_fun, omitted, omitted, omitted, omitted⟩ def restrict' (e : α ≃. β) (p : set α) : α ≃. β := ⟨e.to_fun.restrict' p, e.inv_fun.restrict' (e.to_fun.image p), omitted, omitted, omitted, omitted⟩ def subtype_pequiv (p : α → Prop) : subtype p ≃. α := ⟨pfun.lift subtype.val, to_subtype p, omitted, omitted, omitted, omitted⟩ end pequiv