=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence of actions for a robot to perform a specific long-horizon task. The robot starts from a ready position and moves to the floor. It picks up a dice from the floor, then repositions itself. Next, it picks up the handle of a drawer and pulls the drawer open. The robot then places the dice into the open drawer, pushes the drawer closed, and finally returns to the ready position. Each step is executed through a robot controller that performs movements or manipulations based on specified objects and actions. If any error occurs during the sequence, it is caught and printed.
Similarity: {'ok': True, 'reason': 'The described code sequence covers all necessary actions to place one dice into a drawer, including picking the dice, opening the drawer, placing the dice inside, closing the drawer, and returning to ready pose.'}
Differences: 1. **Explicitness of Drawer State Manipulation**:  
   - **CODE_FUNC** explicitly describes the robot picking up the handle, pulling the drawer open, placing the dice, pushing the drawer closed, and returning to ready pose.  
   - **TASK** only instructs to "place one dice into a drawer" and does not specify the need to open or close the drawer, nor to return to a ready pose.

2. **Assumption of Drawer Accessibility**:  
   - **TASK** is ambiguous about the initial state of the drawer (open/closed/locked/unlocked).  
   - **CODE_FUNC** assumes the drawer is closed and must be opened via the handle before placing the dice.

3. **Handle Manipulation**:  
   - **CODE_FUNC** includes the step of picking up the handle and using it to open the drawer.  
   - **TASK** does not mention the handle or the need to manipulate it.

4. **Return to Ready Pose**:  
   - **CODE_FUNC** includes returning the robot to the ready position at the end.  
   - **TASK** does not specify any post-task robot pose.

5. **Error Handling**:  
   - **CODE_FUNC** mentions catching and printing errors during execution.  
   - **TASK** does not mention error handling.

6. **Sequence of Movements**:  
   - **CODE_FUNC** details the robot's movement between locations (ready pose, floor, drawer area, etc.).  
   - **TASK** does not specify any movement or location transitions.

7. **Single vs. Multiple Dice**:  
   - **TASK** says "one dice" (ambiguous, but likely means a single die).  
   - **CODE_FUNC** describes picking up "a dice" (assumed to be one).

8. **Drawer Selection**:  
   - **TASK** does not specify which drawer to use if multiple are present.  
   - **CODE_FUNC** assumes a specific drawer is targeted.

9. **Precondition Awareness**:  
   - **CODE_FUNC** is aware of and acts upon preconditions (e.g., drawer must be open to place dice).  
   - **TASK** does not mention or require awareness of such preconditions.

10. **Level of Abstraction**:  
    - **TASK** is high-level and goal-oriented.  
    - **CODE_FUNC** is low-level and procedural, specifying each required step.

11. **Object Identification**:  
    - **CODE_FUNC** assumes the robot can identify and select the correct dice and handle.  
    - **TASK** does not specify how to identify the dice or drawer.

12. **Drawer Capacity**:  
    - **CODE_FUNC** does not mention checking if the drawer is full or empty.  
    - **TASK** does not specify this either, but the domain allows for such checks.

13. **Lock State**:  
    - **CODE_FUNC** assumes the drawer is unlocked or does not address unlocking.  
    - **TASK** does not mention the lock state.

14. **Generalization**:  
    - **TASK** could apply to any dice and any drawer.  
    - **CODE_FUNC** is written for a specific instance (one dice, one drawer).

15. **Implicit vs. Explicit Actions**:  
    - **TASK** leaves all intermediate actions implicit.  
    - **CODE_FUNC** makes all necessary actions explicit.

---

**Summary**:  
The main semantic differences are that CODE_FUNC is a fully specified, step-by-step procedural plan that makes explicit all necessary sub-actions and assumptions, while TASK is a high-level, underspecified goal that leaves all implementation details implicit.

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

