6.12.6.1. Product

The term product is the categorical word for tuple, for sets it is the cartesian product. We form the product by delegation. The element arrows are tuples of arrows. Objects are tuples of objects. Composition is componentwise.
Start python section to interscript/felix/model/cons.py[2 /6 ] Next Prev Last
     4: #line 16 "felix_cons.ipk"
     5: class cat_product(category):
     6:   def __init__(self, *args):
     7:     self.args = args
     8:     self.len = len(args)
     9: 
    10:   def is_arrow(self,arrow):
    11:     for i in range(self.len)):
    12:        if not self.args[i].is_arrow(arrow[i]): return 0
    13:     return 1
    14: 
    15:   def is_object(self,object):
    16:     for i in range(self.len)):
    17:        if not self.args[i].is_object(object[i]): return 0
    18:     return 1
    19: 
    20:   def can_compose(self, left, right):
    21:     for i in range(self.len):
    22:       if not self.args[i].can_compose(left[i],right[i]): return 0
    23:     return 1
    24: 
    25:   def compose(self, left, right):
    26:     l = []
    27:     for i in range(self.len):
    28:       l.append(self.args[i](left[i],right[i]))
    29:     return tuple(l)
    30: 
    31:   def domain(self, x):
    32:     l = []
    33:     for i in range(self.len):
    34:       l.append(self.args[i].domain(x[i]))
    35:     return tuple(l)
    36: 
    37:   def codomain(self, x):
    38:     l = []
    39:     for i in range(self.len):
    40:       l.append(self.args[i].codomain(x[i]))
    41:     return tuple(l)
    42: 
End python section to interscript/felix/model/cons.py[2]