=== Instruction 1 ===
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 by approaching along the x-axis. Next, the robot pulls the drawer open by pulling the handle along the same axis for a specified distance. The code handles possible errors during each step and prints error messages if any occur.
Similarity: {'ok': True, 'reason': "The described code achieves the task of opening one drawer by picking the handle and pulling to open the bottom drawer, matching the domain's requirements and initial state."}
Differences: 1. **Specificity of Drawer**:  
   - TASK: The instruction is to "Open one drawer," which is general and does not specify which drawer to open.
   - CODE_FUNC: The code specifically targets the "bottom drawer" (drawer_bottom), not any drawer.

2. **Handle Selection**:  
   - TASK: Does not mention how to select or interact with a handle.
   - CODE_FUNC: Explicitly picks the handle of the bottom drawer (handle_bottom) as the object to manipulate.

3. **Movement Details**:  
   - TASK: Does not specify how the robot should move or approach the drawer.
   - CODE_FUNC: Specifies that the robot approaches along the x-axis to pick the handle and pulls along the same axis for a set distance.

4. **Error Handling**:  
   - TASK: No mention of error handling or what to do if an action fails.
   - CODE_FUNC: Includes error handling and prints error messages if steps fail.

5. **Number of Steps**:  
   - TASK: Implies a single action ("Open one drawer").
   - CODE_FUNC: Describes a two-step process: (1) pick the handle, (2) pull to open.

6. **Assumed Preconditions**:  
   - TASK: Does not specify preconditions (e.g., whether the drawer is locked/unlocked, closed/open, or if the robot is at a certain location).
   - CODE_FUNC: Assumes the robot can approach and pick the handle, and that the drawer can be pulled open.

7. **Domain Knowledge**:  
   - TASK: Is agnostic to the specific domain predicates and actions.
   - CODE_FUNC: Implies knowledge of the physical structure (handle, drawer, axes) and the robot's capabilities.

8. **Output/Feedback**:  
   - TASK: No mention of output or feedback.
   - CODE_FUNC: Provides feedback via printed error messages.

9. **Object Manipulation**:  
   - TASK: Does not specify what object (if any) is to be manipulated to open the drawer.
   - CODE_FUNC: Explicitly manipulates the handle object to open the drawer.

10. **Drawer State**:  
    - TASK: Only specifies the end goal (drawer open).
    - CODE_FUNC: Implies the drawer starts closed and is opened by pulling.

11. **Location Handling**:  
    - TASK: No mention of robot or object locations.
    - CODE_FUNC: Specifies movement along the x-axis and approaching the drawer.

12. **Language/Format**:  
    - TASK: Natural language instruction.
    - CODE_FUNC: Technical description of code logic and flow.

13. **Action Granularity**:  
    - TASK: High-level, abstract action.
    - CODE_FUNC: Low-level, concrete sequence of actions.

14. **Drawer Lock State**:  
    - TASK: Does not mention if the drawer is locked or unlocked.
    - CODE_FUNC: Assumes the drawer can be opened (i.e., is unlocked).

15. **Generalization vs. Instantiation**:  
    - TASK: General instruction, could apply to any drawer.
    - CODE_FUNC: Instantiated for a specific drawer and handle.

Refined Code Generated:
-------------------
"""Module to open one drawer using the robot controller."""

from Object_list import Object
from skill_mapping import RobotController

def open_one_drawer():
    """Open any available drawer."""
    robot = RobotController()

    # List of candidate drawers and their handles
    drawers = [
        ("drawer_bottom", "handle_bottom"),
        ("drawer_middle", "handle_middle"),
        ("drawer_top", "handle_top"),
    ]

    for drawer_name, handle_name in drawers:
        drawer = Object.get(drawer_name)
        handle = Object.get(f"{drawer_name}_handle") if f"{drawer_name}_handle" in Object else Object.get(handle_name)
        if drawer is None or handle is None:
            continue

        # Check if the drawer is unlocked and closed
        if getattr(drawer, "is_unlocked", False) and getattr(drawer, "is_closed", False):
            try:
                robot.execute_movement(handle, mode=1, axis=0)
            except Exception as error:
                print(f"Error in execute_pick for {handle_name}: {error}")
                continue

            try:
                robot.execute_movement(handle, mode=4, distance=0.1, axis=0)
            except Exception as error:
                print(f"Error in execute_pull for {handle_name}: {error}")
                continue

            # Drawer opened, exit after opening one
            break

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: This code defines a sequence for a robot to interact with a drawer. First, the robot picks up the bottom handle of the drawer from a ready position, approaching along the x-axis. Next, the robot pulls the drawer open using the same handle, again approaching along the x-axis and moving 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': True, 'reason': 'The code describes picking up the correct handle and pulling open the corresponding unlocked, closed drawer, which matches the task of pulling open a single drawer.'}
Differences: 1. **Specificity of Drawer**  
   - TASK: "Pull open a single drawer" is generic; it does not specify which drawer to open.
   - CODE_FUNC: The code specifically interacts with the "bottom" drawer (using "handle_bottom" and "drawer_bottom").

