Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 710fe04

Browse files
feat(model_theory/order): Defines ordered languages and structures (#13088)
Defines ordered languages and ordered structures Defines the theories of pre-, partial, and linear orders, shows they are modeled by the respective structures. Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
1 parent 7340720 commit 710fe04

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

src/model_theory/order.lean

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/-
2+
Copyright (c) 2022 Aaron Anderson. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Aaron Anderson
5+
-/
6+
import model_theory.semantics
7+
8+
/-!
9+
# Ordered First-Ordered Structures
10+
This file defines ordered first-order languages and structures, as well as their theories.
11+
12+
## Main Definitions
13+
* `first_order.language.order` is the language consisting of a single relation representing `≤`.
14+
* `first_order.language.order_Structure` is the structure on an ordered type, assigning the symbol
15+
representing `≤` to the actual relation `≤`.
16+
* `first_order.language.is_ordered` points out a specific symbol in a language as representing `≤`.
17+
* `first_order.language.is_ordered_structure` indicates that a structure over a
18+
* `first_order.language.linear_order` and similar define the theories of preorders, partial orders,
19+
and linear orders.
20+
21+
## Main Results
22+
* `partial_order`s model the theory of partial orders, and `linear_order`s model the theory of
23+
linear orders.
24+
25+
-/
26+
27+
universes u v w
28+
29+
namespace first_order
30+
namespace language
31+
open Structure
32+
33+
variables {L : language.{u v}} {α : Type w} {n : ℕ}
34+
35+
/-- The language consisting of a single relation representing `≤`. -/
36+
protected def order : language :=
37+
language.mk₂ empty empty empty empty unit
38+
39+
instance order.Structure [has_le α] : language.order.Structure α :=
40+
Structure.mk₂ empty.elim empty.elim empty.elim empty.elim (λ _, (≤))
41+
42+
instance : is_relational (language.order) := language.is_relational_mk₂
43+
44+
instance : subsingleton (language.order.relations n) :=
45+
language.subsingleton_mk₂_relations
46+
47+
/-- A language is ordered if it has a symbol representing `≤`. -/
48+
class is_ordered (L : language.{u v}) := (le_symb : L.relations 2)
49+
50+
export is_ordered (le_symb)
51+
52+
section is_ordered
53+
54+
variables [is_ordered L]
55+
56+
/-- Joins two terms `t₁, t₂` in a formula representing `t₁ ≤ t₂`. -/
57+
def term.le (t₁ t₂ : L.term (α ⊕ fin n)) : L.bounded_formula α n :=
58+
le_symb.bounded_formula₂ t₁ t₂
59+
60+
variable (L)
61+
62+
/-- The language homomorphism sending the unique symbol `≤` of `language.order` to `≤` in an ordered
63+
language. -/
64+
def order_Lhom : language.order →ᴸ L :=
65+
Lhom.mk₂ empty.elim empty.elim empty.elim empty.elim (λ _, le_symb)
66+
67+
end is_ordered
68+
69+
instance : is_ordered language.order := ⟨unit.star⟩
70+
71+
@[simp]
72+
lemma order_Lhom_order : order_Lhom language.order = Lhom.id language.order :=
73+
Lhom.funext (subsingleton.elim _ _) (subsingleton.elim _ _)
74+
75+
instance : is_ordered (L.sum language.order) := ⟨sum.inr is_ordered.le_symb⟩
76+
77+
/-- The theory of preorders. -/
78+
protected def Theory.preorder : language.order.Theory :=
79+
{le_symb.reflexive, le_symb.transitive}
80+
81+
/-- The theory of partial orders. -/
82+
protected def Theory.partial_order : language.order.Theory :=
83+
{le_symb.reflexive, le_symb.antisymmetric, le_symb.transitive}
84+
85+
/-- The theory of linear orders. -/
86+
protected def Theory.linear_order : language.order.Theory :=
87+
{le_symb.reflexive, le_symb.antisymmetric, le_symb.transitive, le_symb.total}
88+
89+
variables (L α)
90+
91+
/-- A structure is ordered if its language has a `≤` symbol whose interpretation is -/
92+
def is_ordered_structure [is_ordered L] [has_le α] [L.Structure α] : Prop :=
93+
Lhom.is_expansion_on (order_Lhom L) α
94+
95+
instance is_ordered_structure_has_le [has_le α] :
96+
is_ordered_structure language.order α :=
97+
begin
98+
rw [is_ordered_structure, order_Lhom_order],
99+
exact Lhom.id_is_expansion_on α,
100+
end
101+
102+
instance model_preorder [preorder α] :
103+
α ⊨ Theory.preorder :=
104+
begin
105+
simp only [Theory.preorder, Theory.model_iff, set.mem_insert_iff, set.mem_singleton_iff,
106+
forall_eq_or_imp, relations.realize_reflexive, rel_map_apply₂, forall_eq,
107+
relations.realize_transitive],
108+
exact ⟨le_refl, λ _ _ _, le_trans⟩
109+
end
110+
111+
instance model_partial_order [partial_order α] :
112+
α ⊨ Theory.partial_order :=
113+
begin
114+
simp only [Theory.partial_order, Theory.model_iff, set.mem_insert_iff, set.mem_singleton_iff,
115+
forall_eq_or_imp, relations.realize_reflexive, rel_map_apply₂, relations.realize_antisymmetric,
116+
forall_eq, relations.realize_transitive],
117+
exact ⟨le_refl, λ _ _, le_antisymm, λ _ _ _, le_trans⟩,
118+
end
119+
120+
instance model_linear_order [linear_order α] :
121+
α ⊨ Theory.linear_order :=
122+
begin
123+
simp only [Theory.linear_order, Theory.model_iff, set.mem_insert_iff, set.mem_singleton_iff,
124+
forall_eq_or_imp, relations.realize_reflexive, rel_map_apply₂, relations.realize_antisymmetric,
125+
relations.realize_transitive, forall_eq, relations.realize_total],
126+
exact ⟨le_refl, λ _ _, le_antisymm, λ _ _ _, le_trans, le_total⟩,
127+
end
128+
129+
end language
130+
end first_order

0 commit comments

Comments
 (0)