|
| 1 | +#= Cartan Eilenberg resolutions of 1-dimensional complexes |
| 2 | +# |
| 3 | +# Suppose |
| 4 | +# |
| 5 | +# 0 ← C₀ ← C₁ ← C₂ ← … |
| 6 | +# |
| 7 | +# is a bounded below complex. We compute a double complex |
| 8 | +# |
| 9 | +# 0 0 0 |
| 10 | +# ↑ ↑ ↑ |
| 11 | +# 0 ← P₀₀ ← P₀₁ ← P₀₂ ← … |
| 12 | +# ↑ ↑ ↑ |
| 13 | +# 0 ← P₁₀ ← P₁₁ ← P₁₂ ← … |
| 14 | +# ↑ ↑ ↑ |
| 15 | +# 0 ← P₂₀ ← P₂₁ ← P₂₂ ← … |
| 16 | +# ↑ ↑ ↑ |
| 17 | +# ⋮ ⋮ ⋮ |
| 18 | +# |
| 19 | +# whose total complex is quasi-isomorphic to C via some augmentation map |
| 20 | +# |
| 21 | +# ε = (εᵢ : P₀ᵢ → Cᵢ)ᵢ |
| 22 | +# |
| 23 | +# The challenge is that if we were only computing resolutions of the Cᵢ's |
| 24 | +# and lifting the maps, then the rows of the resulting diagrams would |
| 25 | +# not necessarily form complexes. To accomplish that, we split the original |
| 26 | +# complex into short exact sequences |
| 27 | +# |
| 28 | +# 0 ← Bᵢ ← Cᵢ ← Zᵢ ← 0 |
| 29 | +# |
| 30 | +# and apply the Horse shoe lemma to these. Together with the induced maps |
| 31 | +# from Bᵢ ↪ Zᵢ₋₁ we get the desired double complex. |
| 32 | +# |
| 33 | +# If the original complex C is known to be exact, then there is no need |
| 34 | +# to compute the resolutions of both Bᵢ and Zᵢ and we can shorten the procedure. |
| 35 | +=# |
| 36 | +### Production of the chains |
| 37 | +struct CEChainFactory{ChainType} <: HyperComplexChainFactory{ChainType} |
| 38 | + c::AbsHyperComplex |
| 39 | + is_exact::Bool |
| 40 | + kernel_resolutions::Dict{Int, <:AbsHyperComplex} # the kernels of Cᵢ → Cᵢ₋₁ |
| 41 | + boundary_resolutions::Dict{Int, <:AbsHyperComplex} # the boundaries of Cᵢ₊₁ → Cᵢ |
| 42 | + induced_maps::Dict{Int, <:AbsHyperComplexMorphism} # the induced maps from the free |
| 43 | + # resolutions of the boundary and kernel |
| 44 | + |
| 45 | + function CEChainFactory(c::AbsHyperComplex; is_exact::Bool=false) |
| 46 | + @assert dim(c) == 1 "complex must be 1-dimensional" |
| 47 | + #@assert has_lower_bound(c, 1) "complex must be bounded from below" |
| 48 | + return new{chain_type(c)}(c, is_exact, Dict{Int, AbsHyperComplex}(), Dict{Int, AbsHyperComplex}(), Dict{Int, AbsHyperComplexMorphism}()) |
| 49 | + end |
| 50 | +end |
| 51 | + |
| 52 | +function kernel_resolution(fac::CEChainFactory, i::Int) |
| 53 | + if !haskey(fac.kernel_resolutions, i) |
| 54 | + Z, _ = kernel(fac.c, i) |
| 55 | + fac.kernel_resolutions[i] = free_resolution(SimpleFreeResolution, Z)[1] |
| 56 | + end |
| 57 | + return fac.kernel_resolutions[i] |
| 58 | +end |
| 59 | + |
| 60 | +function boundary_resolution(fac::CEChainFactory, i::Int) |
| 61 | + if !haskey(fac.boundary_resolutions, i) |
| 62 | + Z, _ = boundary(fac.c, i) |
| 63 | + fac.boundary_resolutions[i] = free_resolution(SimpleFreeResolution, Z)[1] |
| 64 | + end |
| 65 | + return fac.boundary_resolutions[i] |
| 66 | +end |
| 67 | + |
| 68 | +function induced_map(fac::CEChainFactory, i::Int) |
| 69 | + if !haskey(fac.induced_maps, i) |
| 70 | + Z, inc = kernel(fac.c, i) |
| 71 | + B, pr = boundary(fac.c, i) |
| 72 | + @assert ambient_free_module(Z) === ambient_free_module(B) |
| 73 | + img_gens = elem_type(Z)[Z(g) for g in ambient_representatives_generators(B)] |
| 74 | + res_Z = kernel_resolution(fac, i) |
| 75 | + res_B = boundary_resolution(fac, i) |
| 76 | + aug_Z = augmentation_map(res_Z) |
| 77 | + aug_B = augmentation_map(res_B) |
| 78 | + img_gens = gens(res_B[0]) |
| 79 | + img_gens = aug_B[0].(img_gens) |
| 80 | + img_gens = elem_type(res_Z[0])[preimage(aug_Z[0], Z(repres(aug_B[0](g)))) for g in gens(res_B[0])] |
| 81 | + psi = hom(res_B[0], res_Z[0], img_gens; check=true) # TODO: Set to false |
| 82 | + @assert domain(psi) === boundary_resolution(fac, i)[0] |
| 83 | + @assert codomain(psi) === kernel_resolution(fac, i)[0] |
| 84 | + fac.induced_maps[i] = lift_map(boundary_resolution(fac, i), kernel_resolution(fac, i), psi; start_index=0) |
| 85 | + end |
| 86 | + return fac.induced_maps[i] |
| 87 | +end |
| 88 | + |
| 89 | +function (fac::CEChainFactory)(self::AbsHyperComplex, I::Tuple) |
| 90 | + (i, j) = I # i the resolution index, j the index in C |
| 91 | + |
| 92 | + res_Z = kernel_resolution(fac, j) |
| 93 | + |
| 94 | + if can_compute_map(fac.c, 1, (j,)) |
| 95 | + if fac.is_exact # Use the next kernel directly |
| 96 | + res_B = kernel_resolution(fac, j-1) |
| 97 | + return direct_sum(res_B[i], res_Z[i])[1] |
| 98 | + else |
| 99 | + res_B = boundary_resolution(fac, j-1) |
| 100 | + return direct_sum(res_B[i], res_Z[i])[1] |
| 101 | + end |
| 102 | + end |
| 103 | + # We may assume that the next map can not be computed and is, hence, zero. |
| 104 | + return res_Z[i] |
| 105 | +end |
| 106 | + |
| 107 | +function can_compute(fac::CEChainFactory, self::AbsHyperComplex, I::Tuple) |
| 108 | + (i, j) = I |
| 109 | + can_compute_index(fac.c, (j,)) || return false |
| 110 | + return i >= 0 |
| 111 | +end |
| 112 | + |
| 113 | +### Production of the morphisms |
| 114 | +struct CEMapFactory{MorphismType} <: HyperComplexMapFactory{MorphismType} end |
| 115 | + |
| 116 | +function (fac::CEMapFactory)(self::AbsHyperComplex, p::Int, I::Tuple) |
| 117 | + (i, j) = I |
| 118 | + cfac = chain_factory(self) |
| 119 | + if p == 1 # vertical upwards maps |
| 120 | + if can_compute_map(cfac.c, 1, (j,)) |
| 121 | + # both dom and cod are direct sums in this case |
| 122 | + dom = self[I] |
| 123 | + cod = self[(i-1, j)] |
| 124 | + pr1 = canonical_projection(dom, 1) |
| 125 | + pr2 = canonical_projection(dom, 2) |
| 126 | + @assert domain(pr1) === domain(pr2) === dom |
| 127 | + inc1 = canonical_injection(cod, 1) |
| 128 | + inc2 = canonical_injection(cod, 2) |
| 129 | + @assert codomain(inc1) === codomain(inc2) === cod |
| 130 | + res_Z = kernel_resolution(cfac, j) |
| 131 | + @assert domain(map(res_Z, i)) === codomain(pr2) |
| 132 | + @assert codomain(map(res_Z, i)) === domain(inc2) |
| 133 | + res_B = boundary_resolution(cfac, j-1) |
| 134 | + @assert domain(map(res_B, i)) === codomain(pr1) |
| 135 | + @assert codomain(map(res_B, i)) === domain(inc1) |
| 136 | + return compose(pr1, compose(map(res_B, i), inc1)) + compose(pr2, compose(map(res_Z, i), inc2)) |
| 137 | + else |
| 138 | + res_Z = kernel_resolution(cfac, j) |
| 139 | + return map(res_Z, i) |
| 140 | + end |
| 141 | + error("execution should never reach this point") |
| 142 | + elseif p == 2 # the horizontal maps |
| 143 | + dom = self[I] |
| 144 | + cod = self[(i, j-1)] |
| 145 | + if can_compute_map(cfac.c, 1, (j-1,)) |
| 146 | + # the codomain is also a direct sum |
| 147 | + if !cfac.is_exact |
| 148 | + psi = induced_map(cfac, j-1) |
| 149 | + phi = psi[i] |
| 150 | + inc = canonical_injection(cod, 2) |
| 151 | + pr = canonical_projection(dom, 1) |
| 152 | + @assert codomain(phi) === domain(inc) |
| 153 | + @assert codomain(pr) === domain(phi) |
| 154 | + return compose(pr, compose(phi, inc)) |
| 155 | + else |
| 156 | + inc = canonical_injection(cod, 2) |
| 157 | + pr = canonical_projection(dom, 1) |
| 158 | + return compose(pr, inc) |
| 159 | + end |
| 160 | + error("execution should never reach this point") |
| 161 | + else |
| 162 | + # the codomain is just the kernel |
| 163 | + if !cfac.is_exact |
| 164 | + psi = induced_map(cfac, j-1) |
| 165 | + phi = psi[i] |
| 166 | + pr = canonical_projection(dom, 1) |
| 167 | + return compose(pr, phi) |
| 168 | + else |
| 169 | + pr = canonical_projection(dom, 1) |
| 170 | + return pr |
| 171 | + end |
| 172 | + error("execution should never reach this point") |
| 173 | + end |
| 174 | + error("execution should never reach this point") |
| 175 | + end |
| 176 | + error("direction $p out of bounds") |
| 177 | +end |
| 178 | + |
| 179 | +function can_compute(fac::CEMapFactory, self::AbsHyperComplex, p::Int, I::Tuple) |
| 180 | + (i, j) = I |
| 181 | + if p == 1 # vertical maps |
| 182 | + return i > 0 && can_compute(chain_factory(self).c, j) |
| 183 | + elseif p == 2 # horizontal maps |
| 184 | + return i >= 0 && can_compute_map(chain_factory(self).c, j) |
| 185 | + end |
| 186 | + return false |
| 187 | +end |
| 188 | + |
| 189 | +### The concrete struct |
| 190 | +@attributes mutable struct CartanEilenbergResolution{ChainType, MorphismType} <: AbsHyperComplex{ChainType, MorphismType} |
| 191 | + internal_complex::HyperComplex{ChainType, MorphismType} |
| 192 | + |
| 193 | + function CartanEilenbergResolution( |
| 194 | + c::AbsHyperComplex{ChainType, MorphismType}; |
| 195 | + is_exact::Bool=false |
| 196 | + ) where {ChainType, MorphismType} |
| 197 | + @assert dim(c) == 1 "complexes must be 1-dimensional" |
| 198 | + @assert has_lower_bound(c, 1) "complexes must be bounded from below" |
| 199 | + @assert direction(c, 1) == :chain "resolutions are only implemented for chain complexes" |
| 200 | + chain_fac = CEChainFactory(c; is_exact) |
| 201 | + map_fac = CEMapFactory{MorphismType}() # TODO: Do proper type inference here! |
| 202 | + |
| 203 | + # Assuming d is the dimension of the new complex |
| 204 | + internal_complex = HyperComplex(2, chain_fac, map_fac, [:chain, :chain]; lower_bounds = Union{Int, Nothing}[0, lower_bound(c, 1)]) |
| 205 | + # Assuming that ChainType and MorphismType are provided by the input |
| 206 | + return new{ChainType, MorphismType}(internal_complex) |
| 207 | + end |
| 208 | +end |
| 209 | + |
| 210 | +### Implementing the AbsHyperComplex interface via `underlying_complex` |
| 211 | +underlying_complex(c::CartanEilenbergResolution) = c.internal_complex |
| 212 | + |
0 commit comments