{"record":{"id":"afee9586eced114e","repo":"datawhalechina/hello-agents","slug":"when-the-theorem-name-contains-perimeter-area","errorCode":null,"errorMessage":"When the theorem name contains 'perimeter', 'area', 'similar' and 'congruent', theorem parameters must be added.","messagePattern":"When the theorem name contains 'perimeter', 'area', 'similar' and 'congruent', theorem parameters must be added\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py","lineNumber":1331,"sourceCode":"            fact_id, goal_ids = self._add_conclusion(theorem_gdl, replace, premise_ids, operation_id)\n            if fact_id is None:\n                return f\"定理'{theorem}'所有前提已满足，但添加结论失败。结论可能已经存在，或者结论未通过合法性检查。\"\n\n            self._check_goals(goal_ids)\n\n            result = f\"定理'{theorem}'执行成功，以下为问题的状态更新。\\n\"\n            return result + self._get_update(old_fact_id, old_goal_id, old_goal_status)\n\n        else:\n            if theorem_name in special_theorem:\n                msg = f\"When using the 'apply' tool with theorem '{theorem_name}', theorem parameters must be added.\"\n                raise Exception(msg)\n\n            if ('perimeter' in theorem_name or 'area' in theorem_name or\n                    'similar' in theorem_name or 'congruent' in theorem_name):\n                msg = (\"When the theorem name contains 'perimeter', 'area', 'similar' and 'congruent', \"\n                       \"theorem parameters must be added.\")\n                raise Exception(msg)\n\n            all_goal_ids = set()\n            theorem_gdl = self.parsed_gdl['Theorems'][theorem_name]\n            paras, instances, premise_ids = self._run_gpl(theorem_gdl['premises_gpl'])\n            for i in range(len(instances)):\n                replace = dict(zip(paras, instances[i]))\n\n                # add operation\n                theorem_paras = replace_paras(theorem_gdl['paras'], replace)\n                operation_id = self._add_operation(('Apply', theorem_name, theorem_paras))\n\n                # add conclusions\n                fact_id, goal_ids = self._add_conclusion(theorem_gdl, replace, premise_ids[i], operation_id)\n                all_goal_ids.update(goal_ids)\n\n            self._check_goals(all_goal_ids)\n\n            if len(all_goal_ids) == 0:","sourceCodeStart":1313,"sourceCodeEnd":1349,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py#L1313-L1349","documentation":"Raised in the no-parameter branch of apply() when the theorem name (even when not in special_theorem) contains one of the substrings 'perimeter', 'area', 'similar' or 'congruent' and no parameters were given. These theorem families have combinatorially explosive or ambiguous premise matching when auto-instantiated, so the solver requires the caller to bind points explicitly instead of enumerating all instances via GPL.","triggerScenarios":"Calling solver.apply('area_formula') or solver.apply('similar_triangle') bare; any bare apply whose theorem name merely contains one of the four substrings, even as part of a longer word.","commonSituations":"Agents trying bare invocation because it works for simpler theorems; theorem named e.g. 'compare_areas' accidentally matching the substring check and surprising the caller.","solutions":["Add an explicit parameter list with the correct arity, e.g. apply('similar_triangle(A,B,C,D,E,F)').","Look up the expected parameter count from parsed_gdl['Theorems'][name]['paras'] first.","If auto-instantiation is genuinely needed, pick an equivalent theorem whose name avoids the four substrings."],"exampleFix":"# before\nsolver.apply('congruent_triangle')\n\n# after\nn = len(solver.parsed_gdl['Theorems']['congruent_triangle']['paras'])\nsolver.apply('congruent_triangle(A,B,C,D,E,F)')","handlingStrategy":"validation","validationCode":"NEEDS_PARAMS_SUBSTR = ('perimeter', 'area', 'similar', 'congruent')\ndef must_bind_explicitly(theorem_name):\n    return any(s in theorem_name for s in NEEDS_PARAMS_SUBSTR)","typeGuard":null,"tryCatchPattern":"try:\n    solver.apply(theorem)\nexcept Exception as e:\n    if 'perimeter' in str(e):\n        theorem = bind_params_from_gdl(solver, theorem)  # fill arity from parsed_gdl, retry","preventionTips":["Treat the four substrings as a hard rule in the tool schema: these theorems require explicit points.","Avoid naming custom theorems with these substrings unless they truly need explicit binding (substring check is name-based).","Have the agent fall back to a differently-named equivalent theorem when it cannot produce bindings."],"tags":["geometry","symbolic-solver","validation","substring-check"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}