def setUp(self): self.max_length = 2 self.x = GroupTerm([Literal('x')]) self.y = GroupTerm([Literal('y')]) self.generators = {Literal('x'), Literal('y')} self.truncated_group = TruncatedFreeGroup(self.max_length, self.generators)
def setUp(self) -> None: self.parser = Parser("(x)") self.x = Atom(GroupTerm([Literal('x')])) self.y = Atom(GroupTerm([Literal('y')])) self.z = Atom(GroupTerm([Literal('z')])) self.xyz = self.x.prod(self.y).prod(self.z) self.e = Atom(GroupTerm([]))
def parse_atom(self) -> Atom: assert self.meet_delimiter not in self.string assert self.join_delimiter not in self.string assert self.inv_character not in self.string literals = [] for char in self.string: if char.lower() == 'e': pass elif char.isupper(): literals.append(Literal(char.lower(), True)) else: literals.append(Literal(char)) return Atom(GroupTerm(literals))
def replace_under_bijection(self, old_symbols: List[Literal], new_symbols: List[Literal]) -> GroupTerm: assert len(old_symbols) == len(new_symbols) new_literals = [] for literal in self.literals: current_symbol_index = old_symbols.index(literal.non_inverted()) new_literals.append(Literal(new_symbols[current_symbol_index].char, literal.is_inverted)) return GroupTerm(new_literals)
def test_replace(self): x = Literal('x') y = Literal('y') z = Literal('z') term = GroupTerm([x, y.inv(), z]).replace_under_bijection([x, y, z], [z, x, y]) string = str(term) self.assertEqual(GroupTerm([z, x.inv(), y]), term, "expected zXy but got " + str(term))
def setUp(self): self.x = Atom(GroupTerm([Literal('x')])) self.y = Atom(GroupTerm([Literal('y')]))
def setUp(self): self.x = Atom(GroupTerm([Literal('x', False)])) self.y = Atom(GroupTerm([Literal('y', False)])) self.z = Atom(GroupTerm([Literal('z', False)])) self.meet = Meet({self.x, self.y, self.z})
def setUp(self) -> None: self.lit = Literal('a', False)
def setUp(self): self.lit = Literal('a', False) self.lit_inv = Literal('a', True)
def test_invert(self): self.assertEqual(Literal('a', True), self.lit.inv()) self.assertEqual(Literal('a', False), self.lit_inv.inv())
def setUp(self): self.terms = {GroupTerm([Literal('x')]), GroupTerm([Literal('y')])}
def setUp(self): self.literals = {Literal('x'), Literal('y')}