Repetition of Functions #
We define what it means to apply a function a given number of times. This only works for function where the types of domain and image coincide.
Repetition of a Function defined in the obvious way. Repeating zero times is defined as the id function.
Equations
- Function.repeat_fun f Nat.zero = id
- Function.repeat_fun f j.succ = f ∘ Function.repeat_fun f j
Instances For
Applying a zero-times repetition yields the original value.
Applying a n+1-times repetition means applying the function to the result of the n-times repetition.
Repeating a function once yields exactly the function.
It does not matter if we add another repetition on the left or the right.
It does not matter if we add another repetition on the left or the right.
The numbers of two composed repetitions can be swapped.
The numbers of two composed repetitions can be swapped.
A (i+j)-times repetition can be split into the composition of an j-times repetition followed by an i-times repetition.
A (i+j)-times repetition can be split into the composition of an j-times repetition followed by an i-times repetition.
If a repetition maps a value to itself, then each multiple of the repetition must also map the value to itself.
If some repetition maps a value to itself, then each other value that is part of this loop is also mapped to itself.
Consider a list of values. If each value is reachable by some non-zero number of repetitions from some value, then, for each value in the list, there is a non-zero number of repetitions that maps the value to itself. Intuitively this holds by a pigeonhole argument: if for each value you need to pick a value from that you can reach it, but only finitely many values are available, then eventually you need to complete a cycle.
If each value from a (finite) list is mapped to itself after some number of repetitions, then there is a global repetition number that maps each value from the list to itself. Basically any common multiple of the individual repetition numbers works.
If a mapping is surjective for a given list of values, then there exists a repetition count $k$ such that repeating $k+1$ times maps each value from the list to itself. Note that we use $k+1$ repetitions as otherwise the result would be trivial for zero repetitions, which correspond to the id function by definition.