2. **Approach Direction**  
   - TASK: No mention of approach direction.
   - CODE_FUNC: Specifies that the robot approaches along the x-axis.

3. **Movement Distance**  
   - TASK: No mention of how far to move or pull.
   - CODE_FUNC: Specifies a movement distance when pulling the drawer.

4. **Error Handling**  
   - TASK: No mention of error handling.
   - CODE_FUNC: Includes error catching and printing if actions fail.

5. **Execution Context**  
   - TASK: Purely an instruction, not tied to code execution.
   - CODE_FUNC: The sequence is executed when the script is run directly (i.e., includes a main guard).

6. **Sequence of Actions**  
   - TASK: Only specifies pulling open a drawer.
   - CODE_FUNC: Includes both picking up the handle and pulling the drawer open.

7. **Initial Robot Position**  
   - TASK: No mention of robot's starting position.
   - CODE_FUNC: Specifies starting from a "ready position".

8. **Handle Manipulation**  
   - TASK: Does not mention the need to pick up a handle.
   - CODE_FUNC: Explicitly picks up the handle before pulling.

9. **Drawer State Assumptions**  
   - TASK: No explicit assumption about the drawer's state (locked/unlocked, open/closed).
   - CODE_FUNC: Implicitly assumes the drawer is closed and unlocked (since it proceeds to open it).

10. **Object References**  
    - TASK: Refers generically to "a single drawer".
    - CODE_FUNC: Refers specifically to "handle_bottom" and "drawer_bottom".

11. **Parameterization**  
    - TASK: No parameters or variable values.
    - CODE_FUNC: Uses specific parameters (handle, drawer, approach direction, distance).

12. **Domain Knowledge**  
    - TASK: Does not reference domain-specific actions or predicates.
    - CODE_FUNC: Implies knowledge of the robot's action primitives and environment layout.

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

def pull_open_drawer(drawer_name, handle_name, location_name):
    """
    Pull open a single drawer by picking up its handle and pulling.
    Args:
        drawer_name (str): Name of the drawer to open.
        handle_name (str): Name of the handle attached to the drawer.
        location_name (str): Name of the location where the robot starts.
    """
    robot = RobotController()
    try:
        robot.execute_movement(Object[handle_name], mode=1, axis=0)
        robot.execute_movement(Object[handle_name], mode=4, distance=0.1, axis=0)
    except Exception as error:
        print(f"Error during task execution: {error}")

def main():
    # Example: open the bottom drawer
    pull_open_drawer("drawer_bottom", "handle_bottom", "ready-pose")

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

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a sequence for a robot to interact with a drawer. First, the robot moves to grasp the bottom handle of the drawer. Then, the robot pulls the drawer open by moving along the appropriate 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': True, 'reason': 'The described code sequence matches the required actions (pick up the handle and pull to open) for sliding one drawer open according to the domain and initial state.'}
Differences: 1. **Specificity of Drawer**:  
   - TASK: "Slide one drawer open" is generic; it does not specify which drawer to open.
   - CODE_FUNC: The code specifically targets the "bottom" drawer by grasping the "bottom handle".

2. **Handle Grasping**:  
   - TASK: The instruction does not mention the need to grasp a handle; it only says to open a drawer.
   - CODE_FUNC: The robot explicitly grasps the bottom handle before pulling.

