def test2(): D=Diagram() P1=Object(D,'P1') P1.latex='P_1' P2=Object(D,'P2') P1.latex='P_1' id1=Identity(P1) id2=Identity(P2) P1xP2=Object(D,'P1xP2') P1xP2.latex="P_1 \oplus P_2" idprod=Identity(P1xP2) i1=Morphism(P1,P1xP2,'i1') i2=Morphism(P2,P1xP2,'i2') CoProductProperty(i1,i2) B=Object(D,'B') C=Object(D,'C') pi=Morphism(B,C) f=Morphism(P1xP2,C) Epimorphism(pi) pi.latex=r"\pi" f.latex=r"\varphi" Projective(P1) Projective(P2) P1.gridpos=(0,0) P2.gridpos=(0,2) P1xP2.gridpos=(0,1) B.gridpos=(1,1) C.gridpos=(2,1) P1.latex='P_1' P2.latex='P_2' P1xP2.latex='P_1 \oplus P_2' B.latex='B' C.latex='C' SRM = SimpleRuleMaster(D,maxMorphisms=1) diagSequence=[] while(True): result=SRM(numberOfExtensions=10,verbose=False,printlatex=True) if (result==False): break diagSequence.append(result) print processDiagSequence(diagSequence) return D
def implement(self): '''carry out the pushout of the Extension Meta-Diagram''' #Extend hom to a lift of the extension to the main Diagram lift = self.hom*self.rule.partialInverse #inefficient for obj in self.rule.newObjects: try: names=[] for s in obj.namescheme[1]: obj_item = self.charDiag[s] if isinstance(obj_item,Object): names.append(self.hom[self.charDiag[s]].name) else:#morphism names.append(self.hom.get_edge_image(self.charDiag[s]).representative.name) newname=obj.namescheme[0].format(*names) newobj = Object(self.mainDiag,newname) #try naming according to scheme except: try: newobj=Object(self.mainDiag,self.mainDiag.giveName(mode=newname)) #append a number to name if this failed except: newobj = Object(self.mainDiag) #give a generic name if everything fails latexlist=[] try: for s in obj.latexscheme[1]: try: try: latexlist.append(self.hom[self.charDiag[s]].latex) except: latexlist.append(self.hom[self.charDiag[s]].name) except: try: latexlist.append(self.hom.edgeMap[self.charDiag.Morphisms[s]].latex) except: latexlist.append(self.hom.edgeMap[self.charDiag.Morphisms[s]].name) newobj.latex=obj.latexscheme[0].format(*latexlist) #set LaTeX display string except: newobj.latex=newobj.name lift.set_node_image(obj,newobj) for morphi in self.rule.newMorphisms: source = lift[morphi.source] target = lift[morphi.target] if isinstance(morphi,Identity): newmorphi = getIdentity(source) elif isMorphismZero(morphi): newmorphi = GiveZeroMorphism(source,target) else: newmorphi = Morphism(source,target) #do not implement nameschemes for morphisms for now latexlist=[] try: for s in morphi.latexscheme[1]: try: try: latexlist.append(self.hom[self.charDiag[s]].latex) except: latexlist.append(self.hom[self.charDiag[s]].name) except: try: latexlist.append(self.hom.edgeMap[self.charDiag[s]].representative.latex) except: latexlist.append(self.hom.edgeMap[self.charDiag[s]].representative.name) newmorphi.latex=morphi.latexscheme[0].format(*latexlist) #set LaTeX display string except: pass lift.set_edge_image(morphi,self.mainDiag.CommutativityQuotient.get_edge_image(newmorphi)) #compose characteristic homomorphism of property with lift to get #characteristic homomorphism in the extended main Diagram #for commutativity classes, just choose an arbitrary section for prop in self.rule.newProperties: prop.push_forward(lift)