Lists as Functions #
Definitions for using lists as finite representations of finitely-supported functions with domain ℕ.
These include pointwise operations on lists, as well as get and set operations.
Notations #
An index notation is introduced in this file for setting a particular element of a list. With as
as a list m
as an index, and a
as a new element, the notation is as {m ↦ a}
.
So, for example
[1, 3, 5] {1 ↦ 9}
would result in [1, 9, 5]
This notation is in the locale list.func
.
Elementwise negation of a list
Equations
- list.func.neg as = list.map (λ (a : α), -a) as
Update element of a list by index. If the index is out of range, extend the list with default elements
Get element of a list by index. If the index is out of range, return the default element
Equations
- list.func.get (n + 1) (a :: as) = list.func.get n as
- list.func.get n.succ list.nil = default α
- list.func.get 0 (a :: as) = a
- list.func.get 0 list.nil = default α
Pointwise equality of lists. If lists are different lengths, compare with the default element.
Equations
- list.func.equiv as1 as2 = ∀ (m : ℕ), list.func.get m as1 = list.func.get m as2
Pointwise operations on lists. If lists are different lengths, use the default element.
Equations
- list.func.pointwise f (a :: as) (b :: bs) = f a b :: list.func.pointwise f as bs
- list.func.pointwise f (a :: as) list.nil = list.map (λ (x : α), f x (default β)) (a :: as)
- list.func.pointwise f list.nil (b :: bs) = list.map (f (default α)) (b :: bs)
- list.func.pointwise f list.nil list.nil = list.nil
Pointwise addition on lists. If lists are different lengths, use zero.
Equations
Pointwise subtraction on lists. If lists are different lengths, use zero.