def place_one_dice_in_drawer():
    """
    Place one dice into a drawer.
    Assumes the robot starts at any position, the dice is on the floor, and the drawer is open and not full.
    """
    robot = RobotController()
    # Move to the dice location (floor)
    robot.execute_movement(Object.get("floor", None), mode=7)
    # Pick up dice1 (assuming dice1 is the one to use)
    robot.execute_movement(Object.get("dice1", None), mode=1, axis=2)
    # Move to the drawer area
    robot.execute_movement(Object.get("drawer-area", None), mode=7)
    # Place dice1 into drawer_bottom (assuming drawer_bottom is the target and is open)
    robot.execute_movement(Object.get("drawer_bottom", None), mode=2, axis=2)

def main():
    place_one_dice_in_drawer()

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

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence of actions for a robot to perform a specific task involving a dice and a drawer. The robot first picks up a dice from the floor, then picks up the handle of a drawer. It pulls the drawer open using the handle, places the dice inside the drawer, and then pushes the drawer closed. After each major action, the robot moves to a ready position. The process is wrapped in error handling to catch and report any issues during execution. The main function simply runs this task sequence when the script is executed.
Similarity: {'ok': False, 'reason': 'The code attempts to pick up both the dice and the handle simultaneously, but the domain only allows the robot to hold one object at a time, so the described sequence cannot be executed as specified.'}
Differences: 1. **Handle Pickup**:  
   - *CODE_FUNC* specifies that the robot picks up the handle of the drawer before pulling it open.  
   - *TASK* ("Put a single dice into the drawer") does not mention the handle or require the robot to pick it up; it only specifies the end goal.

2. **Drawer Manipulation Details**:  
   - *CODE_FUNC* explicitly describes the robot pulling the drawer open using the handle and pushing it closed after placing the dice.  
   - *TASK* only requires the dice to be put into the drawer, without specifying how the drawer is to be opened or closed.

3. **Ready Position**:  
   - *CODE_FUNC* states that after each major action, the robot moves to a ready position.  
   - *TASK* does not mention anything about the robot's pose or returning to a ready position.

4. **Error Handling**:  
   - *CODE_FUNC* includes error handling to catch and report issues during execution.  
   - *TASK* does not mention error handling or robustness.

5. **Single Dice vs. Dice Selection**:  
   - *TASK* says "a single dice" but does not specify which dice if multiple are present.  
   - *CODE_FUNC* assumes a specific dice is picked up (though which one is not specified in the summary).

6. **Action Sequence Explicitness**:  
   - *CODE_FUNC* provides a detailed, step-by-step sequence of actions.  
   - *TASK* is an abstract instruction, not specifying the steps.

7. **Main Function/Script Execution**:  
   - *CODE_FUNC* mentions a main function that runs the sequence when the script is executed.  
   - *TASK* is just an instruction, not a program or script.

8. **Object and Drawer Identification**:  
   - *CODE_FUNC* assumes the robot knows which dice and which drawer/handle to use.  
   - *TASK* does not specify which dice or which drawer.

9. **Plurality**:  
   - *TASK* says "a single dice," which could be ambiguous if more than one dice is present.  
   - *CODE_FUNC* assumes only one dice is handled in the sequence.

10. **Implicit Preconditions**:  
    - *CODE_FUNC* assumes the robot starts at a ready position and that the drawer is closed and locked, requiring handle manipulation.  
    - *TASK* does not specify the initial state of the robot or the drawer.

11. **Post-Condition**:  
    - *CODE_FUNC* ends with the drawer closed and the robot in a ready position.  
    - *TASK* only requires the dice to be in the drawer, not specifying the final state of the drawer or robot.

---

**Summary**:  
The main semantic differences are that CODE_FUNC is much more specific, procedural, and robust, detailing the exact steps, error handling, and robot states, while TASK is a high-level, underspecified instruction.

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

def put_single_dice_in_drawer():
    """
    Put a single dice into the drawer.
    """
    robot = RobotController()

    # Pick up the first available dice (e.g., dice1)
    robot.execute_movement(Object.get("dice1", None), mode=1, axis=2)

    # Place the dice into the drawer (e.g., drawer_bottom)
    robot.execute_movement(Object.get("drawer_bottom_place_left", None), mode=2, axis=2)

