def tensorDandDD(self, d_graph, dd_graph): """Computes the type D structure D1 * CFAA(Id) * DD2, where D1 is a type D structure with graph d_graph, CFAA(Id) is represented by this graph, and DD2 is a type DD structure with graph dd_graph. """ assert dd_graph.tensor_side == 1 assert d_graph.algebra.opp() == self.pmc_alg assert dd_graph.algebra1 == self.pmc_alg dstr = SimpleDStructure(F2, dd_graph.algebra2) # Generators of the type D structure: for node1 in d_graph.getNodes(): for ddgen, node2 in dd_graph.ddgen_node.items(): if node1.idem == node2.idem1.opp().comp(): cur_gen = ATensorDDGenerator(dstr, node1.dgen, ddgen) dstr.addGenerator(cur_gen) # Search the graphs for type D operations for gen_start in dstr.getGenerators(): dgen, ddgen = gen_start d1_pos = d_graph.graph_node[dgen] d2_pos = dd_graph.ddgen_node[ddgen] aa_pos = self.homology_node[dgen.idem.opp()] pos = [(d1_pos, d2_pos, aa_pos)] end_states = self._searchDoubleD(d_graph, dd_graph, pos)[0] for d1_end, d2_end, aa_end in end_states: gen_end = ATensorDDGenerator(dstr, d1_end.dgen, d2_end.ddgen) dstr.addDelta(gen_start, gen_end, d2_end.sd, 1) 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