=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence for a robot to interact with a drawer. First, the robot attempts to pick the bottom handle of the drawer by approaching it along the x-axis. Next, the robot tries to pull the drawer open by pulling the same handle along the x-axis for a specified distance. If any errors occur during these actions, they are caught and printed. The sequence is executed when the script is run directly.
Similarity: {'ok': False, 'reason': "The code does not account for turning on the light, which is required before picking the handle or opening the drawer according to the domain's preconditions."}
Differences: 1. **Level of Abstraction**  
   - TASK is a high-level instruction ("Open one drawer") without specifying which drawer or how to open it.
   - CODE_FUNC is a low-level, concrete sequence: it specifies picking the bottom handle, moving along the x-axis, and pulling the drawer open by a certain distance.

2. **Drawer Selection**  
   - TASK does not specify which drawer to open.
   - CODE_FUNC explicitly operates on the "bottom" drawer (via "handle_bottom" and "drawer_bottom").

3. **Precondition Handling**  
   - TASK does not mention or handle preconditions (e.g., lighting, lock state, robot location, hand state).
   - CODE_FUNC implicitly assumes the robot can approach and manipulate the handle, but does not explicitly check or handle all PDDL preconditions (e.g., room brightness, drawer unlocked).

4. **Error Handling**  
   - TASK does not mention error handling.
   - CODE_FUNC includes try/except blocks to catch and print errors during execution.

5. **Action Granularity**  
   - TASK is a single, atomic instruction.
   - CODE_FUNC decomposes the task into multiple steps: approach, pick, pull, with explicit movement directions and distances.

6. **Domain Knowledge Usage**  
   - TASK is agnostic to the domain's predicates and actions.
   - CODE_FUNC is written with implicit knowledge of the robot's capabilities and the physical arrangement (e.g., x-axis movement, handle manipulation).

7. **Generalization**  
   - TASK is general and could apply to any drawer in the environment.
   - CODE_FUNC is specific to a particular drawer and handle.

8. **Lighting Condition**  
   - TASK does not mention the need to turn on the light.
   - CODE_FUNC does not include a step to turn on the light, even though the domain requires the room to be bright for manipulation actions.

9. **Lock State**  
   - TASK does not mention unlocking the drawer.
   - CODE_FUNC does not include a step to unlock the drawer, assuming it is already unlocked.

10. **Object References**  
    - TASK refers generically to "one drawer".
    - CODE_FUNC refers specifically to "handle_bottom" and "drawer_bottom".

11. **Robot State**  
    - TASK does not specify the robot's initial or final state.
    - CODE_FUNC assumes the robot can approach and manipulate the handle without specifying or checking its state.

12. **Output/Feedback**  
    - TASK does not specify what to do after opening the drawer.
    - CODE_FUNC prints errors if they occur, but otherwise does not specify post-action feedback.

13. **Parameterization**  
    - TASK is parameter-free.
    - CODE_FUNC uses explicit parameters (e.g., x-axis, distance).

14. **Script Execution**  
    - TASK is a static instruction.
    - CODE_FUNC is executable code, with a main guard (`if __name__ == "__main__":`).

15. **Assumptions**  
    - TASK makes no assumptions about the environment.
    - CODE_FUNC assumes the robot is at the correct location, the handle is accessible, and the drawer is unlocked and can be opened.

16. **Language/Format**  
    - TASK is in natural language.
    - CODE_FUNC is in code (likely Python).

17. **Goal Specification**  
    - TASK specifies a goal state (drawer open).
    - CODE_FUNC specifies a sequence of actions to achieve the goal.

18. **Reactivity**  
    - TASK is not reactive.
    - CODE_FUNC can react to errors via exception handling.

19. **Completeness**  
    - TASK is complete as a goal statement.
    - CODE_FUNC may be incomplete with respect to the domain's requirements (e.g., does not ensure light is on, drawer is unlocked).

20. **Multiplicity**  
    - TASK allows for any one drawer to be opened.
    - CODE_FUNC only opens the bottom drawer.

---

**Summary:**  
The main semantic differences are in specificity, abstraction, error handling, precondition management, and domain assumption. The TASK is a general, high-level instruction, while CODE_FUNC is a specific, low-level, partially domain-aware implementation for a particular drawer.

Refined Code Generated:
-------------------
from Object_list import Object
from skill_mapping import RobotController