def main():
    """
    Main function to execute the task.
    """
    put_single_dice_in_drawer()

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

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence of actions for a robot to perform a long-horizon task involving moving objects and interacting with a drawer. The robot starts from a ready position, moves to the floor, and picks up a dice object. It then moves to a drawer area, picks the drawer handle, pulls the drawer open, picks the dice again, places the dice inside the drawer, pushes the drawer closed, and finally returns to the ready position. Each step attempts to use specific object locations and parameters, with fallback options if those are unavailable. The main function simply runs this task sequence.
Similarity: {'ok': False, 'reason': 'The described code sequence incorrectly picks the dice before opening the drawer, but then picks the handle and opens the drawer, which would require the robot to put down the dice and pick it up again, violating the action preconditions and not ensuring the die is inserted into the drawer in a valid order.'}
Differences: 1. **Explicitness of Sequence**:  
   - **TASK**: Only specifies the high-level instruction "Insert one die into a drawer" without detailing the required steps or their order.
   - **CODE_FUNC**: Explicitly enumerates the full sequence of low-level actions (move, pick, pull, place, push, return) needed to accomplish the task, including fallback logic.

2. **Object and Drawer Selection**:  
   - **TASK**: Does not specify which die or which drawer to use.
   - **CODE_FUNC**: Selects specific objects (e.g., dice1) and drawers (e.g., drawer_bottom), and includes logic to choose alternatives if the preferred ones are unavailable.

3. **Handle Manipulation**:  
   - **TASK**: Does not mention the need to interact with a handle to open the drawer.
   - **CODE_FUNC**: Explicitly includes picking the handle and pulling it to open the drawer.

4. **Robot State Management**:  
   - **TASK**: Does not mention the robot's starting or ending pose.
   - **CODE_FUNC**: Starts and ends the sequence with the robot in a "ready" pose.

5. **Fallback/Robustness**:  
   - **TASK**: No mention of fallback or alternative strategies.
   - **CODE_FUNC**: Contains fallback logic for object and location selection if the preferred options are unavailable.

6. **Level of Abstraction**:  
   - **TASK**: High-level, abstract instruction.
   - **CODE_FUNC**: Low-level, concrete action sequence.

7. **Parameterization**:  
   - **TASK**: No parameters or explicit variable bindings.
   - **CODE_FUNC**: Uses explicit parameters for actions (object, drawer, handle, location).

8. **Assumptions about Initial State**:  
   - **TASK**: Assumes the die is not in the drawer, but does not specify the initial state.
   - **CODE_FUNC**: Assumes and checks for specific initial states (e.g., die on floor, drawer closed, robot at ready-pose).

9. **Drawer State Transitions**:  
   - **TASK**: Does not mention opening or closing the drawer.
   - **CODE_FUNC**: Explicitly opens the drawer before placing the die and closes it afterward.

10. **Regrasping**:  
    - **TASK**: Does not mention the need to pick up the die again after opening the drawer.
    - **CODE_FUNC**: Includes a step to pick the die again after opening the drawer, in case it was put down to manipulate the handle.

11. **Error Handling**:  
    - **TASK**: No error handling or recovery.
    - **CODE_FUNC**: Includes fallback and recovery steps if certain actions cannot be performed as planned.

12. **Completeness**:  
    - **TASK**: Leaves many details unspecified.
    - **CODE_FUNC**: Provides a complete, step-by-step plan to achieve the goal.

13. **Use of Domain Knowledge**:  
    - **TASK**: Does not reference the domain's predicates or actions.
    - **CODE_FUNC**: Maps directly to the available PDDL actions and predicates.

14. **Goal Specification**:  
    - **TASK**: Goal is implicit ("insert one die into a drawer").
    - **CODE_FUNC**: Goal is operationalized as a sequence of actions that result in the die being in the drawer and the robot returning to ready-pose.

15. **Multi-object/Drawer Handling**:  
    - **TASK**: Does not specify if multiple dice or drawers are present.
    - **CODE_FUNC**: Handles the possibility of multiple dice and drawers, and selects among them.

