def morToD(self, other): """Compute the type D structure of morphisms from self to other. Note ``other`` must be a type D structure. """ assert self.algebra1 == other.algebra alg_gens = self.algebra1.getGenerators() xlist = self.getGenerators() ylist = other.getGenerators() gens = list() dstr = SimpleDStructure(F2, self.algebra2.opp()) genType = MorDDtoDGenerator def morGradingSet(): """Find the grading set of the new type D structure.""" lr_domains = [(d1, d2.opp()) for d1, d2 in self.gr_set.periodic_domains] self.lr_set = SimpleDbGradingSet( self.gr_set.gr_group1, ACTION_LEFT, self.gr_set.gr_group2.opp(), ACTION_RIGHT, lr_domains) return GeneralGradingSet([self.lr_set.inverse(), other.gr_set]) def morGrading(gr_set, x, a, y): """Find the grading of the generator x -> ay in the morphism type D structure. The grading set need to be provided as gr_set. """ gr_x1, gr_x2 = self.grading[x].data gr_x_lr = SimpleDbGradingSetElement(self.lr_set, (gr_x1, gr_x2.opp())) gr = [gr_x_lr.inverse(), other.grading[y] * a.getGrading()] return GeneralGradingSetElement(gr_set, gr) # Prepare rev_delta for the last step in computing differentials rev_delta = self.getReverseDelta() # Get the list of generators for x in xlist: for a in alg_gens: for y in ylist: if x.idem1 == a.getLeftIdem() and \ y.idem == a.getRightIdem(): gens.append(genType(dstr, x, a, y)) for gen in gens: dstr.addGenerator(gen) # Get the type D structure maps for gen in gens: # Differential of y in (x -> ay) x, a, y = gen.source, gen.coeff, gen.target ady = a * y.delta() for (b, q), coeff in ady.items(): dstr.addDelta(gen, genType(dstr, x, b, q), None, coeff) # Differential of a for da_gen, coeff in a.diff().items(): dstr.addDelta(gen, genType(dstr, x, da_gen, y), None, coeff) # For each p such that (b1,b2)*x is in dp, add opp(b2)*(p->(b1*a)y) for (b1, b2, p), coeff1 in rev_delta[x]: for b1a_gen, coeff2 in (b1*a).items(): dstr.addDelta(gen, genType(dstr, p, b1a_gen, y), b2.opp(), coeff1*coeff2) # Find grading set and grading of elements if hasattr(self, "gr_set") and hasattr(other, "gr_set"): dstr.gr_set = morGradingSet() dstr.grading = dict() for gen in gens: dstr.grading[gen] = morGrading( dstr.gr_set, gen.source, gen.coeff, gen.target) return dstr
def tensorD(self, dstr): """Compute the box tensor product DA * D of this bimodule with the given type D structure. Returns the resulting type D structure. Uses delta() and deltaPrefix() functions of this type DA structure. """ dstr_result = SimpleDStructure(F2, self.algebra1) # Compute list of generators in the box tensor product for gen_left in self.getGenerators(): for gen_right in dstr.getGenerators(): if gen_left.idem2 == gen_right.idem: dstr_result.addGenerator(DATensorDGenerator( dstr_result, gen_left, gen_right)) def search(start_gen, cur_dgen, cur_coeffs_a): """Searching for an arrow in the box tensor product. - start_gen: starting generator in the box tensor product. The resulting arrow will start from here. - cur_dgen: current location in the type D structure. - cur_coeffs_a: current list of A-side inputs to the type DA structure (or alternatively, list of algebra outputs produced by the existing path through the type D structure). """ start_dagen, start_dgen = start_gen cur_delta = self.delta(start_dagen, cur_coeffs_a) for (coeff_d, gen_to), ring_coeff in cur_delta.items(): dstr_result.addDelta(start_gen, DATensorDGenerator( dstr_result, gen_to, cur_dgen), coeff_d, 1) if self.deltaPrefix(start_dagen, cur_coeffs_a): for (coeff_out, dgen_to), ring_coeff in \ dstr.delta(cur_dgen).items(): search(start_gen, dgen_to, cur_coeffs_a + (coeff_out,)) for x in dstr_result.getGenerators(): dagen, dgen = x search(x, dgen, ()) # Add arrows coming from idempotent output on the D-side for (coeff_out, dgen_to), ring_coeff in dstr.delta(dgen).items(): if coeff_out.isIdempotent(): dstr_result.addDelta( x, DATensorDGenerator(dstr_result, dagen, dgen_to), dagen.idem1.toAlgElt(self.algebra1), 1) # Find grading set if available on both components def tensorGradingSet(): """Find the grading set of the new type D structure.""" return GeneralGradingSet([self.gr_set, dstr.gr_set]) def tensorGrading(gr_set, dagen, dgen): """Find the grading of the generator (x, y) in the tensor type D structure. The grading set need to be provided as gr_set. """ return GeneralGradingSetElement( gr_set, [self.grading[dagen], dstr.grading[dgen]]) if hasattr(self, "gr_set") and hasattr(dstr, "gr_set"): dstr_result.gr_set = tensorGradingSet() dstr_result.grading = dict() for x in dstr_result.getGenerators(): dagen, dgen = x dstr_result.grading[x] = tensorGrading( dstr_result.gr_set, dagen, dgen) return dstr_result
def tensorD(self, dstr): """Compute the box tensor product DA * D of this bimodule with the given type D structure. Returns the resulting type D structure. Uses delta() and deltaPrefix() functions of this type DA structure. """ dstr_result = SimpleDStructure(F2, self.algebra1) # Compute list of generators in the box tensor product for gen_left in self.getGenerators(): for gen_right in dstr.getGenerators(): if gen_left.idem2 == gen_right.idem: dstr_result.addGenerator(DATensorDGenerator( dstr_result, gen_left, gen_right)) def search(start_gen, cur_dgen, algs, last_assign, algs_local, last_prod_d): """Searching for an arrow in the box tensor product. - start_gen: starting generator in the box tensor product. The resulting arrow will start from here. - cur_dgen: current location in the type D structure. - algs: current list of A-side inputs to the type DA structure (or alternatively, list of algebra outputs produced by the existing path through the type D structure). - algs_local: current list of local restrictions of algs. - last_assign: a list of length self.num_singles. For each split idempotent, specify the single assignments at the last algebra input. - prod_d: product of the outer restrictions, except for the last algebra input. """ start_dagen, start_dgen = start_gen local_MGen = start_dagen.local_gen # Preliminary tests if len(algs) > 0: assert algs[0].left_idem == start_dagen.idem2 for i in range(len(algs)-1): assert algs[i].right_idem == algs[i+1].left_idem if any(alg.isIdempotent() for alg in algs): return # First, adjust local module generator, and check for delta. if len(algs_local) > 0: local_MGen = self.adjustLocalMGen(local_MGen, algs_local[0]) if local_MGen is None: return local_delta = self.local_da.delta(local_MGen, tuple(algs_local)) has_delta = (local_delta != E0) # Second, check for delta prefix. has_delta_prefix = False if len(algs) == 0: has_delta_prefix = True else: dbls = [self.single_idems2[i] for i in range(self.num_singles) if last_assign[i] == self.DOUBLE] for to_remove in subset(dbls): if len(to_remove) != 0: cur_algs_local = tuple([alg.removeSingleHor(to_remove) for alg in algs_local]) else: cur_algs_local = algs_local if self.testPrefix(local_MGen, cur_algs_local): has_delta_prefix = True break if (not has_delta) and (not has_delta_prefix): return # Now, compute new prod_d. if len(algs) > 0: prod_d = self.getNewProdD(last_assign, algs[-1], last_prod_d) else: prod_d = last_prod_d if prod_d is None: return # If has_delta is True, add to delta for (local_d, local_y), ring_coeff in local_delta.items(): alg_d, y = self.joinOutput(local_d, local_y, prod_d) if alg_d is not None: dstr_result.addDelta(start_gen, DATensorDGenerator( dstr_result, y, cur_dgen), alg_d, 1) if not has_delta_prefix: return for (new_alg, dgen_to), ring_coeff in dstr.delta(cur_dgen).items(): new_assign, new_local, last_prod_d = self.extendRestrictions( last_assign, algs_local, prod_d, new_alg) if new_assign is not None: search(start_gen, dgen_to, algs + [new_alg], new_assign, new_local, last_prod_d) # Perform search for each generator in dstr_result. for x in dstr_result.getGenerators(): dagen, dgen = x prod_d = \ self.splitting2.restrictIdempotentOuter(dagen.idem2).toAlgElt() prod_d = prod_d.removeSingleHor() # always goes to LOCAL search(x, dgen, [], [self.DOUBLE] * self.num_singles, [], prod_d) # Add arrows coming from idempotent output on the D-side for (coeff_out, dgen_to), ring_coeff in dstr.delta(dgen).items(): if coeff_out.isIdempotent(): dstr_result.addDelta( x, DATensorDGenerator(dstr_result, dagen, dgen_to), dagen.idem1.toAlgElt(self.algebra1), 1) # Find grading set if available on both components def tensorGradingSet(): """Find the grading set of the new type D structure.""" return GeneralGradingSet([self.gr_set, dstr.gr_set]) def tensorGrading(gr_set, dagen, dgen): """Find the grading of the generator (x, y) in the tensor type D structure. The grading set need to be provided as gr_set. """ return GeneralGradingSetElement( gr_set, [self.grading[dagen], dstr.grading[dgen]]) if hasattr(self, "gr_set") and hasattr(dstr, "gr_set"): dstr_result.gr_set = tensorGradingSet() dstr_result.grading = dict() for x in dstr_result.getGenerators(): dagen, dgen = x dstr_result.grading[x] = tensorGrading( dstr_result.gr_set, dagen, dgen) return dstr_result