@@ -68,8 +68,9 @@ lemma map_map {ε ζ : Type*}
68
68
prod.map g g' (prod.map f f' x) = prod.map (g ∘ f) (g' ∘ f') x :=
69
69
rfl
70
70
71
- @[simp] theorem mk.inj_iff {a₁ a₂ : α} {b₁ b₂ : β} : (a₁, b₁) = (a₂, b₂) ↔ (a₁ = a₂ ∧ b₁ = b₂) :=
72
- ⟨prod.mk.inj, by cc⟩
71
+ variables {a a₁ a₂ : α} {b b₁ b₂ : β}
72
+
73
+ @[simp] lemma mk.inj_iff : (a₁, b₁) = (a₂, b₂) ↔ a₁ = a₂ ∧ b₁ = b₂ := ⟨prod.mk.inj, by cc⟩
73
74
74
75
lemma mk.inj_left {α β : Type *} (a : α) :
75
76
function.injective (prod.mk a : β → α × β) :=
@@ -79,6 +80,9 @@ lemma mk.inj_right {α β : Type*} (b : β) :
79
80
function.injective (λ a, prod.mk a b : α → α × β) :=
80
81
by { intros b₁ b₂ h, by simpa only [and_true, eq_self_iff_true, mk.inj_iff] using h }
81
82
83
+ lemma mk_inj_left : (a, b₁) = (a, b₂) ↔ b₁ = b₂ := (mk.inj_left _).eq_iff
84
+ lemma mk_inj_right : (a₁, b) = (a₂, b) ↔ a₁ = a₂ := (mk.inj_right _).eq_iff
85
+
82
86
lemma ext_iff {p q : α × β} : p = q ↔ p.1 = q.1 ∧ p.2 = q.2 :=
83
87
by rw [← @mk.eta _ _ p, ← @mk.eta _ _ q, mk.inj_iff]
84
88
@@ -148,6 +152,8 @@ lemma fst_eq_iff : ∀ {p : α × β} {x : α}, p.1 = x ↔ p = (x, p.2)
148
152
lemma snd_eq_iff : ∀ {p : α × β} {x : β}, p.2 = x ↔ p = (p.1 , x)
149
153
| ⟨a, b⟩ x := by simp
150
154
155
+ variables {r : α → α → Prop } {s : β → β → Prop } {x y : α × β}
156
+
151
157
theorem lex_def (r : α → α → Prop ) (s : β → β → Prop )
152
158
{p q : α × β} : prod.lex r s p q ↔ r p.1 q.1 ∨ p.1 = q.1 ∧ s p.2 q.2 :=
153
159
⟨λ h, by cases h; simp *,
@@ -157,6 +163,8 @@ theorem lex_def (r : α → α → Prop) (s : β → β → Prop)
157
163
by change a = c at e; subst e; exact lex.right _ h
158
164
end ⟩
159
165
166
+ lemma lex_iff : lex r s x y ↔ r x.1 y.1 ∨ x.1 = y.1 ∧ s x.2 y.2 := lex_def _ _
167
+
160
168
instance lex.decidable [decidable_eq α]
161
169
(r : α → α → Prop ) (s : β → β → Prop ) [decidable_rel r] [decidable_rel s] :
162
170
decidable_rel (prod.lex r s) :=
@@ -178,6 +186,9 @@ instance is_refl_right {r : α → α → Prop} {s : β → β → Prop} [is_ref
178
186
is_refl (α × β) (lex r s) :=
179
187
⟨lex.refl_right _ _⟩
180
188
189
+ instance is_irrefl [is_irrefl α r] [is_irrefl β s] : is_irrefl (α × β) (lex r s) :=
190
+ ⟨by rintro ⟨i, a⟩ (⟨_, _, h⟩ | ⟨_, h⟩); exact irrefl _ h⟩
191
+
181
192
@[trans] lemma lex.trans {r : α → α → Prop } {s : β → β → Prop } [is_trans α r] [is_trans β s] :
182
193
∀ {x y z : α × β}, prod.lex r s x y → prod.lex r s y z → prod.lex r s x z
183
194
| (x₁, x₂) (y₁, y₂) (z₁, z₂) (lex.left _ _ hxy₁) (lex.left _ _ hyz₁) :=
@@ -212,6 +223,15 @@ instance is_total_right {r : α → α → Prop} {s : β → β → Prop} [is_tr
212
223
{ exact or.inr (lex.left _ _ hji) }
213
224
end ⟩
214
225
226
+ instance is_trichotomous [is_trichotomous α r] [is_trichotomous β s] :
227
+ is_trichotomous (α × β) (lex r s) :=
228
+ ⟨λ ⟨i, a⟩ ⟨j, b⟩, begin
229
+ obtain hij | rfl | hji := trichotomous_of r i j,
230
+ { exact or.inl (lex.left _ _ hij) },
231
+ { exact (trichotomous_of s a b).imp3 (lex.right _) (congr_arg _) (lex.right _) },
232
+ { exact or.inr (or.inr $ lex.left _ _ hji) }
233
+ end ⟩
234
+
215
235
end prod
216
236
217
237
open prod
0 commit comments