(* Permutation matrix *)

Definition perm_mx n s : 'M_n := row_perm s 1%:M.Definition tperm_mx n i1 i2 : 'M_n := perm_mx (tperm i1 i2).

(* Specifications: *)
Lemma col_permE m n s (A : 'M_(m, n)) : col_perm s A = A *m perm_mx s^-1.
Lemma row_permE m n s (A : 'M_(m, n)) : row_perm s A = perm_mx s *m A.
Lemma xcolE m n j1 j2 (A : 'M_(m, n)) : xcol j1 j2 A = A *m tperm_mx j1 j2.
Lemma xrowE m n i1 i2 (A : 'M_(m, n)) : xrow i1 i2 A = tperm_mx i1 i2 *m A.
Lemma tr_tperm_mx n i1 i2 : (tperm_mx i1 i2)^T = tperm_mx i1 i2 :> 'M_n.
Lemma perm_mx1 n : perm_mx 1 = 1%:M :> 'M_n.
Lemma is_perm_mxP n (A : 'M_n) : reflect (exists s, A = perm_mx s) (is_perm_mx A).
Lemma is_perm_mx1 n : is_perm_mx (1%:M : 'M_n).
Lemma is_perm_mxMl n (A B : 'M_n) : is_perm_mx A -> is_perm_mx (A *m B) = is_perm_mx B.
Lemma is_perm_mx_tr n (A : 'M_n) : is_perm_mx A^T = is_perm_mx A.
Lemma is_perm_mxMr n (A B : 'M_n) : is_perm_mx B -> is_perm_mx (A *m B) = is_perm_mx A.