def simplify(self):
        if self.iscanonical:
            return self
        args = [arg.simplify() for arg in self.args]
        expr = self.__class__(*args)
        expr = expr.literalize()
        expr = expr.flatten()
        if self.annihilator in expr.args:
            return self.annihilator
        args = []
        for arg in expr.args:
            if arg not in args:
                args.append(arg)
        if len(args) == 1:
            return args[0]
        if self.identity in args:
            args.remove(self.identity)
            if len(args) == 1:
                return args[0]
        for arg in args:
            if self.NOT(arg) in args:
                return self.annihilator
        i = 0
        while i < len(args) - 1:
            j = i + 1
            ai = args[i]
            if not isinstance(ai, self.dual):
                i += 1
                continue
            while j < len(args):
                aj = args[j]
                if not isinstance(aj, self.dual) or len(ai.args) != len(aj.args):
                    j += 1
                    continue
                negated = None
                for arg in ai.args:
                    if arg in aj.args:
                        pass
                    elif self.NOT(arg).cancel() in aj.args:
                        if negated is None:
                            negated = arg
                        else:
                            negated = None
                            break
                    else:
                        negated = None
                        break
                if negated is not None:
                    del args[j]
                    aiargs = list(ai.args)
                    aiargs.remove(negated)
                    if len(aiargs) == 1:
                        args[i] = aiargs[0]
                    else:
                        args[i] = self.dual(*aiargs)
                    if len(args) == 1:
                        return args[0]
                    else:
                        return self.__class__(*args).simplify()
                j += 1
            i += 1
        args = self.absorb(args)
        if len(args) == 1:
            return args[0]
        args.sort()
        expr = self.__class__(*args)
        expr.iscanonical = True
        return expr