def doEdgesMatch(self,edge1,edge2):
     P1 = edge1["propertyTags"]
     P2 = edge2["propertyTags"]
     
     for propTag in P1:
         prop = propTag.prop
         if isinstance(prop, IsNot):
             notprop = prop.notprop
             morph = edge2["morphism"]
             #check that morphism is not known to be zero
             if notprop is ZeroMorphism:
                 if isMorphismZero(morph):
                     return False
             
             elif notprop is Isomorphism:
                 #check that morphism is not known to be zero
                 if isIsomorphism(morph):
                     return False
             else:
                 assert issubclass(notprop,MorphismsProperty)
                 for p2 in P2:
                     if isinstance(p2.prop,notprop):
                         return False  
         else:
             if propTag not in P2: # P1 subset P2
                 return False
     return True
 def get_edge_image(self,item):
     if self.edgeMap.has_key(item):
         return self.edgeMap[item]
     elif len(item.Composition)>1:
         iterator = item.iterComposingMorphisms()
         morphi = self.edgeMap[next(iterator)]
         
         if isMorphismZero(morphi):
             return  GiveZeroMorphism(self.nodeMap[item.source],self.nodeMap[item.target]).equivalenceClass()
         
         for atomic in iterator: #inefficient #it just got even more inefficient
             atomicimage = self.edgeMap[atomic]
             if isMorphismZero(atomicimage):
                 return GiveZeroMorphism(self.nodeMap[item.source],self.nodeMap[item.target]).equivalenceClass()
             
             morphi = morphi.compose(atomicimage)
         return morphi
     elif isinstance(item,Identity):
         return getIdentity(self.edgeMap[item.source])
예제 #3
0
 def __init__(self,rule,hom):
     self.FC = hom.get_edge_image(F)
     self.GC = hom.get_edge_image(G)
     self.mainDiag = hom.D2
     self.charDiag = hom.D1
     
     
     self.useful = True
     
     if isMorphismZero(self.FC) or isMorphismZero(self.GC):
         self.useful = False
     
     for m_f in self.FC.Morphisms:
         for m_g in self.GC.Morphisms:
             m = m_f.compose(m_g,dry = True)
             if self.mainDiag.doesDryMorphismExist(m):
                 self.useful = False
     
     self.hom = hom
     self.rule = rule
예제 #4
0
    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)
예제 #5
0
 def implement(self):
     #here the morphism is build and then added to the diagram
     if isMorphismZero(self.FC) or isMorphismZero(self.GC):
         return
     morph = self.FC.representative*self.GC.representative