3. **Error Handling**:  
   - TASK: No mention of error handling or what to do if the action fails.
   - CODE_FUNC: The code includes error catching and printing if something goes wrong during the actions.

4. **Movement Details**:  
   - TASK: No details on how the drawer is to be opened (e.g., direction, distance, axis).
   - CODE_FUNC: The code specifies moving along a particular axis for a set distance to open the drawer.

5. **Execution Context**:  
   - TASK: No mention of when or how the instruction is to be executed.
   - CODE_FUNC: The sequence is executed only if the script is run directly (i.e., under `if __name__ == "__main__":`).

6. **Implicit Preconditions**:  
   - TASK: Assumes the drawer can be opened, but does not specify preconditions (e.g., unlocked, closed).
   - CODE_FUNC: Assumes the robot can grasp the handle and pull, but does not explicitly check for lock/unlock state or whether the drawer is already open/closed.

7. **Object Identification**:  
   - TASK: "one drawer" could refer to any drawer.
   - CODE_FUNC: The code identifies and interacts with a specific handle and drawer ("bottom").

8. **Robot Location**:  
   - TASK: No mention of the robot's starting or required location.
   - CODE_FUNC: The robot moves to the handle's location as part of the sequence.

9. **Action Decomposition**:  
   - TASK: Treated as a single high-level action.
   - CODE_FUNC: Decomposes into sub-actions: move to handle, grasp handle, pull to open.

10. **Language vs. Implementation**:  
    - TASK: Natural language, high-level intent.
    - CODE_FUNC: Low-level, stepwise implementation with programming constructs.

Refined Code Generated:
-------------------
"""Module to slide one drawer open using the robot controller."""
from Object_list import Object
from skill_mapping import RobotController

def slide_one_drawer_open():
    """Slides any available closed and unlocked drawer open."""
    robot = RobotController()
    # List of drawers and their handles
    drawers = [
        ("drawer_bottom", "drawer_bottom_handle"),
        ("drawer_middle", "drawer_middle_handle"),
        ("drawer_top", "drawer_top_handle"),
    ]
    for drawer_name, handle_name in drawers:
        drawer = Object.get(drawer_name)
        handle = Object.get(handle_name)
        if drawer is not None and handle is not None:
            # Check if the drawer is closed and unlocked
            if drawer.is_closed() and not drawer.is_locked():
                # Move to the handle and open the drawer
                robot.execute_movement(handle, mode=1, axis=0)
                robot.execute_movement(handle, mode=4, distance=0.1)
                break

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

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

=== Instruction 4 ===
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 grasps the bottom handle of the drawer in a ready position. Next, the robot pulls the drawer open by moving the handle a specified distance. If any error occurs during these actions, it is caught and printed.
Similarity: {'ok': True, 'reason': "The code describes grasping the bottom handle and pulling to open the drawer, which matches the domain's requirements for opening a drawer."}
Differences: 1. **Specificity of Drawer**  
   - TASK: "Open up one of the drawers." is ambiguous as to which drawer should be opened.
   - CODE_FUNC: Specifies the "bottom" drawer by grasping the "bottom handle" and opening that specific drawer.

2. **Implicit Preconditions**  
   - TASK: Does not specify preconditions such as the drawer being unlocked, the robot being at a certain location, or the handle being available.
   - CODE_FUNC: Assumes and acts upon the robot being at the "ready position," the handle being accessible, and the drawer being unlocked and closed.

3. **Action Granularity**  
   - TASK: Describes the goal at a high level ("open up one of the drawers").
   - CODE_FUNC: Breaks the task into concrete steps: (a) grasp the handle, (b) pull to open the drawer.

4. **Error Handling**  
   - TASK: No mention of error handling or contingencies.
   - CODE_FUNC: Explicitly includes error catching and reporting during the execution of the steps.

5. **Drawer State Change**  
   - TASK: Only specifies the end state (drawer open), not the process.
   - CODE_FUNC: Specifies the process (grasp, pull) and the expected state transitions.

6. **Robot Location**  
   - TASK: Does not mention where the robot should be.
   - CODE_FUNC: Specifies the robot starts at the "ready position."

7. **Handle Usage**  
   - TASK: Does not mention the use of a handle.
   - CODE_FUNC: Explicitly requires grasping the handle to open the drawer.

