/
cofibonacci.lagda.md
142 lines (115 loc) · 4.15 KB
/
cofibonacci.lagda.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# The cofibonacci sequence
```agda
module elementary-number-theory.cofibonacci where
```
<details><summary>Imports</summary>
```agda
open import elementary-number-theory.divisibility-natural-numbers
open import elementary-number-theory.equality-natural-numbers
open import elementary-number-theory.fibonacci-sequence
open import elementary-number-theory.inequality-natural-numbers
open import elementary-number-theory.modular-arithmetic-standard-finite-types
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.pisano-periods
open import elementary-number-theory.well-ordering-principle-natural-numbers
open import foundation.cartesian-product-types
open import foundation.decidable-types
open import foundation.dependent-pair-types
open import foundation.empty-types
open import foundation.identity-types
open import foundation.universe-levels
```
</details>
## Idea
The [**cofibonacci sequence**][1] is the unique function G : ℕ → ℕ satisfying
the property that
```text
div-ℕ (G m) n ↔ div-ℕ m (Fibonacci-ℕ n).
```
## Definitions
### The predicate of being a multiple of the `m`-th cofibonacci number
```agda
is-multiple-of-cofibonacci : (m x : ℕ) → UU lzero
is-multiple-of-cofibonacci m x =
is-nonzero-ℕ m → is-nonzero-ℕ x × div-ℕ m (Fibonacci-ℕ x)
is-decidable-is-multiple-of-cofibonacci :
(m x : ℕ) → is-decidable (is-multiple-of-cofibonacci m x)
is-decidable-is-multiple-of-cofibonacci m x =
is-decidable-function-type
( is-decidable-is-nonzero-ℕ m)
( is-decidable-prod
( is-decidable-is-nonzero-ℕ x)
( is-decidable-div-ℕ m (Fibonacci-ℕ x)))
cofibonacci-multiple : (m : ℕ) → Σ ℕ (is-multiple-of-cofibonacci m)
cofibonacci-multiple zero-ℕ = pair zero-ℕ (λ f → (ex-falso (f refl)))
cofibonacci-multiple (succ-ℕ m) =
pair
( pisano-period m)
( λ f → pair (is-nonzero-pisano-period m) (div-fibonacci-pisano-period m))
```
### The cofibonacci sequence
```agda
least-multiple-of-cofibonacci :
(m : ℕ) → minimal-element-ℕ (is-multiple-of-cofibonacci m)
least-multiple-of-cofibonacci m =
well-ordering-principle-ℕ
( is-multiple-of-cofibonacci m)
( is-decidable-is-multiple-of-cofibonacci m)
( cofibonacci-multiple m)
cofibonacci : ℕ → ℕ
cofibonacci m = pr1 (least-multiple-of-cofibonacci m)
is-multiple-of-cofibonacci-cofibonacci :
(m : ℕ) → is-multiple-of-cofibonacci m (cofibonacci m)
is-multiple-of-cofibonacci-cofibonacci m =
pr1 (pr2 (least-multiple-of-cofibonacci m))
is-lower-bound-cofibonacci :
(m x : ℕ) → is-multiple-of-cofibonacci m x →
cofibonacci m ≤-ℕ x
is-lower-bound-cofibonacci m =
pr2 (pr2 (least-multiple-of-cofibonacci m))
```
## Properties
### The `0`-th cofibonacci number is `0`
```agda
is-zero-cofibonacci-zero-ℕ : is-zero-ℕ (cofibonacci zero-ℕ)
is-zero-cofibonacci-zero-ℕ =
is-zero-leq-zero-ℕ
( cofibonacci zero-ℕ)
( is-lower-bound-cofibonacci zero-ℕ zero-ℕ ( λ f → ex-falso (f refl)))
```
### The cofibonacci sequence is left adjoint to the Fibonacci sequence
```agda
forward-is-left-adjoint-cofibonacci :
(m n : ℕ) → div-ℕ (cofibonacci m) n → div-ℕ m (Fibonacci-ℕ n)
forward-is-left-adjoint-cofibonacci zero-ℕ n H =
tr
( div-ℕ zero-ℕ)
( ap
( Fibonacci-ℕ)
( inv
( is-zero-div-zero-ℕ n
( tr (λ t → div-ℕ t n) is-zero-cofibonacci-zero-ℕ H))))
( refl-div-ℕ zero-ℕ)
forward-is-left-adjoint-cofibonacci (succ-ℕ m) zero-ℕ H =
div-zero-ℕ (succ-ℕ m)
forward-is-left-adjoint-cofibonacci (succ-ℕ m) (succ-ℕ n) H =
div-Fibonacci-div-ℕ
( succ-ℕ m)
( cofibonacci (succ-ℕ m))
( succ-ℕ n)
( H)
( pr2
( is-multiple-of-cofibonacci-cofibonacci
( succ-ℕ m)
( is-nonzero-succ-ℕ m)))
{-
converse-is-left-adjoint-cofibonacci :
(m n : ℕ) → div-ℕ m (Fibonacci-ℕ n) → div-ℕ (cofibonacci m) n
converse-is-left-adjoint-cofibonacci m n H = {!!}
is-left-adjoint-cofibonacci :
(m n : ℕ) → div-ℕ (cofibonacci m) n ↔ div-ℕ m (Fibonacci-ℕ n)
is-left-adjoint-cofibonacci m n = {!!}
-}
```
## References
[1]: https://oeis.org/A001177