@@ -376,11 +376,44 @@ lemma compose_injective {R S : V} (hR : Injective R) (hS : Injective S) : Inject
376376 rcases this
377377 exact hR x₁ x₂ y₁ hx₁y₁ hx₂y₂
378378
379+ /- This definition of value is adapted from NM's contribution to Metamath: https://us.metamath.org/mpeuni/fv3.html -/
380+ noncomputable def value (f x : V) := {z ∈ ⋃ˢ range f ; ∃ y, z ∈ y ∧ ⟨x, y⟩ₖ ∈ f}
381+
382+ /-- If `x` is in `domain f`, then `f ‘ x` is the value of `f` at `x`, else it is `∅`. -/
383+ scoped notation f:arg " ‘ " x:arg => value f x
384+
385+ def value.dfn : Semisentence ℒₛₑₜ 3 := f“v f x. ∀ z, z ∈ v ↔ z ∈ !sUnion.dfn (!range.dfn f) ∧ ∃ y, z ∈ y ∧ !kpair.dfn x y ∈ f”
386+
387+ instance value.defined : ℒₛₑₜ-function₂[V] value via value.dfn :=
388+ ⟨fun v ↦ by simp [dfn, value]; simp only [mem_ext_iff, mem_sep_iff]⟩
389+
390+ instance value.definable : ℒₛₑₜ-function₂[V] value := value.defined.to_definable
391+
392+ lemma value_mem_range {f x : V} {X Y : V} (hf : f ∈ Y ^ X) (hx : x ∈ X) : f ‘ x ∈ range f := by
393+ simp_all only [mem_function_iff, value, mem_range_iff]
394+ obtain ⟨hfleft, hfright⟩ := hf
395+ specialize hfright x hx
396+ obtain ⟨y, hy⟩ := ExistsUnique.exists hfright
397+ have h1 {w : V} : ⟨x, w⟩ₖ ∈ f → w = y := by
398+ intro h; exact hfright.unique h hy
399+ have h2 : y = {z ∈ ⋃ˢ range f ; ∃ y, z ∈ y ∧ ⟨x, y⟩ₖ ∈ f} := by
400+ ext z
401+ simp only [mem_sep_iff, mem_sUnion_iff, mem_range_iff]
402+ constructor <;> intro h <;> grind
403+ grind
404+
379405/-- Restricting the domain of a relation -/
380406noncomputable def restrict (R A : V) : V := R ∩ (A ×ˢ range R)
381407
382408/-- Restricting the domain of a relation -/
383- notation R:arg " ↾ " A:arg => restrict R A
409+ scoped notation R:arg " ↾ " A:arg => restrict R A
410+
411+ def restrict.dfn : Semisentence ℒₛₑₜ 3 := f“r R A. r = !inter.dfn R (!prod.dfn A (!range.dfn R))”
412+
413+ instance restrict.defined : ℒₛₑₜ-function₂[V] restrict via restrict.dfn :=
414+ ⟨fun v ↦ by simp [dfn, restrict]⟩
415+
416+ instance restrict.definable : ℒₛₑₜ-function₂[V] restrict := restrict.defined.to_definable
384417
385418lemma domain_restrict_eq (R A : V) : domain (R ↾ A) = domain R ∩ A := by
386419 ext z
@@ -397,7 +430,14 @@ lemma domain_restrict_eq (R A : V) : domain (R ↾ A) = domain R ∩ A := by
397430noncomputable def image (R A : V) : V := range (restrict R A)
398431
399432/-- Image of a set under a relation -/
400- notation R:arg " ” " A:arg => restrict R A
433+ scoped notation R:arg " “ " A:arg => image R A
434+
435+ def image.dfn : Semisentence ℒₛₑₜ 3 := f“B R A. B = !range.dfn (!restrict.dfn R A)”
436+
437+ instance image.defined : ℒₛₑₜ-function₂[V] image via image.dfn :=
438+ ⟨fun v ↦ by simp [dfn, image]⟩
439+
440+ instance image.definable : ℒₛₑₜ-function₂[V] image := image.defined.to_definable
401441
402442/-! ### Cardinality comparison -/
403443
0 commit comments