8. **Drawer Selection Criteria**  
   - TASK: Leaves the choice of drawer open.
   - CODE_FUNC: Hardcodes the bottom drawer as the target.

9. **Object Manipulation**  
   - TASK: No mention of manipulating objects other than the drawer.
   - CODE_FUNC: Involves manipulating the handle object as part of the process.

10. **Level of Abstraction**  
    - TASK: High-level, user-facing instruction.
    - CODE_FUNC: Low-level, implementation-specific sequence of actions.

Refined Code Generated:
-------------------
"""Module to open one of the drawers using the robot controller."""

from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Open one of the drawers (bottom drawer) by grasping its handle and pulling."""
    robot = RobotController()
    try:
        # Pick the handle of the bottom drawer at ready-pose (axis=0 for handle grasp)
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)
        # Pull the bottom drawer using its handle at ready-pose (mode=4 is pull, axis=0 by default)
        robot.execute_movement(Object["drawer_bottom_handle"], mode=4, 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 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, the robot pulls the bottom drawer open by a specified distance. If any error occurs during these actions, it is caught and printed.
Similarity: {'ok': True, 'reason': "The code describes picking the handle and pulling the bottom drawer open, which matches the task of uncovering a drawer by opening it according to the domain's actions and predicates."}
Differences: 1. **Level of Abstraction**  
   - TASK describes the *goal* at a high level: "Uncover a drawer by opening it."  
   - CODE_FUNC describes the *procedure*: move to pick the handle, then pull the drawer open.

2. **Explicitness of Steps**  
   - TASK does not specify *how* to open the drawer (e.g., which handle to pick, which drawer, or the sequence of actions).
   - CODE_FUNC specifies: pick the handle of the *bottom* drawer, then pull the *bottom* drawer open.

3. **Drawer Selection**  
   - TASK is generic: "a drawer."
   - CODE_FUNC is specific: "bottom drawer."

4. **Error Handling**  
   - TASK does not mention error handling.
   - CODE_FUNC explicitly catches and prints errors during execution.

5. **Parameterization**  
   - TASK does not mention any parameters (e.g., distance to open).
   - CODE_FUNC specifies opening the drawer by a "specified distance."

6. **Assumed Preconditions**  
   - TASK assumes the drawer can be opened (does not mention lock/unlock state).
   - CODE_FUNC assumes the robot can pick the handle and pull (implies the drawer is unlocked and closed, matching the domain's preconditions).

7. **Robot's Perspective**  
   - TASK is from a human instruction perspective.
   - CODE_FUNC is from a robot control/programming perspective.

8. **Outcome**  
   - TASK's outcome is the drawer being "uncovered" (implies open).
   - CODE_FUNC's outcome is the drawer being physically opened by a certain distance.

9. **Object Manipulation**  
   - TASK does not mention manipulating the handle.
   - CODE_FUNC explicitly includes picking the handle as a step.

10. **Domain Knowledge**  
    - TASK does not reference domain-specific predicates or actions.
    - CODE_FUNC implicitly references domain actions (pick, pull) and object relations (handle, drawer).

11. **Granularity**  
    - TASK is a single-step instruction.
    - CODE_FUNC is a multi-step procedure.

12. **Ambiguity**  
    - TASK is ambiguous about which drawer, which handle, and how much to open.
    - CODE_FUNC is unambiguous: bottom drawer, pick handle, open by distance.

13. **Error Recovery**  
    - TASK does not address what happens if the action fails.
    - CODE_FUNC includes error catching and reporting.

14. **Temporal Structure**  
    - TASK is atemporal (just "open").
    - CODE_FUNC is sequential (first pick, then pull).

15. **Physical Constraints**  
    - TASK does not mention physical constraints (e.g., need to hold handle).
    - CODE_FUNC assumes and acts on such constraints (must pick handle before pulling).

---

**Summary:**  
The semantic differences are primarily in specificity, procedural detail, error handling, and perspective (goal vs. implementation).

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

def uncover_drawer_by_opening():
    """Uncover a drawer by opening it."""
    robot = RobotController()
    try:
        # Pick a handle of a closed, unlocked drawer (choose bottom drawer for demonstration)
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)
        # Pull the 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 uncover a drawer by opening it."""
    uncover_drawer_by_opening()

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

