def from_hyperplanes_matroid(matroid: tuple[set[T], list[set[T]]]) -> Callable[[set[T]], int]: """Construct a nulity function from a matroid defined by hyperplanes Args: matroid (tuple[set[T], list[set[T]]]): A matroid defined by hyperplanes Returns: Callable[[set[T]], int]: The nulity function of a given matroid. """ E, _ = matroid return from_independent_matroid((E, independent_sets.from_hyperplanes_matroid(matroid)))
def from_hyperplanes_matroid(matroid: tuple[set[T], list[set[T]]]) -> list[set[T]]: """Construct dependent sets from a matroid defined by hyperplanes. Args: matroid (tuple[set[T], list[set[T]]]): A matroid defined by hyperplanes. Returns: list[set[T]]: The dependent sets of a matroid. """ E, _ = matroid return from_independent_matroid((E, independent_sets.from_hyperplanes_matroid(matroid)))
def independent_sets(self) -> list[set[T]]: return independent_sets.from_hyperplanes_matroid( (self.ground_set, self.hyperplanes))
def test_from_hyperplanes_matroid(hyperplanes_matroid, expected): Is1 = from_hyperplanes_matroid(hyperplanes_matroid) Is2 = expected assert all(map(lambda I1: I1 in Is2, Is1)) and all(map(lambda I2: I2 in Is1, Is2))