from typing import TypeVar import act4e_interfaces as I from .maps_representation import MyFiniteMap A = TypeVar("A") B = TypeVar("B") C = TypeVar("C") class SolFiniteMapOperations(I.FiniteMapOperations): def identity(self, s: I.Setoid[A]) -> I.Mapping[A, A]: values = [] for a in s.elements(): values.append([a, a]) return MyFiniteMap(s, s, values) def compose(self, f: I.FiniteMap[A, B], g: I.FiniteMap[B, C]) -> I.FiniteMap[A, C]: values = [] for a in f.source().elements(): values.append([a, g(f(a))]) return MyFiniteMap(f.source(), g.target(), values)