playground/coq/mathcomp/matrix-egs.v

28 lines
711 B
Coq

From mathcomp Require Import all_ssreflect all_algebra.
Open Scope ring_scope.
(* https://coq.zulipchat.com/#narrow/stream/237664-math-comp-users/topic/A.20matrix.20mul.20proof *)
Goal
let mt: 'M[bool]_(2,3) :=
\matrix_(i<2, j<3) (if i == 0 && (j == 1) :> nat then 1 else 0) in
let rw := (\row_i (if i == 0 then 1 else 0)) *m mt in
(\sum_j (rw 0 j)) == 1.
Proof.
rewrite //=.
by do ![rewrite !big_ord_recl !big_ord0 !mxE].
Qed.
Lemma constMxElem {V: Type} (rows cols: nat) (v: V):
forall (i: 'I_rows) (j: 'I_cols),
(((const_mx v):'M_(rows, cols)) i j) = v.
Proof.
move=> i j.
rewrite /const_mx unlock.
rewrite /fun_of_matrix /=.
by rewrite ffunE.
Qed.
Check castmx.
Print erefl.