---

**Summary**:  
The semantic differences are primarily in explicitness, level of detail, error handling, and mapping to domain actions. The TASK is a high-level, underspecified instruction, while CODE_FUNC is a fully specified, robust, and operational sequence that implements the task using the available domain actions and handles contingencies.

Refined Code Generated:
-------------------
"""Module to insert one die into a drawer using robot primitive skills."""
from Object_list import Object
from skill_mapping import RobotController

def insert_die_into_drawer():
    """Insert one die into a drawer following valid action preconditions and sequence."""
    robot = RobotController()

    # Move from ready-pose to floor
    try:
        robot.execute_movement(Object.get("ready-pose", None), Object.get("floor", None), mode=7)
    except Exception as exc:
        robot.execute_movement(mode=7)

    # Pick up handle_bottom from floor (axis=0 for handle)
    try:
        robot.execute_movement(Object.get("handle_bottom", None), mode=1, axis=0)
    except Exception as exc:
        robot.execute_movement(mode=1, axis=0)

    # Move to drawer-area with handle
    try:
        robot.execute_movement(Object.get("floor", None), Object.get("drawer-area", None), mode=7)
    except Exception as exc:
        robot.execute_movement(mode=7)

    # Pull drawer_bottom using handle_bottom at drawer-area
    try:
        robot.execute_movement(Object.get("drawer_bottom_handle", None), mode=4, distance=0.1)
    except Exception as exc:
        robot.execute_movement(mode=4, distance=0.1)

    # Move to floor to pick up dice1
    try:
        robot.execute_movement(Object.get("drawer-area", None), Object.get("floor", None), mode=7)
    except Exception as exc:
        robot.execute_movement(mode=7)

    # Pick up dice1 from floor (axis=2 for general object)
    try:
        robot.execute_movement(Object.get("dice1", None), mode=1, axis=2)
    except Exception as exc:
        robot.execute_movement(mode=1, axis=2)

    # Move to drawer-area with dice1
    try:
        robot.execute_movement(Object.get("floor", None), Object.get("drawer-area", None), mode=7)
    except Exception as exc:
        robot.execute_movement(mode=7)

    # Place dice1 into drawer_bottom at drawer-area (axis=2)
    try:
        robot.execute_movement(Object.get("drawer_bottom_place_left", None), mode=2, axis=2)
    except Exception as exc:
        robot.execute_movement(mode=2, axis=2)

    # Push drawer_bottom at drawer-area to close
    try:
        robot.execute_movement(Object.get("drawer_bottom_handle", None), mode=3, distance=0.1)
    except Exception as exc:
        robot.execute_movement(mode=3, distance=0.1)

    # Move from drawer-area to ready-pose
    try:
        robot.execute_movement(Object.get("drawer-area", None), Object.get("ready-pose", None), mode=7)
    except Exception as exc:
        robot.execute_movement(mode=7)

def main():
    """Main entry point to insert one die into a drawer."""
    insert_die_into_drawer()

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

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence of robot actions to store a dice inside a drawer and then return the robot to its ready position. The robot controller is initialized, and the robot is instructed to move to the drawer handle, open the drawer, move to the dice, pick up the dice, move back to the drawer, place the dice inside, return to the handle, close the drawer, and finally return to the starting pose. Each step uses predefined movement skills and handles errors by printing messages if any step fails. The sequence is executed when the script is run as the main program.
Similarity: {'ok': True, 'reason': "The described code functionally achieves the task by moving, opening the drawer, picking up the dice, placing it inside, closing the drawer, and returning to ready pose, matching the domain's available actions and predicates."}
Differences: 1. **Explicit Return to Ready Pose**:  
   - *CODE_FUNC* explicitly includes a step to return the robot to its ready position after storing the dice, while *TASK* does not specify this as part of the instruction.

2. **Error Handling**:  
   - *CODE_FUNC* describes handling errors by printing messages if any step fails. *TASK* does not mention error handling.

