Matrix and vector notation #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file includes simp
lemmas for applying operations in data.matrix.basic
to values built out
of the matrix notation ![a, b] = vec_cons a (vec_cons b vec_empty)
defined in
data.fin.vec_notation
.
This also provides the new notation !![a, b; c, d] = matrix.of ![![a, b], ![c, d]]
.
This notation also works for empty matrices; !![,,,] : matrix (fin 0) (fin 3)
and
!![;;;] : matrix (fin 3) (fin 0)
.
Implementation notes #
The simp
lemmas require that one of the arguments is of the form vec_cons _ _
.
This ensures simp
works with entries only when (some) entries are already given.
In other words, this notation will only appear in the output of simp
if it
already appears in the input.
Notations #
This file provide notation !![a, b; c, d]
for matrices, which corresponds to
matrix.of ![![a, b], ![c, d]]
.
A parser for a, b; c, d
-style strings is provided as matrix.entry_parser
, while
matrix.notation
provides the hook for the !!
notation.
Note that in lean 3 the pretty-printer will not show !!
notation, instead showing the version
with of ![![...]]
.
Examples #
Examples of usage can be found in the test/matrix.lean
file.
Use ![...]
notation for displaying a fin
-indexed matrix, for example:
#eval !![1, 2; 3, 4] + !![3, 4; 5, 6] -- !![4, 6; 8, 10]
Equations
- matrix.has_repr = {repr := λ (f : matrix (fin m) (fin n) α), "!![" ++ "; ".intercalate (list.map (λ (i : fin m), ", ".intercalate (list.map (λ (j : fin n), repr (f i j)) (list.fin_range n))) (list.fin_range m)) ++ "]"}
Updating a row then removing it is the same as removing it.
Updating a column then removing it is the same as removing it.