from typing import Any, overload, Sequence, TypeVar, Tuple from .sets_sum import MyFiniteSetDisjointUnion import act4e_interfaces as I C = TypeVar("C") E = Tuple[int, C] class MyFinitePosetDisjointUnion(I.FinitePosetDisjointUnion[C, E]): _posets: Sequence[I.FinitePoset[C]] _carrier: I.FiniteSetDisjointUnion[C, E] def __init__(self, posets: Sequence[I.FinitePoset[C]]): self._posets = posets self._carrier = MyFiniteSetDisjointUnion(p.carrier() for p in posets) def components(self) -> Sequence[I.FinitePoset[C]]: return self._posets def carrier(self) -> I.FiniteSetDisjointUnion[C, E]: return self._carrier def holds(self, a: E, b: E): ia, va = self._carrier.unpack(a) ib, vb = self._carrier.unpack(b) if ia != ib: return False return self._posets[ia].holds(va, vb) X = TypeVar("X") class SolFinitePosetConstructionSum(I.FinitePosetConstructionSum): def disjoint_union(self, ps: Sequence[I.FinitePoset[X]]) -> I.FinitePosetDisjointUnion[X, Any]: return MyFinitePosetDisjointUnion(ps)