def open_one_drawer():
    """
    Opens one drawer by executing the necessary sequence:
    1. Turn on the light if the room is dark.
    2. Pick a handle of an unlocked, closed drawer.
    3. Pull the handle to open the drawer.
    """
    robot = RobotController()

    # Step 1: Turn on the light (execute_push_switch)
    try:
        robot.execute_movement(Object["light_switch"], mode=7, location="ready-pose")
    except Exception as error:
        print(f"Error during execute_push_switch on light_switch: {error}")

    # Step 2: Pick the handle of an unlocked, closed drawer (choose bottom drawer for example)
    try:
        robot.execute_movement(Object["handle_bottom"], mode=1, axis=0)
    except Exception as error:
        print(f"Error during execute_pick on handle_bottom: {error}")

    # Step 3: Pull the handle to open the drawer
    try:
        robot.execute_movement(Object["handle_bottom"], mode=4, distance=0.1)
    except Exception as error:
        print(f"Error during execute_pull on handle_bottom: {error}")

def main():
    """
    Main entry point to open one drawer.
    """
    open_one_drawer()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a sequence for a robot to interact with a drawer. First, the robot approaches and picks the bottom handle of the drawer along the x-axis. Next, the robot pulls the drawer open using the same handle, moving it a specified distance. If any errors occur during these actions, they are caught and printed. The sequence is executed when the script is run directly.
Similarity: {'ok': False, 'reason': "The code does not account for turning on the light, which is required before picking the handle and pulling the drawer open according to the domain's preconditions."}
Differences: 1. The TASK specifies only the high-level instruction: "Pull open a single drawer," without specifying which drawer, which handle, or any details about the process.
2. The CODE_FUNC specifically describes interacting with the bottom drawer by picking the bottom handle and pulling it open, implying a particular drawer and handle.
3. The CODE_FUNC includes explicit robot movement to the handle (approaching along the x-axis), which is not mentioned in the TASK.
4. The CODE_FUNC includes error handling (catching and printing errors), which is not present in the TASK.
5. The CODE_FUNC describes the sequence as executable code (with a main guard), while the TASK is a natural language instruction.
6. The CODE_FUNC assumes the robot is already able to see and access the handle, while the TASK does not specify any preconditions or environment state.
7. The CODE_FUNC does not mention any requirements about lighting (room brightness), while the TASK (and domain) may implicitly require the room to be bright before pulling.
8. The CODE_FUNC does not mention unlocking the drawer, while the TASK is agnostic about the lock state.
9. The CODE_FUNC is specific to the "bottom" drawer and handle, while the TASK is generic ("a single drawer").
10. The CODE_FUNC describes the action as a sequence of lower-level steps (approach, pick, pull), while the TASK is a single high-level instruction.

Refined Code Generated:
-------------------
"""Module to pull open a single drawer using the robot controller."""

from Object_list import Object
from skill_mapping import RobotController

def pull_open_single_drawer():
    """Pull open a single drawer."""
    robot = RobotController()

    # Step 1: Turn on the light if the room is dark
    robot.execute_push_switch(Object["light_switch"], Object["ready-pose"])

    # Step 2: Pick up a handle (e.g., handle_bottom) from the floor
    robot.execute_pick(Object["handle_bottom"], Object["ready-pose"])

    # Step 3: Pull open the corresponding drawer (e.g., drawer_bottom) using the handle
    robot.execute_pull(Object["drawer_bottom"], Object["handle_bottom"], Object["ready-pose"])

def main():
    """Main function to execute the pull open drawer task."""
    pull_open_single_drawer()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to perform a two-step task. First, the robot grasps the handle of the bottom drawer. Next, it pulls the bottom drawer open by a specified distance. If any error occurs during these actions, it prints an error message.
Similarity: {'ok': False, 'reason': "The code does not specify turning on the light, which is required before the robot can grasp the handle and open the drawer according to the domain's preconditions."}
Differences: 1. **Explicitness of Steps**:  
   - **TASK**: Only specifies the high-level instruction "Slide one drawer open," without detailing how to achieve it.
   - **CODE_FUNC**: Explicitly describes two sub-steps: (a) grasping the handle of the bottom drawer, and (b) pulling the drawer open by a specified distance.

2. **Drawer Selection**:  
   - **TASK**: "One drawer" is generic; it does not specify which drawer to open.
   - **CODE_FUNC**: Specifies the "bottom drawer" explicitly.

3. **Handle Interaction**:  
   - **TASK**: Does not mention the need to grasp the handle.
   - **CODE_FUNC**: Explicitly states that the robot must grasp the handle before pulling.

4. **Distance Specification**:  
   - **TASK**: Does not mention how far to open the drawer.
   - **CODE_FUNC**: States that the drawer is pulled open "by a specified distance."

