def METHOD_NAME(self, hd_vars: List[HDVariable]) -> List[str]:
    lines = [f"    def to_answer_set(self) -> AnswerSet:", f"        result = AnswerSet()"]
    for var in hd_vars:
        prop = f"self.{var.snake_case_name}"
        lines.extend(
            [
                f"        result.add_opt({repr(var.name)},",
                f'                       {self.get_var_add_arg("self", var)})',
            ]
        )
    for repeat in self.lib.repeated_vars:
        prop = f"self.{repeat.py_prop_name}"
        lines.extend(
            [
                f"        if {prop}:",
                f"            {repeat.py_class_name}.add_to_answer_set({prop}, result)",
            ]
        )
    lines.append(f"        return result\n")
    return lines