{"record":{"id":"72ad9177c055c09c","repo":"datawhalechina/hello-agents","slug":"error-when-set-init-goal-self-parsed-cdl-goal-cd","errorCode":null,"errorMessage":"Error when set init goal {self.parsed_cdl['goal_cdl']}.","messagePattern":"Error when set init goal (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py","lineNumber":396,"sourceCode":"            for instance in extend_constructions[predicate]:\n                self._add_fact(predicate, instance, premise_ids, operation_id)\n\n        # 5.Add facts\n        operation_id = self._add_operation(('Preset', 'init_fact', None))\n        for predicate, instance in self.parsed_cdl['relation_cdl']:\n            if not self._pass_geometric_constraints(predicate, instance):\n                raise Exception(f'EE check not passed when add init fact {(predicate, instance)}.')\n            if (predicate, instance) in self.fact_id:\n                continue\n            fact_id, _ = self._add_fact(predicate, instance, (), operation_id)\n            if fact_id is None:\n                raise Exception(f'Error when add init fact {(predicate, instance)}.')\n\n        # 6.Set goal\n        init_goal_operation_id = self._add_operation(('Preset', 'init_goal', None))\n        goal_ids = self._add_goals([self.parsed_cdl['goal_cdl']], None, init_goal_operation_id)\n        if goal_ids is None:\n            raise Exception(f\"Error when set init goal {self.parsed_cdl['goal_cdl']}.\")\n        self._check_goals(goal_ids)\n\n    def _add_fact(self, predicate, instance, premise_ids, operation_id):\n        if predicate == 'Eq':\n            instance = self._adjust_expr(instance)\n            if instance is None or len(instance.free_symbols) == 0:\n                return None, set()\n\n        if (predicate, instance) in self.fact_id:\n            return None, set()\n\n        fact_id = len(self.facts)\n        self.facts.append((predicate, instance, set(premise_ids), operation_id))\n        self.fact_id[(predicate, instance)] = fact_id\n        self.predicate_to_fact_instances[predicate].append(instance)\n        self.operation_groups[operation_id].add(fact_id)\n\n        goal_ids = set()","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/BitSecret-GPSAgent/src/gps/symbolic_solver.py#L378-L414","documentation":"An exception raised by the symbolic geometry solver (src/gps/symbolic_solver.py) when _add_goals returns None while setting the problem's initial goal from the CDL's goal_cdl. The goal statement could not be converted into an internal goal node: its predicate may be unknown, its entities may not exist in the constructed diagram, or its syntax fails goal parsing. Since the goal is the solver's objective, the whole run aborts at initialization.","triggerScenarios":"Calling the solver on a CDL whose goal section uses a predicate outside the solver's goal grammar (e.g. 'ProveSomething(...)'), references entities not constructed (goal about line EF when E, F are undefined), or is syntactically malformed so parse fails inside _add_goals. Any of these yields goal_ids None and this raise.","commonSituations":"LLM-generated problems with invented goal predicates; copied problems from another solver dialect with different goal syntax; renamed entities in constructions but not in the goal; missing goal section producing a None/empty goal_cdl passed to _add_goals.","solutions":["Print parsed_cdl['goal_cdl'] and verify the goal predicate is one the solver supports and every referenced entity was constructed","Fix the goal statement's syntax/entities in the CDL and re-run","Guard before solving: assert the goal string parses with the library's parse_fact and its entities match constructed ones","When generating CDL programmatically, validate the goal against the same grammar used for relations"],"exampleFix":"# before (goal references undeclared point)\n# goal: Equal(LengthOfLine(AB), LengthOfLine(EF))  # E, F never constructed\n\n# after\n# construct E and F first, or change goal to:\n# Equal(LengthOfLine(AB), LengthOfLine(CD))","handlingStrategy":"validation","validationCode":"goal = parsed['goal_cdl']\nname, paras = parse_fact(goal.replace(' ', ''))\nassert name in supported_goal_predicates(), f'unsupported goal predicate: {name}'\nassert entities_referenced(paras) <= constructed_entities(parsed), 'goal references undeclared entities'","typeGuard":null,"tryCatchPattern":"try:\n    solver.solve(problem_cdl)\nexcept Exception as e:\n    if 'Error when set init goal' in str(e):\n        reject_problem(cdl=problem_cdl, reason=f'invalid goal: {parsed_goal}')\n    raise","preventionTips":["Verify the goal predicate and its entities before running the solver","Keep goal syntax in the same dialect as relations","Reject LLM-generated problems whose goals fail a pre-parse check"],"tags":["geometry","solver","cdl","goal","validation"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}