5. **Error Handling**:  
   - **TASK**: No mention of error handling or what to do if the action fails.
   - **CODE_FUNC**: Specifies that if any error occurs during the actions, an error message is printed.

6. **Number of Drawers**:  
   - **TASK**: Leaves the drawer unspecified; could be any drawer.
   - **CODE_FUNC**: Only the bottom drawer is considered.

7. **Assumed Preconditions**:  
   - **TASK**: Does not specify preconditions (e.g., light state, robot location, drawer lock state).
   - **CODE_FUNC**: Implicitly assumes the robot can grasp and pull the handle, but does not mention environmental preconditions (e.g., light, lock).

8. **Level of Abstraction**:  
   - **TASK**: High-level, goal-oriented.
   - **CODE_FUNC**: Low-level, step-by-step procedural.

9. **Output/Feedback**:  
   - **TASK**: No output or feedback mechanism.
   - **CODE_FUNC**: Provides feedback via error messages if something goes wrong.

10. **Object Manipulation**:  
    - **TASK**: Does not specify how the drawer is to be opened (e.g., by handle, by pushing/pulling).
    - **CODE_FUNC**: Specifies opening by pulling the handle.

11. **Robustness**:  
    - **TASK**: No mention of robustness or error recovery.
    - **CODE_FUNC**: Includes basic robustness via error reporting.

12. **Robot Actions**:  
    - **TASK**: Implies a single action ("slide open").
    - **CODE_FUNC**: Decomposes into two actions: grasp and pull.

13. **Parameterization**:  
    - **TASK**: No parameters.
    - **CODE_FUNC**: Parameterizes the "distance" to open the drawer.

14. **Assumed Context**:  
    - **TASK**: Context-free; could apply to any drawer in any state.
    - **CODE_FUNC**: Context-specific; assumes the bottom drawer and its handle.

15. **Domain Knowledge**:  
    - **TASK**: Does not assume knowledge of handles or drawer structure.
    - **CODE_FUNC**: Assumes knowledge of handles and their association with drawers.

Refined Code Generated:
-------------------
"""Module to slide one drawer open, ensuring all domain preconditions are satisfied."""