3. **Initialization**:  
   - *CODE_FUNC* mentions initializing the robot controller before executing actions. *TASK* does not specify any initialization.

4. **Sequence Explicitness**:  
   - *CODE_FUNC* details the full sequence of actions (move to handle, open drawer, move to dice, pick up dice, move to drawer, place dice, return to handle, close drawer, return to ready pose). *TASK* only instructs to "store a dice inside the drawer" without specifying the sequence or intermediate steps.

5. **Scope of Completion**:  
   - *CODE_FUNC* includes closing the drawer after placing the dice, while *TASK* does not specify whether the drawer should be closed after storing the dice.

6. **Handling Multiple Dice**:  
   - *TASK* is ambiguous about which dice to store if more than one is present, while *CODE_FUNC* refers to "a dice" but may be implemented for a specific dice (not specified in the summary).

7. **Assumed Preconditions**:  
   - *CODE_FUNC* assumes the robot starts at the ready pose and that the drawer is closed and locked/unlocked as needed, while *TASK* does not specify any initial conditions.

8. **Level of Abstraction**:  
   - *TASK* is a high-level instruction. *CODE_FUNC* is a low-level, step-by-step implementation.

9. **Drawer State Management**:  
   - *CODE_FUNC* includes both opening and closing the drawer as part of the process. *TASK* only requires the dice to end up inside the drawer, not specifying the final state of the drawer.

10. **Robot Location After Task**:  
    - *CODE_FUNC* ensures the robot ends at the ready pose. *TASK* does not specify the robot's final location.

Refined Code Generated:
-------------------
"""Module to store a dice inside the drawer using predefined robot skills."""

from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """
    Store a dice inside the drawer using the robot's primitive skills.
    """
    robot = RobotController()

    # Move to handle_bottom location
    try:
        robot.execute_movement(Object["drawer_bottom_handle"], mode=7)
    except Exception as error:
        print(f"Error in step 1 (go to handle_bottom): {error}")

    # Pick handle_bottom (approach along x-axis)
    try:
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)
    except Exception as error:
        print(f"Error in step 2 (pick handle_bottom): {error}")

    # Pull drawer_bottom using handle_bottom (approach along x-axis)
    try:
        robot.execute_movement(Object["drawer_bottom_handle"], mode=4, axis=0, distance=0.1)
    except Exception as error:
        print(f"Error in step 3 (pull drawer_bottom): {error}")

    # Move to dice1 location
    try:
        robot.execute_movement(Object["drawer_bottom_place_left"], mode=7)
    except Exception as error:
        print(f"Error in step 4 (go to dice1): {error}")

    # Pick dice1 (approach along z-axis)
    try:
        robot.execute_movement(Object["drawer_bottom_place_left"], mode=1, axis=2)
    except Exception as error:
        print(f"Error in step 5 (pick dice1): {error}")

    # Move to drawer_bottom location
    try:
        robot.execute_movement(Object["drawer_bottom_place_left"], mode=7)
    except Exception as error:
        print(f"Error in step 6 (go to drawer_bottom): {error}")

    # Place dice1 in drawer_bottom (approach along z-axis)
    try:
        robot.execute_movement(Object["drawer_bottom_place_left"], mode=2, axis=2)
    except Exception as error:
        print(f"Error in step 7 (place dice1): {error}")

    # Move to handle_bottom location
    try:
        robot.execute_movement(Object["drawer_bottom_handle"], mode=7)
    except Exception as error:
        print(f"Error in step 8 (go to handle_bottom): {error}")

    # Push drawer_bottom closed (approach along x-axis)
    try:
        robot.execute_movement(Object["drawer_bottom_handle"], mode=3, axis=0, distance=0.1)
    except Exception as error:
        print(f"Error in step 9 (push drawer_bottom): {error}")

