@@ -2328,6 +2328,15 @@ end
2328
2328
@[simp] lemma image2_empty_left : image2 f ∅ t = ∅ := ext $ by simp
2329
2329
@[simp] lemma image2_empty_right : image2 f s ∅ = ∅ := ext $ by simp
2330
2330
2331
+ lemma nonempty.image2 : s.nonempty → t.nonempty → (image2 f s t).nonempty :=
2332
+ λ ⟨a, ha⟩ ⟨b, hb⟩, ⟨_, mem_image2_of_mem ha hb⟩
2333
+
2334
+ @[simp] lemma image2_nonempty_iff : (image2 f s t).nonempty ↔ s.nonempty ∧ t.nonempty :=
2335
+ ⟨λ ⟨_, a, b, ha, hb, _⟩, ⟨⟨a, ha⟩, b, hb⟩, λ h, h.1 .image2 h.2 ⟩
2336
+
2337
+ @[simp] lemma image2_eq_empty_iff : image2 f s t = ∅ ↔ s = ∅ ∨ t = ∅ :=
2338
+ by simp_rw [←not_nonempty_iff_eq_empty, image2_nonempty_iff, not_and_distrib]
2339
+
2331
2340
lemma image2_inter_subset_left : image2 f (s ∩ s') t ⊆ image2 f s t ∩ image2 f s' t :=
2332
2341
by { rintro _ ⟨a, b, ⟨h1a, h2a⟩, hb, rfl⟩, split; exact ⟨_, _, ‹_›, ‹_›, rfl⟩ }
2333
2342
@@ -2360,6 +2369,9 @@ def image3 (g : α → β → γ → δ) (s : set α) (t : set β) (u : set γ)
2360
2369
@[simp] lemma mem_image3 : d ∈ image3 g s t u ↔ ∃ a b c, a ∈ s ∧ b ∈ t ∧ c ∈ u ∧ g a b c = d :=
2361
2370
iff.rfl
2362
2371
2372
+ lemma image3_mono (hs : s ⊆ s') (ht : t ⊆ t') (hu : u ⊆ u') : image3 g s t u ⊆ image3 g s' t' u' :=
2373
+ λ x, Exists₃.imp $ λ a b c ⟨ha, hb, hc, hx⟩, ⟨hs ha, ht hb, hu hc, hx⟩
2374
+
2363
2375
@[congr] lemma image3_congr (h : ∀ (a ∈ s) (b ∈ t) (c ∈ u), g a b c = g' a b c) :
2364
2376
image3 g s t u = image3 g' s t u :=
2365
2377
by { ext x,
@@ -2385,11 +2397,6 @@ begin
2385
2397
{ rintro ⟨a, b, c, ha, hb, hc, rfl⟩, refine ⟨a, _, ha, ⟨b, c, hb, hc, rfl⟩, rfl⟩ }
2386
2398
end
2387
2399
2388
- lemma image2_assoc {ε'} {f : δ → γ → ε} {g : α → β → δ} {f' : α → ε' → ε} {g' : β → γ → ε'}
2389
- (h_assoc : ∀ a b c, f (g a b) c = f' a (g' b c)) :
2390
- image2 f (image2 g s t) u = image2 f' s (image2 g' t u) :=
2391
- by simp only [image2_image2_left, image2_image2_right, h_assoc]
2392
-
2393
2400
lemma image_image2 (f : α → β → γ) (g : γ → δ) :
2394
2401
g '' image2 f s t = image2 (λ a b, g (f a b)) s t :=
2395
2402
begin
@@ -2424,8 +2431,38 @@ by simp [nonempty_def.mp h, ext_iff]
2424
2431
@[simp] lemma image2_right (h : s.nonempty) : image2 (λ x y, y) s t = t :=
2425
2432
by simp [nonempty_def.mp h, ext_iff]
2426
2433
2427
- lemma nonempty.image2 (hs : s.nonempty) (ht : t.nonempty) : (image2 f s t).nonempty :=
2428
- by { cases hs with a ha, cases ht with b hb, exact ⟨f a b, ⟨a, b, ha, hb, rfl⟩⟩ }
2434
+ lemma image2_assoc {ε'} {f : δ → γ → ε} {g : α → β → δ} {f' : α → ε' → ε} {g' : β → γ → ε'}
2435
+ (h_assoc : ∀ a b c, f (g a b) c = f' a (g' b c)) :
2436
+ image2 f (image2 g s t) u = image2 f' s (image2 g' t u) :=
2437
+ by simp only [image2_image2_left, image2_image2_right, h_assoc]
2438
+
2439
+ lemma image2_comm {g : β → α → γ} (h_comm : ∀ a b, f a b = g b a) : image2 f s t = image2 g t s :=
2440
+ (image2_swap _ _ _).trans $ by simp_rw h_comm
2441
+
2442
+ lemma image2_left_comm {δ'} {f : α → δ → ε} {g : β → γ → δ} {f' : α → γ → δ'} {g' : β → δ' → ε}
2443
+ (h_left_comm : ∀ a b c, f a (g b c) = g' b (f' a c)) :
2444
+ image2 f s (image2 g t u) = image2 g' t (image2 f' s u) :=
2445
+ by { rw [image2_swap f', image2_swap f], exact image2_assoc (λ _ _ _, h_left_comm _ _ _) }
2446
+
2447
+ lemma image2_right_comm {δ'} {f : δ → γ → ε} {g : α → β → δ} {f' : α → γ → δ'} {g' : δ' → β → ε}
2448
+ (h_right_comm : ∀ a b c, f (g a b) c = g' (f' a c) b) :
2449
+ image2 f (image2 g s t) u = image2 g' (image2 f' s u) t :=
2450
+ by { rw [image2_swap g, image2_swap g'], exact image2_assoc (λ _ _ _, h_right_comm _ _ _) }
2451
+
2452
+ lemma image_image2_distrib {α' β'} {g : γ → δ} {f' : α' → β' → δ} {g₁ : α → α'} {g₂ : β → β'}
2453
+ (h_distrib : ∀ a b, g (f a b) = f' (g₁ a) (g₂ b)) :
2454
+ (image2 f s t).image g = image2 f' (s.image g₁) (t.image g₂) :=
2455
+ by simp_rw [image_image2, image2_image_left, image2_image_right, h_distrib]
2456
+
2457
+ lemma image_image2_distrib_left {α'} {g : γ → δ} {f' : α' → β → δ} {g' : α → α'}
2458
+ (h_distrib : ∀ a b, g (f a b) = f' (g' a) b) :
2459
+ (image2 f s t).image g = image2 f' (s.image g') t :=
2460
+ (image_image2_distrib h_distrib).trans $ by rw image_id'
2461
+
2462
+ lemma image_image2_distrib_right {β'} {g : γ → δ} {f' : α → β' → δ} {g' : β → β'}
2463
+ (h_distrib : ∀ a b, g (f a b) = f' a (g' b)) :
2464
+ (image2 f s t).image g = image2 f' s (t.image g') :=
2465
+ (image_image2_distrib h_distrib).trans $ by rw image_id'
2429
2466
2430
2467
end n_ary_image
2431
2468
0 commit comments