@@ -40,7 +40,8 @@ open equiv equiv.perm finset function
40
40
namespace matrix
41
41
open_locale matrix big_operators
42
42
43
- variables {n : Type u} [decidable_eq n] [fintype n] {R : Type v} [comm_ring R]
43
+ variables {m n : Type u} [decidable_eq n] [fintype n] [decidable_eq m] [fintype m]
44
+ variables {R : Type v} [comm_ring R]
44
45
45
46
local notation `ε ` σ:max := ((sign σ : ℤ ) : R)
46
47
75
76
simp [det, card_eq_zero.mp h, perm_eq],
76
77
end
77
78
79
+ /-- If `n` has only one element, the determinant of an `n` by `n` matrix is just that element.
80
+ Although `unique` implies `decidable_eq` and `fintype`, the instances might
81
+ not be syntactically equal. Thus, we need to fill in the args explicitly. -/
82
+ @[simp]
83
+ lemma det_unique {n : Type *} [unique n] [decidable_eq n] [fintype n] (A : matrix n n R) :
84
+ det A = A (default n) (default n) :=
85
+ by simp [det, univ_unique]
86
+
87
+ lemma det_eq_elem_of_card_eq_one {A : matrix n n R} (h : fintype.card n = 1 ) (k : n) :
88
+ det A = A k k :=
89
+ begin
90
+ have h1 : (univ : finset (perm n)) = {1 },
91
+ { apply univ_eq_singleton_of_card_one (1 : perm n),
92
+ simp [card_univ, fintype.card_perm, h] },
93
+ have h2 := univ_eq_singleton_of_card_one k h,
94
+ simp [det, h1, h2],
95
+ end
96
+
78
97
lemma det_mul_aux {M N : matrix n n R} {p : n → n} (H : ¬bijective p) :
79
98
∑ σ : perm n, (ε σ) * ∏ x, (M (σ x) (p x) * N (p x) x) = 0 :=
80
99
begin
@@ -344,4 +363,78 @@ begin
344
363
exact hkx }
345
364
end
346
365
366
+ /-- The determinant of a 2x2 block matrix with the lower-left block equal to zero is the product of
367
+ the determinants of the diagonal blocks. For the generalization to any number of blocks, see
368
+ `matrix.upper_block_triangular_det`. -/
369
+ lemma upper_two_block_triangular_det (A : matrix m m R) (B : matrix m n R) (D : matrix n n R) :
370
+ (matrix.from_blocks A B 0 D).det = A.det * D.det :=
371
+ begin
372
+ unfold det,
373
+ rw sum_mul_sum,
374
+ let preserving_A : finset (perm (m ⊕ n)) :=
375
+ univ.filter (λ σ, ∀ x, ∃ y, sum.inl y = (σ (sum.inl x))),
376
+ simp_rw univ_product_univ,
377
+ have mem_preserving_A : ∀ {σ : perm (m ⊕ n)},
378
+ σ ∈ preserving_A ↔ ∀ x, ∃ y, sum.inl y = σ (sum.inl x) :=
379
+ λ σ, mem_filter.trans ⟨λ h, h.2 , λ h, ⟨mem_univ _, h⟩⟩,
380
+ rw ← sum_subset (subset_univ preserving_A) _,
381
+ rw (sum_bij (λ (σ : perm m × perm n) _, equiv.sum_congr σ.fst σ.snd) _ _ _ _).symm,
382
+ { intros a ha,
383
+ rw mem_preserving_A,
384
+ intro x,
385
+ use a.fst x,
386
+ simp },
387
+ { simp only [forall_prop_of_true, prod.forall, mem_univ],
388
+ intros σ₁ σ₂,
389
+ rw fintype.prod_sum_type,
390
+ simp_rw [equiv.sum_congr_apply, sum.map_inr, sum.map_inl, from_blocks_apply₁₁,
391
+ from_blocks_apply₂₂],
392
+ have hr : ∀ (a b c d : R), (a * b) * (c * d) = a * c * (b * d), { intros, ac_refl },
393
+ rw hr,
394
+ congr,
395
+ norm_cast,
396
+ rw sign_sum_congr },
397
+ { intros σ₁ σ₂ h₁ h₂,
398
+ dsimp only [],
399
+ intro h,
400
+ have h2 : ∀ x, perm.sum_congr σ₁.fst σ₁.snd x = perm.sum_congr σ₂.fst σ₂.snd x,
401
+ { intro x, exact congr_fun (congr_arg to_fun h) x },
402
+ simp only [sum.map_inr, sum.map_inl, perm.sum_congr_apply, sum.forall] at h2,
403
+ ext,
404
+ { exact h2.left x },
405
+ { exact h2.right x }},
406
+ { intros σ hσ,
407
+ have h1 : ∀ (x : m ⊕ n), (∃ (a : m), sum.inl a = x) → (∃ (a : m), sum.inl a = σ x),
408
+ { rintros x ⟨a, ha⟩,
409
+ rw ← ha,
410
+ exact (@mem_preserving_A σ).mp hσ a },
411
+ have h2 : ∀ (x : m ⊕ n), (∃ (b : n), sum.inr b = x) → (∃ (b : n), sum.inr b = σ x),
412
+ { rintros x ⟨b, hb⟩,
413
+ rw ← hb,
414
+ exact (perm_on_inl_iff_perm_on_inr σ).mp ((@mem_preserving_A σ).mp hσ) b },
415
+ let σ₁' := subtype_perm_of_fintype σ h1,
416
+ let σ₂' := subtype_perm_of_fintype σ h2,
417
+ let σ₁ := perm_congr (equiv.set.range (@sum.inl m n) sum.injective_inl).symm σ₁',
418
+ let σ₂ := perm_congr (equiv.set.range (@sum.inr m n) sum.injective_inr).symm σ₂',
419
+ use [⟨σ₁, σ₂⟩, finset.mem_univ _],
420
+ ext,
421
+ cases x with a b,
422
+ { rw [equiv.sum_congr_apply, sum.map_inl, perm_congr_apply, equiv.symm_symm,
423
+ set.apply_range_symm (@sum.inl m n)],
424
+ erw subtype_perm_apply,
425
+ rw [set.range_apply, subtype.coe_mk, subtype.coe_mk] },
426
+ { rw [equiv.sum_congr_apply, sum.map_inr, perm_congr_apply, equiv.symm_symm,
427
+ set.apply_range_symm (@sum.inr m n)],
428
+ erw subtype_perm_apply,
429
+ rw [set.range_apply, subtype.coe_mk, subtype.coe_mk] }},
430
+ { intros σ h0 hσ,
431
+ obtain ⟨a, ha⟩ := not_forall.mp ((not_congr (@mem_preserving_A σ)).mp hσ),
432
+ generalize hx : σ (sum.inl a) = x,
433
+ cases x with a2 b,
434
+ { have hn := (not_exists.mp ha) a2,
435
+ exact absurd hx.symm hn },
436
+ { rw [finset.prod_eq_zero (finset.mem_univ (sum.inl a)), mul_zero],
437
+ rw [hx, from_blocks_apply₂₁], refl }}
438
+ end
439
+
347
440
end matrix
0 commit comments