SSL matrices.pvs
Interaktion und PortierbarkeitPVS
matrices: THEORY
BEGIN
IMPORTING vect_of_vect
conversion- b2n
n, m,e: VAR nat
pn, pm: VAR posnat
c, r, s: VAR real
%------------------------------------------------------------------ % Matrix definition % We define matrices as records, giving the number or rows, % of columns, and the elements %------------------------------------------------------------------
-(M): Matrix =
M WITH [`matrix := LAMBDA (i: below(M`rows), j: below(M`cols)): -M`matrix(i, j)]
%--------------------------------------------------------------------- % Sum and substraction of matrices % To be able to operate with two matrices they must have same_dim? %---------------------------------------------------------------------
plus_comm: LEMMA FORALL (M, (N: (same_dim?(M)))): M + N = N + M;
% adding zero matrix
zero_left_ident: LEMMA FORALL (Z: Zero, M: (same_dim?(Z))): Z + M = M;
zero_right_ident: LEMMA FORALL (Z: Zero, M: (same_dim?(Z))): M + Z = M;
% Multiplying a matrix by an scalar
*(r, M): Matrix =
M WITH [`matrix := LAMBDA (i: below(M`rows), j: below(M`cols)):
r * M`matrix(i, j)];
*(M, r): Matrix = r * M;
%----------------------------------------------------------------------- % Product of matrices and product of a matrix and a vector %-----------------------------------------------------------------------
sigma_lem: LEMMA% This lemma is just to make other proofs easier FORALL (n: posnat, j: below(n), r: real):
sigma[below(n)](0, n - 1, (lambda (k: below(n)): 0) WITH [(j) := r]) = r
% Multiplying by the identity matrix
right_mult_ident: LEMMA FORALL (M, (I: Matrix | identity?(I) AND M`cols = I`rows)):
M * I = M
left_mult_ident: LEMMA FORALL (M, (I: Matrix | identity?(I) AND M`rows = I`cols)):
I * M = M
trans_mat_scal: LEMMAFORALL (A:Matrix, x:Vector[A`rows], y:Vector[A`cols]): x * (A * y) = (transpose(A) * x) * y
%--------------------------------------------------------------------- % Definition of inverse and invertible matrix %--------------------------------------------------------------------
inverse?(M: Square)(N: Square | N`rows = M`rows): bool =
M * N = I(M`rows) and N * M = I(M`rows)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.