from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Slides one drawer open, ensuring light is on and preconditions are met."""
    robot = RobotController()

    try:
        # Step 1: If the room is dark, turn on the light first
        if robot.get_room_light_state() == "dark":
            robot.execute_push_switch(Object["light_switch"], Object["ready-pose"])

        # Step 2: Move to the drawer area if not already there
        if robot.get_robot_location() != Object["drawer-area"]:
            robot.execute_go(Object["ready-pose"], Object["drawer-area"])

        # Step 3: Pick the handle of one drawer (choose bottom drawer for determinism)
        robot.execute_movement(Object["handle_bottom"], mode=1, axis=0)

        # Step 4: Pull the drawer open using the handle
        robot.execute_movement(Object["handle_bottom"], mode=4, axis=0, distance=0.1)

    except Exception as error:
        print(f"Error during task execution: {error}")

def main():
    """Main entry point to execute the drawer opening task."""
    long_horizon_task2_oracle_seq()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence for a robot to interact with a drawer. When run, it creates a robot controller and instructs the robot to first pick the bottom handle of a drawer by approaching along the x-axis. Then, it commands the robot to pull the drawer open using the same handle, also along the x-axis, for a specified distance. If any error occurs during these actions, it prints an error message.
Similarity: {'ok': False, 'reason': 'The code does not turn on the light before attempting to pick the handle, but the domain requires the room to be bright for picking and pulling actions.'}
Differences: 1. **Specificity of Drawer**  
   - TASK: "Open up one of the drawers." is ambiguous as to which drawer to open.
   - CODE_FUNC: Specifies the "bottom" drawer by picking the "bottom handle" and pulling it.

2. **Reference to Handle**  
   - TASK: Does not mention the need to interact with a handle.
   - CODE_FUNC: Explicitly requires picking the bottom handle before pulling.

3. **Axis of Approach/Action**  
   - TASK: No mention of direction or axis.
   - CODE_FUNC: Specifies actions are performed along the x-axis.

4. **Error Handling**  
   - TASK: No mention of error handling.
   - CODE_FUNC: Includes error handling (prints an error message if an error occurs).

5. **Controller Instantiation**  
   - TASK: No mention of creating or using a robot controller.
   - CODE_FUNC: Explicitly creates a robot controller object.

6. **Action Sequence**  
   - TASK: Only instructs to open a drawer (single high-level action).
   - CODE_FUNC: Breaks down into two actions: pick handle, then pull to open.

7. **Distance Specification**  
   - TASK: No mention of how far to pull.
   - CODE_FUNC: Specifies pulling for a certain distance.

8. **Assumed Preconditions**  
   - TASK: Assumes the drawer can be opened directly.
   - CODE_FUNC: Assumes the robot must first pick the handle before pulling.

9. **Robot Location/Movement**  
   - TASK: No mention of robot's location or movement.
   - CODE_FUNC: Implies the robot must approach the handle (along x-axis).

10. **Drawer State**  
    - TASK: No mention of drawer state (locked/unlocked, open/closed).
    - CODE_FUNC: Assumes the drawer can be opened after picking the handle, but does not explicitly check state.

11. **Lighting/Room State**  
    - TASK: No mention of lighting.
    - CODE_FUNC: No mention of lighting, but the domain requires the room to be bright for actions; this is not handled in the code.

12. **Object Generality**  
    - TASK: "one of the drawers" (any drawer).
    - CODE_FUNC: Only the bottom drawer is targeted.

13. **Plurality**  
    - TASK: "drawers" (plural, but only one to be opened).
    - CODE_FUNC: Only one specific drawer is operated on.

14. **Physical Manipulation Details**  
    - TASK: No details on how to physically open the drawer.
    - CODE_FUNC: Details the physical manipulation (pick handle, pull along axis).

15. **Abstraction Level**  
    - TASK: High-level, human instruction.
    - CODE_FUNC: Low-level, robot action sequence.

16. **Success Criteria**  
    - TASK: Drawer is open.
    - CODE_FUNC: Drawer is pulled open, but does not explicitly check or confirm the final state.

17. **Object Types**  
    - TASK: Refers to "drawer".
    - CODE_FUNC: Refers to both "handle" and "drawer".

18. **Implicit vs. Explicit Steps**  
    - TASK: Implies opening can be done in one step.
    - CODE_FUNC: Makes explicit the need to pick the handle before pulling.

19. **Error Reporting**  
    - TASK: No error reporting.
    - CODE_FUNC: Prints error messages on failure.

20. **Parameterization**  
    - TASK: No parameters.
    - CODE_FUNC: Parameterizes actions (e.g., which handle, which axis, how far).

21. **Reusability**  
    - TASK: General instruction, reusable for any drawer.
    - CODE_FUNC: Hardcoded for the bottom drawer/handle.

22. **Assumed Knowledge**  
    - TASK: Assumes the agent knows how to open a drawer.
    - CODE_FUNC: Encodes the knowledge as a sequence of primitive actions.

23. **Domain Constraints**  
    - TASK: Ignores domain constraints (e.g., lighting, locked state).
    - CODE_FUNC: Ignores some domain constraints (e.g., lighting, locked state), but encodes others (must pick handle).

24. **Language**  
    - TASK: Natural language.
    - CODE_FUNC: Programming code with comments.

25. **Error Recovery**  
    - TASK: No recovery mechanism.
    - CODE_FUNC: Only prints error, does not attempt recovery.

26. **User Intent**  
    - TASK: User intent is to open any drawer.
    - CODE_FUNC: Programmer intent is to open the bottom drawer specifically.

27. **Action Granularity**  
    - TASK: Single, high-level action.
    - CODE_FUNC: Multiple, low-level actions.

28. **Assumed Initial State**  
    - TASK: No assumption about initial state.
    - CODE_FUNC: Assumes handle is accessible and can be picked.

29. **Feedback**  
    - TASK: No feedback mechanism.
    - CODE_FUNC: Feedback only via error message.

30. **Physical Constraints**  
    - TASK: No mention.
    - CODE_FUNC: Implies physical constraints (must pick handle, pull along axis).

---

**Summary:**  
The TASK is a high-level, ambiguous, and general instruction, while the CODE_FUNC is a low-level, specific, and detailed sequence targeting a particular drawer and handle, with explicit manipulation steps, error handling, and parameterization. The CODE_FUNC omits some domain constraints (e.g., lighting), but encodes others (must pick handle). The TASK is reusable and general; the CODE_FUNC is hardcoded and specific.

Refined Code Generated:
-------------------
from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """
    Opens one of the drawers (bottom drawer) by turning on the light, picking the handle, and pulling the drawer.
    """
    robot = RobotController()
    try:
        # Step 1: Move to the light switch and turn on the light if the room is dark
        robot.execute_movement(Object["light_switch"], mode=1, axis=0)
        robot.execute_push_switch(Object["light_switch"])
        # Step 2: Move to the bottom drawer handle and pick it
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)
        robot.execute_pick(Object["drawer_bottom_handle"])
        # Step 3: Pull the bottom drawer using the handle
        robot.execute_movement(Object["drawer_bottom_handle"], mode=4, axis=0, distance=0.1)
    except Exception as error:
        print(f"Error during task execution: {error}")

def main():
    """
    Main function to execute the drawer opening task.
    """
    long_horizon_task2_oracle_seq()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to perform a two-step task involving a drawer. First, the robot moves to pick the handle of the bottom drawer. Next, it pulls the bottom drawer open by a specified distance using the handle. If any error occurs during these actions, it is caught and printed. The process is initiated when the script is run directly.
Similarity: {'ok': False, 'reason': 'The code does not turn on the light before attempting to pick the handle, but the domain requires the room to be bright for picking and pulling actions.'}
Differences: 1. **Lighting Condition Handling**  
   - **TASK**: The instruction "Uncover a drawer by opening it" does not specify any requirement about the lighting condition (whether the room is dark or bright).
   - **CODE_FUNC**: The code does not mention or handle the lighting condition. However, according to the PDDL domain, opening a drawer (execute_pull) requires the room to be bright. If the room is dark (as in the initial state), the robot must first turn on the light (execute_push_switch) before it can pick the handle or open the drawer. The code omits this step.

2. **Handle Acquisition**  
   - **TASK**: The instruction does not specify how the drawer is to be opened (e.g., by pulling a handle, pushing, etc.).
   - **CODE_FUNC**: The code explicitly requires the robot to pick up the handle of the drawer before opening it, matching the domain's requirement that the robot must be holding the handle to execute the pull action.

3. **Drawer Selection**  
   - **TASK**: The instruction is generic ("a drawer"), not specifying which drawer to open.
   - **CODE_FUNC**: The code specifically targets the bottom drawer (drawer_bottom).

4. **Partial vs. Full Opening**  
   - **TASK**: The instruction says to "open" the drawer, which could mean fully or partially.
   - **CODE_FUNC**: The code specifies opening the drawer by a "specified distance," which may imply partial opening, depending on implementation.

5. **Error Handling**  
   - **TASK**: The instruction does not mention error handling.
   - **CODE_FUNC**: The code includes error catching and printing if any step fails.

6. **Action Granularity**  
   - **TASK**: The instruction is high-level and does not specify the sequence of actions.
   - **CODE_FUNC**: The code decomposes the task into explicit steps: move to the handle, pick the handle, pull the drawer.

7. **Initial Robot Location**  
   - **TASK**: The instruction does not specify where the robot starts.
   - **CODE_FUNC**: The code assumes the robot must move to the handle, but does not specify the initial location.

8. **Drawer State Preconditions**  
   - **TASK**: The instruction does not mention the state of the drawer (locked/unlocked, open/closed).
   - **CODE_FUNC**: The code assumes the drawer is unlocked and closed, as required by the domain for opening.

9. **Object Generality**  
   - **TASK**: The instruction is general ("a drawer").
   - **CODE_FUNC**: The code is specific (bottom drawer, bottom handle).

10. **Object Placement**  
    - **TASK**: The instruction does not mention what to do with objects in or around the drawer.
    - **CODE_FUNC**: The code only interacts with the handle and the drawer, not with any objects inside.

---

**Summary**:  
The main semantic differences are that the code is more specific (bottom drawer, handle), omits lighting requirements (which are necessary in the domain), and includes error handling and action decomposition not present in the high-level instruction. The instruction is more general and abstract.

Refined Code Generated:
-------------------
"""Module to uncover a drawer by opening it, following domain requirements."""
from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Sequence to uncover (open) a drawer, ensuring lighting and preconditions."""
    robot = RobotController()

    try:
        # Step 1: Move to the light switch location and turn on the light if needed
        robot.execute_movement(Object["light_switch"], mode=1, axis=0)
        robot.execute_push_switch(Object["light_switch"], Object["light_switch_location"])

        # Step 2: Move to the handle of the bottom drawer
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)

        # Step 3: Pick the handle of the bottom drawer (handle_bottom)
        robot.execute_pick(Object["drawer_bottom_handle"], Object["drawer_bottom_handle_location"])

        # Step 4: Pull the bottom drawer open using the handle
        robot.execute_movement(Object["drawer_bottom_handle"], mode=4, axis=0, distance=0.1)

    except Exception as error:
        print(f"Error during task execution: {error}")

def main():
    """Main entry point to execute the drawer uncovering sequence."""
    long_horizon_task2_oracle_seq()

if __name__ == "__main__":
    main()
-------------------

