def transitive(self, other=None): r""" TBD """ if other is None: raise ValueError, "Enter a reduction map as a parameter" elif self.get_B() != other.get_A(): raise ValueError, "These are not good candidate sets for reduction mapping" else: dic_h = dict() dic_h0 = dict() A = self.get_A() B = self.get_B() C = other.get_B() f = self.get_SRWP() f0 = self.get_SPWP() g = other.get_SRWP() g0 = other.get_SPWP() for elm in A: if elm in fixed_points(f): if f0(elm) in fixed_points(g): dic_h0[elm] = g0(f0(elm)) dic_h[elm] = elm else: dic_h[elm] = inverse(f0)(g(f0(elm))) else: dic_h[elm] = f(elm) h = FiniteSetMaps(A, A).from_dict(dic_h) h0 = FiniteSetMaps(CombinatorialScalarWrapper(dic_h0.keys()), C).from_dict(dic_h0) return ReductionMaps(A, C, h, h0)
def transitive(self,other=None): r""" TBD """ if other is None: raise ValueError, "Enter a reduction map as a parameter" elif self.get_B() != other.get_A(): raise ValueError, "These are not good candidate sets for reduction mapping" else: dic_h = dict() dic_h0 = dict() A = self.get_A() B = self.get_B() C = other.get_B() f = self.get_SRWP() f0 = self.get_SPWP() g = other.get_SRWP() g0 = other.get_SPWP() for elm in A: if elm in fixed_points(f): if f0(elm) in fixed_points(g): dic_h0[elm] = g0(f0(elm)) dic_h[elm] = elm else: dic_h[elm] = inverse(f0)(g(f0(elm))) else: dic_h[elm] = f(elm) h = FiniteSetMaps(A,A).from_dict(dic_h) h0 = FiniteSetMaps(CombinatorialScalarWrapper(dic_h0.keys()),C).from_dict(dic_h0) return ReductionMaps(A,C,h,h0)
def __init__(self, A, B, f, f0): r""" TBD """ if type(A) != CombinatorialScalarWrapper: raise ValueError, "The first input must be a Combinatorial Scalar Wrapper" elif type(B) != CombinatorialScalarWrapper: raise ValueError, "The second input must be a Combinatorial Scalar Wrapper" elif not (bool( A.get_generating_function() == B.get_generating_function())): raise ValueError, "The generating functions of the scalars are not equal" elif type(f) != FiniteSetMap_Set and type(f) != FiniteSetEndoMap_Set: raise ValueError, "The third input must be a map in FiniteSetMaps" elif type(f0) != FiniteSetMap_Set and type(f0) != FiniteSetEndoMap_Set: raise ValueError, "The fourth input must be a map in FiniteSetMaps" elif set(f.domain()) != set(A): raise ValueError, "The third input must have domain of first input" elif set(f0.domain()) != set(fixed_points(f)): raise ValueError, "The fourth input must have domain of fixed points of third the input" elif set(f0.image_set()) != set(B): raise ValueError, "The fourth input must have image of second input" elif not (is_SRWP_involution(f)): raise ValueError, "The third input must be an SRWP involution" elif not (is_SPWP_bijection(f0)): raise ValueError, "The fourth input must be an SPWP bijection" else: self._A = A self._B = B self._f = f self._f0 = f0
def __init__(self, A,B,f,f0): r""" TBD """ if type(A)!=CombinatorialScalarWrapper: raise ValueError, "The first input must be a Combinatorial Scalar Wrapper" elif type(B)!=CombinatorialScalarWrapper: raise ValueError, "The second input must be a Combinatorial Scalar Wrapper" elif not(bool(A.get_generating_function()==B.get_generating_function())): raise ValueError, "The generating functions of the scalars are not equal" elif type(f)!= FiniteSetMap_Set and type(f) != FiniteSetEndoMap_Set: raise ValueError, "The third input must be a map in FiniteSetMaps" elif type(f0) != FiniteSetMap_Set and type(f0) != FiniteSetEndoMap_Set: raise ValueError, "The fourth input must be a map in FiniteSetMaps" elif set(f.domain()) != set(A): raise ValueError, "The third input must have domain of first input" elif set(f0.domain()) != set(fixed_points(f)): raise ValueError, "The fourth input must have domain of fixed points of third the input" elif set(f0.image_set())!=set(B): raise ValueError, "The fourth input must have image of second input" elif not(is_SRWP_involution(f)): raise ValueError, "The third input must be an SRWP involution" elif not(is_SPWP_bijection(f0)): raise ValueError, "The fourth input must be an SPWP bijection" else: self._A = A self._B = B self._f = f self._f0 = f0
def confluence(self, other=None): r""" Returns the reduction of C to B, where the usage is: r1.confluence(r2), and r1 maps A to B, B fully cancelled, and r2 maps A to C. """ if other is None: raise ValueError, "Enter a redution map as a parameter" elif self.get_A() != other.get_A(): raise ValueError, """ "A" """ " sets have to match" elif not (self.get_B().is_fully_cancelled()): raise ValueError, """ "B" """ " on the left is not fully cancelled" else: dic_h = dict() dic_h0 = dict() A = self.get_A() B = self.get_B() C = other.get_B() f = self.get_SRWP() f0 = self.get_SPWP() g = other.get_SRWP() g0 = other.get_SPWP() fxd_f = fixed_points(self.get_SRWP()) fxd_g = fixed_points(other.get_SRWP()) for c in C: x = inverse(g0)(c) while True: if x in fxd_f: #a fixed point of h dic_h[c] = c dic_h0[c] = f0(x) break else: x = f(x) if x in fxd_g: #not a fixed point of h dic_h[c] = g0(x) break else: x = g(x) h = FiniteSetMaps(C, C).from_dict(dic_h) h0 = FiniteSetMaps(CombinatorialScalarWrapper(dic_h0.keys()), B).from_dict(dic_h0) return ReductionMaps(C, B, h, h0)
def confluence(self,other=None): r""" Returns the reduction of C to B, where the usage is: r1.confluence(r2), and r1 maps A to B, B fully cancelled, and r2 maps A to C. """ if other is None: raise ValueError, "Enter a redution map as a parameter" elif self.get_A() != other.get_A(): raise ValueError, """ "A" """ " sets have to match" elif not(self.get_B().is_fully_cancelled()): raise ValueError, """ "B" """ " on the left is not fully cancelled" else: dic_h = dict() dic_h0 = dict() A = self.get_A() B = self.get_B() C = other.get_B() f = self.get_SRWP() f0 = self.get_SPWP() g = other.get_SRWP() g0 = other.get_SPWP() fxd_f = fixed_points(self.get_SRWP()) fxd_g = fixed_points(other.get_SRWP()) for c in C: x = inverse(g0)(c) while True: if x in fxd_f: #a fixed point of h dic_h[c] = c dic_h0[c] = f0(x) break else: x = f(x) if x in fxd_g: #not a fixed point of h dic_h[c]=g0(x) break else: x = g(x) h = FiniteSetMaps(C,C).from_dict(dic_h) h0 = FiniteSetMaps(CombinatorialScalarWrapper(dic_h0.keys()),B).from_dict(dic_h0) return ReductionMaps(C,B,h,h0)
def reduction_identity_matrix(mat,st=None,involution_dict=None): r""" When a matrix reduces to the identity, this returns a ReductionMapDict of from a matrix to I. """ dim = mat.nrows() if involution_dict is None: fs = _involution_dict(mat) else: fs = involution_dict f0s = dict() I = identity_matrix(dim) for i in range(dim): for j in range(dim): if i==j: tmp = CombinatorialScalarWrapper(set(fixed_points(fs[i,j]))) f0s[i,j] = FiniteSetMaps(tmp,I[i,j]).from_dict({tmp.get_set().pop():CombinatorialObject(1,1)}) else: f0s[i,j] = FiniteSetMaps(set(),set()).from_dict({}) d = dict() for i in range(dim): for j in range(dim): d[i,j] = ReductionMaps(mat[i,j],I[i,j],fs[i,j],f0s[i,j]) return ReductionMapsDict(d,st)
def reduction_lemma_28_68(mat, red_adjAA_to_I, st = "an application of lemma 28, reduction_68"): r""" Because only one matrix here has a nontrivial SRWP map, we need not apply the formal indexing given in the proof of lemma 28. Simply enter a matrix (adj_AA)BA and the reduction of adj_AA to I. """ d = dict() dim = mat.nrows() for i in range(dim): for j in range(dim): dic_f = dict() dic_f0 = dict() newset = set() for elm in mat[i,j]: #break tuple apart tmp0 = elm.get_object()[0] tmp1 = elm.get_object()[1] tmp2 = elm.get_object()[2] row = tmp0.get_row() col = tmp0.get_col() f_row_col = red_adjAA_to_I[row,col].get_SRWP() f0_row_col = red_adjAA_to_I[row,col].get_SPWP() #assign map tmp = f_row_col(tmp0) sign = tmp.get_sign()*tmp1.get_sign()*tmp2.get_sign() weight = tmp.get_weight()*tmp1.get_weight()*tmp2.get_weight() dic_f[elm] = CombinatorialObject((tmp,tmp1,tmp2),sign,weight) if tmp in fixed_points(f_row_col): tmpfxd = CombinatorialObject((f0_row_col(tmp0),tmp1,tmp2),elm.get_sign(),elm.get_weight()) dic_f0[elm] = tmpfxd newset.add(tmpfxd) f = FiniteSetMaps(mat[i,j],mat[i,j]).from_dict(dic_f) f0 = FiniteSetMaps(dic_f0.keys(),newset).from_dict(dic_f0) d[i,j] = ReductionMaps(mat[i,j],CombinatorialScalarWrapper(newset),f,f0) return ReductionMapsDict(d,st)