datawhalechina/hello-agents · error · Exception

Unknown theorem name: '{theorem_name}'.

Error message

Unknown theorem name: '{theorem_name}'.

What it means

Raised by GPSAgent's symbolic solver in _parse_theorem when the name part of a theorem string (e.g. 'cong_triangle(A,B,C)') does not exist in the loaded GDL theorem dictionary self.parsed_gdl['Theorems']. The solver validates every theorem passed to apply()/decompose() against the theorem database parsed for the current problem, and rejects names it does not know before doing any inference. It is a pure input-validation error, not an inference failure.

Source

Thrown at Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py:1261

            )
            for goal_id in updated_goal_ids:
                goal = _anti_parse_fact((self.goals[goal_id][0], self.goals[goal_id][1]))
                goal = goal + f'({self.status_of_goal[goal_id]})'
                result.append(goal)

        return '\n'.join(result)

    def _parse_theorem(self, theorem):
        try:
            theorem_name, theorem_paras = parse_fact(theorem.replace(' ', ''))
        except Exception as e:
            e_msg = (f"Error '{repr(e)}' occurred while parsing the theorem '{theorem}'. "
                     f"The theorem format is incorrect.")
            raise Exception(e_msg)

        if theorem_name not in self.parsed_gdl["Theorems"]:
            e_msg = f"Unknown theorem name: '{theorem_name}'."
            raise Exception(e_msg)

        error_paras = set([char for char in theorem_paras if not char.isupper()])
        if len(error_paras) > 0:
            e_msg = (f"Theorem parameters must be uppercase letters and , only. "
                     f"The current theorem contains invalid characters '{str(error_paras)}'.")
            raise Exception(e_msg)

        if len(theorem_paras) != 0 and len(theorem_paras) != len(self.parsed_gdl["Theorems"][theorem_name]['paras']):
            e_msg = (f"'{theorem}' has wrong number of parameters "
                     f"(expected {len(self.parsed_gdl["Theorems"][theorem_name]['paras'])}).")
            raise Exception(e_msg)

        if len(theorem_paras) == 0:
            theorem_paras = None

        return theorem_name, theorem_paras

    def apply(self, theorem):

View on GitHub (pinned to 606a07d341)

Solutions

  1. Print or expose sorted(self.parsed_gdl['Theorems'].keys()) and use only those exact names in the theorem string.
  2. Check the spelling of the theorem name; remember leading/trailing spaces are removed but internal spaces are too, so 'isoceles_triangle' vs 'isosceles_triangle' style typos survive to this check.
  3. If the theorem genuinely should exist, verify the correct problem/GDL configuration was loaded and parsed into parsed_gdl before calling apply/decompose.

Example fix

# before
solver.apply('cong_triangel(A,B,C,D)')  # misspelled name

# after
valid = sorted(solver.parsed_gdl['Theorems'].keys())
print(valid)  # pick exact name from this list
solver.apply('cong_triangle(A,B,C,D)')
Defensive patterns

Strategy: validation

Validate before calling

def check_theorem_name(solver, theorem):
    name = theorem.replace(' ', '').split('(')[0]
    known = solver.parsed_gdl['Theorems']
    if name not in known:
        raise KeyError(f'{name!r} not in {sorted(known)}')
    return theorem

Try / catch

try:
    solver.apply(theorem)
except Exception as e:
    if str(e).startswith("Unknown theorem name"):
        # pick from sorted(solver.parsed_gdl['Theorems']) and retry / re-prompt
        ...

Prevention

When it happens

Trigger: Calling solver.apply(theorem) or solver.decompose(theorem) where parse_fact() extracts a name that is misspelled, uses different naming conventions, or belongs to a different problem's GDL file. Spaces are stripped before parsing ('cong triangle(...)' becomes 'congtriangle(...)'), which can silently merge into an unknown name.

Common situations: LLM-driven agents hallucinating theorem names not in the current geometry problem's theorem set; copying theorems between problems with different GDL configurations; renaming theorems in the GDL source without updating prompts/tool descriptions.

Related errors


AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14). Data as JSON: /api/errors/93817061cfdbd763. Report an issue: GitHub.