def main():
    long_horizon_task2_oracle_seq()

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

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence of actions for a robot to perform a specific task involving objects like a dice and a drawer. The robot first picks up a dice from the floor, then picks up a drawer handle, pulls open the drawer using the handle, and finally places the dice into the opened drawer. Each step involves moving to specific object locations and executing predefined movement modes. If any error occurs during the process, it is caught and printed. The main function runs this task sequence when the script is executed.
Similarity: {'ok': False, 'reason': 'The code description requires picking up a handle to open the drawer, but the domain allows pulling the drawer only with the handle, and the task only asks to drop a dice into any open drawer, so picking up a handle is unnecessary if a drawer is already open.'}
Differences: 1. **Explicit Sequence vs. Open Choice**:  
   - **TASK**: "Drop one dice into any open drawer." The instruction allows the robot to choose *any* open drawer; it does not specify which drawer or which dice.
   - **CODE_FUNC**: The code describes a *fixed* sequence: pick up a dice, pick up a specific handle, open a specific drawer, and place the dice in that drawer. There is no mention of choice; the drawer and dice are implicitly specified.

2. **Drawer State Assumption**:  
   - **TASK**: Assumes there is already an open drawer ("any open drawer").
   - **CODE_FUNC**: The robot must open the drawer itself (by picking up the handle and pulling), implying drawers start closed.

3. **Handle Manipulation**:  
   - **TASK**: Does not mention handles or the need to manipulate them.
   - **CODE_FUNC**: Requires the robot to pick up a handle and use it to open the drawer.

4. **Dice Selection**:  
   - **TASK**: "one dice"—any dice can be chosen.
   - **CODE_FUNC**: The code picks up a specific dice (not specified as a choice).

5. **Error Handling**:  
   - **TASK**: No mention of error handling.
   - **CODE_FUNC**: Includes error catching and printing.

6. **Movement Details**:  
   - **TASK**: Abstracts away movement and location details.
   - **CODE_FUNC**: Specifies moving to object locations and executing movement modes.

7. **Precondition on Drawer Fullness**:  
   - **TASK**: No mention of drawer capacity.
   - **CODE_FUNC**: The PDDL requires the drawer not to be full before placing an object.

8. **Ready Pose**:  
   - **TASK**: No mention of robot pose.
   - **CODE_FUNC**: The robot starts at and may return to a "ready-pose".

9. **Generalization**:  
   - **TASK**: General instruction, could be repeated or applied to multiple dice/drawers.
   - **CODE_FUNC**: Implements a single, specific instance.

10. **Implicit vs. Explicit Steps**:  
    - **TASK**: High-level, leaves implementation details open.
    - **CODE_FUNC**: Explicitly details all steps, including picking up handles, opening drawers, and error handling.

**Summary**: The main semantic differences are that the TASK is high-level, general, and allows for choice, while the CODE_FUNC is specific, prescribes a fixed sequence, and includes additional steps (handle manipulation, opening the drawer) not required by the TASK.

Refined Code Generated:
-------------------
"""Module to drop one dice into any open drawer."""

from Object_list import Object
from skill_mapping import RobotController

def drop_one_dice_into_open_drawer():
    """
    Drops one dice into any open drawer.
    Assumes at least one dice is on the floor and at least one drawer is open and not full.
    """
    robot = RobotController()

    # Find any dice on the floor
    dice_candidates = [name for name in ["dice1", "dice2"] if Object[name].is_on_floor()]
    if not dice_candidates:
        print("No dice available on the floor.")
        return

    # Find any open drawer that is not full
    drawer_candidates = [name for name in ["drawer_bottom", "drawer_middle", "drawer_top"]
                        if Object[name].is_drawer_open() and not Object[name].is_drawer_full()]
    if not drawer_candidates:
        print("No open drawer available.")
        return

    dice = dice_candidates[0]
    drawer = drawer_candidates[0]

    # Pick up the dice (assume approach along z-axis)
    robot.execute_movement(Object[dice], mode=1, axis=2)
    robot.execute_movement(mode=8)

    # Place the dice into the open drawer (assume approach along z-axis)
    place_location = Object[f"{drawer}_place_left"]
    robot.execute_movement(place_location, mode=2, axis=2)
    robot.execute_movement(mode=8)

def main():
    drop_one_dice_into_open_drawer()

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

