6.12.6.3. Undiscriminated Union

The argument categories must have disjoint arrows sets for this construction to work. Use the discriminated union if there is an arrow in common.

The categorical sum, or union, of two categories is just the complete set of all the arrows.

Start python section to interscript/felix/model/cons.py[4 /6 ] Next Prev Last
    66: #line 88 "felix_cons.ipk"
    67: class cat_union(category):
    68:   def __init__(self, *args):
    69:     self.args = args
    70:     self.len = len(args)
    71: 
    72:   def is_arrow(self,arrow):
    73:      for i in range(self.len)):
    74:        if self.args[i].is_arrow(arrow): return 1
    75:     return 0
    76: 
    77:   def is_object(self,object):
    78:      for i in range(self.len)):
    79:        if self.args[i].is_object(object): return 1
    80:     return 0
    81: 
    82:   def can_compose(self, left, right):
    83:     for i in range(self.len):
    84:       if (
    85:         self.args[i].is_arrow(left) and
    86:         self.args[i].is_arrow(right) and
    87:         self.args[i].can_compose.(left,right)): return 1
    88:     return 0
    89: 
    90:   def compose(self, left, right):
    91:     for i in range(self.len):
    92:       if (
    93:         self.args[i].is_arrow(left) and
    94:         self.args[i].is_arrow(right)):
    95:         return self.args[i](left,right)
    96: 
    97:   def domain(self, x):
    98:     for i in range(self.len):
    99:       if self.args[i].is_arrow(x):
   100:         return self.args[i].domain(x)
   101: 
   102:   def codomain(self, x):
   103:     for i in range(self.len):
   104:       if self.args[i].is_arrow(x):
   105:         return self.args[i].codomain(x)
   106: 
End python section to interscript/felix/model/cons.py[4]