% Given E1: (elemM1?(M)(i, j)), E1 * M replaces the ith row X_i by X_i + a*X_j
elemM1?(M: Square)(i: below(M`rows), j: below(M`rows) | i /= j): bool = FORALL (k, l: below(M`rows)): if k = l then M`matrix(k, l) = 1 elsif (k, l) = (i, j) thentrue% arbitrary real else M`matrix(k, l) = 0 endif
% Given E2: (elemM2?(M)(i, j)), E2 * M interchanges row i and row j
elemM2?(M: Square)(i: below(M`rows), j: below(M`rows) | i /= j): bool = FORALL (k, l: below(M`rows)): if k = l and k /= i and k /= j then M`matrix(k, l) = 1 elsif (k, l) = (i, j) or (k, l) = (j, i) then M`matrix(k, l) = 1 else M`matrix(k, l) = 0 endif
% Given E3: (elemM3?(M)(i)), E3 * M multiplies row i by nonzero scalar c
elemM3?(M: Square)(i: below(M`rows)): bool = FORALL (k, l: below(M`rows)): if k = l and k /= i then M`matrix(k, l) = 1 elsif (k, l) = (i, i) then M`matrix(k, l) /= 0 else M`matrix(k, l) = 0 endif
elemMat?(n: posnat)(M: SquareMat(n)): bool =
elemMat1?(n)(M) or elemMat2?(n)(M) or elemMat3?(n)(M)
ElemMat1(n: posnat): TYPE = (elemMat1?(n))
ElemMat2(n: posnat): TYPE = (elemMat2?(n))
ElemMat3(n: posnat): TYPE = (elemMat3?(n))
ElemMat(n: posnat): TYPE = (elemMat?(n))
elemM1(n: posnat)(i: below(n), j: below(n) | i /= j)(a: real): ElemMat1(n) =
(# rows := n, cols := n,
matrix := lambda (k, l: below(n)): if k = l then 1 elsif (k, l) = (i, j) then a else 0 endif #)
elemM2(n: posnat)(i: below(n), j: below(n) | i /= j): ElemMat2(n) =
(# rows := n, cols := n,
matrix := lambda (k, l: below(n)): if k = l and k /= i and k /= j then 1 elsif (k, l) = (i, j) or (k, l) = (j, i) then 1 else 0 endif #)
elemM3(n: posnat)(i: below(n))(c: nzreal): ElemMat3(n) =
(# rows := n, cols := n,
matrix := lambda (k, l: below(n)): if k = l thenif k = i then c else 1 endif else 0 endif #)
% Given M, and rows i, j st i /= j, and real a % ememM1 adds a * row(M, j) + row(M, i) to row(M, i)
elemM1_prop: lemma forall (M: Matrix, i: below(M`rows), j: below(M`rows) | i /= j, a: real): forall (k: below(M`rows)):
rowV(elemM1(M`rows)(i, j)(a) * M)(k) = if k = i then rowV(M)(i) + a * rowV(M)(j) else rowV(M)(k) endif
elemM2_prop: lemmaforall (M: Matrix, i: below(M`rows), j: below(M`rows) | i /= j): forall (k: below(M`rows)):
rowV(elemM2(M`rows)(i, j) * M)(k) = if k = i then rowV(M)(j) elsif k = j then rowV(M)(i) else rowV(M)(k) endif
elemM3_prop: lemma forall (M: Matrix, i: below(M`rows), c: nzreal): forall (k: below(M`rows)):
rowV(elemM3(M`rows)(i)(c) * M)(k) = if k = i then c * rowV(M)(i) else rowV(M)(k) endif
% Elementary matrix products
elem_prod: lemmaforall (M: Matrix, e: ElemMat(M`rows)):
same_dim?(e * M, M)
elem_product_left(M: Matrix, el: list[ElemMat(M`rows)]): recursive Mat(M`rows, M`cols) = if null?(el) then M else elem_product_left(car(el) * M, cdr(el)) endif measure length(el)
% This is used to do induction - need to leave M free for inductive step, % but this makes induction impossible, so we introduce n
elem_prod_append_aux: lemma forall (n: posnat, M: Matrix | M`rows = n, el1, el2: list[ElemMat(n)]):
elem_product_left(elem_product_left(M, el1), el2)
= elem_product_left(M, append[Matrix](el1, el2))
% This is the useful lemma, can be proved from elem_prod_append_aux
elem_prod_append: lemma forall (M: Matrix, el1, el2: list[ElemMat(M`rows)]):
elem_product_left(elem_product_left(M, el1), el2)
= elem_product_left(M, append[Matrix](el1, el2))
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.