diff --git a/README.md b/README.md index 92ac085..df4a951 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,8 @@ huggingface_model = HUGGING_FACE(model_path=args.model_path, max_tokens=args.max ## Planner For ease of use, our library contains submodule [FastDownward](https://github.com/aibasel/downward/tree/308812cf7315fe896dbcd319493277d82aa36bd2). Fast Downward is a domain-independent classical planning system that users can run their PDDL domain and problem files on. The motivation is that the majority of papers involving PDDL-LLM usage uses this library as their planner. +**IMPORTANT** FastDownward is a submodule in L2P. To use the planner, you must clone the GitHub repo of [FastDownward](https://github.com/aibasel/downward/tree/308812cf7315fe896dbcd319493277d82aa36bd2) and run the `planner_path` to that directory. + ## Current Works Reconstructed Using L2P The following are papers that have been reconstructed so far. This list will be updated in the future. diff --git a/l2p/domain_builder.py b/l2p/domain_builder.py index 7c6257d..67400bb 100644 --- a/l2p/domain_builder.py +++ b/l2p/domain_builder.py @@ -3,8 +3,7 @@ """ from .utils import * -from .llm_builder import LLM -from .llm_builder import require_llm +from .llm_builder import LLM, require_llm from collections import OrderedDict import re, time @@ -82,9 +81,9 @@ def extract_type( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract types.") @@ -135,9 +134,9 @@ def extract_type_hierarchy( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract type hierarchy.") @@ -198,9 +197,9 @@ def extract_nl_actions( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract NL actions.") @@ -212,11 +211,12 @@ def extract_pddl_action( prompt_template: str, action_name: str, action_desc: str = None, - action_list: dict[str, str] = None, + action_list: str = None, predicates: list[Predicate] = None, types: dict[str, str] = None, + syntax_validator: SyntaxValidator = None, max_retries: int = 3, - ) -> tuple[Action, list[Predicate], str]: + ) -> tuple[Action, list[Predicate], str, tuple[bool, str]]: """ Extract an action and predicates from a given action description using LLM @@ -235,15 +235,16 @@ def extract_pddl_action( action (Action): constructed action class new_predicates (list[Predicate]): a list of new predicates llm_response (str): the raw string LLM response + validation_info (tuple[bool, str]): validation check information """ # replace prompt placeholders types_str = format_dict(types) if types else "No types provided." predicates_str = ( - format_predicates(predicates) if predicates else "No predicates provided." + "\n".join([f"- {pred['clean']}" for pred in predicates]) if predicates else "No predicates provided." ) action_list_str = ( - str(action_list) if action_list else "No other actions provided" + action_list if action_list else "No other actions provided" ) prompt_template = prompt_template.replace("{domain_desc}", domain_desc) @@ -268,16 +269,39 @@ def extract_pddl_action( llm_response=llm_response, action_name=action_name ) new_predicates = parse_new_predicates(llm_response) + + validation_info = [True, "All validations passed."] + if syntax_validator: + for e in syntax_validator.error_types: + if e == 'invalid_header': + validation_info = syntax_validator.validate_header(llm_response) + elif e == 'invalid_keyword_usage': + validation_info = syntax_validator.validate_keyword_usage(llm_response) + elif e == 'unsupported_keywords': + validation_info = syntax_validator.validate_unsupported_keywords(llm_response, syntax_validator.unsupported_keywords) + elif e == 'invalid_param_types': + validation_info = syntax_validator.validate_params(action['params'], types) + elif e == 'invalid_predicate_name': + validation_info = syntax_validator.validate_types_predicates(new_predicates, types) + elif e == 'invalid_predicate_format': + validation_info = syntax_validator.validate_format_predicates(predicates, types) + elif e == 'invalid_predicate_usage': + validation_info = syntax_validator.validate_usage_predicates(llm_response, predicates, types) + else: + raise NotImplementedError(f"Validation type '{e}' is not implemented.") + + if not validation_info[0]: + return action, new_predicates, llm_response, validation_info if action is not None and new_predicates is not None: - return action, new_predicates, llm_response + return action, new_predicates, llm_response, validation_info except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract PDDL action.") @@ -416,9 +440,9 @@ def extract_parameters( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract parameters.") @@ -486,9 +510,9 @@ def extract_preconditions( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract preconditions.") @@ -559,9 +583,9 @@ def extract_effects( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract effects.") @@ -624,9 +648,9 @@ def extract_predicates( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract predicates.") @@ -729,25 +753,25 @@ def generate_domain( """ desc = "" desc += f"(define (domain {domain})\n" - desc += indent(string=f"(:requirements\n {' '.join(requirements)}\n)\n") - desc += f" (:types \n{indent(types)}\n )\n\n" - desc += f" (:predicates \n{indent(predicates)}\n )" + desc += indent(string=f"(:requirements\n {' '.join(requirements)})", level=1) + "\n\n" + desc += f" (:types \n{indent(string=types, level=2)}\n )\n\n" + desc += f" (:predicates \n{indent(string=predicates, level=2)}\n )" desc += self.action_descs(actions) desc += "\n)" desc = desc.replace("AND", "and").replace( "OR", "or" - ) # The python PDDL package can't handle capital AND and OR + ) return desc def action_desc(self, action: Action) -> str: """Helper function to format individual action descriptions""" param_str = "\n".join( - [f"{name} - {type}" for name, type in action["parameters"].items()] + [f"{name} - {type}" for name, type in action["params"].items()] ) # name includes ? desc = f"(:action {action['name']}\n" - desc += f" :parameters (\n{param_str}\n )\n" - desc += f" :precondition\n{action['preconditions']}\n" - desc += f" :effect\n{action['effects']}\n" + desc += f" :parameters (\n{indent(string=param_str, level=2)}\n )\n" + desc += f" :precondition\n{indent(string=action['preconditions'], level=2)}\n" + desc += f" :effect\n{indent(string=action['effects'], level=2)}\n" desc += ")" return desc @@ -755,7 +779,7 @@ def action_descs(self, actions) -> str: """Helper function to combine all action descriptions""" desc = "" for action in actions: - desc += "\n\n" + self.action_desc(action) + desc += "\n\n" + indent(self.action_desc(action), level=1) return desc def format_predicates(self, predicates: list[Predicate]) -> str: diff --git a/l2p/feedback_builder.py b/l2p/feedback_builder.py index 9bcc48f..410fa4a 100644 --- a/l2p/feedback_builder.py +++ b/l2p/feedback_builder.py @@ -3,11 +3,11 @@ """ from .utils import * -from .llm_builder import LLM -from .llm_builder import require_llm +from .llm_builder import LLM, require_llm from .domain_builder import DomainBuilder from .task_builder import TaskBuilder from collections import OrderedDict +import textwrap domain_builder = DomainBuilder() task_builder = TaskBuilder() @@ -75,13 +75,25 @@ def type_feedback( ) if not no_fb: + structure_prompt = textwrap.dedent(""" + ## OUTPUT + { + "type_1": "description", + "type_2": "description", + "type_3": "description", + } + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" + f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f"\n\nApply the suggestions to your original answer:\n{type_str}" ) + + model.reset_tokens() types, llm_response = domain_builder.extract_type( - model, domain_desc, prompt + model, domain_desc, prompt, type_str ) return types, llm_response @@ -113,12 +125,32 @@ def type_hierarchy_feedback( ) if not no_fb: + structure_prompt = textwrap.dedent(""" + ## OUTPUT + { + "parent_type_1": "description", + "children": [ + { + "child_type_1": "description", + "children": [ + {"child_child_type_1": "description", "children": []}, + {"child_child_type_2": "description", "children": []} + ] + } + ] + } + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" + f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f"\n\nApply the suggestions to your original answer:\n{type_str}" ) + + model.reset_tokens() + type_hierarchy, llm_response = domain_builder.extract_type_hierarchy( - model, domain_desc, prompt + model, domain_desc, prompt, type_str ) return type_hierarchy, llm_response @@ -155,10 +187,23 @@ def nl_action_feedback( ) if not no_fb: + structure_prompt = textwrap.dedent(""" + ## OUTPUT + { + "action_name_1": "action_description", + "action_name_2": "action_description", + "action_name_3": "action_description" + } + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" + f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f"\n\nApply the suggestions to your original answer:\n{nl_action_str}" ) + + model.reset_tokens() + nl_actions, llm_response = domain_builder.extract_type_hierarchy( model, domain_desc, prompt ) @@ -176,7 +221,7 @@ def pddl_action_feedback( action: Action = None, predicates: list[Predicate] = None, types: dict[str, str] = None, - ) -> tuple[Action, list[Predicate], str]: + ) -> tuple[Action, list[Predicate], str, tuple[bool,str], bool]: """Makes LLM call using feedback prompt, then parses it into action format""" model.reset_tokens() @@ -186,7 +231,7 @@ def pddl_action_feedback( format_predicates(predicates) if predicates else "No predicates provided." ) param_str = ( - ", ".join([f"{name} - {type}" for name, type in action["params"].items()]) + "\n".join([f"{name} - {type}" for name, type in action["params"].items()]) if action else "No parameters provided" ) @@ -201,7 +246,7 @@ def pddl_action_feedback( feedback_template = feedback_template.replace("{types}", type_str) feedback_template = feedback_template.replace("{predicates}", predicate_str) feedback_template = feedback_template.replace("{action_name}", action_name) - feedback_template = feedback_template.replace("{parameters}", param_str) + feedback_template = feedback_template.replace("{action_params}", param_str) feedback_template = feedback_template.replace( "{action_preconditions}", preconditions_str ) @@ -211,16 +256,51 @@ def pddl_action_feedback( model, feedback_template, feedback_type, llm_response ) + validation_info = [True, "All validations passed."] if not no_fb: + + structure_prompt = textwrap.dedent(""" + End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL as so: + + ### Action Parameters + ``` + - ?t - type: 'parameter_description' + ``` + + ### Action Preconditions + ``` + (and + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION + ) + ``` + + ### Action Effects + ``` + (and + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION + ) + ``` + + ### New Predicates + ``` + - (predicate_name ?t1 - type_1 ?t2 - type_2): 'predicate_description' + ``` + + If there are no new predicates created, keep an empty space enclosed ``` ``` with the '### New Predicates' header. + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" + f"\n\n{structure_prompt}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() - action, predicates, llm_response = domain_builder.extract_pddl_action( + action, predicates, llm_response, validation_info = domain_builder.extract_pddl_action( model, domain_desc, prompt, action_name ) - return action, predicates, llm_response + return action, predicates, llm_response, validation_info, no_fb @require_llm def parameter_feedback( @@ -264,6 +344,8 @@ def parameter_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() param, param_raw, llm_response = domain_builder.extract_parameters( model, domain_desc, prompt, action_name, action_desc, types @@ -324,6 +406,8 @@ def precondition_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() preconditions, new_predicates, llm_response = ( domain_builder.extract_preconditions( @@ -389,6 +473,8 @@ def effect_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() effects, new_predicates, llm_response = domain_builder.extract_effects( model, domain_desc, prompt, action_name, action_desc @@ -434,6 +520,8 @@ def predicate_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() new_predicates, llm_response = domain_builder.extract_predicates( model, domain_desc, prompt @@ -482,19 +570,50 @@ def task_feedback( feedback_template = feedback_template.replace("{predicates}", predicate_str) feedback_template = feedback_template.replace("{objects}", objects_str) feedback_template = feedback_template.replace( - "{initial_state}", initial_state_str + "{initial_states}", initial_state_str ) - feedback_template = feedback_template.replace("{goal_state}", goal_state_str) + feedback_template = feedback_template.replace("{goal_states}", goal_state_str) no_fb, fb_msg = self.get_feedback( model, feedback_template, feedback_type, llm_response ) if not no_fb: + + structure_prompt = textwrap.dedent(""" + End your final answer starting with headers (in order) "### OBJECTS" (with no brackets) "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: + + ### OBJECTS + ``` + object1 - type_1 + object2 - type_2 + object3 - type_1 + ``` + + ### INITIAL + ``` + (predicate_name object1 object2) ; comment for initial state predicate 1 + (predicate_name object3 object4) ; comment for initial state predicate 2 + (predicate_name object5) ; comment for initial state predicate 3 + ``` + + ### GOAL + ``` + (and + (predicate_name object) ; comment + ) + ``` + + Even if there is one goal state, it must contain the PDDL 'and' syntax. Each object must be declared separately with their type and not grouped - even if objects share the same type. + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" + f"\n\n{structure_prompt}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() objects, initial, goal, _ = task_builder.extract_task( model, problem_desc, prompt @@ -545,6 +664,8 @@ def objects_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() objects, llm_response = task_builder.extract_objects( model, problem_desc, prompt @@ -604,6 +725,8 @@ def initial_state_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() initial, llm_response = task_builder.extract_initial_state( model, problem_desc, prompt @@ -668,6 +791,8 @@ def goal_state_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() goal, llm_response = task_builder.extract_goal_state( model, problem_desc, prompt diff --git a/l2p/prompt_builder.py b/l2p/prompt_builder.py index 52297b9..5bb8e87 100644 --- a/l2p/prompt_builder.py +++ b/l2p/prompt_builder.py @@ -3,9 +3,6 @@ have to use this class, but it is generally advisable for ease of use. """ -import os - - class PromptBuilder: def __init__( self, diff --git a/l2p/task_builder.py b/l2p/task_builder.py index 348b6ef..77cbc30 100644 --- a/l2p/task_builder.py +++ b/l2p/task_builder.py @@ -3,8 +3,7 @@ """ from .utils import * -from .llm_builder import LLM -from .llm_builder import require_llm +from .llm_builder import LLM, require_llm import time @@ -59,7 +58,7 @@ def extract_objects( # replace prompt placeholders predicate_str = ( - format_predicates(predicates) if predicates else "No predicates provided." + "\n".join([f"- {pred['name']}: {pred['desc']}" for pred in predicates]) if predicates else "No predicates provided." ) types_str = "\n".join(types) if types else "No types provided." @@ -83,7 +82,7 @@ def extract_objects( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract objects.") @@ -156,7 +155,7 @@ def extract_initial_state( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract initial states.") @@ -229,7 +228,7 @@ def extract_goal_state( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract goal states.") @@ -298,7 +297,7 @@ def extract_task( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract task.") @@ -364,7 +363,7 @@ def extract_nl_conditions( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract NL task states.") @@ -424,7 +423,7 @@ def format_action(self, actions: list[Action]) -> str: desc = "" for action in actions: param_str = "\n".join( - [f"{name} - {type}" for name, type in action["parameters"].items()] + [f"{name} - {type}" for name, type in action["params"].items()] ) # name includes ? desc += f"(:action {action['name']}\n" desc += f" :parameters (\n{indent(param_str,2)}\n )\n" @@ -434,7 +433,7 @@ def format_action(self, actions: list[Action]) -> str: return desc def format_objects(self, objects: dict[str, str]) -> str: - objects = "\n".join([f"{obj} - {type}" for obj, type in objects.items()]) + objects = "\n".join([f"{obj} - {type}" if type else f"{obj}" for obj, type in objects.items()]) return objects def format_initial(self, initial_states: list[dict[str, str]]) -> str: diff --git a/l2p/utils/__init__.py b/l2p/utils/__init__.py index 9e8c564..6d8c10f 100644 --- a/l2p/utils/__init__.py +++ b/l2p/utils/__init__.py @@ -1,4 +1,4 @@ from .pddl_parser import * from .pddl_types import * from .pddl_validator import * -from .utils import * +from .pddl_planner import * diff --git a/l2p/utils/pddl_parser.py b/l2p/utils/pddl_parser.py index a204bdb..45721fa 100644 --- a/l2p/utils/pddl_parser.py +++ b/l2p/utils/pddl_parser.py @@ -2,11 +2,29 @@ This file contains collection of functions for extracting/parsing information from LLM output """ +from pddl.formatter import domain_to_string, problem_to_string +from pddl import parse_domain, parse_problem from .pddl_types import Action, Predicate from collections import OrderedDict from copy import deepcopy -import re, ast, json +import re, ast, json, sys, os +def load_file(file_path: str): + _, ext = os.path.splitext(file_path) + with open(file_path, "r") as file: + if ext == ".json": + return json.load(file) + else: + return file.read().strip() + +def load_files(folder_path: str): + file_contents = [] + for filename in sorted(os.listdir(folder_path)): + file_path = os.path.join(folder_path, filename) + if os.path.isfile(file_path): + with open(file_path, 'r') as file: + file_contents.append(file.read()) + return file_contents def parse_params(llm_output): """ @@ -16,7 +34,7 @@ def parse_params(llm_output): LLM output header should contain '### Parameters' along with structured content. """ params_info = OrderedDict() - params_heading = llm_output.split("Parameters")[1].strip().split("###")[0] + params_heading = re.split(r"\n#+\s", llm_output.split("Parameters")[1].strip(), maxsplit=1)[0] params_str = combine_blocks(params_heading) params_raw = [] for line in params_str.split("\n"): @@ -189,7 +207,7 @@ def parse_action(llm_response: str, action_name: str) -> Action: ) return { "name": action_name, - "parameters": parameters, + "params": parameters, "preconditions": preconditions, "effects": effects, } @@ -208,6 +226,7 @@ def parse_objects(llm_response: str) -> dict[str, str]: objects_head = extract_heading(llm_response, "OBJECTS") objects_raw = combine_blocks(objects_head) + objects_clean = clear_comments( text=objects_raw, comments=[":", "//", "#", ";", "(", ")"] ) # Remove comments @@ -315,7 +334,7 @@ def prune_types( break else: for action in actions: - if type.split(" ")[0] in action["parameters"].values(): + if type.split(" ")[0] in action["params"].values(): used_types[type] = types[type] break if ( @@ -460,3 +479,29 @@ def format_predicates(predicates: list[Predicate]) -> str: def indent(string: str, level: int = 2): """Indent string helper function to format PDDL domain/task""" return " " * level + string.replace("\n", f"\n{' ' * level}") + + +def check_parse_domain(file_path: str): + """Run PDDL library to check if file is syntactically correct""" + try: + domain = parse_domain(file_path) + pddl_domain = domain_to_string(domain) + return pddl_domain + except Exception as e: + print("------------------") + print(f"Error parsing domain: {e}", file=sys.stderr) + print("------------------") + sys.exit(1) + + +def check_parse_problem(file_path: str): + """Run PDDL library to check if file is syntactically correct""" + try: + problem = parse_problem(file_path) + pddl_problem = problem_to_string(problem) + return pddl_problem + except Exception as e: + print("------------------") + print(f"Error parsing domain: {e}", file=sys.stderr) + print("------------------") + sys.exit(1) diff --git a/l2p/utils/pddl_planner.py b/l2p/utils/pddl_planner.py index 68b0019..c4ead0f 100644 --- a/l2p/utils/pddl_planner.py +++ b/l2p/utils/pddl_planner.py @@ -1,4 +1,12 @@ -import subprocess, os, re +""" +L2P comes pre-packaged with FastDownward: https://www.fast-downward.org + +For usage, users must clone or download the submodule /downward separately and direct the +`planner_path` to the folder. This module is not necessary to use L2P, but for ease of use +to produce plans from generated domain and problem PDDL specifications via LLMs. +""" + +import subprocess, re # Define the exit codes SUCCESS = 0 @@ -27,14 +35,28 @@ class FastDownward: - - def run_fast_downward(self, domain_file, problem_file, plan_file="sas_plan"): + + def __init__(self, planner_path: str): + self.planner_path = planner_path # directory of FastDownward planner + + def run_fast_downward(self, domain_file: str, problem_file: str, search_alg: str="lama-first"): + """ + Main function to run planner. + + Args: + - domain_file (str): PDDL domain file path + - problem_file (str): PDDL problem file path + - search_alg (str): search algorithm/heuristic to use + + refer to: https://www.fast-downward.org/PlannerUsage + + Returns: + - success (bool): if a plan was found, otherwise False for incomplete. + - plan_output (str): plan output information. + + """ try: - downward_path = "downward/fast-downward.py" - - # lmcut() = landmark-cut heuristic - refer to: https://www.fast-downward.org/PlannerUsage result = subprocess.run( - [downward_path, "--alias", "lama-first", domain_file, problem_file], + [self.planner_path, "--alias", search_alg, domain_file, problem_file], capture_output=True, text=True, ) @@ -43,8 +65,6 @@ def run_fast_downward(self, domain_file, problem_file, plan_file="sas_plan"): if result.returncode == SUCCESS: # Planning succeeded - with open(plan_file, "w") as f: - f.write(result.stdout) print("Planning succeeded!") print( "All run components successfully terminated (translator: completed, search: found a plan, validate: validated a plan)" diff --git a/l2p/utils/pddl_validator.py b/l2p/utils/pddl_validator.py index bd6f997..0d97b42 100644 --- a/l2p/utils/pddl_validator.py +++ b/l2p/utils/pddl_validator.py @@ -8,6 +8,26 @@ class SyntaxValidator: + def __init__( + self, + error_types=None, + unsupported_keywords = None + ): + + # current error types available + default_error_types = [ + 'invalid_header', + 'invalid_keyword_usage', + 'unsupported_keywords', + 'invalid_param_types', + 'invalid_predicate_name', + 'invalid_predicate_format', + 'invalid_predicate_usage' + ] + + default_unsupported = ['forall', 'when', 'exists', 'implies'] # current unsupported usage of PDDL + self.error_types = default_error_types if error_types is None else error_types + self.unsupported_keywords = default_unsupported if unsupported_keywords is None else unsupported_keywords # PARAMETER CHECKS @@ -296,6 +316,7 @@ def validate_task_objects( obj_type_found = False for type_key in types.keys(): + current_type, parent_type = type_key.split(" - ") # checks if obj_type is found in types diff --git a/l2p/utils/utils.py b/l2p/utils/utils.py deleted file mode 100644 index 5df3a80..0000000 --- a/l2p/utils/utils.py +++ /dev/null @@ -1,10 +0,0 @@ -import os, json - - -def load_file(file_path): - _, ext = os.path.splitext(file_path) - with open(file_path, "r") as file: - if ext == ".json": - return json.load(file) - else: - return file.read().strip() diff --git a/paper_reconstructions/llm+dm/llm+dm.py b/paper_reconstructions/llm+dm/main.py similarity index 92% rename from paper_reconstructions/llm+dm/llm+dm.py rename to paper_reconstructions/llm+dm/main.py index c780e45..cd6fc0c 100644 --- a/paper_reconstructions/llm+dm/llm+dm.py +++ b/paper_reconstructions/llm+dm/main.py @@ -1,7 +1,7 @@ """ Paper: "Leveraging Pre-trained Large Language Models to Construct and Utilize World Models for Model-based Task Planning" Guan et al. (2023) Source code: https://github.com/GuanSuns/LLMs-World-Models-for-Planning -Run: python3 -m paper_reconstructions.llm+dm.llm+dm +Run: python3 -m paper_reconstructions.llm+dm.main Assumes the following: 1. NL descriptions of all the actions @@ -9,23 +9,11 @@ 3. Information of the object types and hierarchy - fixed set of object types specified in prompt """ -import os, json +import os from copy import deepcopy from l2p import * -def open_txt(file_path): - with open(file_path, "r") as file: - file = file.read().strip() - return file - - -def open_json(file_path): - with open(file_path, "r") as file: - file = json.load(file) - return file - - def construct_action_model( domain_desc, prompt_template, @@ -118,12 +106,12 @@ def construct_action_model( if __name__ == "__main__": # setup prompt templates - action_model = open_json("paper_reconstructions/llm+dm/prompts/action_model.json") - domain_desc = open_txt("paper_reconstructions/llm+dm/prompts/domain_desc.txt") - hierarchy_requirements = open_json( + action_model = load_file("paper_reconstructions/llm+dm/prompts/action_model.json") + domain_desc = load_file("paper_reconstructions/llm+dm/prompts/domain_desc.txt") + hierarchy_requirements = load_file( "paper_reconstructions/llm+dm/prompts/hierarchy_requirements.json" ) - prompt_template = open_txt("paper_reconstructions/llm+dm/prompts/pddl_prompt.txt") + prompt_template = load_file("paper_reconstructions/llm+dm/prompts/pddl_prompt.txt") # setup LLM engine engine = "gpt-4o-mini" diff --git a/paper_reconstructions/llm+dm/results/domain.pddl b/paper_reconstructions/llm+dm/results/domain.pddl index 2b06ea9..1141dc6 100644 --- a/paper_reconstructions/llm+dm/results/domain.pddl +++ b/paper_reconstructions/llm+dm/results/domain.pddl @@ -11,20 +11,22 @@ ) (:predicates - (truck-at ?t - truck ?l - location) ; true if the truck ?t is located at location ?l (package-at ?p - package ?l - location) ; true if the package ?p is located at location ?l + (truck-at ?t - truck ?l - location) ; true if the truck ?t is located at location ?l (truck-has-space ?t - truck) ; true if the truck ?t has space to load more packages (truck-has-package ?t - truck ?p - package) ; true if the truck ?t is carrying the package ?p - (truck-holding ?t - truck ?p - package) ; true if the truck ?t is holding the package ?p - (airplane-at ?a - plane ?l - location) ; true if the airplane ?a is located at location ?l - (airplane-full ?a - plane) ; true if the airplane ?a cannot carry more packages - (airplane-has-package ?a - plane ?p - package) ; true if the airplane ?a is carrying the package ?p - (airplane-holding ?a - plane ?p - package) ; true if the airplane ?a is currently holding the package ?p - (at-airplane ?a - plane ?l - location) ; true if the airplane ?a is located at the location ?l - (location-connected ?l1 - location ?l2 - location ?c - city) ; true if location ?l1 is directly connected to location ?l2 in city ?c - (at-airport ?plane - plane ?city - city) ; true if the airplane ?plane is at the airport in city ?city + (truck-holding ?t - truck ?p - package) ; true if the truck ?t is currently holding the package ?p (truck-at-location ?t - truck ?l - location) ; true if the truck ?t is at the location ?l (package-at-location ?p - package ?l - location) ; true if the package ?p is at the location ?l + (airplane-at-airport ?a - plane) ; true if the airplane ?a is at the designated airport location + (airplane-has-space ?a - plane) ; true if the airplane ?a has space available to load more packages + (airplane-has-package ?a - plane ?p - package) ; true if the airplane ?a is carrying the package ?p + (airplane-holding ?a - plane ?p - package) ; true if the airplane ?a is holding the package ?p + (at-airport ?a - plane ?l - location) ; true if the airplane ?a is at the airport located at ?l + (location-connected ?l1 - location ?l2 - location ?c - city) ; true if location ?l1 is directly connected to location ?l2 in city ?c + (package-on-ground ?p - package) ; true if the package ?p is on the ground and not loaded onto any vehicle + (at-airplane ?a - plane ?l - location) ; true if the airplane ?a is currently at the location ?l + (airplane-in-city ?plane - plane, ?city - city) ; true if the airplane ?plane is currently in the city ?city ) (:action load_truck @@ -68,17 +70,16 @@ :parameters ( ?p - package ?a - plane -?l - location ) :precondition (and - (package-at ?p ?l) - (airplane-at ?a ?l) - (not (airplane-full ?a)) + (package-on-ground ?p) + (airplane-at-airport ?a) + (airplane-has-space ?a) ) :effect (and - (not (package-at ?p ?l)) + (not (package-on-ground ?p)) (airplane-has-package ?a ?p) ) ) @@ -123,21 +124,19 @@ (:action fly_airplane :parameters ( ?plane - plane -?from_airport - location -?to_airport - location ?from_city - city ?to_city - city ) :precondition (and - (at-airport ?from_airport ?from_city) - (at-airport ?to_airport ?to_city) - (airplane-at ?plane ?from_airport) + (at-airport ?from_city) + (at-airport ?to_city) + (airplane-in-city ?plane ?from_city) ) :effect (and - (not (airplane-at ?plane ?from_airport)) - (airplane-at ?plane ?to_airport) + (not (airplane-in-city ?plane ?from_city)) + (airplane-in-city ?plane ?to_city) ) ) ) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domain.py b/paper_reconstructions/llm+p/domain.py new file mode 100644 index 0000000..6d0474f --- /dev/null +++ b/paper_reconstructions/llm+p/domain.py @@ -0,0 +1,102 @@ +""" +This module contains the Domain class which contains all domains found in LLM+P +""" + +import glob + +def postprocess(x): + return x.strip() + +class Domain: + def __init__(self, name): + self.name = name + self.context = ("p_example.nl", "p_example.pddl", "p_example.sol") + self.tasks = [] + self.grab_tasks() + + def grab_tasks(self): + path = f"paper_reconstructions/llm+p/domains/{self.name}/problems" + nls = [] + for fn in glob.glob(f"{path}/*.nl"): + + fn_ = fn.split("/")[-1] + nls.append(fn_) + + self.tasks = sorted(nls) + + def get_task_name(self, i): + name = self.tasks[i] + name = name.replace("nl", "pddl") + return name + + def get_task_file(self, i): + nl = self.tasks[i] + return f"paper_reconstructions/llm+p/domains/{self.name}/problems/{nl}" + + def get_task(self, i): + nl_f = self.get_task_file(i) + + with open(nl_f, 'r') as f: + nl = f.read() + + return postprocess(nl) + + def get_context(self): + nl_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[0]}" + pddl_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[1]}" + sol_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[2]}" + with open(nl_f, 'r') as f: + nl = f.read() + with open(pddl_f, 'r') as f: + pddl = f.read() + with open(sol_f, 'r') as f: + sol = f.read() + return postprocess(nl), postprocess(pddl), postprocess(sol) + + def get_domain_pddl(self): + domain_pddl_f = self.get_domain_pddl_file() + with open(domain_pddl_f, 'r') as f: + domain_pddl = f.read() + return postprocess(domain_pddl) + + def get_domain_pddl_file(self): + domain_pddl_f = f"paper_reconstructions/llm+p/domains/{self.name}/domain.pddl" + return domain_pddl_f + + def get_domain_nl(self): + domain_nl_f = self.get_domain_nl_file() + try: + with open(domain_nl_f, 'r') as f: + domain_nl = f.read() + except: + domain_nl = "Nothing" + return postprocess(domain_nl) + + def get_domain_nl_file(self): + domain_nl_f = f"paper_reconstructions/llm+p/domains/{self.name}/domain.nl" + return domain_nl_f + + +class Barman(Domain): + name = "barman" + +class Floortile(Domain): + name = "floortile" + +class Termes(Domain): + name = "termes" + +class Tyreworld(Domain): + name = "tyreworld" + +class Grippers(Domain): + name = "grippers" + +class Storage(Domain): + name = "storage" + +class Blocksworld(Domain): + name = "blocksworld" + +class Manipulation(Domain): + name = "manipulation" \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/domain.nl b/paper_reconstructions/llm+p/domains/barman/domain.nl new file mode 100644 index 0000000..31b2ab6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/domain.nl @@ -0,0 +1,35 @@ +You are a robot barman that manipulates drink dispensers, shot glasses and a shaker. You have two hands. The goal is to find a plan that serves a desired set of drinks. Here are the actions you can do + +Grasp a container +Leave a container on the table +Fill a shot glass with an ingredient +Refill a shot glass with an ingredient +Empty a shot glass +Clean a shot glass +Pour an ingredient from a shot glass to a clean shaker +Pour an ingredient from a shot glass to a used shaker +Empty a shaker +Clean a shaker +Shake a cocktail in a shaker +Pour from a shaker to a shot glass + +You have the following restrictions on your actions: +You can only grasp a container if your hand is empty and it is on the table. +You can only leave a container if you are holding it. +You can only fill a shot glass if you are holding the shot glass, your other hand is empty, the shot glass is empty and clean. +You can only refill a shot glass if you are holding the shot glass, your other hand is empty, the shot glass is empty and has contained the saree ingredient before. +You can only empty a shot glass if you are holding the shot glass and it contains a beverage. +You can only clean a shot glass if you are holding the shot glass and it is empty, and your other hand is empty. +You can only pour from a shot glass to a clean shaker if you are holding the shot glass, the shot glass contains an ingredient, and the shaker is empty and clean. +You can only pour from a shot glass to a used shaker if you are holding the shot glass, the shot glass contains an ingredient, the shaker is unshaked and at a level not full. +You can only empty a shaker if you are holding the shaker and the shaker contains a shaked beverage. +You can only clean a shaker if you are holding the shaker, your other hand is empty, and the shaker is empty. +You can only shake a cocktail if you are holding the shaker, your other hand is empty, the shaker is unshaked, and the shaker contains two ingredients, and both ingredients are parts of a cocktail. +You can only pour from a shaker to a shot glass if you are holding the shaker, the shaker contains the cocktail, the shaker is shaked, and the shot glass is empty and clean. + +Once you grasp a container, you are holding the container and the container is not on the table. +Once you leave a container on the table, your hand become empty. +Once you pour an ingredient from a shot glass to a shaker, the shaker contains the ingredient and is at one level above the previous level, and the shot glass becomes empty. +Once you empty a shaker, the shaker is at the empty level. +Once you shake, the two ingredients in the shaker become a cocktail. +Once you pour from a shaker to a shot glass, the shot glass contains the beverage in the shaker, the shot glass is no longer clean and empty, and the shaker is at one level below the previous level. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/domain.pddl b/paper_reconstructions/llm+p/domains/barman/domain.pddl new file mode 100644 index 0000000..db9b07c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/domain.pddl @@ -0,0 +1,155 @@ +(define (domain barman) + (:requirements :strips :typing) + (:types hand level beverage dispenser container - object + ingredient cocktail - beverage + shot shaker - container) + (:predicates (ontable ?c - container) + (holding ?h - hand ?c - container) + (handempty ?h - hand) + (empty ?c - container) + (contains ?c - container ?b - beverage) + (clean ?c - container) + (used ?c - container ?b - beverage) + (dispenses ?d - dispenser ?i - ingredient) + (shaker-empty-level ?s - shaker ?l - level) + (shaker-level ?s - shaker ?l - level) + (next ?l1 ?l2 - level) + (unshaked ?s - shaker) + (shaked ?s - shaker) + (cocktail-part1 ?c - cocktail ?i - ingredient) + (cocktail-part2 ?c - cocktail ?i - ingredient)) + + (:action grasp + :parameters (?h - hand ?c - container) + :precondition (and (ontable ?c) (handempty ?h)) + :effect (and (not (ontable ?c)) + (not (handempty ?h)) + (holding ?h ?c))) + + (:action leave + :parameters (?h - hand ?c - container) + :precondition (holding ?h ?c) + :effect (and (not (holding ?h ?c)) + (handempty ?h) + (ontable ?c))) + + (:action fill-shot + :parameters (?s - shot ?i - ingredient ?h1 ?h2 - hand ?d - dispenser) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (dispenses ?d ?i) + (empty ?s) + (clean ?s)) + :effect (and (not (empty ?s)) + (contains ?s ?i) + (not (clean ?s)) + (used ?s ?i))) + + + (:action refill-shot + :parameters (?s - shot ?i - ingredient ?h1 ?h2 - hand ?d - dispenser) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (dispenses ?d ?i) + (empty ?s) + (used ?s ?i)) + :effect (and (not (empty ?s)) + (contains ?s ?i))) + + (:action empty-shot + :parameters (?h - hand ?p - shot ?b - beverage) + :precondition (and (holding ?h ?p) + (contains ?p ?b)) + :effect (and (not (contains ?p ?b)) + (empty ?p))) + + (:action clean-shot + :parameters (?s - shot ?b - beverage ?h1 ?h2 - hand) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (empty ?s) + (used ?s ?b)) + :effect (and (not (used ?s ?b)) + (clean ?s))) + + (:action pour-shot-to-clean-shaker + :parameters (?s - shot ?i - ingredient ?d - shaker ?h1 - hand ?l ?l1 - level) + :precondition (and (holding ?h1 ?s) + (contains ?s ?i) + (empty ?d) + (clean ?d) + (shaker-level ?d ?l) + (next ?l ?l1)) + :effect (and (not (contains ?s ?i)) + (empty ?s) + (contains ?d ?i) + (not (empty ?d)) + (not (clean ?d)) + (unshaked ?d) + (not (shaker-level ?d ?l)) + (shaker-level ?d ?l1))) + + + (:action pour-shot-to-used-shaker + :parameters (?s - shot ?i - ingredient ?d - shaker ?h1 - hand ?l ?l1 - level) + :precondition (and (holding ?h1 ?s) + (contains ?s ?i) + (unshaked ?d) + (shaker-level ?d ?l) + (next ?l ?l1)) + :effect (and (not (contains ?s ?i)) + (contains ?d ?i) + (empty ?s) + (not (shaker-level ?d ?l)) + (shaker-level ?d ?l1))) + + (:action empty-shaker + :parameters (?h - hand ?s - shaker ?b - cocktail ?l ?l1 - level) + :precondition (and (holding ?h ?s) + (contains ?s ?b) + (shaked ?s) + (shaker-level ?s ?l) + (shaker-empty-level ?s ?l1)) + :effect (and (not (shaked ?s)) + (not (shaker-level ?s ?l)) + (shaker-level ?s ?l1) + (not (contains ?s ?b)) + (empty ?s))) + + (:action clean-shaker + :parameters (?h1 ?h2 - hand ?s - shaker) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (empty ?s)) + :effect (and (clean ?s))) + + (:action shake + :parameters (?b - cocktail ?d1 ?d2 - ingredient ?s - shaker ?h1 ?h2 - hand) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (contains ?s ?d1) + (contains ?s ?d2) + (cocktail-part1 ?b ?d1) + (cocktail-part2 ?b ?d2) + (unshaked ?s)) + :effect (and (not (unshaked ?s)) + (not (contains ?s ?d1)) + (not (contains ?s ?d2)) + (shaked ?s) + (contains ?s ?b))) + + (:action pour-shaker-to-shot + :parameters (?b - beverage ?d - shot ?h - hand ?s - shaker ?l ?l1 - level) + :precondition (and (holding ?h ?s) + (shaked ?s) + (empty ?d) + (clean ?d) + (contains ?s ?b) + (shaker-level ?s ?l) + (next ?l1 ?l)) + :effect (and (not (clean ?d)) + (not (empty ?d)) + (contains ?d ?b) + (shaker-level ?s ?l1) + (not (shaker-level ?s ?l)))) + ) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/p_example.nl b/paper_reconstructions/llm+p/domains/barman/p_example.nl new file mode 100644 index 0000000..d025773 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/p_example.nl @@ -0,0 +1,5 @@ +You have 1 shaker with 3 levels, 3 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient3. The second ingredient of cocktail1 is ingredient1. +Your goal is to make 1 cocktails. +shot1 contains cocktail1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/p_example.pddl b/paper_reconstructions/llm+p/domains/barman/p_example.pddl new file mode 100644 index 0000000..470f855 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/p_example.pddl @@ -0,0 +1,40 @@ +(define (problem prob) + (:domain barman) + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level +) + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient3) + (cocktail-part2 cocktail1 ingredient1) +) + (:goal + (and + (contains shot1 cocktail1) +))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/p_example.sol b/paper_reconstructions/llm+p/domains/barman/p_example.sol new file mode 100644 index 0000000..8bea1a3 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/p_example.sol @@ -0,0 +1,10 @@ +Grasp shot2 with right hand, +fill shot2 with ingredient1 from dispenser1 using right and left hands, +pour shot2 with ingredient1 into clean shaker1 using right hand, +clean shot2 with right and left hands, +fill shot2 with ingredient3 from dispenser3 using right and left hands, +grasp shaker1 with left hand, +pour shot2 with ingredient3 into used shaker1 using right hand, +leave shot2 with right hand, +shake cocktail1 with ingredient3 and ingredient1 in shaker1 using left and right hands, +pour shaker1 with cocktail1 into shot1 using left hand. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p01.nl b/paper_reconstructions/llm+p/domains/barman/problems/p01.nl new file mode 100644 index 0000000..31ebe54 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p01.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient1. The second ingredient of cocktail1 is ingredient3. +The first ingredient of cocktail2 is ingredient2. The second ingredient of cocktail2 is ingredient3. +The first ingredient of cocktail3 is ingredient1. The second ingredient of cocktail3 is ingredient2. +Your goal is to make 3 cocktails. +shot1 contains cocktail1. shot2 contains cocktail3. shot3 contains cocktail2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p02.nl b/paper_reconstructions/llm+p/domains/barman/problems/p02.nl new file mode 100644 index 0000000..ce65c7c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p02.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient3. The second ingredient of cocktail1 is ingredient1. +The first ingredient of cocktail2 is ingredient3. The second ingredient of cocktail2 is ingredient2. +The first ingredient of cocktail3 is ingredient3. The second ingredient of cocktail3 is ingredient1. +Your goal is to make 3 cocktails. +shot1 contains cocktail1. shot2 contains cocktail3. shot3 contains cocktail2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p03.nl b/paper_reconstructions/llm+p/domains/barman/problems/p03.nl new file mode 100644 index 0000000..17e4683 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p03.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient1. The second ingredient of cocktail1 is ingredient3. +The first ingredient of cocktail2 is ingredient2. The second ingredient of cocktail2 is ingredient3. +The first ingredient of cocktail3 is ingredient2. The second ingredient of cocktail3 is ingredient1. +Your goal is to make 3 cocktails. +shot1 contains cocktail2. shot2 contains cocktail1. shot3 contains cocktail3. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p04.nl b/paper_reconstructions/llm+p/domains/barman/problems/p04.nl new file mode 100644 index 0000000..c826dde --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p04.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient2. The second ingredient of cocktail1 is ingredient1. +The first ingredient of cocktail2 is ingredient2. The second ingredient of cocktail2 is ingredient3. +The first ingredient of cocktail3 is ingredient1. The second ingredient of cocktail3 is ingredient2. +Your goal is to make 3 cocktails. +shot1 contains cocktail1. shot2 contains cocktail3. shot3 contains cocktail2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p01.pddl new file mode 100644 index 0000000..5262b49 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p01.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient1) + (cocktail-part2 cocktail1 ingredient3) + (cocktail-part1 cocktail2 ingredient2) + (cocktail-part2 cocktail2 ingredient3) + (cocktail-part1 cocktail3 ingredient1) + (cocktail-part2 cocktail3 ingredient2) + ) + + (:goal + (and + (contains shot1 cocktail1) + (contains shot2 cocktail3) + (contains shot3 cocktail2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p02.pddl new file mode 100644 index 0000000..ce4e561 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p02.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient3) + (cocktail-part2 cocktail1 ingredient1) + (cocktail-part1 cocktail2 ingredient3) + (cocktail-part2 cocktail2 ingredient2) + (cocktail-part1 cocktail3 ingredient3) + (cocktail-part2 cocktail3 ingredient1) + ) + + (:goal + (and + (contains shot1 cocktail1) + (contains shot2 cocktail3) + (contains shot3 cocktail2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p03.pddl new file mode 100644 index 0000000..af035c8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p03.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient1) + (cocktail-part2 cocktail1 ingredient3) + (cocktail-part1 cocktail2 ingredient2) + (cocktail-part2 cocktail2 ingredient3) + (cocktail-part1 cocktail3 ingredient2) + (cocktail-part2 cocktail3 ingredient1) + ) + + (:goal + (and + (contains shot1 cocktail2) + (contains shot2 cocktail1) + (contains shot3 cocktail3) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p04.pddl new file mode 100644 index 0000000..367949e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p04.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient2) + (cocktail-part2 cocktail1 ingredient1) + (cocktail-part1 cocktail2 ingredient2) + (cocktail-part2 cocktail2 ingredient3) + (cocktail-part1 cocktail3 ingredient1) + (cocktail-part2 cocktail3 ingredient2) + ) + + (:goal + (and + (contains shot1 cocktail1) + (contains shot2 cocktail3) + (contains shot3 cocktail2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt new file mode 100644 index 0000000..3332513 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt @@ -0,0 +1,48 @@ +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient1 ingredient2 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot2 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +clean-shot shot4 ingredient2 right left (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail2 ingredient2 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot3 left shaker1 l2 l1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +leave right shot4 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient1 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail1 ingredient1 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot1 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt new file mode 100644 index 0000000..9972c1e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt @@ -0,0 +1,50 @@ +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient3 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient3 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot2 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot3 (1) +leave left shaker1 (1) +grasp left shot4 (1) +pour-shot-to-clean-shaker shot4 ingredient2 shaker1 left l0 l1 (1) +leave right shot3 (1) +clean-shot shot4 ingredient2 left right (1) +leave left shot4 (1) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient3 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail2 ingredient3 ingredient2 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot3 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot1 (1) +leave left shaker1 (1) +fill-shot shot1 ingredient3 right left dispenser3 (1) +pour-shot-to-clean-shaker shot1 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot1 ingredient3 right left (1) +fill-shot shot1 ingredient1 right left dispenser1 (1) +pour-shot-to-used-shaker shot1 ingredient1 shaker1 right l1 l2 (1) +clean-shot shot1 ingredient1 right left (1) +grasp left shaker1 (1) +leave right shot1 (1) +shake cocktail1 ingredient3 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot1 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt new file mode 100644 index 0000000..473618b --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt @@ -0,0 +1,48 @@ +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient2 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot3 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +clean-shot shot4 ingredient2 right left (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail2 ingredient2 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot1 left shaker1 l2 l1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +leave right shot4 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient1 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail1 ingredient1 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot2 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt new file mode 100644 index 0000000..4076b18 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt @@ -0,0 +1,50 @@ +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient1 ingredient2 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot2 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot3 (1) +leave left shaker1 (1) +grasp left shot4 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 left l0 l1 (1) +leave right shot3 (1) +clean-shot shot4 ingredient3 left right (1) +leave left shot4 (1) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail2 ingredient2 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot3 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail1 ingredient2 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot1 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/blocksworld.txt b/paper_reconstructions/llm+p/domains/blocksworld/domain.nl similarity index 100% rename from paper_reconstructions/nl2plan/prompts/blocksworld.txt rename to paper_reconstructions/llm+p/domains/blocksworld/domain.nl diff --git a/paper_reconstructions/llm+p/domains/blocksworld/domain.pddl b/paper_reconstructions/llm+p/domains/blocksworld/domain.pddl new file mode 100644 index 0000000..5e69df1 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/domain.pddl @@ -0,0 +1,32 @@ +(define (domain blocksworld) + (:requirements :strips) + (:types block - object) +(:predicates (clear ?x) + (on-table ?x) + (arm-empty) + (holding ?x) + (on ?x ?y)) + +(:action pickup + :parameters (?ob - block) + :precondition (and (clear ?ob) (on-table ?ob) (arm-empty)) + :effect (and (holding ?ob) (not (clear ?ob)) (not (on-table ?ob)) + (not (arm-empty)))) + +(:action putdown + :parameters (?ob - block) + :precondition (holding ?ob) + :effect (and (clear ?ob) (arm-empty) (on-table ?ob) + (not (holding ?ob)))) + +(:action stack + :parameters (?ob ?underob - block) + :precondition (and (clear ?underob) (holding ?ob)) + :effect (and (arm-empty) (clear ?ob) (on ?ob ?underob) + (not (clear ?underob)) (not (holding ?ob)))) + +(:action unstack + :parameters (?ob ?underob - block) + :precondition (and (on ?ob ?underob) (clear ?ob) (arm-empty)) + :effect (and (holding ?ob) (clear ?underob) + (not (on ?ob ?underob)) (not (clear ?ob)) (not (arm-empty))))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/p_example.nl b/paper_reconstructions/llm+p/domains/blocksworld/p_example.nl new file mode 100644 index 0000000..3db1f60 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/p_example.nl @@ -0,0 +1,10 @@ +You have 5 blocks. +b2 is on top of b5. +b5 is on top of b1. +b1 is on top of b4. +b3 is on top of b2. +b4 is on the table. +b3 is clear. +Your arm is empty. +Your goal is to move the blocks. +b4 should be on top of b3. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/p_example.pddl b/paper_reconstructions/llm+p/domains/blocksworld/p_example.pddl new file mode 100644 index 0000000..32b4dbc --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/p_example.pddl @@ -0,0 +1,20 @@ + + +(define (problem BW-rand-5) +(:domain blocksworld-4ops) +(:objects b1 b2 b3 b4 b5 ) +(:init +(arm-empty) +(on b1 b4) +(on b2 b5) +(on b3 b2) +(on-table b4) +(on b5 b1) +(clear b3) +) +(:goal +(and +(on b4 b3)) +) +) + diff --git a/paper_reconstructions/llm+p/domains/blocksworld/p_example.sol b/paper_reconstructions/llm+p/domains/blocksworld/p_example.sol new file mode 100644 index 0000000..9e8b2e6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/p_example.sol @@ -0,0 +1,10 @@ +unstack b3 from b2, +putdown b3, +unstack b2 from b5, +putdown b2, +unstack b5 from b1, +putdown b5, +unstack b1 from b4, +putdown b1, +pickup b4, +stack b4 on b3 \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/problems/p01.nl b/paper_reconstructions/llm+p/domains/blocksworld/problems/p01.nl new file mode 100644 index 0000000..9c4bab6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p01.nl @@ -0,0 +1,9 @@ +You have 3 blocks. +b2 is on top of b3. +b3 is on top of b1. +b1 is on the table. +b2 is clear. +Your arm is empty. +Your goal is to move the blocks. +b2 should be on top of b3. +b3 should be on top of b1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/prompts/problem_desc.txt b/paper_reconstructions/llm+p/domains/blocksworld/problems/p02.nl similarity index 83% rename from paper_reconstructions/llm+p/prompts/problem_desc.txt rename to paper_reconstructions/llm+p/domains/blocksworld/problems/p02.nl index 81b3a5b..900ce4f 100644 --- a/paper_reconstructions/llm+p/prompts/problem_desc.txt +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p02.nl @@ -1,4 +1,3 @@ -""" You have 3 blocks. b3 is on top of b2. b1 is on top of b3. @@ -7,5 +6,4 @@ b1 is clear. Your arm is empty. Your goal is to move the blocks. b2 should be on top of b3. -b3 should be on top of b1. -""" \ No newline at end of file +b3 should be on top of b1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/problems/p03.nl b/paper_reconstructions/llm+p/domains/blocksworld/problems/p03.nl new file mode 100644 index 0000000..979dbcf --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p03.nl @@ -0,0 +1,11 @@ +You have 4 blocks. +b3 is on top of b2. +b1 is on top of b3. +b4 is on the table. +b2 is on the table. +b1 is clear. +b4 is clear. +Your arm is empty. +Your goal is to move the blocks. +b2 should be on top of b1. +b3 should be on top of b4. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/problems/p04.nl b/paper_reconstructions/llm+p/domains/blocksworld/problems/p04.nl new file mode 100644 index 0000000..c50786b --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p04.nl @@ -0,0 +1,11 @@ +You have 4 blocks. +b4 is on top of b2. +b3 is on top of b1. +b1 is on top of b4. +b2 is on the table. +b3 is clear. +Your arm is empty. +Your goal is to move the blocks. +b1 should be on top of b2. +b2 should be on top of b3. +b3 should be on top of b4. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p01.pddl new file mode 100644 index 0000000..4574d83 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p01.pddl @@ -0,0 +1,26 @@ +(define + (problem blocksworld-4ops_problem) + (:domain blocksworld) + + (:objects + b1 - block + b2 - block + b3 - block + ) + + (:init + (on b2 b3) + (on b3 b1) + (on-table b1) + (clear b2) + (arm-empty ) + ) + + (:goal + (and + (on b2 b3) + (on b3 b1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/results/problem.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p02.pddl similarity index 90% rename from paper_reconstructions/llm+p/results/problem.pddl rename to paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p02.pddl index 58073e0..49d1ab9 100644 --- a/paper_reconstructions/llm+p/results/problem.pddl +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p02.pddl @@ -1,6 +1,6 @@ (define (problem blocksworld-4ops_problem) - (:domain blocksworld-4ops) + (:domain blocksworld) (:objects b1 - block diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p03.pddl new file mode 100644 index 0000000..7fb72b3 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p03.pddl @@ -0,0 +1,29 @@ +(define + (problem blocksworld-4ops_problem) + (:domain blocksworld) + + (:objects + b1 - block + b2 - block + b3 - block + b4 - block + ) + + (:init + (on b1 b3) + (on b3 b2) + (on-table b4) + (on-table b2) + (clear b1) + (clear b4) + (arm-empty ) + ) + + (:goal + (and + (on b2 b1) + (on b3 b4) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p04.pddl new file mode 100644 index 0000000..32b3340 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p04.pddl @@ -0,0 +1,29 @@ +(define + (problem blocksworld-4ops_problem) + (:domain blocksworld) + + (:objects + b1 - block + b2 - block + b3 - block + b4 - block + ) + + (:init + (on b1 b4) + (on b4 b2) + (on b3 b1) + (on-table b2) + (clear b3) + (arm-empty ) + ) + + (:goal + (and + (on b1 b2) + (on b2 b3) + (on b3 b4) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt new file mode 100644 index 0000000..bcc1701 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt @@ -0,0 +1 @@ +Success. Goal state already met. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt new file mode 100644 index 0000000..cdce7cd --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt @@ -0,0 +1,6 @@ +unstack b1 b3 (1) +putdown b1 (1) +unstack b3 b2 (1) +stack b3 b1 (1) +pickup b2 (1) +stack b2 b3 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt new file mode 100644 index 0000000..f6915d6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt @@ -0,0 +1,6 @@ +unstack b1 b3 (1) +putdown b1 (1) +unstack b3 b2 (1) +stack b3 b4 (1) +pickup b2 (1) +stack b2 b1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt new file mode 100644 index 0000000..9beb791 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt @@ -0,0 +1,16 @@ +unstack b3 b1 (1) +putdown b3 (1) +unstack b1 b4 (1) +putdown b1 (1) +unstack b4 b2 (1) +putdown b4 (1) +pickup b1 (1) +stack b1 b2 (1) +pickup b3 (1) +stack b3 b4 (1) +unstack b1 b2 (1) +putdown b1 (1) +pickup b2 (1) +stack b2 b3 (1) +pickup b1 (1) +stack b1 b2 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/domain.nl b/paper_reconstructions/llm+p/domains/floortile/domain.nl new file mode 100644 index 0000000..21feca7 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/domain.nl @@ -0,0 +1,15 @@ +You control a set of robots that use different colors to paint patterns in floor tiles. The robots can move around the floor tiles in four directions (up, down, left and right). Robots paint with one color at a time, but can change their spray guns to any available color. However, robots can only paint the tile that is in front (up) and behind (down) them, and once a tile has been painted no robot can stand on it. + +Here are the actions each robot can do +Change the spray gun color +Paint the tile that is up from the robot +Paint the tile that is down from the robot +Move up +Move down +Move right +Move left + +You have the following restrictions on your actions: +A robot can only paint a tile if the tile has not been painted. +A robot can only paint a tile to the color of its spray gun. +A robot cannot move to a tile that has been painted. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/domain.pddl b/paper_reconstructions/llm+p/domains/floortile/domain.pddl new file mode 100644 index 0000000..190b603 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/domain.pddl @@ -0,0 +1,81 @@ +;;Created by Tomas de la Rosa +;;Domain for painting floor tiles with two colors + +(define (domain floortile) +(:requirements :typing :action-costs) +(:types robot tile color - object) + +(:predicates + (robot-at ?r - robot ?x - tile) + (up ?x - tile ?y - tile) + (down ?x - tile ?y - tile) + (right ?x - tile ?y - tile) + (left ?x - tile ?y - tile) + + (clear ?x - tile) + (painted ?x - tile ?c - color) + (robot-has ?r - robot ?c - color) + (available-color ?c - color) + (free-color ?r - robot)) + +(:functions (total-cost)) + +(:action change-color + :parameters (?r - robot ?c - color ?c2 - color) + :precondition (and (robot-has ?r ?c) (available-color ?c2)) + :effect (and (not (robot-has ?r ?c)) (robot-has ?r ?c2) + (increase (total-cost) 5)) +) + + +(:action paint-up + :parameters (?r - robot ?y - tile ?x - tile ?c - color) + :precondition (and (robot-has ?r ?c) (robot-at ?r ?x) (up ?y ?x) (clear ?y)) + :effect (and (not (clear ?y)) (painted ?y ?c) + (increase (total-cost) 2)) +) + + +(:action paint-down + :parameters (?r - robot ?y - tile ?x - tile ?c - color) + :precondition (and (robot-has ?r ?c) (robot-at ?r ?x) (down ?y ?x) (clear ?y)) + :effect (and (not (clear ?y)) (painted ?y ?c) +(increase (total-cost) 2)) +) + + +; Robot movements +(:action up + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (up ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 3)) +) + + +(:action down + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (down ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 1)) +) + +(:action right + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (right ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 1)) +) + +(:action left + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (left ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 1)) +) + +) diff --git a/paper_reconstructions/llm+p/domains/floortile/p_example.nl b/paper_reconstructions/llm+p/domains/floortile/p_example.nl new file mode 100644 index 0000000..e1021ef --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/p_example.nl @@ -0,0 +1,11 @@ +You have 4 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +You have 1 robot. +Each robot can paint in color white. +robot2 is at tile_2-2. +robot1 is at tile_0-1. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is white; tile_1-3 is white. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/p_example.pddl b/paper_reconstructions/llm+p/domains/floortile/p_example.pddl new file mode 100644 index 0000000..a945788 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/p_example.pddl @@ -0,0 +1,67 @@ +(define (problem p01-432) + (:domain floor-tile) + (:objects tile_0-1 tile_0-2 tile_0-3 + tile_1-1 tile_1-2 tile_1-3 + tile_2-1 tile_2-2 tile_2-3 + tile_3-1 tile_3-2 tile_3-3 - tile + robot1 - robot + white - color +) + (:init + (robot-at robot1 tile_0-1) + (robot-has robot1 white) + (robot-at robot2 tile_2-2) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-3) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) +) + (:goal (and + (painted tile_1-1 white) + (painted tile_1-2 white) + (painted tile_1-3 white) +)) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/p_example.sol b/paper_reconstructions/llm+p/domains/floortile/p_example.sol new file mode 100644 index 0000000..bfa6f25 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/p_example.sol @@ -0,0 +1,5 @@ +Robot 1 paints tile_1-1 white, +Robot 1 moves right to tile_0-2, +Robot 1 paints tile_1-2 white, +Robot 1 moves right to tile_0-3, +Robot 1 paints tile_1-3 white. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p01.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p01.nl new file mode 100644 index 0000000..1d9caa9 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p01.nl @@ -0,0 +1,12 @@ +You have 5 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +tile_4-1 tile_4-2 tile_4-3 +You have 2 robots. +Each robot can paint in color white or black. +robot1 is at tile_4-1. +robot2 is at tile_4-3. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p02.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p02.nl new file mode 100644 index 0000000..c27f608 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p02.nl @@ -0,0 +1,12 @@ +You have 5 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +tile_4-1 tile_4-2 tile_4-3 +You have 2 robots. +Each robot can paint in color white or black. +robot2 is at tile_4-1. +robot1 is at tile_3-2. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p03.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p03.nl new file mode 100644 index 0000000..df4e675 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p03.nl @@ -0,0 +1,12 @@ +You have 5 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +tile_4-1 tile_4-2 tile_4-3 +You have 2 robots. +Each robot can paint in color white or black. +robot2 is at tile_1-1. +robot1 is at tile_2-3. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p04.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p04.nl new file mode 100644 index 0000000..8e10fd6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p04.nl @@ -0,0 +1,12 @@ +You have 5 rows and 4 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 tile_0-4 +tile_1-1 tile_1-2 tile_1-3 tile_1-4 +tile_2-1 tile_2-2 tile_2-3 tile_2-4 +tile_3-1 tile_3-2 tile_3-3 tile_3-4 +tile_4-1 tile_4-2 tile_4-3 tile_4-4 +You have 2 robots. +Each robot can paint in color white or black. +robot1 is at tile_0-3. +robot2 is at tile_3-4. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_1-4 is black; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_2-4 is white; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_3-4 is black; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black; tile_4-4 is white. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p01.pddl new file mode 100644 index 0000000..3207b31 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p01.pddl @@ -0,0 +1,110 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_4-1) + (robot-at robot2 tile_4-3) + (robot-has robot1 black) + (robot-has robot2 white) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_2-3) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-2) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p02.pddl new file mode 100644 index 0000000..7da0e99 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p02.pddl @@ -0,0 +1,113 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_3-2) + (robot-at robot2 tile_4-1) + (robot-has robot1 white) + (robot-has robot1 black) + (robot-has robot2 white) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_2-3) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-2) + (clear tile_4-3) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p03.pddl new file mode 100644 index 0000000..7420cf9 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p03.pddl @@ -0,0 +1,112 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_2-3) + (robot-at robot2 tile_1-1) + (robot-has robot1 white) + (robot-has robot1 black) + (robot-has robot2 white) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-1) + (clear tile_4-2) + (clear tile_4-3) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p04.pddl new file mode 100644 index 0000000..9202ab1 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p04.pddl @@ -0,0 +1,142 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_0-4 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_1-4 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_2-4 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_3-4 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + tile_4-4 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_0-3) + (robot-has robot1 white) + (robot-at robot2 tile_3-4) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-4) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_1-4) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_2-3) + (clear tile_2-4) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-1) + (clear tile_4-2) + (clear tile_4-3) + (clear tile_4-4) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_1-4 tile_0-4) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_2-4 tile_1-4) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_3-4 tile_2-4) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (up tile_4-4 tile_3-4) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_0-4 tile_1-4) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_1-4 tile_2-4) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_2-4 tile_3-4) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (down tile_3-4 tile_4-4) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_0-4 tile_0-3) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_1-4 tile_1-3) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_2-4 tile_2-3) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_3-4 tile_3-3) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (right tile_4-4 tile_4-3) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_0-3 tile_0-4) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_1-3 tile_1-4) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_2-3 tile_2-4) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_3-3 tile_3-4) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + (left tile_4-3 tile_4-4) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_1-4 black) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_2-4 white) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_3-4 black) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + (painted tile_4-4 white) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt new file mode 100644 index 0000000..acf01fe --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt @@ -0,0 +1,48 @@ +down robot1 tile_4-1 tile_3-1 (1) +paint-up robot1 tile_4-1 tile_3-1 black (1) +down robot1 tile_3-1 tile_2-1 (1) +down robot2 tile_4-3 tile_3-3 (1) +change-color robot2 white black (1) +paint-up robot2 tile_4-3 tile_3-3 black (1) +change-color robot1 black white (1) +paint-up robot1 tile_3-1 tile_2-1 white (1) +change-color robot2 black white (1) +change-color robot1 white black (1) +down robot1 tile_2-1 tile_1-1 (1) +paint-up robot1 tile_2-1 tile_1-1 black (1) +down robot1 tile_1-1 tile_0-1 (1) +change-color robot1 black white (1) +paint-up robot1 tile_1-1 tile_0-1 white (1) +change-color robot1 white black (1) +right robot1 tile_0-1 tile_0-2 (1) +down robot2 tile_3-3 tile_2-3 (1) +paint-up robot2 tile_3-3 tile_2-3 white (1) +left robot1 tile_0-2 tile_0-1 (1) +change-color robot2 white black (1) +left robot2 tile_2-3 tile_2-2 (1) +down robot2 tile_2-2 tile_1-2 (1) +down robot2 tile_1-2 tile_0-2 (1) +right robot2 tile_0-2 tile_0-3 (1) +right robot1 tile_0-1 tile_0-2 (1) +change-color robot2 black white (1) +change-color robot1 black white (1) +up robot1 tile_0-2 tile_1-2 (1) +up robot1 tile_1-2 tile_2-2 (1) +up robot1 tile_2-2 tile_3-2 (1) +paint-up robot1 tile_4-2 tile_3-2 white (1) +down robot1 tile_3-2 tile_2-2 (1) +change-color robot1 white black (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +down robot1 tile_2-2 tile_1-2 (1) +change-color robot1 black white (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +change-color robot1 white black (1) +down robot1 tile_1-2 tile_0-2 (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) +change-color robot2 white black (1) +up robot2 tile_0-3 tile_1-3 (1) +paint-up robot2 tile_2-3 tile_1-3 black (1) +change-color robot1 black white (1) +down robot2 tile_1-3 tile_0-3 (1) +change-color robot2 black white (1) +paint-up robot2 tile_1-3 tile_0-3 white (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt new file mode 100644 index 0000000..73c96bd --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt @@ -0,0 +1,25 @@ +paint-up robot1 tile_4-2 tile_3-2 white (1) +right robot1 tile_3-2 tile_3-3 (1) +paint-up robot1 tile_4-3 tile_3-3 black (1) +down robot1 tile_3-3 tile_2-3 (1) +paint-up robot1 tile_3-3 tile_2-3 white (1) +left robot1 tile_2-3 tile_2-2 (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +down robot2 tile_4-1 tile_3-1 (1) +paint-up robot2 tile_4-1 tile_3-1 black (1) +right robot1 tile_2-2 tile_2-3 (1) +down robot1 tile_2-3 tile_1-3 (1) +paint-up robot1 tile_2-3 tile_1-3 black (1) +down robot1 tile_1-3 tile_0-3 (1) +paint-up robot1 tile_1-3 tile_0-3 white (1) +left robot1 tile_0-3 tile_0-2 (1) +down robot2 tile_3-1 tile_2-1 (1) +paint-up robot2 tile_3-1 tile_2-1 white (1) +up robot1 tile_0-2 tile_1-2 (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +down robot1 tile_1-2 tile_0-2 (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) +down robot2 tile_2-1 tile_1-1 (1) +paint-up robot2 tile_2-1 tile_1-1 black (1) +down robot2 tile_1-1 tile_0-1 (1) +paint-up robot2 tile_1-1 tile_0-1 white (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt new file mode 100644 index 0000000..a328d46 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt @@ -0,0 +1,29 @@ +up robot1 tile_2-3 tile_3-3 (1) +paint-up robot1 tile_4-3 tile_3-3 black (1) +up robot2 tile_1-1 tile_2-1 (1) +up robot2 tile_2-1 tile_3-1 (1) +paint-up robot2 tile_4-1 tile_3-1 black (1) +down robot1 tile_3-3 tile_2-3 (1) +paint-up robot1 tile_3-3 tile_2-3 white (1) +down robot1 tile_2-3 tile_1-3 (1) +paint-up robot1 tile_2-3 tile_1-3 black (1) +down robot1 tile_1-3 tile_0-3 (1) +paint-up robot1 tile_1-3 tile_0-3 white (1) +left robot1 tile_0-3 tile_0-2 (1) +down robot2 tile_3-1 tile_2-1 (1) +paint-up robot2 tile_3-1 tile_2-1 white (1) +down robot2 tile_2-1 tile_1-1 (1) +paint-up robot2 tile_2-1 tile_1-1 black (1) +up robot1 tile_0-2 tile_1-2 (1) +down robot2 tile_1-1 tile_0-1 (1) +paint-up robot2 tile_1-1 tile_0-1 white (1) +up robot1 tile_1-2 tile_2-2 (1) +change-color robot2 black white (1) +up robot1 tile_2-2 tile_3-2 (1) +paint-up robot1 tile_4-2 tile_3-2 white (1) +down robot1 tile_3-2 tile_2-2 (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +down robot1 tile_2-2 tile_1-2 (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +down robot1 tile_1-2 tile_0-2 (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt new file mode 100644 index 0000000..a6c8cfb --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt @@ -0,0 +1,53 @@ +left robot1 tile_0-3 tile_0-2 (1) +up robot1 tile_0-2 tile_1-2 (1) +left robot1 tile_1-2 tile_1-1 (1) +change-color robot2 black white (1) +paint-up robot2 tile_4-4 tile_3-4 white (1) +up robot1 tile_1-1 tile_2-1 (1) +change-color robot2 white black (1) +left robot2 tile_3-4 tile_3-3 (1) +paint-up robot2 tile_4-3 tile_3-3 black (1) +change-color robot1 white black (1) +right robot2 tile_3-3 tile_3-4 (1) +up robot1 tile_2-1 tile_3-1 (1) +paint-up robot1 tile_4-1 tile_3-1 black (1) +down robot2 tile_3-4 tile_2-4 (1) +paint-up robot2 tile_3-4 tile_2-4 black (1) +change-color robot1 black white (1) +right robot1 tile_3-1 tile_3-2 (1) +paint-up robot1 tile_4-2 tile_3-2 white (1) +change-color robot2 black white (1) +left robot1 tile_3-2 tile_3-1 (1) +down robot2 tile_2-4 tile_1-4 (1) +paint-up robot2 tile_2-4 tile_1-4 white (1) +down robot2 tile_1-4 tile_0-4 (1) +down robot1 tile_3-1 tile_2-1 (1) +paint-up robot1 tile_3-1 tile_2-1 white (1) +change-color robot2 white black (1) +paint-up robot2 tile_1-4 tile_0-4 black (1) +change-color robot1 white black (1) +right robot1 tile_2-1 tile_2-2 (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +change-color robot2 black white (1) +change-color robot1 black white (1) +right robot1 tile_2-2 tile_2-3 (1) +paint-up robot1 tile_3-3 tile_2-3 white (1) +left robot1 tile_2-3 tile_2-2 (1) +left robot2 tile_0-4 tile_0-3 (1) +down robot1 tile_2-2 tile_1-2 (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +down robot1 tile_1-2 tile_0-2 (1) +change-color robot1 white black (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) +left robot1 tile_0-2 tile_0-1 (1) +up robot1 tile_0-1 tile_1-1 (1) +paint-up robot1 tile_2-1 tile_1-1 black (1) +change-color robot1 black white (1) +down robot1 tile_1-1 tile_0-1 (1) +paint-up robot1 tile_1-1 tile_0-1 white (1) +change-color robot2 white black (1) +up robot2 tile_0-3 tile_1-3 (1) +paint-up robot2 tile_2-3 tile_1-3 black (1) +change-color robot2 black white (1) +down robot2 tile_1-3 tile_0-3 (1) +paint-up robot2 tile_1-3 tile_0-3 white (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/domain.nl b/paper_reconstructions/llm+p/domains/grippers/domain.nl new file mode 100644 index 0000000..2548ab6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/domain.nl @@ -0,0 +1,9 @@ +You are a robot with a gripper that can move objects between different rooms. + +There are three actions defined in this domain: + +The move action: This action allows the robot to move from one room to another.The action has a single precondition, which is that the robot is currently in a room. The effect of this action is to move the robot to another room and to remove the fact that it is in the original room. + +The pick action: This action allows the robot to pick up an object using the gripper. The action has three preconditions: (1) the object is located in a room (2) the robot is currently in the same room and (3) the gripper is free (i.e., not holding any object). The effect of this action is to update the state of the world to show that the robot is carrying the object using the gripper, the object is no longer in the room, and the gripper is no longer free. + +The drop action: This action allows the robot to drop an object that it is carrying. The action has two preconditions: (1) the robot is currently carrying the object using the gripper, and (2) the robot is currently in a room. The effect of this action is to update the state of the world to show that the robot is no longer carrying the object using the gripper, the object is now located in the room, and the gripper is now free. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/domain.pddl b/paper_reconstructions/llm+p/domains/grippers/domain.pddl new file mode 100644 index 0000000..bcba5bd --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/domain.pddl @@ -0,0 +1,27 @@ +(define (domain grippers) + (:requirements :strips :typing) + (:types room object robot gripper) + (:predicates (at-robby ?r - robot ?x - room) + (at ?o - object ?x - room) + (free ?r - robot ?g - gripper) + (carry ?r - robot ?o - object ?g - gripper)) + + (:action move + :parameters (?r - robot ?from ?to - room) + :precondition (and (at-robby ?r ?from)) + :effect (and (at-robby ?r ?to) + (not (at-robby ?r ?from)))) + + (:action pick + :parameters (?r - robot ?obj - object ?room - room ?g - gripper) + :precondition (and (at ?obj ?room) (at-robby ?r ?room) (free ?r ?g)) + :effect (and (carry ?r ?obj ?g) + (not (at ?obj ?room)) + (not (free ?r ?g)))) + + (:action drop + :parameters (?r - robot ?obj - object ?room - room ?g - gripper) + :precondition (and (carry ?r ?obj ?g) (at-robby ?r ?room)) + :effect (and (at ?obj ?room) + (free ?r ?g) + (not (carry ?r ?obj ?g))))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/p_example.nl b/paper_reconstructions/llm+p/domains/grippers/p_example.nl new file mode 100644 index 0000000..af2162c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/p_example.nl @@ -0,0 +1,12 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 4 rooms and 6 balls. +robot2 is in room3. robot1 is in room2. +ball1 is in room3. ball2 is in room1. ball3 is in room3. ball4 is in room2. ball5 is in room4. ball6 is in room4. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room4. +ball2 should be in room1. +ball3 should be in room1. +ball4 should be in room2. +ball5 should be in room1. +ball6 should be in room1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/p_example.pddl b/paper_reconstructions/llm+p/domains/grippers/p_example.pddl new file mode 100644 index 0000000..8ddce33 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/p_example.pddl @@ -0,0 +1,31 @@ +(define (problem gripper-2-4-6) +(:domain gripper-strips) +(:objects robot1 robot2 - robot +rgripper1 lgripper1 rgripper2 lgripper2 - gripper +room1 room2 room3 room4 - room +ball1 ball2 ball3 ball4 ball5 ball6 - object) +(:init +(at-robby robot1 room2) +(free robot1 rgripper1) +(free robot1 lgripper1) +(at-robby robot2 room3) +(free robot2 rgripper2) +(free robot2 lgripper2) +(at ball1 room3) +(at ball2 room1) +(at ball3 room3) +(at ball4 room2) +(at ball5 room4) +(at ball6 room4) +) +(:goal +(and +(at ball1 room4) +(at ball2 room1) +(at ball3 room1) +(at ball4 room2) +(at ball5 room1) +(at ball6 room1) +) +) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/p_example.sol b/paper_reconstructions/llm+p/domains/grippers/p_example.sol new file mode 100644 index 0000000..563230e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/p_example.sol @@ -0,0 +1,11 @@ +Robot2 picks up ball1 with its left gripper in room3. +Robot2 picks up ball3 with its right gripper in room3. +Robot2 moves from room3 to room1. +Robot2 drops ball3 in room1 with its right gripper. +Robot2 moves from room1 to room4. +Robot2 picks up ball5 with its right gripper in room4. +Robot2 drops ball1 in room4 with its left gripper. +Robot2 picks up ball6 with its left gripper in room4. +Robot2 moves from room4 to room1. +Robot2 drops ball6 in room1 with its left gripper. +Robot2 drops ball5 in room1 with its right gripper. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p01.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p01.nl new file mode 100644 index 0000000..4e67f28 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p01.nl @@ -0,0 +1,8 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 2 rooms and 2 balls. +robot1 is in room1. robot2 is in room1. +ball2 is in room1. ball1 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room1. +ball2 should be in room1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p02.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p02.nl new file mode 100644 index 0000000..4e88348 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p02.nl @@ -0,0 +1,10 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 3 rooms and 4 balls. +robot2 is in room3. robot1 is in room2. +ball1 is in room3. ball2 is in room1. ball4 is in room3. ball3 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room2. +ball2 should be in room2. +ball3 should be in room3. +ball4 should be in room3. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p03.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p03.nl new file mode 100644 index 0000000..73eccc7 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p03.nl @@ -0,0 +1,8 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 5 rooms and 2 balls. +robot1 is in room1. robot2 is in room2. +ball2 is in room1. ball1 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room5. +ball2 should be in room4. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p04.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p04.nl new file mode 100644 index 0000000..00a6229 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p04.nl @@ -0,0 +1,10 @@ +You control 3 robots, each robot has a left gripper and a right gripper. +There are 4 rooms and 4 balls. +robot1 is in room4. robot3 is in room1. robot2 is in room4. +ball2 is in room1. ball4 is in room2. ball1 is in room1. ball3 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room1. +ball2 should be in room1. +ball3 should be in room3. +ball4 should be in room2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p01.pddl new file mode 100644 index 0000000..ae51550 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p01.pddl @@ -0,0 +1,36 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + lgripper1 - gripper + rgripper1 - gripper + lgripper2 - gripper + rgripper2 - gripper + room1 - room + room2 - room + ball1 - object + ball2 - object + ) + + (:init + (at-robby robot1 room1) + (free robot1 rgripper1) + (free robot1 lgripper1) + (at-robby robot2 room1) + (free robot2 rgripper2) + (free robot2 lgripper2) + (at ball1 room1) + (at ball2 room1) + ) + + (:goal + (and + (at ball1 room1) + (at ball2 room1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p02.pddl new file mode 100644 index 0000000..f451de0 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p02.pddl @@ -0,0 +1,43 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + rgripper1 - gripper + lgripper1 - gripper + rgripper2 - gripper + lgripper2 - gripper + room1 - room + room2 - room + room3 - room + ball1 - object + ball2 - object + ball3 - object + ball4 - object + ) + + (:init + (at-robby robot1 room2) + (free robot1 rgripper1) + (free robot1 lgripper1) + (at-robby robot2 room3) + (free robot2 rgripper2) + (free robot2 lgripper2) + (at ball1 room3) + (at ball2 room1) + (at ball3 room1) + (at ball4 room3) + ) + + (:goal + (and + (at ball1 room2) + (at ball2 room2) + (at ball3 room3) + (at ball4 room3) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p03.pddl new file mode 100644 index 0000000..8dfaf92 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p03.pddl @@ -0,0 +1,39 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + rgripper1 - gripper + lgripper1 - gripper + rgripper2 - gripper + lgripper2 - gripper + room1 - room + room2 - room + room3 - room + room4 - room + room5 - room + ball1 - object + ball2 - object + ) + + (:init + (at-robby robot1 room1) + (free robot1 rgripper1) + (free robot1 lgripper1) + (at-robby robot2 room2) + (free robot2 rgripper2) + (free robot2 lgripper2) + (at ball1 room1) + (at ball2 room1) + ) + + (:goal + (and + (at ball1 room5) + (at ball2 room4) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p04.pddl new file mode 100644 index 0000000..7ac538a --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p04.pddl @@ -0,0 +1,50 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + robot3 - robot + lgripper1 - gripper + rgripper1 - gripper + lgripper2 - gripper + rgripper2 - gripper + lgripper3 - gripper + rgripper3 - gripper + room1 - room + room2 - room + room3 - room + room4 - room + ball1 - object + ball2 - object + ball3 - object + ball4 - object + ) + + (:init + (at-robby robot1 room4) + (at-robby robot2 room4) + (at-robby robot3 room1) + (free robot1 rgripper1) + (free robot1 lgripper1) + (free robot2 rgripper2) + (free robot2 lgripper2) + (free robot3 rgripper3) + (free robot3 lgripper3) + (at ball1 room1) + (at ball2 room1) + (at ball3 room1) + (at ball4 room2) + ) + + (:goal + (and + (at ball1 room1) + (at ball2 room1) + (at ball3 room3) + (at ball4 room2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt new file mode 100644 index 0000000..bcc1701 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt @@ -0,0 +1 @@ +Success. Goal state already met. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt new file mode 100644 index 0000000..a480b32 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt @@ -0,0 +1,11 @@ +move robot2 room3 room1 (1) +pick robot2 ball2 room1 lgripper2 (1) +move robot2 room1 room2 (1) +drop robot2 ball2 room2 lgripper2 (1) +move robot1 room2 room1 (1) +pick robot1 ball3 room1 lgripper1 (1) +move robot1 room1 room3 (1) +pick robot1 ball1 room3 rgripper1 (1) +drop robot1 ball3 room3 lgripper1 (1) +move robot1 room3 room2 (1) +drop robot1 ball1 room2 rgripper1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt new file mode 100644 index 0000000..2511d65 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt @@ -0,0 +1,6 @@ +pick robot1 ball1 room1 lgripper1 (1) +pick robot1 ball2 room1 rgripper1 (1) +move robot1 room1 room4 (1) +drop robot1 ball2 room4 rgripper1 (1) +move robot1 room4 room5 (1) +drop robot1 ball1 room5 lgripper1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt new file mode 100644 index 0000000..a11eeb7 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt @@ -0,0 +1,3 @@ +pick robot3 ball3 room1 lgripper3 (1) +move robot3 room1 room3 (1) +drop robot3 ball3 room3 lgripper3 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/domain.nl b/paper_reconstructions/llm+p/domains/storage/domain.nl new file mode 100644 index 0000000..5a0719e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/domain.nl @@ -0,0 +1,13 @@ +Your goal is to move all crates to a depot. + +There are five actions in the domain: "lift", "drop", "move", "go-out" and "go-in", each with their own parameters, preconditions, and effects. + +"lift" action lifts a crate using a hoist from a store area to an area that is connected to it, and places the crate in a place. The preconditions for the "lift" action require that the hoist is available, the hoist is at the destination area, the crate is on the surface in the source store area, and the source store area is in the place. The effects of the "lift" action remove the crate from the source store area, make the source area clear, make the hoist unavailable, make the hoist lifting the crate, and remove the crate from the place. + +"drop" action drops a crate from the hoist onto a surface in a store area that is connected to the area where the hoist is currently located. The preconditions for the "drop" action require that the hoist is at the destination area, the hoist is lifting the crate, the destination store area is clear, and the destination store area is in the place. The effects of the "drop" action remove the hoist lifting the crate, make the hoist available, make the destination area occupied by the crate, and make the crate in the destination store area. + +"move" action moves a hoist from one store area to another connected store area. The preconditions for the "move" action require that the hoist is in the source store area, the destination store area is clear, and the source and destination areas are connected. The effects of the "move" action remove the hoist from the source area, place the hoist in the destination area, make the source area occupied, and make the destination area clear. + +"go-out" action moves a hoist from a store area to a transit area that is connected to it. The preconditions for the "go-out" action require that the hoist is in the source store area, and the source and destination areas are connected. The effects of the "go-out" action remove the hoist from the source area, place the hoist in the transit area, and make the source area clear. + +"go-in" action moves a hoist from a transit area to a store area that is connected to it. The preconditions for the "go-in" action require that the hoist is in the transit area, the source and destination areas are connected, and the destination area is clear. The effects of the "go-in" action remove the hoist from the transit area, place the hoist in the destination store area, and make the destination store area occupied. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/domain.pddl b/paper_reconstructions/llm+p/domains/storage/domain.pddl new file mode 100644 index 0000000..90b58cb --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/domain.pddl @@ -0,0 +1,48 @@ +; IPC5 Domain: Storage Propositional +; Authors: Alfonso Gerevini and Alessandro Saetti + +(define (domain storage) +(:requirements :typing) +(:types hoist surface place area - object + container depot - place + storearea transitarea - area + area crate - surface) + +(:predicates (clear ?s - storearea) + (in ?x - (either storearea crate) ?p - place) + (available ?h - hoist) + (lifting ?h - hoist ?c - crate) + (at ?h - hoist ?a - area) + (on ?c - crate ?s - storearea) + (connected ?a1 ?a2 - area) + (compatible ?c1 ?c2 - crate)) + +(:action lift + :parameters (?h - hoist ?c - crate ?a1 - storearea ?a2 - area ?p - place) + :precondition (and (connected ?a1 ?a2) (at ?h ?a2) (available ?h) + (on ?c ?a1) (in ?a1 ?p)) + :effect (and (not (on ?c ?a1)) (clear ?a1) + (not (available ?h)) (lifting ?h ?c) (not (in ?c ?p)))) + +(:action drop + :parameters (?h - hoist ?c - crate ?a1 - storearea ?a2 - area ?p - place) + :precondition (and (connected ?a1 ?a2) (at ?h ?a2) (lifting ?h ?c) + (clear ?a1) (in ?a1 ?p)) + :effect (and (not (lifting ?h ?c)) (available ?h) + (not (clear ?a1)) (on ?c ?a1) (in ?c ?p))) + +(:action move + :parameters (?h - hoist ?from ?to - storearea) + :precondition (and (at ?h ?from) (clear ?to) (connected ?from ?to)) + :effect (and (not (at ?h ?from)) (at ?h ?to) (not (clear ?to)) (clear ?from))) + +(:action go-out + :parameters (?h - hoist ?from - storearea ?to - transitarea) + :precondition (and (at ?h ?from) (connected ?from ?to)) + :effect (and (not (at ?h ?from)) (at ?h ?to) (clear ?from))) + +(:action go-in + :parameters (?h - hoist ?from - transitarea ?to - storearea) + :precondition (and (at ?h ?from) (connected ?from ?to) (clear ?to)) + :effect (and (not (at ?h ?from)) (at ?h ?to) (not (clear ?to)))) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/p_example.nl b/paper_reconstructions/llm+p/domains/storage/p_example.nl new file mode 100644 index 0000000..237dafc --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/p_example.nl @@ -0,0 +1,22 @@ +You have 6 depot storeareas, 3 container storeareas, 3 hoists, 3 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 depot48-1-3 depot48-2-1 depot48-2-2 depot48-2-3 +Container storeareas are: container-0-0 container-0-1 container-0-2 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 depot48-1-3 +depot48-2-1 depot48-2-2 depot48-2-3 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate2 is on container-0-2. +crate1 is on container-0-1. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-2-2 and loadarea are connected. +depot48-1-3 depot48-2-1 depot48-1-2 are clear. +hoist2 is in depot48-2-3 +hoist1 is in depot48-1-1 +hoist0 is in depot48-2-2 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/p_example.pddl b/paper_reconstructions/llm+p/domains/storage/p_example.pddl new file mode 100644 index 0000000..fa6c2b8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/p_example.pddl @@ -0,0 +1,75 @@ +; Domain designed by Alfonso Gerevini and Alessandro Saetti +; This file has been automatically generated by the generator available from +; http://zeus.ing.unibs.it/ipc-5/generators/index.html +; +; Map of the Depots: +; 000 +; 0*0 +;---- +; 48: depot48 area +; *: Depot access point +; =: Transit area + +(define (problem storage-9) +(:domain Storage-Propositional) +(:objects + depot48-1-1 depot48-1-2 depot48-1-3 depot48-2-1 depot48-2-2 depot48-2-3 container-0-0 container-0-1 container-0-2 - storearea + hoist0 hoist1 hoist2 - hoist + crate0 crate1 crate2 - crate + container0 - container + depot48 - depot + loadarea - transitarea) + +(:init + (connected depot48-1-1 depot48-2-1) + (connected depot48-1-1 depot48-1-2) + (connected depot48-1-2 depot48-2-2) + (connected depot48-1-2 depot48-1-3) + (connected depot48-1-2 depot48-1-1) + (connected depot48-1-3 depot48-2-3) + (connected depot48-1-3 depot48-1-2) + (connected depot48-2-1 depot48-1-1) + (connected depot48-2-1 depot48-2-2) + (connected depot48-2-2 depot48-1-2) + (connected depot48-2-2 depot48-2-3) + (connected depot48-2-2 depot48-2-1) + (connected depot48-2-3 depot48-1-3) + (connected depot48-2-3 depot48-2-2) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (in depot48-1-3 depot48) + (in depot48-2-1 depot48) + (in depot48-2-2 depot48) + (in depot48-2-3 depot48) + (on crate0 container-0-0) + (on crate1 container-0-1) + (on crate2 container-0-2) + (in crate0 container0) + (in crate1 container0) + (in crate2 container0) + (in container-0-0 container0) + (in container-0-1 container0) + (in container-0-2 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected loadarea container-0-1) + (connected container-0-1 loadarea) + (connected loadarea container-0-2) + (connected container-0-2 loadarea) + (connected depot48-2-2 loadarea) + (connected loadarea depot48-2-2) + (clear depot48-2-1) + (clear depot48-1-2) + (clear depot48-1-3) + (at hoist0 depot48-2-2) + (available hoist0) + (at hoist1 depot48-1-1) + (available hoist1) + (at hoist2 depot48-2-3) + (available hoist2)) + +(:goal (and + (in crate0 depot48) + (in crate1 depot48) + (in crate2 depot48))) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/p_example.sol b/paper_reconstructions/llm+p/domains/storage/p_example.sol new file mode 100644 index 0000000..68ec20b --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/p_example.sol @@ -0,0 +1,11 @@ +Go out with hoist0 from depot48-2-2 to loadarea. +Lift crate0 in container-0-0 in container 0 with hoist0 from loadarea. +Go in with hoist0 from loadarea to depot48-2-2. +Drop crate0 with hoist0 from depot48-2-2 to depot48-1-2 in depot48. +Go out with hoist0 from depot48-2-2 to loadarea. +Lift crate1 in container-0-1 in container 0 with hoist0 from loadarea. +Drop crate1 with hoist0 from loadarea to depot48-2-2 in depot48. +Lift crate2 in container-0-2 in container0 with hoist0 from loadarea. +Lift crate1 in depot48-2-2 in depot48 with hoist2 from depot48-2-3. +Drop crate2 with hoist0 from loadarea to depot48-2-2 in depot48. +Drop crate1 with hoist2 from depot48-2-3 to depot48-1-3 in depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p01.nl b/paper_reconstructions/llm+p/domains/storage/problems/p01.nl new file mode 100644 index 0000000..589e485 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p01.nl @@ -0,0 +1,16 @@ +You have 1 depot storeareas, 1 container storeareas, 1 hoists, 1 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 +Container storeareas are: container-0-0 +Here is a map of depot storeareas: + +depot48-1-1 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-1-1 and loadarea are connected. +hoist0 is in depot48-1-1 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p02.nl b/paper_reconstructions/llm+p/domains/storage/problems/p02.nl new file mode 100644 index 0000000..da6a4d6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p02.nl @@ -0,0 +1,17 @@ +You have 2 depot storeareas, 1 container storeareas, 2 hoists, 1 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 +Container storeareas are: container-0-0 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-1-1 and loadarea are connected. +hoist1 is in depot48-1-2 +hoist0 is in depot48-1-1 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p03.nl b/paper_reconstructions/llm+p/domains/storage/problems/p03.nl new file mode 100644 index 0000000..9878a5b --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p03.nl @@ -0,0 +1,18 @@ +You have 3 depot storeareas, 1 container storeareas, 3 hoists, 1 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 depot48-1-3 +Container storeareas are: container-0-0 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 depot48-1-3 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-1-2 and loadarea are connected. +hoist0 is in depot48-1-2 +hoist2 is in depot48-1-1 +hoist1 is in depot48-1-3 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p04.nl b/paper_reconstructions/llm+p/domains/storage/problems/p04.nl new file mode 100644 index 0000000..592cc10 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p04.nl @@ -0,0 +1,19 @@ +You have 4 depot storeareas, 2 container storeareas, 1 hoists, 2 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 depot48-2-1 depot48-2-2 +Container storeareas are: container-0-0 container-0-1 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 +depot48-2-1 depot48-2-2 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate1 is on container-0-1. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-2-1 and loadarea are connected. +depot48-2-2 depot48-2-1 depot48-1-2 are clear. +hoist0 is in depot48-1-1 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p01.pddl new file mode 100644 index 0000000..37a39d3 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p01.pddl @@ -0,0 +1,35 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 - storearea + container-0-0 - storearea + hoist0 - hoist + crate0 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-1) + (on crate0 container-0-0) + (in crate0 container0) + (in container-0-0 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected depot48-1-1 loadarea) + (connected loadarea depot48-1-1) + (at hoist0 depot48-1-1) + (available hoist0) + (in depot48-1-1 depot48) + ) + + (:goal + (and + (in crate0 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p02.pddl new file mode 100644 index 0000000..d437fd5 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p02.pddl @@ -0,0 +1,39 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 depot48-1-2 - storearea + container-0-0 - storearea + hoist0 hoist1 - hoist + crate0 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-2) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (on crate0 container-0-0) + (in crate0 container0) + (in container-0-0 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected depot48-1-1 loadarea) + (at hoist0 depot48-1-1) + (available hoist0) + (at hoist1 depot48-1-2) + (available hoist1) + (clear depot48-1-1) + (clear depot48-1-2) + ) + + (:goal + (and + (in crate0 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p03.pddl new file mode 100644 index 0000000..f1868a5 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p03.pddl @@ -0,0 +1,44 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 depot48-1-2 depot48-1-3 - storearea + container-0-0 - storearea + hoist0 hoist1 hoist2 - hoist + crate0 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-2) + (connected depot48-1-2 depot48-1-3) + (connected depot48-1-1 depot48-1-3) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (in depot48-1-3 depot48) + (on crate0 container-0-0) + (in crate0 container0) + (in container-0-0 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected depot48-1-2 loadarea) + (clear depot48-1-1) + (clear depot48-1-3) + (at hoist0 depot48-1-2) + (available hoist0) + (at hoist1 depot48-1-3) + (available hoist1) + (at hoist2 depot48-1-1) + (available hoist2) + ) + + (:goal + (and + (in crate0 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p04.pddl new file mode 100644 index 0000000..de3bdbe --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p04.pddl @@ -0,0 +1,59 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 - storearea + depot48-1-2 - storearea + depot48-2-1 - storearea + depot48-2-2 - storearea + container-0-0 - storearea + container-0-1 - storearea + hoist0 - hoist + crate0 - crate + crate1 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-2) + (connected depot48-1-1 depot48-2-1) + (connected depot48-1-2 depot48-1-1) + (connected depot48-1-2 depot48-2-2) + (connected depot48-2-1 depot48-1-1) + (connected depot48-2-1 depot48-2-2) + (connected depot48-2-2 depot48-1-2) + (connected depot48-2-2 depot48-2-1) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (in depot48-2-1 depot48) + (in depot48-2-2 depot48) + (on crate0 container-0-0) + (on crate1 container-0-1) + (in crate0 container0) + (in crate1 container0) + (in container-0-0 container0) + (in container-0-1 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected loadarea container-0-1) + (connected container-0-1 loadarea) + (connected depot48-2-1 loadarea) + (connected loadarea depot48-2-1) + (clear depot48-2-2) + (clear depot48-2-1) + (clear depot48-1-2) + (at hoist0 depot48-1-1) + (available hoist0) + ) + + (:goal + (and + (in crate0 depot48) + (in crate1 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt new file mode 100644 index 0000000..f294261 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt @@ -0,0 +1,3 @@ +go-out hoist0 depot48-1-1 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +drop hoist0 crate0 depot48-1-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt new file mode 100644 index 0000000..f294261 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt @@ -0,0 +1,3 @@ +go-out hoist0 depot48-1-1 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +drop hoist0 crate0 depot48-1-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt new file mode 100644 index 0000000..a10e9bd --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt @@ -0,0 +1,3 @@ +go-out hoist0 depot48-1-2 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +drop hoist0 crate0 depot48-1-2 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt new file mode 100644 index 0000000..dae98b4 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt @@ -0,0 +1,8 @@ +move hoist0 depot48-1-1 depot48-2-1 (1) +go-out hoist0 depot48-2-1 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +go-in hoist0 loadarea depot48-2-1 (1) +drop hoist0 crate0 depot48-1-1 depot48-2-1 depot48 (1) +go-out hoist0 depot48-2-1 loadarea (1) +lift hoist0 crate1 container-0-1 loadarea container0 (1) +drop hoist0 crate1 depot48-2-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/domain.nl b/paper_reconstructions/llm+p/domains/termes/domain.nl new file mode 100644 index 0000000..3c89ec0 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/domain.nl @@ -0,0 +1,15 @@ +You control a robot that can take the following actions to build complex structures. + +Move from a position to another. The new position and the old position must be at the same height. + +Move up from a position to another, and the height at the new position is one block higher than the old position. + +Move down from a position to another, and the height at the new position is one block lower than the old position. + +Place a block at a neighboring position from the robot's current position. The robot must have a block. The current height at the robot's position and the block's position must be the same. A block cannot be placed at the depot. The height at the block's position will be one block higher than the current height. + +Remove a block at a neighboring position from the robot's current position. The robot must not have a block. A block cannot be removed from the depot. The current height at the robot's position must be the same as the new height at the block's position. The new height at the block's position will be one block lower than the current height. + +Create a block at the depot. The robot will have the block. + +Destroy a block at the depot. The robot must have a block. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/domain.pddl b/paper_reconstructions/llm+p/domains/termes/domain.pddl new file mode 100644 index 0000000..cdcaf30 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/domain.pddl @@ -0,0 +1,134 @@ +(define (domain termes) +(:requirements :typing :negative-preconditions) +(:types + numb - object + position - object +) +(:predicates + (height ?p - position ?h - numb) + (at ?p - position) + (has-block) + ; + ; static predicates + (SUCC ?n1 - numb ?n2 - numb) + (NEIGHBOR ?p1 - position ?p2 - position) + (IS-DEPOT ?p - position) +) +(:action move + :parameters (?from - position ?to - position ?h - numb) + :precondition + (and + (at ?from) + (NEIGHBOR ?from ?to) + (height ?from ?h) + (height ?to ?h) + ) + :effect + (and + (not (at ?from)) + (at ?to) + ) +) + +(:action move-up + :parameters (?from - position ?hfrom - numb ?to - position ?hto - numb) + :precondition + (and + (at ?from) + (NEIGHBOR ?from ?to) + (height ?from ?hfrom) + (height ?to ?hto) + (SUCC ?hto ?hfrom) + ) + :effect + (and + (not (at ?from)) + (at ?to) + ) +) + +(:action move-down + :parameters (?from - position ?hfrom - numb ?to - position ?hto - numb) + :precondition + (and + (at ?from) + (NEIGHBOR ?from ?to) + (height ?from ?hfrom) + (height ?to ?hto) + (SUCC ?hfrom ?hto) + ) + :effect + (and + (not (at ?from)) + (at ?to) + ) +) + +(:action place-block + :parameters (?rpos - position ?bpos - position ?hbefore - numb ?hafter - numb) + :precondition + (and + (at ?rpos) + (NEIGHBOR ?rpos ?bpos) + (height ?rpos ?hbefore) + (height ?bpos ?hbefore) + (SUCC ?hafter ?hbefore) + (has-block) + (not (IS-DEPOT ?bpos)) + ) + :effect + (and + (not (height ?bpos ?hbefore)) + (height ?bpos ?hafter) + (not (has-block)) + ) +) + +(:action remove-block + :parameters (?rpos - position ?bpos - position ?hbefore - numb ?hafter - numb) + :precondition + (and + (at ?rpos) + (NEIGHBOR ?rpos ?bpos) + (height ?rpos ?hafter) + (height ?bpos ?hbefore) + (SUCC ?hbefore ?hafter) + (not (has-block)) + ) + :effect + (and + (not (height ?bpos ?hbefore)) + (height ?bpos ?hafter) + (has-block) + ) +) + +(:action create-block + :parameters (?p - position) + :precondition + (and + (at ?p) + (not (has-block)) + (IS-DEPOT ?p) + ) + :effect + (and + (has-block) + ) +) + +(:action destroy-block + :parameters (?p - position) + :precondition + (and + (at ?p) + (has-block) + (IS-DEPOT ?p) + ) + :effect + (and + (not (has-block)) + ) +) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/p_example.nl b/paper_reconstructions/llm+p/domains/termes/p_example.nl new file mode 100644 index 0000000..3d2a393 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/p_example.nl @@ -0,0 +1,9 @@ +The robot is on a grid with 3 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 1. +Your goal is to build blocks so that the height at pos-1-1 is 1. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/p_example.pddl b/paper_reconstructions/llm+p/domains/termes/p_example.pddl new file mode 100644 index 0000000..f7973cf --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/p_example.pddl @@ -0,0 +1,77 @@ +(define (problem prob) +(:domain termes) +; Initial state: +; 0 0 R0D +; 0 0 0 +; 0 0 0 +; Goal state: +; 0 0 0 +; 0 1 0 +; 0 0 0 +; Maximal height: 1 +(:objects + n0 - numb + n1 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position +) +(:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (NEIGHBOR pos-0-0 pos-1-0) + (NEIGHBOR pos-0-0 pos-0-1) + (NEIGHBOR pos-0-1 pos-1-1) + (NEIGHBOR pos-0-1 pos-0-0) + (NEIGHBOR pos-0-1 pos-0-2) + (NEIGHBOR pos-0-2 pos-1-2) + (NEIGHBOR pos-0-2 pos-0-1) + (NEIGHBOR pos-1-0 pos-0-0) + (NEIGHBOR pos-1-0 pos-2-0) + (NEIGHBOR pos-1-0 pos-1-1) + (NEIGHBOR pos-1-1 pos-0-1) + (NEIGHBOR pos-1-1 pos-2-1) + (NEIGHBOR pos-1-1 pos-1-0) + (NEIGHBOR pos-1-1 pos-1-2) + (NEIGHBOR pos-1-2 pos-0-2) + (NEIGHBOR pos-1-2 pos-2-2) + (NEIGHBOR pos-1-2 pos-1-1) + (NEIGHBOR pos-2-0 pos-1-0) + (NEIGHBOR pos-2-0 pos-2-1) + (NEIGHBOR pos-2-1 pos-1-1) + (NEIGHBOR pos-2-1 pos-2-0) + (NEIGHBOR pos-2-1 pos-2-2) + (NEIGHBOR pos-2-2 pos-1-2) + (NEIGHBOR pos-2-2 pos-2-1) + (IS-DEPOT pos-2-0) +) +(:goal +(and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n1) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (not (has-block)) +) +) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/p_example.sol b/paper_reconstructions/llm+p/domains/termes/p_example.sol new file mode 100644 index 0000000..3edc184 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/p_example.sol @@ -0,0 +1,3 @@ +Create block at pos-2-0, +move to pos-2-1, +place block at pos-1-1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p01.nl b/paper_reconstructions/llm+p/domains/termes/problems/p01.nl new file mode 100644 index 0000000..83f6258 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p01.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 3. +Your goal is to build blocks so that the height at pos-1-2 is 3. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p02.nl b/paper_reconstructions/llm+p/domains/termes/problems/p02.nl new file mode 100644 index 0000000..441911e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p02.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 3. +Your goal is to build blocks so that the height at pos-2-1 is 3, the height at pos-3-0 is 3. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p03.nl b/paper_reconstructions/llm+p/domains/termes/problems/p03.nl new file mode 100644 index 0000000..b509432 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p03.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 4. +Your goal is to build blocks so that the height at pos-3-1 is 4. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p04.nl b/paper_reconstructions/llm+p/domains/termes/problems/p04.nl new file mode 100644 index 0000000..7d6f9be --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p04.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The depot for new blocks is at pos-1-0. +The robot is at pos-1-0. +The maximum height of blocks is 4. +Your goal is to build blocks so that the height at pos-2-0 is 3, the height at pos-3-2 is 4. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p01.pddl new file mode 100644 index 0000000..cfea6da --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p01.pddl @@ -0,0 +1,91 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-2-0) + ) + + (:goal + (and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n3) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p02.pddl new file mode 100644 index 0000000..c8a8b56 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p02.pddl @@ -0,0 +1,93 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-2-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-2-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-2-0) + ) + + (:goal + (and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n3) + (height pos-2-2 n0) + (height pos-3-0 n3) + (height pos-3-1 n0) + (height pos-3-2 n0) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p03.pddl new file mode 100644 index 0000000..ed16d07 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p03.pddl @@ -0,0 +1,95 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + n4 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (SUCC n4 n3) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-2-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-2-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-2-0) + ) + + (:goal + (and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n4) + (height pos-3-2 n0) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p04.pddl new file mode 100644 index 0000000..f6f30c6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p04.pddl @@ -0,0 +1,84 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + n4 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-1-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (SUCC n4 n3) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-3-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-1-0) + ) + + (:goal + (and + (height pos-2-0 n3) + (height pos-3-2 n4) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt new file mode 100644 index 0000000..f13deda --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt @@ -0,0 +1,50 @@ +create-block pos-2-0 (1) +move pos-2-0 pos-1-0 n0 (1) +place-block pos-1-0 pos-1-1 n0 n1 (1) +move pos-1-0 pos-2-0 n0 (1) +create-block pos-2-0 (1) +move pos-2-0 pos-1-0 n0 (1) +move-up pos-1-0 n0 pos-1-1 n1 (1) +move-down pos-1-1 n1 pos-1-2 n0 (1) +move pos-1-2 pos-2-2 n0 (1) +place-block pos-2-2 pos-2-1 n0 n1 (1) +move pos-2-2 pos-1-2 n0 (1) +remove-block pos-1-2 pos-1-1 n1 n0 (1) +move pos-1-2 pos-2-2 n0 (1) +place-block pos-2-2 pos-1-2 n0 n1 (1) +move-up pos-2-2 n0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +move pos-1-0 pos-2-0 n0 (1) +create-block pos-2-0 (1) +move pos-2-0 pos-1-0 n0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-0-1 n0 n1 (1) +remove-block pos-1-1 pos-2-1 n1 n0 (1) +move pos-1-1 pos-2-1 n0 (1) +place-block pos-2-1 pos-2-2 n0 n1 (1) +move pos-2-1 pos-1-1 n0 (1) +remove-block pos-1-1 pos-0-1 n1 n0 (1) +move-up pos-1-1 n0 pos-1-2 n1 (1) +move pos-1-2 pos-2-2 n1 (1) +place-block pos-2-2 pos-1-2 n1 n2 (1) +move-down pos-2-2 n1 pos-2-1 n0 (1) +move pos-2-1 pos-2-0 n0 (1) +create-block pos-2-0 (1) +place-block pos-2-0 pos-2-1 n0 n1 (1) +create-block pos-2-0 (1) +move-up pos-2-0 n0 pos-2-1 n1 (1) +place-block pos-2-1 pos-2-2 n1 n2 (1) +move-down pos-2-1 n1 pos-2-0 n0 (1) +create-block pos-2-0 (1) +move-up pos-2-0 n0 pos-2-1 n1 (1) +move-up pos-2-1 n1 pos-2-2 n2 (1) +place-block pos-2-2 pos-1-2 n2 n3 (1) +move-down pos-2-2 n2 pos-2-1 n1 (1) +remove-block pos-2-1 pos-2-2 n2 n1 (1) +move-down pos-2-1 n1 pos-2-0 n0 (1) +destroy-block pos-2-0 (1) +remove-block pos-2-0 pos-2-1 n1 n0 (1) +destroy-block pos-2-0 (1) +move pos-2-0 pos-2-1 n0 (1) +remove-block pos-2-1 pos-2-2 n1 n0 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p02.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p02.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p03.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p03.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt new file mode 100644 index 0000000..d0784a2 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt @@ -0,0 +1,148 @@ +create-block pos-1-0 (1) +move pos-1-0 pos-2-0 n0 (1) +move pos-2-0 pos-3-0 n0 (1) +move pos-3-0 pos-3-1 n0 (1) +place-block pos-3-1 pos-3-0 n0 n1 (1) +move-up pos-3-1 n0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-2-0 n0 (1) +move pos-2-0 pos-1-0 n0 (1) +create-block pos-1-0 (1) +place-block pos-1-0 pos-2-0 n0 n1 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-3-1 n0 (1) +place-block pos-3-1 pos-3-2 n0 n1 (1) +remove-block pos-3-1 pos-3-0 n1 n0 (1) +move pos-3-1 pos-3-0 n0 (1) +place-block pos-3-0 pos-3-1 n0 n1 (1) +remove-block pos-3-0 pos-2-0 n1 n0 (1) +move-up pos-3-0 n0 pos-3-1 n1 (1) +place-block pos-3-1 pos-3-2 n1 n2 (1) +move-down pos-3-1 n1 pos-3-0 n0 (1) +remove-block pos-3-0 pos-3-1 n1 n0 (1) +move pos-3-0 pos-3-1 n0 (1) +place-block pos-3-1 pos-3-0 n0 n1 (1) +move-up pos-3-1 n0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-2-0 n0 (1) +move pos-2-0 pos-1-0 n0 (1) +create-block pos-1-0 (1) +place-block pos-1-0 pos-2-0 n0 n1 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-3-1 n0 (1) +remove-block pos-3-1 pos-3-0 n1 n0 (1) +move pos-3-1 pos-3-0 n0 (1) +place-block pos-3-0 pos-3-1 n0 n1 (1) +remove-block pos-3-0 pos-2-0 n1 n0 (1) +move pos-3-0 pos-2-0 n0 (1) +place-block pos-2-0 pos-3-0 n0 n1 (1) +move pos-2-0 pos-1-0 n0 (1) +create-block pos-1-0 (1) +place-block pos-1-0 pos-2-0 n0 n1 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +place-block pos-3-0 pos-3-1 n1 n2 (1) +move pos-3-0 pos-2-0 n1 (1) +move-down pos-2-0 n1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +move-up pos-3-0 n1 pos-3-1 n2 (1) +place-block pos-3-1 pos-3-2 n2 n3 (1) +move-down pos-3-1 n2 pos-3-0 n1 (1) +move pos-3-0 pos-2-0 n1 (1) +move-down pos-2-0 n1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +place-block pos-2-0 pos-3-0 n1 n2 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +move pos-3-0 pos-3-1 n2 (1) +remove-block pos-3-1 pos-3-2 n3 n2 (1) +move pos-3-1 pos-3-0 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move-down pos-2-0 n1 pos-1-0 n0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-2-1 n0 n1 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +place-block pos-3-0 pos-3-1 n2 n3 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-1-2 n0 n1 (1) +remove-block pos-1-1 pos-2-1 n1 n0 (1) +move pos-1-1 pos-2-1 n0 (1) +place-block pos-2-1 pos-1-1 n0 n1 (1) +move pos-2-1 pos-2-2 n0 (1) +remove-block pos-2-2 pos-1-2 n1 n0 (1) +move pos-2-2 pos-2-1 n0 (1) +place-block pos-2-1 pos-2-2 n0 n1 (1) +remove-block pos-2-1 pos-1-1 n1 n0 (1) +move pos-2-1 pos-1-1 n0 (1) +place-block pos-1-1 pos-2-1 n0 n1 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-1-2 n0 n1 (1) +move-up pos-1-1 n0 pos-2-1 n1 (1) +move pos-2-1 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +remove-block pos-3-0 pos-3-1 n3 n2 (1) +move pos-3-0 pos-3-1 n2 (1) +place-block pos-3-1 pos-3-2 n2 n3 (1) +move pos-3-1 pos-3-0 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +place-block pos-3-0 pos-3-1 n2 n3 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +move-up pos-3-0 n2 pos-3-1 n3 (1) +place-block pos-3-1 pos-3-2 n3 n4 (1) +move-down pos-3-1 n3 pos-3-0 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move pos-1-0 pos-1-1 n0 (1) +move-up pos-1-1 n0 pos-2-1 n1 (1) +move pos-2-1 pos-2-2 n1 (1) +place-block pos-2-2 pos-2-1 n1 n2 (1) +move-up pos-2-2 n1 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +remove-block pos-3-0 pos-3-1 n3 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-2 n1 (1) +place-block pos-2-2 pos-1-2 n1 n2 (1) +move-up pos-2-2 n1 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-0 n1 (1) +remove-block pos-2-0 pos-3-0 n2 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +place-block pos-3-0 pos-2-0 n1 n2 (1) +move-up pos-3-0 n1 pos-2-0 n2 (1) +move pos-2-0 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-2 n1 (1) +remove-block pos-2-2 pos-1-2 n2 n1 (1) +move-up pos-2-2 n1 pos-2-1 n2 (1) +place-block pos-2-1 pos-2-0 n2 n3 (1) +move-down pos-2-1 n2 pos-2-2 n1 (1) +remove-block pos-2-2 pos-2-1 n2 n1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/domain.nl b/paper_reconstructions/llm+p/domains/tyreworld/domain.nl new file mode 100644 index 0000000..f2f560a --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/domain.nl @@ -0,0 +1,29 @@ +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. + +There are 13 actions defined in this domain: + +"open" action: The precondition for this action is that the container is unlocked and closed. The effect of this action is that the container is open and not closed. + +"close" action: The precondition for this action is that the container is open. The effect of this action is that the container is closed and not open. + +"fetch" action: The precondition for this action is that the object is inside the container and the container is open. The effect of this action is that the object is held by the agent and not inside the container. + +"put-away" action: The precondition for this action is that the object is held by the agent and the container is open. The effect of this action is that the object is inside the container and not held by the agent. + +"loosen" action: The precondition for this action is that the agent has a wrench, the nut on hub is tight, and the hub is on the ground. The effect of this action is that the nut on hub is loose and not tight. + +"tighten" action: The precondition for this action is that the agent has a wrench, the nut on hub is loose, and the hub is on the ground. The effect of this action is that the nut on hub is tight and not loose. + +"jack-up" action: This action represents the process of lifting a hub off the ground using a jack. It requires the agent to have a jack and for the hub to be on the ground. After performing this action, the hub will no longer be on the ground and the agent will no longer have the jack. + +"jack-down" action: This action represents the process of lowering a hub back to the ground from an elevated position using a jack. It requires the agent to have the hub off the ground. After performing this action, the hub will be back on the ground and the agent will have the jack. + +"undo" action: This action undo the fastening of a nut on a hub. The preconditions are the hub is not on the ground (i.e., it has been jacked up), the hub is fastened, the agent has a wrench and the nut is loose. The effects are the agent has the nut, the hub is unfastened, the hub is no longer loose and the hub is not fastened anymore. + +"do-up" action: This action fasten a nut on a hub. The preconditions are the agent has a wrench, the hub is unfastened, the hub is not on the ground (i.e., it has been jacked up) and the agent has the nut to be fastened. The effects are the nut is now loose on the hub, the hub is fastened, the hub is no longer unfastened and the agent no longer has the nut. + +"remove-wheel" action: This action removes a wheel from a hub. It can only be performed if the hub is not on the ground, the wheel is currently on the hub, and the hub is unfastened. After the action is performed, the agent will have the removed wheel and the hub will be free, meaning that the wheel is no longer on the hub. + +"put-on-wheel" action: This action puts a wheel onto a hub. It can only be performed if the agent has the wheel, the hub is free, the hub is unfastened, and the hub is not on the ground. After the action is performed, the wheel will be on the hub, the hub will no longer be free, and the agent will no longer have the wheel. + +"inflate" action: This action inflates a wheel using a pump. It can only be performed if the agent has a pump, the wheel is not inflated, and the wheel is intact. After the action is performed, the wheel will be inflated. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/domain.pddl b/paper_reconstructions/llm+p/domains/tyreworld/domain.pddl new file mode 100644 index 0000000..51d1d2c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/domain.pddl @@ -0,0 +1,102 @@ +(define (domain tyreworld) + (:types obj - object + tool wheel nut - obj + container hub - object) +(:predicates (open ?x) + (closed ?x) + (have ?x) + (in ?x ?y) + (loose ?x ?y) + (tight ?x ?y) + (unlocked ?x) + (on-ground ?x) + (not-on-ground ?x) + (inflated ?x) + (not-inflated ?x) + (fastened ?x) + (unfastened ?x) + (free ?x) + (on ?x ?y) + (intact ?x)) + + +(:action open +:parameters (?x - container) +:precondition (and (unlocked ?x) + (closed ?x)) +:effect (and (open ?x) + (not (closed ?x)))) + +(:action close +:parameters (?x - container) +:precondition (open ?x) +:effect (and (closed ?x) + (not (open ?x)))) + +(:action fetch +:parameters (?x - obj ?y - container) +:precondition (and (in ?x ?y) (open ?y)) +:effect (and (have ?x) + (not (in ?x ?y)))) + +(:action put-away +:parameters (?x - obj ?y - container) +:precondition (and (have ?x) (open ?y)) +:effect (and (in ?x ?y) + (not (have ?x)))) + +(:action loosen +:parameters (?x - nut ?y - hub) +:precondition (and (have wrench) (tight ?x ?y) (on-ground ?y)) +:effect (and (loose ?x ?y) + (not (tight ?x ?y)))) + +(:action tighten +:parameters (?x - nut ?y - hub) +:precondition (and (have wrench) (loose ?x ?y) (on-ground ?y)) +:effect (and (tight ?x ?y) + (not (loose ?x ?y)))) + +(:action jack-up +:parameters (?y - hub) +:precondition (and (on-ground ?y) (have jack)) +:effect (and (not-on-ground ?y) + (not (on-ground ?y)) (not (have jack)))) + +(:action jack-down +:parameters (?y - hub) +:precondition (not-on-ground ?y) +:effect (and (on-ground ?y) (have jack) + (not (not-on-ground ?y)))) + +(:action undo +:parameters (?x - nut ?y - hub) +:precondition (and (not-on-ground ?y) (fastened ?y) (have wrench) (loose ?x ?y)) +:effect (and (have ?x) (unfastened ?y) + (not (fastened ?y)) (not (loose ?x ?y)))) + +(:action do-up +:parameters (?x - nut ?y - hub) +:precondition (and (have wrench) (unfastened ?y) (not-on-ground ?y) (have ?x)) +:effect (and (loose ?x ?y) (fastened ?y) + (not (unfastened ?y)) (not (have ?x)))) + +(:action remove-wheel +:parameters (?x - wheel ?y - hub) +:precondition (and (not-on-ground ?y) (on ?x ?y) (unfastened ?y)) +:effect (and (have ?x) (free ?y) + (not (on ?x ?y)))) + +(:action put-on-wheel +:parameters (?x - wheel ?y - hub) +:precondition (and (have ?x) (free ?y) (unfastened ?y) (not-on-ground ?y)) +:effect (and (on ?x ?y) + (not (free ?y)) (not (have ?x)))) + +(:action inflate +:parameters (?x - wheel) +:precondition (and (have pump) (not-inflated ?x) (intact ?x)) +:effect (and (inflated ?x) + (not (not-inflated ?x))))) + + diff --git a/paper_reconstructions/llm+p/domains/tyreworld/p_example.nl b/paper_reconstructions/llm+p/domains/tyreworld/p_example.nl new file mode 100644 index 0000000..50b63f4 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/p_example.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 2 hubs, 2 nuts, 2 flat tyres, and 2 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/p_example.pddl b/paper_reconstructions/llm+p/domains/tyreworld/p_example.pddl new file mode 100644 index 0000000..c4262d8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/p_example.pddl @@ -0,0 +1,55 @@ + + + +(define (problem tireworld-2) +(:domain tyreworld) +(:objects +wrench jack pump - tool +the-hub1 the-hub2 +- hub +nuts1 nuts2 +- nut + +boot - container +r1 w1 r2 w2 +- wheel +) +(:init +(in jack boot) +(in pump boot) +(in wrench boot) +(unlocked boot) +(closed boot) +(intact r1) +(in r1 boot) +(not-inflated r1) +(intact r2) +(in r2 boot) +(not-inflated r2) +(on w1 the-hub1) +(on-ground the-hub1) +(tight nuts1 the-hub1) +(fastened the-hub1) +(on w2 the-hub2) +(on-ground the-hub2) +(tight nuts2 the-hub2) +(fastened the-hub2) +) +(:goal +(and +(on r1 the-hub1) +(inflated r1) +(tight nuts1 the-hub1) +(in w1 boot) +(on r2 the-hub2) +(inflated r2) +(tight nuts2 the-hub2) +(in w2 boot) +(in wrench boot) +(in jack boot) +(in pump boot) +(closed boot) +) +) +) + diff --git a/paper_reconstructions/llm+p/domains/tyreworld/p_example.sol b/paper_reconstructions/llm+p/domains/tyreworld/p_example.sol new file mode 100644 index 0000000..3e91359 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/p_example.sol @@ -0,0 +1,26 @@ +Open boot, +fetch r2, r1, pump, +inflate r2, r1, +put away pump, +fetch wrench, jack, +loosen nuts1, +jack-up the-hub1, +undo nuts1, +remove wheel w1, +put away w1, +put on wheel r1, +do-up nuts1, +jack-down the-hub1, +tighten nuts1, +loosen nuts2, +jack-up the-hub2, +undo nuts2, +remove wheel w2, +put away w2, +put on wheel r2, +do-up nuts2, +jack-down the-hub2, +put away jack, +tighten nuts2, +put away wrench, +close boot. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p01.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p01.nl new file mode 100644 index 0000000..66ce07f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p01.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 1 hubs, 1 nuts, 1 flat tyres, and 1 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p02.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p02.nl new file mode 100644 index 0000000..48ba897 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p02.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 9 hubs, 9 nuts, 9 flat tyres, and 9 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p03.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p03.nl new file mode 100644 index 0000000..3d2e69e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p03.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 3 hubs, 3 nuts, 3 flat tyres, and 3 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p04.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p04.nl new file mode 100644 index 0000000..2c51c1e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p04.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 4 hubs, 4 nuts, 4 flat tyres, and 4 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p01.pddl new file mode 100644 index 0000000..ed4a1a9 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p01.pddl @@ -0,0 +1,44 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + the-hub - hub + nut - nut + boot - container + r1 - wheel + w1 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (on w1 the-hub) + (on-ground the-hub) + (tight nut the-hub) + (fastened the-hub) + ) + + (:goal + (and + (on r1 the-hub) + (inflated r1) + (tight nut the-hub) + (in w1 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p02.pddl new file mode 100644 index 0000000..b1aacc8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p02.pddl @@ -0,0 +1,164 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + the-hub1 - hub + the-hub2 - hub + the-hub3 - hub + the-hub4 - hub + the-hub5 - hub + the-hub6 - hub + the-hub7 - hub + the-hub8 - hub + the-hub9 - hub + nuts1 - nut + nuts2 - nut + nuts3 - nut + nuts4 - nut + nuts5 - nut + nuts6 - nut + nuts7 - nut + nuts8 - nut + nuts9 - nut + boot - container + r1 - wheel + w1 - wheel + r2 - wheel + w2 - wheel + r3 - wheel + w3 - wheel + r4 - wheel + w4 - wheel + r5 - wheel + w5 - wheel + r6 - wheel + w6 - wheel + r7 - wheel + w7 - wheel + r8 - wheel + w8 - wheel + r9 - wheel + w9 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (intact r2) + (in r2 boot) + (not-inflated r2) + (intact r3) + (in r3 boot) + (not-inflated r3) + (intact r4) + (in r4 boot) + (not-inflated r4) + (intact r5) + (in r5 boot) + (not-inflated r5) + (intact r6) + (in r6 boot) + (not-inflated r6) + (intact r7) + (in r7 boot) + (not-inflated r7) + (intact r8) + (in r8 boot) + (not-inflated r8) + (intact r9) + (in r9 boot) + (not-inflated r9) + (on w1 the-hub1) + (on-ground the-hub1) + (tight nuts1 the-hub1) + (fastened the-hub1) + (on w2 the-hub2) + (on-ground the-hub2) + (tight nuts2 the-hub2) + (fastened the-hub2) + (on w3 the-hub3) + (on-ground the-hub3) + (tight nuts3 the-hub3) + (fastened the-hub3) + (on w4 the-hub4) + (on-ground the-hub4) + (tight nuts4 the-hub4) + (fastened the-hub4) + (on w5 the-hub5) + (on-ground the-hub5) + (tight nuts5 the-hub5) + (fastened the-hub5) + (on w6 the-hub6) + (on-ground the-hub6) + (tight nuts6 the-hub6) + (fastened the-hub6) + (on w7 the-hub7) + (on-ground the-hub7) + (tight nuts7 the-hub7) + (fastened the-hub7) + (on w8 the-hub8) + (on-ground the-hub8) + (tight nuts8 the-hub8) + (fastened the-hub8) + (on w9 the-hub9) + (on-ground the-hub9) + (tight nuts9 the-hub9) + (fastened the-hub9) + ) + + (:goal + (and + (on r1 the-hub1) + (inflated r1) + (tight nuts1 the-hub1) + (in w1 boot) + (on r2 the-hub2) + (inflated r2) + (tight nuts2 the-hub2) + (in w2 boot) + (on r3 the-hub3) + (inflated r3) + (tight nuts3 the-hub3) + (in w3 boot) + (on r4 the-hub4) + (inflated r4) + (tight nuts4 the-hub4) + (in w4 boot) + (on r5 the-hub5) + (inflated r5) + (tight nuts5 the-hub5) + (in w5 boot) + (on r6 the-hub6) + (inflated r6) + (tight nuts6 the-hub6) + (in w6 boot) + (on r7 the-hub7) + (inflated r7) + (tight nuts7 the-hub7) + (in w7 boot) + (on r8 the-hub8) + (inflated r8) + (tight nuts8 the-hub8) + (in w8 boot) + (on r9 the-hub9) + (inflated r9) + (tight nuts9 the-hub9) + (in w9 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p03.pddl new file mode 100644 index 0000000..56f370f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p03.pddl @@ -0,0 +1,73 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + the-hub1 - hub + the-hub2 - hub + the-hub3 - hub + nuts1 - nut + nuts2 - nut + nuts3 - nut + r1 - wheel + r2 - wheel + r3 - wheel + w1 - wheel + w2 - wheel + w3 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (intact r2) + (in r2 boot) + (not-inflated r2) + (intact r3) + (in r3 boot) + (not-inflated r3) + (on w1 the-hub1) + (on-ground the-hub1) + (tight nuts1 the-hub1) + (fastened the-hub1) + (on w2 the-hub2) + (on-ground the-hub2) + (tight nuts2 the-hub2) + (fastened the-hub2) + (on w3 the-hub3) + (on-ground the-hub3) + (tight nuts3 the-hub3) + (fastened the-hub3) + ) + + (:goal + (and + (on r1 the-hub1) + (inflated r1) + (tight nuts1 the-hub1) + (in w1 boot) + (on r2 the-hub2) + (inflated r2) + (tight nuts2 the-hub2) + (in w2 boot) + (on r3 the-hub3) + (inflated r3) + (tight nuts3 the-hub3) + (in w3 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p04.pddl new file mode 100644 index 0000000..5292c6d --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p04.pddl @@ -0,0 +1,89 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + boot - container + the-hub1 - hub + the-hub2 - hub + the-hub3 - hub + the-hub4 - hub + nuts1 - nut + nuts2 - nut + nuts3 - nut + nuts4 - nut + r1 - wheel + r2 - wheel + r3 - wheel + r4 - wheel + w1 - wheel + w2 - wheel + w3 - wheel + w4 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (intact r2) + (in r2 boot) + (not-inflated r2) + (intact r3) + (in r3 boot) + (not-inflated r3) + (intact r4) + (in r4 boot) + (not-inflated r4) + (on w1 the-hub1) + (on-ground the-hub1) + (tight nuts1 the-hub1) + (fastened the-hub1) + (on w2 the-hub2) + (on-ground the-hub2) + (tight nuts2 the-hub2) + (fastened the-hub2) + (on w3 the-hub3) + (on-ground the-hub3) + (tight nuts3 the-hub3) + (fastened the-hub3) + (on w4 the-hub4) + (on-ground the-hub4) + (tight nuts4 the-hub4) + (fastened the-hub4) + ) + + (:goal + (and + (on r1 the-hub1) + (inflated r1) + (tight nuts1 the-hub1) + (in w1 boot) + (on r2 the-hub2) + (inflated r2) + (tight nuts2 the-hub2) + (in w2 boot) + (on r3 the-hub3) + (inflated r3) + (tight nuts3 the-hub3) + (in w3 boot) + (on r4 the-hub4) + (inflated r4) + (tight nuts4 the-hub4) + (in w4 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt new file mode 100644 index 0000000..e55e176 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt @@ -0,0 +1,25 @@ +open boot (1) +fetch wrench boot (1) +fetch pump boot (1) +fetch r1 boot (1) +loosen nut the-hub (1) +inflate r1 (1) +put-away pump boot (1) +fetch jack boot (1) +jack-up the-hub (1) +undo nut the-hub (1) +put-away wrench boot (1) +remove-wheel w1 the-hub (1) +put-away w1 boot (1) +close boot (1) +put-on-wheel r1 the-hub (1) +open boot (1) +fetch wrench boot (1) +do-up nut the-hub (1) +jack-down the-hub (1) +put-away jack boot (1) +close boot (1) +tighten nut the-hub (1) +open boot (1) +put-away wrench boot (1) +close boot (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt new file mode 100644 index 0000000..a8964d7 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt @@ -0,0 +1,113 @@ +open boot (1) +fetch r9 boot (1) +fetch r8 boot (1) +fetch r7 boot (1) +fetch r6 boot (1) +fetch r5 boot (1) +fetch r4 boot (1) +fetch r3 boot (1) +fetch r2 boot (1) +fetch r1 boot (1) +fetch pump boot (1) +inflate r9 (1) +inflate r8 (1) +inflate r7 (1) +inflate r6 (1) +inflate r5 (1) +inflate r4 (1) +inflate r3 (1) +inflate r2 (1) +inflate r1 (1) +fetch wrench boot (1) +put-away pump boot (1) +loosen nuts1 the-hub1 (1) +loosen nuts2 the-hub2 (1) +loosen nuts3 the-hub3 (1) +loosen nuts4 the-hub4 (1) +loosen nuts5 the-hub5 (1) +loosen nuts6 the-hub6 (1) +loosen nuts7 the-hub7 (1) +loosen nuts8 the-hub8 (1) +loosen nuts9 the-hub9 (1) +fetch jack boot (1) +jack-up the-hub1 (1) +undo nuts1 the-hub1 (1) +remove-wheel w1 the-hub1 (1) +put-away w1 boot (1) +put-on-wheel r1 the-hub1 (1) +do-up nuts1 the-hub1 (1) +jack-down the-hub1 (1) +tighten nuts1 the-hub1 (1) +jack-up the-hub2 (1) +undo nuts2 the-hub2 (1) +remove-wheel w2 the-hub2 (1) +put-away w2 boot (1) +put-on-wheel r2 the-hub2 (1) +do-up nuts2 the-hub2 (1) +jack-down the-hub2 (1) +tighten nuts2 the-hub2 (1) +jack-up the-hub3 (1) +undo nuts3 the-hub3 (1) +remove-wheel w3 the-hub3 (1) +put-away w3 boot (1) +put-on-wheel r3 the-hub3 (1) +do-up nuts3 the-hub3 (1) +jack-down the-hub3 (1) +tighten nuts3 the-hub3 (1) +jack-up the-hub4 (1) +undo nuts4 the-hub4 (1) +remove-wheel w4 the-hub4 (1) +put-away w4 boot (1) +put-on-wheel r4 the-hub4 (1) +do-up nuts4 the-hub4 (1) +jack-down the-hub4 (1) +tighten nuts4 the-hub4 (1) +jack-up the-hub5 (1) +undo nuts5 the-hub5 (1) +remove-wheel w5 the-hub5 (1) +put-away w5 boot (1) +put-on-wheel r5 the-hub5 (1) +do-up nuts5 the-hub5 (1) +jack-down the-hub5 (1) +tighten nuts5 the-hub5 (1) +jack-up the-hub6 (1) +undo nuts6 the-hub6 (1) +remove-wheel w6 the-hub6 (1) +put-away w6 boot (1) +put-on-wheel r6 the-hub6 (1) +do-up nuts6 the-hub6 (1) +jack-down the-hub6 (1) +tighten nuts6 the-hub6 (1) +jack-up the-hub7 (1) +undo nuts7 the-hub7 (1) +remove-wheel w7 the-hub7 (1) +put-away w7 boot (1) +put-on-wheel r7 the-hub7 (1) +do-up nuts7 the-hub7 (1) +jack-down the-hub7 (1) +tighten nuts7 the-hub7 (1) +jack-up the-hub8 (1) +undo nuts8 the-hub8 (1) +remove-wheel w8 the-hub8 (1) +put-away w8 boot (1) +put-on-wheel r8 the-hub8 (1) +do-up nuts8 the-hub8 (1) +jack-down the-hub8 (1) +tighten nuts8 the-hub8 (1) +jack-up the-hub9 (1) +undo nuts9 the-hub9 (1) +put-away wrench boot (1) +remove-wheel w9 the-hub9 (1) +put-away w9 boot (1) +close boot (1) +put-on-wheel r9 the-hub9 (1) +open boot (1) +fetch wrench boot (1) +do-up nuts9 the-hub9 (1) +jack-down the-hub9 (1) +put-away jack boot (1) +close boot (1) +tighten nuts9 the-hub9 (1) +open boot (1) +put-away wrench boot (1) +close boot (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p03.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p03.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt new file mode 100644 index 0000000..94f8f00 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt @@ -0,0 +1,58 @@ +open boot (1) +fetch r4 boot (1) +fetch r3 boot (1) +fetch r2 boot (1) +fetch r1 boot (1) +fetch pump boot (1) +inflate r4 (1) +inflate r3 (1) +inflate r2 (1) +inflate r1 (1) +put-away pump boot (1) +fetch wrench boot (1) +loosen nuts1 the-hub1 (1) +loosen nuts2 the-hub2 (1) +loosen nuts3 the-hub3 (1) +loosen nuts4 the-hub4 (1) +fetch jack boot (1) +jack-up the-hub1 (1) +undo nuts1 the-hub1 (1) +remove-wheel w1 the-hub1 (1) +put-away w1 boot (1) +put-on-wheel r1 the-hub1 (1) +do-up nuts1 the-hub1 (1) +jack-down the-hub1 (1) +tighten nuts1 the-hub1 (1) +jack-up the-hub2 (1) +undo nuts2 the-hub2 (1) +remove-wheel w2 the-hub2 (1) +put-away w2 boot (1) +put-on-wheel r2 the-hub2 (1) +do-up nuts2 the-hub2 (1) +jack-down the-hub2 (1) +tighten nuts2 the-hub2 (1) +jack-up the-hub3 (1) +undo nuts3 the-hub3 (1) +remove-wheel w3 the-hub3 (1) +put-away w3 boot (1) +put-on-wheel r3 the-hub3 (1) +do-up nuts3 the-hub3 (1) +jack-down the-hub3 (1) +tighten nuts3 the-hub3 (1) +jack-up the-hub4 (1) +undo nuts4 the-hub4 (1) +put-away wrench boot (1) +remove-wheel w4 the-hub4 (1) +put-away w4 boot (1) +close boot (1) +put-on-wheel r4 the-hub4 (1) +open boot (1) +fetch wrench boot (1) +do-up nuts4 the-hub4 (1) +jack-down the-hub4 (1) +put-away jack boot (1) +close boot (1) +tighten nuts4 the-hub4 (1) +open boot (1) +put-away wrench boot (1) +close boot (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/llm+p.py b/paper_reconstructions/llm+p/llm+p.py deleted file mode 100644 index c528b7b..0000000 --- a/paper_reconstructions/llm+p/llm+p.py +++ /dev/null @@ -1,73 +0,0 @@ -""" -Paper: "LLM+P: Empowering Large Language Models with Optimal Planning Proficiency" Liu et al (2023) -Source code: https://github.com/Cranial-XIX/llm-pddl -Run: python3 -m tests.paper_reconstructions.llm+p.llm+p - -Assumes the following: - 1. NL task description - 2. Ground-truth PDDL domain - -This library only focuses on model generation, so it is not concerned with the other phase of LLM+P: LLM translating PDDL plans to NL -""" - -import os -from l2p import * -from l2p.utils.pddl_planner import FastDownward - - -def open_file(file_path): - with open(file_path, "r") as file: - file = file.read().strip() - return file - - -if __name__ == "__main__": - - # setup L2P requirements - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - openai_llm = OPENAI(model=engine, api_key=api_key) - planner = FastDownward() - - # prompts taken from LLM+P - role = open_file("paper_reconstructions/llm+p/prompts/role.txt") - example = open_file("paper_reconstructions/llm+p/prompts/example.txt") - task = open_file("paper_reconstructions/llm+p/prompts/task.txt") - - problem_desc = open_file("paper_reconstructions/llm+p/prompts/problem_desc.txt") - - # assemble prompt builder - prompt_builder = PromptBuilder(role=role, examples=[example], task=task) - - task_builder = TaskBuilder() - - # extract PDDL from prompt - objects, initial, goal, llm_response = task_builder.extract_task( - model=openai_llm, - problem_desc=problem_desc, - prompt_template=prompt_builder.generate_prompt(), - ) - - # construct PDDL components into PDDL problem file - object_str = task_builder.format_objects(objects) - initial_state_str = task_builder.format_initial(initial) - goal_state_str = task_builder.format_goal(goal) - - pddl_problem = task_builder.generate_task( - "blocksworld-4ops", - "blocksworld-4ops_problem", - object_str, - initial_state_str, - goal_state_str, - ) - - # write down PDDL problem file - problem_file = "paper_reconstructions/llm+p/results/problem.pddl" - domain_file = "paper_reconstructions/llm+p/results/domain.pddl" - with open(problem_file, "w") as f: - f.write(pddl_problem) - - print("PDDL problem:\n", pddl_problem) - - # run planner - planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) diff --git a/paper_reconstructions/llm+p/main.py b/paper_reconstructions/llm+p/main.py new file mode 100644 index 0000000..7624497 --- /dev/null +++ b/paper_reconstructions/llm+p/main.py @@ -0,0 +1,123 @@ +""" +Paper: "LLM+P: Empowering Large Language Models with Optimal Planning Proficiency" Liu et al (2023) +Source code: https://github.com/Cranial-XIX/llm-pddl +Run: python3 -m paper_reconstructions.llm+p.main + +Assumes the following: + 1. NL task description + 2. Ground-truth PDDL domain + +This library only focuses on model generation, so it is not concerned with the other phase of LLM+P: LLM translating PDDL plans to NL. +This module contains all domains from LLM+P code (except Manipulation domain as L2P currently does not support cost actions). +Experimentation recreation was only done on first four problems of each domain. Example results found in `./domains/blocksworld/results` +""" + +import os, argparse +from .domain import Domain +from l2p import * + +DOMAINS = [ + "barman", + "blocksworld", + "floortile", + "grippers", + "storage", + "termes", + "tyreworld", + "manipulation" +] + +def create_llm_ic_pddl_prompt(task_nl, domain_pddl, context): + # (LM+P), create the problem PDDL given the context + + context_nl, context_pddl, context_sol = context + + prompt = f"I want you to solve planning problems. " + \ + f"An example planning problem is: \n{context_nl} \n" + \ + f"The problem PDDL file to this problem is: \n{context_pddl} \n" + \ + f"Now I have a new planning problem and its description is: \n{task_nl} \n" + \ + f"Provide me with the problem PDDL file that describes " + \ + f"the new planning problem directly without further explanations. Do not return anything else." + + # add in L2P default format prompt + prompt += "\n\n" + load_file("templates/task_templates/extract_task.txt") + return prompt + + +def llm_ic_pddl_planner(args, problem_name): + + # create necessary classes + task_builder = TaskBuilder() # L2P task builder + domain = Domain(name=args.domain) + planner = FastDownward(planner_path=args.planner) # FastDownward planner + + # initialize OpenAI engine + api_key = os.environ.get("OPENAI_API_KEY") + model = OPENAI(model=args.model, api_key=api_key) + + # extract assumptions + context = domain.get_context() + domain_pddl = domain.get_domain_pddl() + domain_pddl_file = domain.get_domain_pddl_file() + + # create the tmp / result folders + result_folder = f"paper_reconstructions/llm+p/domains/{domain.name}/results/pddl" + plan_results_folder = f"paper_reconstructions/llm+p/domains/{domain.name}/results/plan" + + task = args.task # extract task arguments + + # A. generate problem pddl file + task_nl = domain.get_task(task) + prompt = create_llm_ic_pddl_prompt(task_nl, domain_pddl, context) + + # query LLM using L2P + objects, initial, goal, llm_response = task_builder.extract_task( + model=model, + problem_desc="", + prompt_template=prompt, + ) + + # construct PDDL components into PDDL problem file + object_str = task_builder.format_objects(objects) + initial_state_str = task_builder.format_initial(initial) + goal_state_str = task_builder.format_goal(goal) + + # generate proper PDDL structure + pddl_problem = task_builder.generate_task( + domain.name, + problem_name, + object_str, + initial_state_str, + goal_state_str, + ) + + # write generated pddl into folder + pddl_file_path = os.path.join(result_folder, domain.get_task_name(task)) + os.makedirs(result_folder, exist_ok=True) + with open(pddl_file_path, 'w') as file: + file.write(pddl_problem) + + # B. run planner + plan_name = domain.get_task_name(task).replace("pddl", "txt") + _, output = planner.run_fast_downward(domain_file=domain_pddl_file, problem_file=pddl_file_path) + + # write generated plan into folder + plan_file_path = os.path.join(plan_results_folder, plan_name) + os.makedirs(plan_results_folder, exist_ok=True) + with open(plan_file_path, 'w') as file: + file.write(output) + + + +if __name__ == "__main__": + + # load in arguments to run program + parser = argparse.ArgumentParser(description="LLM+P") + parser.add_argument('--model', type=str, default="gpt-4o-mini") + parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") + parser.add_argument('--task', type=int, default=0) # task to run + parser.add_argument('--planner', type=str, default="downward/fast-downward.py") + args = parser.parse_args() + + # run LLM+P method + llm_ic_pddl_planner(args=args, problem_name="blocksworld_problem") diff --git a/paper_reconstructions/llm+p/prompts/example.txt b/paper_reconstructions/llm+p/prompts/example.txt deleted file mode 100644 index 19ff829..0000000 --- a/paper_reconstructions/llm+p/prompts/example.txt +++ /dev/null @@ -1,48 +0,0 @@ -An example planning problem is: -""" -You have 5 blocks. -b2 is on top of b5. -b5 is on top of b1. -b1 is on top of b4. -b3 is on top of b2. -b4 is on the table. -b3 is clear. -Your arm is empty. -Your goal is to move the blocks. -b4 should be on top of b3. -""" - -The problem PDDL file to this problem is: -""" -(define (problem BW-rand-5) -(:domain blocksworld-4ops) -(:objects b1 b2 b3 b4 b5 ) -(:init -(arm-empty) -(on b1 b4) -(on b2 b5) -(on b3 b2) -(on-table b4) -(on b5 b1) -(clear b3) -) -(:goal -(and -(on b4 b3)) -) -) -""" - -The solution to this problem is: -""" -unstack b3 from b2, -putdown b3, -unstack b2 from b5, -putdown b2, -unstack b5 from b1, -putdown b5, -unstack b1 from b4, -putdown b1, -pickup b4, -stack b4 on b3 -""" \ No newline at end of file diff --git a/paper_reconstructions/llm+p/prompts/role.txt b/paper_reconstructions/llm+p/prompts/role.txt deleted file mode 100644 index 6eceb87..0000000 --- a/paper_reconstructions/llm+p/prompts/role.txt +++ /dev/null @@ -1,28 +0,0 @@ -Your role is to solve planning problems. - -Do not attempt to declare any types. - -The problem you are to extract from is under the header '## Problem description' - -Do not, under any circumstance, output the answers in PDDL format. Final answer must be in the following format at the end: - -""" -## Problem description - -### OBJECTS -``` -truck1 - truck -``` - -### INITIAL -``` -(at truck1 chicago_depot): truck1 is at the chicago_depot -``` - -### GOAL -``` -(AND ; all the following should be done - (finalised house1) ; house 1 is done -) -``` -""" \ No newline at end of file diff --git a/paper_reconstructions/llm+p/prompts/task.txt b/paper_reconstructions/llm+p/prompts/task.txt deleted file mode 100644 index 36354b6..0000000 --- a/paper_reconstructions/llm+p/prompts/task.txt +++ /dev/null @@ -1,3 +0,0 @@ -Now I have a new planning problem and its description is: - -{problem_desc} \ No newline at end of file diff --git a/paper_reconstructions/llm+p/results/domain.pddl b/paper_reconstructions/llm+p/results/domain.pddl deleted file mode 100644 index 95cf297..0000000 --- a/paper_reconstructions/llm+p/results/domain.pddl +++ /dev/null @@ -1,25 +0,0 @@ -(define (domain blocksworld-4ops) - (:requirements :conditional-effects :disjunctive-preconditions :negative-preconditions :strips :typing :universal-preconditions) - (:types block - object) - (:predicates (arm-empty) (clear ?x - block) (holding ?x - block) (on ?x - block ?y - block) (on-table ?x - block)) - (:action pickup - :parameters (?ob - block) - :precondition (and (clear ?ob) (on-table ?ob) (arm-empty)) - :effect (and (holding ?ob) (not (clear ?ob)) (not (on-table ?ob)) (not (arm-empty))) - ) - (:action putdown - :parameters (?ob - block) - :precondition (holding ?ob) - :effect (and (clear ?ob) (arm-empty) (on-table ?ob) (not (holding ?ob))) - ) - (:action stack - :parameters (?ob - block ?underob - block) - :precondition (and (clear ?underob) (holding ?ob)) - :effect (and (arm-empty) (clear ?ob) (on ?ob ?underob) (not (clear ?underob)) (not (holding ?ob))) - ) - (:action unstack - :parameters (?ob - block ?underob - block) - :precondition (and (on ?ob ?underob) (clear ?ob) (arm-empty)) - :effect (and (holding ?ob) (clear ?underob) (not (on ?ob ?underob)) (not (clear ?ob)) (not (arm-empty))) - ) -) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt b/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt new file mode 100644 index 0000000..0c2ad46 --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt @@ -0,0 +1 @@ +The AI agent here is a mechanical robot arm that can pick and place the blocks. Only one block may be moved at a time: it may either be placed on the table or placed atop another block. Because of this, any blocks that are, at a given time, under another block cannot be moved. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task1.txt similarity index 100% rename from paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt rename to paper_reconstructions/nl2plan/domains/blocksworld/task1.txt diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt new file mode 100644 index 0000000..ac747b5 --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt @@ -0,0 +1 @@ +There are four blocks in two piles. The first has blue on red and the second has green on yellow. I want a single stack ordered (lowest first): red, green, blue, yellow. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt new file mode 100644 index 0000000..fdab06f --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt @@ -0,0 +1 @@ +I've got five blocks of three colours and want to stack them in a single pile such that the red blocks are at the bottom, the blue are on those and the green are on top. Currently they're in two stacks, (red, blue, green) and (green, red) ordered from the bottom up. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/desc.txt b/paper_reconstructions/nl2plan/domains/household/desc.txt new file mode 100644 index 0000000..4861b0b --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/household/desc.txt @@ -0,0 +1 @@ +The AI agent here is a household robot that can navigate to various large and normally immovable furniture pieces or appliances in the house to carry out household tasks. Note that the robot has only one gripper, so (a) it can only hold one object; (b) it shouldn't hold any other irrelevant objects in its gripper while performing some manipulation tasks (e.g., opening a drawer or closing a window); (c) operations on small household items should be carried out on furniture with a flat surface to get enough space for manipulation. In this domain, the locations of the robot and small household items (e.g., apples, oranges, bowls, lunch boxes or lamps) are determined by large and normally immovable furniture pieces or appliances. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/task1.txt b/paper_reconstructions/nl2plan/domains/household/task1.txt new file mode 100644 index 0000000..a0b2359 --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/household/task1.txt @@ -0,0 +1,23 @@ +Please toggle lamp_1 on and humidifier_1 off starting from the following state: + +- drawer_1 is opened +- drawer_2 is opened +- fridge_1 is opened +- cabinet_1 is not opened +- cabinet_2 is opened +- cup_1 in/on cabinet_2 +- plate_1 in/on drawer_2 +- cutting_board_1 in/on countertop_1 +- cutting_board_1 is pickupable +- blender_1 in/on dining_table_1 +- blender_1 is not pickupable +- blender_1 is turned off +- lamp_1 in/on side_table_1 +- lamp_1 is turned off +- humidifier_1 in/on side_table_1 +- humidifier_1 is turned on +- apple_1 in/on cabinet_2 +- book_1 in/on dining_table_1 +- book_2 in/on dining_table_1 +- robot at cabinet_1 +- robot is holding mug_1 \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/task2.txt b/paper_reconstructions/nl2plan/domains/household/task2.txt new file mode 100644 index 0000000..76f04ee --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/household/task2.txt @@ -0,0 +1,34 @@ +Your task is to transfer potato_1 from a lunch box to plate_1 and close the fridge after yourself. + +This is the current state: +- drawer_1 is not opened +- fridge_1 is opened +- cabinet_1 is not opened +- bowl_1 in/on cabinet_2 +- bowl_2 in/on drawer_2 +- plate_1 in/on dining_table_1 +- plate_2 in/on dish_washer_1 +- pan_1 in/on cabinet_3 +- pan_2 in/on cabinet_4 +- lunch_box_1 in/on fridge_1 +- lunch_box_1 is not opened +- lunch_box_2 in/on fridge_1 +- lunch_box_2 is not opened +- pizza_box_1 in/on drawer_4 +- pizza_box_1 is not opened +- cutting_board_1 in/on drawer_1 +- cutting_board_1 is pickupable +- apple_1 in/on cabinet_1 +- apple_1 is not sliced +- apple_2 in/on fridge_1 +- apple_2 is not sliced +- pizza_1 in/on lunch_box_1 +- pizza_1 is not pickupable +- toast_1 in/on lunch_box_1 +- toast_1 is not sliced +- banana_1 in/on cabinet_2 +- banana_1 is not sliced +- potato_1 in/on lunch_box_2 +- potato_1 is not sliced +- robot at cabinet_2 +- robot is not holding anything \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/task3.txt b/paper_reconstructions/nl2plan/domains/household/task3.txt new file mode 100644 index 0000000..18b33e0 --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/household/task3.txt @@ -0,0 +1,74 @@ +I want you to heat pizza_1 with pan_2. + +The following are the current objects and their state: +- drawer_1 is opened +- drawer_2 is not opened +- drawer_3 is opened +- drawer_4 is not opened +- fridge_1 is not opened +- cabinet_1 is opened +- cabinet_2 is not opened +- cabinet_3 is not opened +- cabinet_4 is opened +- microwave_1 is not opened +- carpet_1 is not clean +- carpet_2 is not clean +- dish_washer_1 is opened +- garbage_can_1 is not opened +- cup_1 in/on drawer_3 +- bowl_1 in/on dish_washer_1 +- bowl_2 in/on cabinet_4 +- plate_1 in/on dining_table_1 +- plate_2 in/on cabinet_3 +- pan_1 in/on stove_burner_1 +- pan_2 in/on dining_table_1 +- lunch_box_1 in/on fridge_1 +- lunch_box_1 is not opened +- lunch_box_2 in/on cabinet_3 +- lunch_box_2 is not opened +- pizza_box_1 in/on cabinet_2 +- pizza_box_1 is not opened +- cutting_board_1 in/on countertop_2 +- cutting_board_1 is pickupable +- toaster_1 in/on countertop_2 +- toaster_1 is not pickupable +- toaster_1 is turned off +- blender_1 in/on dining_table_1 +- blender_1 is not pickupable +- blender_1 is turned off +- lamp_1 in/on side_table_2 +- lamp_1 is turned on +- lamp_1 is not pickupable +- humidifier_1 in/on side_table_2 +- humidifier_1 is turned on +- humidifier_1 is not pickupable +- apple_1 in/on lunch_box_2 +- apple_1 is not sliced +- apple_2 in/on drawer_2 +- apple_2 is not sliced +- pizza_1 in/on pizza_box_1 +- pizza_1 is not pickupable +- toast_1 in/on lunch_box_1 +- toast_1 is not sliced +- orange_1 in/on lunch_box_1 +- orange_1 is not sliced +- orange_2 in/on drawer_1 +- orange_2 is not sliced +- banana_1 in/on cabinet_3 +- banana_1 is not sliced +- potato_1 in/on cabinet_1 +- potato_1 is not sliced +- fork_1 in/on cabinet_4 +- spoon_1 in/on drawer_4 +- knife_1 in/on cabinet_2 +- book_1 in/on dining_table_1 +- book_2 in/on side_table_2 +- book_3 in/on side_table_2 +- book_4 in/on side_table_1 +- book_5 in/on side_table_1 +- cloth_1 in/on cabinet_3 +- cloth_1 is clean +- handheld_vacuum_1 in/on shelf_1 +- handheld_vacuum_1 has an empty dust bin +- robot at drawer_1 +- robot is holding mug_1 \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/logistics/desc.txt b/paper_reconstructions/nl2plan/domains/logistics/desc.txt new file mode 100644 index 0000000..00f75d0 --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/logistics/desc.txt @@ -0,0 +1 @@ +The AI agent here is a logistics planner that has to plan to transport packages within the locations in a city through a truck and between cities through an airplane. Within a city, the locations are directly linked, allowing trucks to travel between any two of these locations. Similarly, cities are directly connected to each other allowing airplanes to travel between any two cities. Also, there is no limit to how many packages a truck or plane can carry (so in theory a truck or plane can carry an infinite number of packages). \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/logistics/task1.txt b/paper_reconstructions/nl2plan/domains/logistics/task1.txt new file mode 100644 index 0000000..3029f3f --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/logistics/task1.txt @@ -0,0 +1 @@ +Currently I've got five packages to ship, 3 in a storage in Ado and the rest in Betar's storage. Those from Ado should be sent 1 to Bal Street in Betar, 2 to Cli Promenade in Colin. Those from Betar should be moved to the Ado storage. The only plane is currently in Duran's airport, but each city has it's own truck and airport. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt b/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt new file mode 100644 index 0000000..40e066b --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt @@ -0,0 +1 @@ +The AI agent here is a robot that has to replace a flat tyre with a spare one. This involves fetching the tools (wrench, jack, pump) from the boot, undoing the nuts on the flat tyre, jacking up the (appropriate) hub(s), removing the tyre, doing up the spare one, etc. Note that there is no restriction on how many objects the AI agent (i.e., the robot) can carry. Also note that each hub has only one nut. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt new file mode 100644 index 0000000..80103c0 --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt @@ -0,0 +1 @@ +The robot is already holding all the tools and has a whole, but uninflated, wheel. The flat tire is already loosened and jacked up, but still left on the hub. Safely replace the flat tire with the whole one and prepare it. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt new file mode 100644 index 0000000..1f5a498 --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt @@ -0,0 +1 @@ +The robot currently only has a wrench, but the other tools and a spare (already inflated) tyre are in the open boot. The back left wheel is flat, and still attached. It should be safely replaced. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt new file mode 100644 index 0000000..1e22e9a --- /dev/null +++ b/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt @@ -0,0 +1 @@ +The car is already in the process of having wheels changed, so the front left hub is raised with the jack and its wheel removed. I want you to remove and replace the back left tyre. You'll find an uninflated tyre, the wrench and a pump in the closed trunk. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/main.py b/paper_reconstructions/nl2plan/main.py new file mode 100644 index 0000000..29472d7 --- /dev/null +++ b/paper_reconstructions/nl2plan/main.py @@ -0,0 +1,218 @@ +""" +Paper: "NL2Plan: Robust LLM-Driven Planning from Minimal Text Descriptions" Gestrin et al (2024) +Source code: https://github.com/mrlab-ai/NL2Plan +Run: python3 -m paper_reconstructions.nl2plan.main +""" + +import argparse +from l2p import * +from .nl2plan import * + +DOMAINS = [ + "blocksworld", + "household", + "isr", # currently unsupported + "isr-assisted", # currently unsupported + "logistics", + "tyreworld" +] + +REQUIREMENTS = [ + ":strips", + ":typing", + ":equality", + ":negative-preconditions", + ":disjunctive-preconditions", + ":universal-preconditions", + ":conditional-effects", + ] + +UNSUPPORTED_KEYWORDS = ["object", "pddl", "lisp"] + +separator = "-" * 20 + +def run_nl2plan(args, domain: str, problem: str): + # create necessary classes + domain_builder = DomainBuilder() # L2P domain builder + task_builder = TaskBuilder() # L2P task builder + planner = FastDownward(planner_path=args.planner) # FastDownward planner + log = "" # string to log all step output + + # initialize OpenAI engine + api_key = os.environ.get("OPENAI_API_KEY") + model = OPENAI(model=args.model, api_key=api_key) + + + # A. Type Extraction + type_extraction = TypeExtraction() + type_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") + + types = type_extraction.type_extraction( + model=model, + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), + type_extraction_prompt=type_extraction.prompt_template, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt")) + + log += f"STEP ONE: TYPE EXTRACTION\n\n{types}\n\n" + model.reset_tokens() + + # B. Hierarchy Construction + hierarchy_construction = HierarchyConstruction() + hierarchy_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") + + type_hierarchy = hierarchy_construction.hierarchy_construction( + model=model, + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), + type_hierarchy_prompt=hierarchy_construction.prompt_template, + types=types, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt")) + + log += f"{separator}\nSTEP TWO: HIERARCHY CONSTRUCTION\n\n{type_hierarchy}\n\n" + model.reset_tokens() + + # C. Action Extraction + action_extraction = ActionExtraction() + action_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") + + nl_actions = action_extraction.action_extraction( + model=model, + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), + action_extraction_prompt=action_extraction.prompt_template, + type_hierarchy=type_hierarchy, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt")) + + log += f"{separator}\nSTEP THREE: ACTION EXTRACTION\n\n{nl_actions}\n\n" + model.reset_tokens() + + # D. Action Construction + action_construction = ActionConstruction() + action_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") + + actions, predicates, = action_construction.action_construction( + model=model, + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), + act_constr_prompt=action_construction.prompt_template, + nl_actions=nl_actions, + type_hierarchy=type_hierarchy, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt"), + max_attempts=1 + ) + + log += f"{separator}\n" + log += "STEP FOUR: ACTION CONSTRUCTION\n\n" + log += "ACTIONS:\n" + log += '\n'.join([str(action) for action in actions]) + "\n\n" + log += "PREDICATES:\n" + log += '\n'.join([str(predicate) for predicate in predicates]) + "\n\n" + model.reset_tokens() + + # E. Task Extraction + task_extraction = TaskExtraction() + task_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") + + objects, initial, goal = task_extraction.task_extraction( + model=model, + problem_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/{problem}.txt"), + task_extraction_prompt=task_extraction.prompt_template, + types=type_hierarchy, + predicates=predicates, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt"), + error_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/error.txt") + ) + + log += f"{separator}\nSTEP FIVE: TASK EXTRACTION\n\n" + log += f"OBJECTS:\n{objects}\n" + log += f"INITIAL STATES:\n{initial}\n" + log += f"GOAL STATES:\n{goal}\n" + + predicate_str = "\n".join( + [pred["clean"].replace(":", " ; ") for pred in predicates] + ) + + types = format_types(type_hierarchy) # retrieve types + pruned_types = { + name: description + for name, description in types.items() + if name not in UNSUPPORTED_KEYWORDS + } # remove unsupported words + + # format strings + types_str = "\n".join(pruned_types) + + # generate PDDL specifications + pddl_domain = domain_builder.generate_domain( + domain=args.domain, + requirements=args.requirements, + types=types_str, + predicates=predicate_str, + actions=actions, + ) + + log += f"\n\nPDDL DOMAIN:\n{pddl_domain}" + + problem_name = args.domain + "_problem" + pddl_problem = task_builder.generate_task( + domain=args.domain, + problem=problem_name, + objects=objects, + initial=initial, + goal=goal, + ) + + log += f"\n\nPDDL PROBLEM:\n{pddl_problem}" + + # Ensure that the directories exist + main_directory = f"paper_reconstructions/nl2plan/results/{domain}/{problem}" + os.makedirs(main_directory, exist_ok=True) # Creates the directory, if it doesn't exist + + # Write log file + log_file = f"{main_directory}/log.txt" + with open(log_file, "w") as f: + f.write(log) + + # Write domain and problem files + domain_file = f"{main_directory}/domain.pddl" + with open(domain_file, "w") as f: + f.write(pddl_domain) + problem_file = f"{main_directory}/problem.pddl" + with open(problem_file, "w") as f: + f.write(pddl_problem) + + # Run planner + _, plan = planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) + + # Write plan file + plan_file = f"{main_directory}/plan.txt" + with open(plan_file, "w") as f: + f.write(plan) + + + + +if __name__ == "__main__": + + # load in arguments to run program + parser = argparse.ArgumentParser(description="NL2Plan") + parser.add_argument('--model', type=str, default="gpt-4o-mini") + parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") + parser.add_argument('--requirements', type=list[str], default=REQUIREMENTS) + parser.add_argument('--planner', type=str, default="/Users/marcustantakoun/Downloads/downward/fast-downward.py") + args = parser.parse_args() + + # run LLM+P method + run_nl2plan(args=args, domain="blocksworld", problem="task1") diff --git a/paper_reconstructions/nl2plan/nl2plan.py b/paper_reconstructions/nl2plan/nl2plan.py deleted file mode 100644 index 1d9fb88..0000000 --- a/paper_reconstructions/nl2plan/nl2plan.py +++ /dev/null @@ -1,407 +0,0 @@ -""" -Paper: "NL2Plan: Robust LLM-Driven Planning from Minimal Text Descriptions" Gestrin et al (2024) -Source code: https://github.com/mrlab-ai/NL2Plan -Run: python3 -m paper_reconstructions.nl2plan.nl2plan -""" - -import os, json -from l2p import * -from l2p.utils.pddl_planner import FastDownward - - -def open_file(file_path): - with open(file_path, "r") as file: - file = file.read().strip() - return file - - -def format_json_output(data): - return json.dumps(data, indent=4) - - -engine = "gpt-4o-mini" -api_key = os.environ.get("OPENAI_API_KEY") -openai_llm = OPENAI(model=engine, api_key=api_key) - -domain_desc = open_file("paper_reconstructions/nl2plan/prompts/blocksworld.txt") -problem_desc = open_file("paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt") - -# open and create type extraction prompt builder class -role_desc = open_file("paper_reconstructions/nl2plan/prompts/type_extraction/role.txt") -tech_desc = open_file( - "paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt" -) -task_desc = open_file("paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") -type_extraction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create type hierarchy prompt builder class -role_desc = open_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt" -) -tech_desc = open_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt" -) -task_desc = open_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt" -) -type_hierarchy_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create NL action prompt builder class -role_desc = open_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/role.txt" -) -tech_desc = open_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt" -) -task_desc = open_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/task.txt" -) -action_extraction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create PDDL action prompt builder class -role_desc = open_file( - "paper_reconstructions/nl2plan/prompts/action_construction/role.txt" -) -tech_desc = open_file( - "paper_reconstructions/nl2plan/prompts/action_construction/technique.txt" -) -task_desc = open_file( - "paper_reconstructions/nl2plan/prompts/action_construction/task.txt" -) -action_construction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create compact action prompt builder class -role_desc = open_file("paper_reconstructions/nl2plan/prompts/task_extraction/role.txt") -tech_desc = open_file( - "paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt" -) -task_desc = open_file("paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") -task_extraction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -domain_builder = DomainBuilder() -task_builder = TaskBuilder() -syntax_validator = SyntaxValidator() -planner = FastDownward() -feedback_builder = FeedbackBuilder() - -unsupported_keywords = ["object", "pddl", "lisp"] - - -def type_extraction( - model: LLM, domain_desc: str, type_extraction_prompt: PromptBuilder -) -> dict[str, str]: - # STEP ONE: type extraction - types, response = domain_builder.extract_type( - model, domain_desc, type_extraction_prompt.generate_prompt() - ) - - feedback_template = open_file( - "paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt" - ) - types, _ = feedback_builder.type_feedback( - model=model, - domain_desc=domain_desc, - feedback_template=feedback_template, - feedback_type="llm", - types=types, - llm_response=response, - ) - - print("Types:", format_json_output(types)) - return types - - -def hierarchy_construction( - model, domain_desc, type_hierarchy_prompt, types -) -> dict[str, str]: - # STEP TWO: type hierarchy extraction - type_hierarchy, response = domain_builder.extract_type_hierarchy( - model=model, - domain_desc=domain_desc, - prompt_template=type_hierarchy_prompt.generate_prompt(), - types=types, - ) - - feedback_template = open_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt" - ) - type_hierarchy, _ = feedback_builder.type_hierarchy_feedback( - model=model, - domain_desc=domain_desc, - feedback_template=feedback_template, - feedback_type="llm", - type_hierarchy=type_hierarchy, - llm_response=response, - ) - - print("Type Hierarchy", format_json_output(type_hierarchy)) - return type_hierarchy - - -def action_extraction( - model, domain_desc, action_extraction_prompt, type_hierarchy -) -> dict[str, str]: - # STEP THREE: action extraction - nl_actions, response = domain_builder.extract_nl_actions( - model=model, - domain_desc=domain_desc, - prompt_template=action_extraction_prompt.generate_prompt(), - types=type_hierarchy, - ) - - feedback_template = open_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt" - ) - nl_actions, _ = feedback_builder.nl_action_feedback( - model=model, - domain_desc=domain_desc, - llm_response=response, - feedback_template=feedback_template, - feedback_type="llm", - nl_actions=nl_actions, - type_hierarchy=type_hierarchy, - ) - - print("Natural Language Actions") - for i in nl_actions: - print(i) - return nl_actions - - -def action_construction( - model, domain_desc, action_construction_prompt, nl_actions, type_hierarchy -) -> tuple[list[Action], list[Predicate]]: - # STEP FOUR: action construction - - predicates = [] - max_iters = 2 - for _ in range(max_iters): - - actions = [] - current_preds = len(predicates) - - for action_name, action_desc in nl_actions.items(): - - feedback_template = open_file( - "paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt" - ) - - # retrieve rest of list - action_list = { - a_name: a_desc - for a_name, a_desc in nl_actions.items() - if a_name != action_name - } - - action, new_predicates, llm_response = domain_builder.extract_pddl_action( - model=model, - domain_desc=domain_desc, - prompt_template=action_construction_prompt.generate_prompt(), - action_name=action_name, - action_desc=action_desc, - action_list=action_list, - predicates=predicates, - types=type_hierarchy, - ) - - # perform syntax check on action model - is_valid, feedback_msg = syntax_validator.validate_usage_predicates( - llm_response, predicates, type_hierarchy - ) - # if there is syntax error, run through feedback mechanism to retrieve new action model - if is_valid == False: - feedback_template += ( - "\n\nThe following is a syntax error with your response:\n" - + feedback_msg - ) - - # RUN FEEDBACK - action, new_predicates, _ = feedback_builder.pddl_action_feedback( - model=model, - domain_desc=domain_desc, - llm_response=llm_response, - feedback_template=feedback_template, - feedback_type="llm", - action=action, - predicates=predicates, - types=types, - ) - - actions.append(action) - predicates.extend(new_predicates) - - if len(predicates) == current_preds: - print("No new predicates created. Stopping action construction.") - break - - # discard predicates not found in action models + duplicates - predicates = prune_predicates(predicates=predicates, actions=actions) - - return actions, predicates - - -def task_extraction( - model, problem_desc, task_extraction_prompt, types, predicates, actions -) -> tuple[dict[str, str], list[dict[str, str]], list[dict[str, str]]]: - # STEP FIVE: task extraction - feedback_template = open_file( - "paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt" - ) - - objects, initial, goal, llm_response = task_builder.extract_task( - model=model, - problem_desc=problem_desc, - prompt_template=task_extraction_prompt.generate_prompt(), - types=types, - predicates=predicates, - actions=actions, - ) - - feedback_msgs = [] - all_valid = True - - # List of validation checks - validation_checks = [ - (syntax_validator.validate_task_objects, (objects, types)), - ( - syntax_validator.validate_task_states, - (initial, objects, predicates, "initial"), - ), - (syntax_validator.validate_task_states, (goal, objects, predicates, "goal")), - ] - - # Perform each validation check - for validator, args in validation_checks: - is_valid, feedback_msg = validator(*args) - if not is_valid: - all_valid = False - feedback_msgs.append(feedback_msg) - - # If any check fails, append feedback messages - if not all_valid: - feedback_template += ( - "\n\nThe following is a syntax error with your response:" - + "\n".join(feedback_msgs) - ) - - objects, initial, goal, _ = feedback_builder.task_feedback( - model=model, - problem_desc=problem_desc, - llm_response=llm_response, - feedback_template=feedback_template, - feedback_type="llm", - predicates=predicates, - types=types, - objects=objects, - initial=initial, - goal=goal, - ) - - objects = task_builder.format_objects(objects) - initial = task_builder.format_initial(initial) - goal = task_builder.format_goal(goal) - - print("Objects:\n", objects) - print("Initial States:\n", initial) - print("Goal States:\n", goal) - - return objects, initial, goal - - -if __name__ == "__main__": - - # STEP ONE: type extraction - types = type_extraction(openai_llm, domain_desc, type_extraction_prompt) - - print("END OF STEP ONE") - - # STEP TWO: hierarchy construction - type_hierarchy = hierarchy_construction( - openai_llm, domain_desc, type_hierarchy_prompt, types - ) - - print("END OF STEP TWO") - - # STEP THREE: action extraction - nl_actions = action_extraction( - openai_llm, domain_desc, action_extraction_prompt, type_hierarchy - ) - - print("END OF STEP THREE") - - # STEP FOUR: action construction - actions, predicates = action_construction( - openai_llm, domain_desc, action_construction_prompt, nl_actions, type_hierarchy - ) - - print("END OF STEP FOUR") - - types = format_types(type_hierarchy) # retrieve types - types = prune_types( - types=types, predicates=predicates, actions=actions - ) # discard types not in predicates / actions + duplicates - types = { - name: description - for name, description in types.items() - if name not in unsupported_keywords - } # remove unsupported words - - # STEP FIVE: task extraction - objects, initial, goal = task_extraction( - openai_llm, problem_desc, task_extraction_prompt, types, predicates, actions - ) - - print("END OF STEP FIVE") - - # format strings - predicate_str = "\n".join( - [pred["clean"].replace(":", " ; ") for pred in predicates] - ) - types_str = "\n".join(types) - - requirements = [ - ":strips", - ":typing", - ":equality", - ":negative-preconditions", - ":disjunctive-preconditions", - ":universal-preconditions", - ":conditional-effects", - ] - - # generate PDDL specifications - pddl_domain = domain_builder.generate_domain( - domain="test_domain", - requirements=requirements, - types=types_str, - predicates=predicate_str, - actions=actions, - ) - pddl_problem = task_builder.generate_task( - domain="test_domain", - problem="test_problem", - objects=objects, - initial=initial, - goal=goal, - ) - - # write files - domain_file = "paper_reconstructions/nl2plan/results/domain.pddl" - with open(domain_file, "w") as f: - f.write(pddl_domain) - problem_file = "paper_reconstructions/nl2plan/results/problem.pddl" - with open(problem_file, "w") as f: - f.write(pddl_problem) - - # run planner - planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) diff --git a/paper_reconstructions/nl2plan/nl2plan/__init__.py b/paper_reconstructions/nl2plan/nl2plan/__init__.py new file mode 100644 index 0000000..5c1fe55 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/__init__.py @@ -0,0 +1,5 @@ +from .type_extraction import TypeExtraction +from .hierarchy_construction import HierarchyConstruction +from .action_extraction import ActionExtraction +from .action_construction import ActionConstruction +from .task_extraction import TaskExtraction \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/action_construction.py b/paper_reconstructions/nl2plan/nl2plan/action_construction.py new file mode 100644 index 0000000..0ef0cf5 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/action_construction.py @@ -0,0 +1,252 @@ +import os +from l2p import * + +class ActionConstruction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.syntax_validator = SyntaxValidator() + self.pddl_actions = list[Action] + self.pddl_predicates = list[Predicate] + + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + + def set_actions(self, actions: list[Action]): + self.pddl_actions = actions + + + def set_predicates(self, predicates: list[Predicate]): + self.pddl_predicates = predicates + + + def construct_action( + self, + model: LLM, + domain_desc: str, + act_constr_prompt: PromptBuilder, + action_list: str, + action_name: str, + action_desc: str, + predicates: list[Predicate], + type_hierarchy: dict[str,str], + syntax_validator: SyntaxValidator, + feedback_prompt: str = None, + max_attempts = 2, + feedback = True + ) -> tuple[Action, list[Predicate]]: + """ + Construct a single action from a given action description using LLM language model. + + Args: + model (LLM): The LLM language model connection. + act_constr_prompt (PromptBuilder): action construction prompt. + action_name (str): The name of the action. + action_desc (str): The action description. + predicates (list[Predicate]): A list of predicates. + syntax_validator (SyntaxValidator): The PDDL syntax validator. + feedback_prompt (str): Feedback template. + max_iters (int): Maximum number of iterations to construct action. Defaults to 8. + feedback (bool): Whether to request feedback from LLM. Defaults to True. + + Returns: + Action: The constructed action. + new_predicates (list[Predicate]): A list of new predicates + """ + + # fill in action construction prompt placeholders + action_prompt = act_constr_prompt.generate_prompt() + action_prompt = action_prompt.replace('{action_desc}', action_desc) + action_prompt = action_prompt.replace('{action_name}', action_name) + + if len(predicates) == 0: + predicate_str = "No predicate has been defined yet" + else: + predicate_str = "" + predicate_str = "\n".join([f"- {pred['clean']}" for pred in predicates]) + action_prompt = action_prompt.replace('{predicates}', predicate_str) + + # replace specific feedback template + if feedback_prompt is not None: + feedback_prompt = feedback_prompt.replace('{action_desc}', action_desc) + feedback_prompt = feedback_prompt.replace('{action_name}', action_name) + elif feedback: + raise ValueError("Feedback template is required when feedback is enabled.") + + for iter in range(1, max_attempts + 1 + (feedback is not None)): + print(f"Generating PDDL of action: `{action_name}`") + + try: + action, new_predicates, llm_response, validation_info = self.domain_builder.extract_pddl_action( + model=model, + domain_desc=domain_desc, + prompt_template=action_prompt, + action_name=action_name, + action_desc=action_desc, + action_list=action_list, + predicates=predicates, + types=format_types(type_hierarchy), + syntax_validator=syntax_validator + ) + + no_error, error_msg = validation_info + + except Exception as e: + no_error = False + error_msg = str(e) + + if no_error: + if feedback is not None: + + action, new_predicates, response_fb, _, no_fb = self.feedback_builder.pddl_action_feedback( + model=model, + domain_desc=domain_desc, + llm_response=llm_response, + feedback_template=feedback_prompt, + feedback_type="llm", + action=action, + predicates=predicates, + types=type_hierarchy + ) + + if no_fb == True: + break + + else: + with open("paper_reconstructions/nl2plan/prompts/action_construction/error.txt") as f: + error_template = f.read().strip() + error_prompt = error_template.replace('{action_name}', action_name) + error_prompt = error_prompt.replace('{action_desc}', action_desc) + error_prompt = error_prompt.replace('{predicate_list}', predicate_str) + error_prompt = error_prompt.replace('{error_msg}', error_msg) + error_prompt = error_prompt.replace('{llm_response}', llm_response) + + action, new_predicates, llm_response, validation_info = self.domain_builder.extract_pddl_action( + model=model, + domain_desc=domain_desc, + prompt_template=error_prompt, + action_name=action_name, + action_desc=action_desc, + action_list=action_list, + predicates=predicates, + types=type_hierarchy, + syntax_validator=syntax_validator + ) + + return action, new_predicates + + + def action_construction( + self, + model: LLM, + domain_desc: str, + act_constr_prompt: PromptBuilder, + nl_actions: dict[str,str], + type_hierarchy: dict[str,str], + feedback_prompt: str | None = None, + max_attempts: int = 2, + max_iters: int = 2 + ) -> tuple[list[Action], list[Predicate]]: + + action_list = "\n".join([f"- {name}: {desc}" for name, desc in nl_actions.items()]) + + syntax_validator = SyntaxValidator() + + predicates = [] + for iter in range(max_iters): + actions = [] + print(f"Starting iteration {iter + 1} of action construction") + curr_preds = len(predicates) + + for action_name, action_desc in nl_actions.items(): + action, new_predicates = self.construct_action( + model=model, + domain_desc=domain_desc, + act_constr_prompt=act_constr_prompt, + action_list=action_list, + action_name=action_name, + action_desc=action_desc, + predicates=predicates, + type_hierarchy=type_hierarchy, + syntax_validator=syntax_validator, + feedback_prompt=feedback_prompt, + max_attempts=max_attempts, + feedback=True + ) + actions.append(action) + predicates.extend(new_predicates) + predicates = prune_predicates(predicates, actions) + + if len(predicates) == curr_preds: + print("No new predicates created. Stopping action construction.") + break + else: + print("Reached maximum iterations. Stopping action construction.") + + return actions, predicates + + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + hierarchy = { + 'object': 'Object is always root, everything is an object', + 'children': [ + {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', + 'children': [ + {'block': 'A type of movable_object.', 'children': []} + ] + }, + {'surface': 'A parent type for all surfaces, including tables.', + 'children': [ + {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} + ] + } + ] + } + + nl_actions = { + "pick_block": "The robot arm picks up a block from a surface. Requires the block to be on a surface and not currently held by the arm. Example: robot_arm picks up block_1 from table_1.", + "place_on_table": "The robot arm places a block on a table. Requires the block to be held by the arm and the table to be clear of other blocks. Example: robot_arm places block_1 on table_1.", + "place_on_block": "The robot arm places a block on top of another block. Requires the block to be held by the arm and the target block to be clear (not currently held or covered by another block). Example: robot_arm places block_1 on block_2.", + "release_block": "The robot arm releases a block it is currently holding. Requires the block to be held by the arm. Example: robot_arm releases block_1." + } + + action_construction = ActionConstruction() + action_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") + + actions, predicates, = action_construction.action_construction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + act_constr_prompt=action_construction.prompt_template, + nl_actions=nl_actions, + type_hierarchy=hierarchy, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt"), + max_attempts=1 + ) + + for i in actions: + print(i) + + print() + + for i in predicates: + print(i) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py new file mode 100644 index 0000000..cc2b3ee --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py @@ -0,0 +1,90 @@ +import os +from l2p import * + +class ActionExtraction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.nl_actions = dict[str,str] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_nl_actions(self, nl_actions: dict[str,str]): + self.nl_actions = nl_actions + + def action_extraction( + self, + model: LLM, + domain_desc: str, + action_extraction_prompt: PromptBuilder, + type_hierarchy: dict[str,str], + feedback_prompt: str + ) -> dict[str, str]: + + nl_actions, response = self.domain_builder.extract_nl_actions( + model=model, + domain_desc=domain_desc, + prompt_template=action_extraction_prompt.generate_prompt(), + types=type_hierarchy, + ) + + nl_actions, response_fb = self.feedback_builder.nl_action_feedback( + model=model, + domain_desc=domain_desc, + llm_response=response, + feedback_template=feedback_prompt, + feedback_type="llm", + nl_actions=nl_actions, + type_hierarchy=type_hierarchy, + ) + + return nl_actions + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + hierarchy = { + 'object': 'Object is always root, everything is an object', + 'children': [ + {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', + 'children': [ + {'block': 'A type of movable_object.', 'children': []} + ] + }, + {'surface': 'A parent type for all surfaces, including tables.', + 'children': [ + {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} + ] + } + ] + } + + action_extraction = ActionExtraction() + action_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") + + nl_actions = action_extraction.action_extraction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + action_extraction_prompt=action_extraction.prompt_template, + type_hierarchy=hierarchy, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt")) + + for i in nl_actions: + print(i) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py new file mode 100644 index 0000000..ca21e54 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py @@ -0,0 +1,77 @@ +import os +from l2p import * + +class HierarchyConstruction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.type_hierarchy = dict[str, str] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_types(self, types: dict[str,str]): + self.type_hierarchy = types + + def hierarchy_construction( + self, + model: LLM, + domain_desc: str, + type_hierarchy_prompt: PromptBuilder, + types: dict[str,str], + feedback_prompt: str + ) -> dict[str, str]: + + type_hierarchy, _ = self.domain_builder.extract_type_hierarchy( + model=model, + domain_desc=domain_desc, + prompt_template=type_hierarchy_prompt.generate_prompt(), + types=types, + ) + + type_hierarchy, _ = self.feedback_builder.type_hierarchy_feedback( + model=model, + domain_desc=domain_desc, + feedback_template=feedback_prompt, + feedback_type="llm", + type_hierarchy=type_hierarchy, + llm_response="", + ) + + return type_hierarchy + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + types = { + 'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', + 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', + 'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm, specifically blocks in this case.'} + + hierarchy_construction = HierarchyConstruction() + hierarchy_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") + + type_hierarchy = hierarchy_construction.hierarchy_construction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + type_hierarchy_prompt=hierarchy_construction.prompt_template, + types=types, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt")) + + print(type_hierarchy) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/task_extraction.py b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py new file mode 100644 index 0000000..eb6a240 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py @@ -0,0 +1,151 @@ +import os +from l2p import * + +class TaskExtraction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.task_builder = TaskBuilder() + self.feedback_builder = FeedbackBuilder() + self.syntax_validator = SyntaxValidator() + self.pddl_predicates = list[Predicate] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_predicates(self, predicates: list[Predicate]): + self.pddl_predicates = predicates + + def task_extraction( + self, + model: LLM, + problem_desc: str, + task_extraction_prompt: PromptBuilder, + types: dict[str,str], + predicates: list[Predicate], + feedback_prompt: str, + error_prompt: str, + max_attempts: int = 8 + ) -> tuple[dict[str, str], list[dict[str, str]], list[dict[str, str]]]: + + objects, initial, goal, llm_response = self.task_builder.extract_task( + model=model, + problem_desc=problem_desc, + prompt_template=task_extraction_prompt.generate_prompt(), + types=format_types(types), + predicates=predicates + ) + + all_valid = True + for _ in range(max_attempts): + + feedback_msgs = [] + all_valid = True + types_list = format_types(types) + types_list = {k: types_list[k] for i, k in enumerate(types_list) if i != 0} + + # list of validation checks + validation_checks = [ + self.syntax_validator.validate_task_objects(objects, types_list), + self.syntax_validator.validate_task_states(initial, objects, predicates, "initial"), + self.syntax_validator.validate_task_states(goal, objects, predicates, "goal"), + ] + + # Perform each validation check + for validator, args in validation_checks: + is_valid, feedback_msg = validator, args + if not is_valid: + all_valid = False + feedback_msgs.append(feedback_msg) + + # If any check fails, append feedback messages + if not all_valid: + error_prompt = error_prompt.replace("{error_msg}", str(feedback_msgs)) + error_prompt = error_prompt.replace("{task}", "goal and state extraction") + objects, initial, goal, _ = self.feedback_builder.task_feedback( + model=model, + problem_desc=problem_desc, + llm_response=llm_response, + feedback_template=error_prompt, + feedback_type="llm" + ) + + else: break + + if not all_valid: + raise ValueError(f"Validation failed: {feedback_msgs}") + + objects, initial, goal, _ = self.feedback_builder.task_feedback( + model=model, + problem_desc=problem_desc, + llm_response=llm_response, + feedback_template=feedback_prompt, + feedback_type="llm", + predicates=predicates, + types=types, + objects=objects, + initial=initial, + goal=goal, + ) + + objects = self.task_builder.format_objects(objects) + initial = self.task_builder.format_initial(initial) + goal = self.task_builder.format_goal(goal) + + return objects, initial, goal + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + hierarchy = { + 'object': 'Object is always root, everything is an object', + 'children': [ + {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', + 'children': [ + {'block': 'A type of movable_object.', 'children': []} + ] + }, + {'surface': 'A parent type for all surfaces, including tables.', + 'children': [ + {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} + ] + } + ] + } + + + predicates = [{'name': 'on_surface', 'desc': 'true if the block ?b is on the surface ?s', 'raw': '(on_surface ?b - block ?s - surface): true if the block ?b is on the surface ?s', 'params': OrderedDict([('?b', 'block'), ('?s', 'surface')]), 'clean': '(on_surface ?b - block ?s - surface): true if the block ?b is on the surface ?s'}, + {'name': 'held', 'desc': 'true if the block ?b is currently held by the robot arm', 'raw': '(held ?b - block): true if the block ?b is currently held by the robot arm', 'params': OrderedDict([('?b', 'block')]), 'clean': '(held ?b - block): true if the block ?b is currently held by the robot arm'}, + {'name': 'movable', 'desc': "'The block is movable (not under another block)'", 'raw': "(movable ?b - block): 'The block is movable (not under another block)'", 'params': OrderedDict([('?b', 'block')]), 'clean': "(movable ?b - block): 'The block is movable (not under another block)'"}, + {'name': 'on_block', 'desc': "'Indicates that block ?b is placed on top of block ?b2'", 'raw': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'", 'params': OrderedDict([('?b', 'block'), ('?b2', 'block')]), 'clean': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'"}] + + task_extraction = TaskExtraction() + task_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") + + object, initial, goal = task_extraction.task_extraction( + model=openai_llm, + problem_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/task1.txt"), + task_extraction_prompt=task_extraction.prompt_template, + types=hierarchy, + predicates=predicates, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt"), + error_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/error.txt") + ) + + print(object) + print(initial) + print(goal) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py new file mode 100644 index 0000000..db6b005 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py @@ -0,0 +1,69 @@ +import os +from l2p import * + +class TypeExtraction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.types = dict[str, str] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_types(self, types: dict[str,str]): + self.types = types + + def type_extraction( + self, + model: LLM, + domain_desc: str, + type_extraction_prompt: PromptBuilder, + feedback_prompt: str + ) -> tuple[dict[str, str], str]: + + types, _ = self.domain_builder.extract_type( + model=model, + domain_desc=domain_desc, + prompt_template=type_extraction_prompt.generate_prompt() + ) + + types, _ = self.feedback_builder.type_feedback( + model=model, + domain_desc=domain_desc, + feedback_template=feedback_prompt, + feedback_type="llm", + types=types, + llm_response="", + ) + + return types + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + type_extraction = TypeExtraction() + type_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") + + types = type_extraction.type_extraction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + type_extraction_prompt=type_extraction.prompt_template, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt")) + + print(types) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/error.txt b/paper_reconstructions/nl2plan/prompts/action_construction/error.txt index dce1b5c..ec6fc09 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/error.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/error.txt @@ -1,5 +1,5 @@ ## Error -There was an issue with or feedback for generating the specified action. Correct the following error and regenerate the action, using the exact same headers. Remember that you MUST reuse all the headers ("Action Parameters", "Action Preconditions", "Action Effects" and "New Predicates") +There was an issue with or feedback for generating the specified action. Correct the following error and regenerate the action, using the exact same headers. Remember that you MUST reuse all the headers ("### Action Parameters", "### Action Preconditions", "### Action Effects" and "### New Predicates") {error_msg} @@ -13,4 +13,5 @@ Make sure to reply with all four parts of the action: parameters, preconditions, ### Available Predicates {predicate_list} -### Response \ No newline at end of file +### Original Response +{llm_response} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/action_construction/examples/example1.txt similarity index 83% rename from paper_reconstructions/nl2plan/prompts/action_construction/examples/example.txt rename to paper_reconstructions/nl2plan/prompts/action_construction/examples/example1.txt index fc0c88a..4445a1e 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/examples/example.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/examples/example1.txt @@ -1,38 +1,26 @@ -The following is an in-context example following the CoT technique. - -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. - -Given type hierarchy: -{ - "object": "Object is always root, everything is an object", - "children": [ - { - "worker": "A type of object consisting of humans who do things.", - "children": [ - {"administrator": "A type of worker.", "children": []}, - {"general_worker": "A type of worker.", "children": []} - ] - }, - {"vehicle": "A type of object consisting of vehicles.", "children": []}, - { - "location": "A type of object consisting of places which can be visited.", - "children": [ - {"house": "A type of location.", "children": []} - ] - } - ] -} - -Given action: description -drive: A vehicle drives from a location to another. Requires that the vehicle is at the starting location and that the two locations are connected. Example: truck1 drives from loc1 to house1. +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport workers. + +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. + +## Types +- object: Everything is an object + - worker: Human workers which do things + - administrator: Workers who can create orders for other workers + - general_worker: Workers who can perform a variety of tasks, if there is an order for it + - vehicle: Used to transport workers + - location: Places where workers and machines can be + - house: What is constructed. + +## Action +drive + +A vehicle drives from a location to another. Requires that the vehicle is at the starting location and that the two locations are connected. Example: truck1 drives from loc1 to house1. ### Available Predicates No predicate has been defined yet ------------------------------------------------------ - -Get predicates: +### Action Parameters Well, first we need to know which vehicle is travelling. ``` - ?v - vehicle: The vehicle travelling @@ -44,7 +32,7 @@ Then, we need to know where it's travelling to and from. Any type of location (b - ?to - location: The location travelling to ``` -Get preconditions: +### Action Preconditions To be able to drive from ?from to ?to it's specified that: 1: The truck has to be at the starting location. 2: The two locations have to be connected. @@ -67,7 +55,7 @@ Let's specify this in PDDL: ) ``` -Get effects: +### Action Effects So, what happens when the action is performed? - The vehicle is no longer at ?from. - The vehicle is now at ?to. @@ -82,7 +70,7 @@ Let's write the PDDL: ) ``` -State new predicates: +### New Predicates We used several new predicates. Those have to be specified formally here. The first predicate we created is "at" which shows where something is. To make it compatible for both vehicles and workers, we use the general object type. @@ -169,7 +157,6 @@ These are the exact same as above, but they need to be reiterated: ``` ### New Predicates -These are the same as before: ``` - (at ?o - object ?l - location): true if the object ?o (a vehicle or a worker) is at the location ?l - (connected ?l1 - location ?l2 - location): true if a road exists between ?l1 and ?l2 allowing vehicle travel between them. diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt b/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt index 2d938d3..c5b1933 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt @@ -1,7 +1,7 @@ # Role -You are a PDDL expert and will be given a set of PDDL actions to correct and give feedback and advice on. Consider not only if the actions are technically correct, but also whether they are defined following good standards such as flexibility and clarity. Overly specifying types by use of "is-type" predicates should generally be avoided. Remember that the preconditions should make sure that only valid objects are passed to the action, we can't assume anything except the provided types. Don't assume any restrictions beyond those specified by the domain itself. Don't unnecessarily overcomplicate the actions. Note that creating new options isn't possible. If the action is well defined, respond with "No feedback". +You are a PDDL expert and will be given a set of PDDL actions to correct and give feedback and advice on. Consider not only if the actions are technically correct, but also whether they are defined following good standards such as flexibility and clarity. Overly specifying types by use of "is-type" predicates should generally be avoided. Remember that the preconditions should make sure that only valid objects are passed to the action, we can't assume anything except the provided types. Don't assume any restrictions beyond those specified by the domain itself. Don't unnecessarily overcomplicate the actions. Note that creating new options isn't possible. If the action is well defined, respond with "No feedback" under header '# JUDGEMENT'. -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +IMPORTANT: Duplicate predicates are acceptable and should not be considered as a suggestion/judge to fix. Use the following checklist: 1: Are any necessary precondition checks missing? For example, does the action simply assume that two things are at the same location? @@ -41,6 +41,7 @@ A ranger guards a location from poachers. The ranger has to be at the location. - ?l - location: The location to guard. ``` + #### Action Preconditions ``` (and @@ -78,6 +79,7 @@ A ranger guards a location from poachers. The ranger has to be at the location. 6: Should any predicate be used in a symmetrical manner? None of the predicates are symmetrical. Therefore: No. +# JUDGEMENT My concrete suggestions are: - Remove the check for "(at ?l ?l)" from the preconditions. - Remove "(not (at ?r ?l))" from the effect. @@ -139,7 +141,6 @@ A truck driver from point A to point B. They need to be connected by a road and ) ``` - ### Feedback 1: Are any necessary precondition checks missing? The action explicitly states the truck has to be at the starting location, which also makes sense, but this is never checked. Thereby: Yes. @@ -159,6 +160,7 @@ A truck driver from point A to point B. They need to be connected by a road and 6: Should any predicate be used in a symmetrical manner? Since roads are undirected, we need to check if there is a road from ?from to ?to or vice versa. Not doing so creates brittle PDDL. This should always be done under symmetry. As such: Yes. +# JUDGEMENT You should take the following concrete steps: - Check that the truck is actually at the starting location by adding "(at ?t ?from)" to the precondition. - Make sure that both directions are checked for a road by replacing "(road_between ?from ?to)" with "(or (road_between ?from ?to) (road_between ?to ?from))" @@ -232,16 +234,14 @@ An elevator picks up a person at a floor where they both are. Example: elevator_ 6: Should any predicate be used in a symmetrical manner? None of the predicates have symmetries of that sort. The answer is: No. +# JUDGEMENT Therefore: No feedback. ----------------------------------------- - -Here is the original output: - +# Task ## Domain {domain_desc} -## Available types +## Available Types {types} ## Available Predicates @@ -250,21 +250,24 @@ The following are the predicates which could be used: You can also suggest new predicates to add. -## Action name +## Action {action_name} -### Action Parameters you gave -{parameters} +{action_desc} + +### Action Parameters +``` +{action_params} +``` -### Action Preconditions you gave +### Action Preconditions ``` {action_preconditions} ``` -### Action Effects you gave +### Action Effects ``` {action_effects} ``` -## Original LLM response -{llm_response} \ No newline at end of file +### Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/role.txt b/paper_reconstructions/nl2plan/prompts/action_construction/role.txt index c579e32..025af9a 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/role.txt @@ -1,31 +1,36 @@ -You are defining the preconditions and effects (represented in PDDL format) of an AI agent's actions. Information about the AI agent will be provided in the domain description. Note that individual conditions in preconditions and effects should be listed separately. For example, "object_1 is washed and heated" should be considered as two separate conditions "object_1 is washed" and "object_1 is heated". Also, in PDDL, two predicates cannot have the same name even if they have different parameters. Each predicate in PDDL must have a unique name, and its parameters must be explicitly defined in the predicate definition. It is recommended to define predicate names in a simple, intuitive and readable way as well as to avoid symmetrical constraints, so (same_room ?b1 - block ?b2 - block2 ?r - room) should instead be modelled with two predicates, (in_room ?b1 - block ?r - room) and (in_room ?b2 - block ?r - room). Note that creating new actions is not an option. Your end response should not contain random words/characters not found in a PDDL file. +You are defining the preconditions and effects (represented in PDDL format) of an AI agent's actions. Information about the AI agent will be provided in the domain description. Note that individual conditions in preconditions and effects should be listed separately. For example, "object_1 is washed and heated" should be considered as two separate conditions "object_1 is washed" and "object_1 is heated". Also, in PDDL, two predicates cannot have the same name even if they have different parameters. Each predicate in PDDL must have a unique name, and its parameters must be explicitly defined in the predicate definition. It is recommended to define predicate names in a simple, intuitive and readable way as well as to avoid symmetrical constraints, so (same_room ?b1 - block ?b2 - block2 ?r - room) should instead be modelled with two predicates, (in_room ?b1 - block ?r - room) and (in_room ?b2 - block ?r - room). Note that creating new actions is not an option. -No generated types should be of 'object' but their respective types +Think through your choices and comment on them as you go. -Every action given must be defined. Think through your choices and comment on them as you go. There should not be any unnecessary words in the final output such as "pddl" or "lisp" - -End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL. Follow the exact example syntax as the following: +End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL. There must be 3 hastags (#) being used `###`. Here is an example: ### Action Parameters ``` -- ?v - vehicle: The vehicle travelling +- ?t - type: 'parameter_description' ``` ### Action Preconditions ``` (and - (at ?v ?from) ; The vehicle is at the starting location + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION ) ``` ### Action Effects ``` (and - (not (at ?v ?from)) ; ?v is no longer at ?from + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION ) ``` ### New Predicates ``` -- (at ?o - object ?l - location): true if the object ?o (a vehicle or a worker) is at the location ?l +- (predicate_name ?t1 - type_1 ?t2 - type_2): 'predicate_description' +``` + +IMPORTANT: If there are no new predicates created, keep an empty space enclosed ``` ``` with the '### New Predicates' header like so: + +### New Predicates +``` + ``` \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/task.txt b/paper_reconstructions/nl2plan/prompts/action_construction/task.txt index 3c05c8e..d7696d9 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/task.txt @@ -1,17 +1,17 @@ -## Domain +## Domain {domain_desc} -## Available types +## Types {types} -## Future actions to be implemented later +## Future Actions +The following actions will be defined later and together they make up the entire domain: {action_list} -## Action name +## Action {action_name} -## Action description {action_desc} -## Available predicates +### Available Predicates {predicates} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/technique.txt b/paper_reconstructions/nl2plan/prompts/action_construction/technique.txt deleted file mode 100644 index 800b1e7..0000000 --- a/paper_reconstructions/nl2plan/prompts/action_construction/technique.txt +++ /dev/null @@ -1,6 +0,0 @@ -Chain of Thought for constructing a PDDL action: - -1. Construct action parameters and create necessary predicates to produce action preconditions in PDDL -2. Construct necessary predicates to produce action effects in PDDL -3. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding types) -4. Re-iterate parameters, preconditions, effects, and predicates \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example.txt deleted file mode 100644 index 12454d5..0000000 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example.txt +++ /dev/null @@ -1,149 +0,0 @@ -The following is an in-context example following the CoT technique. - -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport the workers. Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. - -Given types: -- object: Everything is an object - - worker: Human workers which do things - - administrator: Workers who can create orders for other workers - - general_worker: Workers who can perform a variety of tasks, if there is an order for it - - order: Instructions to general_workers to perform something. Created by administrators - - vehicle: Used to transport workers. - - location: Places where workers and machines can be - - house: What is constructed. Can be finalised when all components are built - - depot: Where material is stored and vehicles can be loaded - -Given actions: -No actions available. - ------------------------------------------------------ - -1. Iterate over parent types and extract actions: -### Worker related actions -There are two general types of workers, administrators and general_workers. - -The adminstrators have one task, to create orders. -``` -create_order: An administrator creates a new order for something. Example: administrator_1 creates a build_floor_order for house_0. -``` - -The other workers can perform a wide array of construction work, given an order. - -They can build floors. -``` -build_floor: A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists. -``` - -They can build walls. -``` -build_wall: A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists. -``` - -They can build roofs. -``` -build_roof: A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists. -``` - -Those are all the actions the workers can perform directly. - -### Order related actions -The orders don't have any other actions. - -### Vehicle related actions -There are probably a lot of types of vehicles, but to transport things they all have to be able to move. -``` -move_vehicle: A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1. -``` - -This lets the vehicles move. - -### Material related actions -The materials don't have any other actions assosiated with them. - -### House component related actions -The components can't do anything by themselves. - -### Location related actions -The depot don't have any actions, however the house can be finalised. -``` -finalise_house: The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9. -``` - -2. Feedback - 1: Are there any more actions needed for this domain? Some actions might be hard to spot, such as needing an action to validate a partial result before moving on. - Yes. For the vehicles to be able to transport workers we need to add actions to allow workers to step on and off the vehicles, "enter_vehicle" and "exit_vehicle". Definitions are given below. - - 2: Should any of the actions be split or combined? To model actions in PDDL its sometimes required to split it into three parts, one which initiates the action, one which performs a part of the action and is usually repeated, and lastly an action ending the action. - Yes. In PDDL it's not functional to have a single "create_order" action for all parts of the house (floor, walls, roof and finalisation). The results of applying the action have to be simple, so we'll split it into "order_floor" and so on. - - 3: Should any of the actions be removed? For example, actions which model irrelevant details. - Yes. The "build_floor" action should be removed since building floors isn't needed. - - 4: Should the actions and constraints be clarified or the examples modified? Are they currently unclear or missing objects? - No. The action descriptions and constraints are stated. - - 5: Should any preconditions be changed? For example, are any preconditions such as object states or action ordering missing? Are any unnecessary preconditions included? - 6: Should any effects be changed? For example, is some effect forgotten? Is any any incorrect effect included? - -3. My concrete suggestions are the following: - - Add the following two vehicle-related actions: - - enter_vehicle: A worker enters a vehicle while at the vehicle's location. Example: worker_7 enters truck_4 at house_6. - - exit_vehicle: A worker exits a vehicle at the vehicle's location. Example: worker_8 exits truck_5 at house_7. - - Remove the "build_floor" action. - - Remove the "create_order" action. - - Replace the "create_order" action with the following four actions: - - create_floor_order: An administrator creates an order to build a floor at a house. The administrator doesn't have to be there. Example: administrator_2 creates an order the floor at house_8. - - create_wall_order: An administrator creates an order to build walls at a house. The administrator doesn't have to be there. Example: administrator_3 creates an order to build walls at house_9. - - create_roof_order: An administrator creates an order to build a roof at a house. The administrator doesn't have to be there. Example: administrator_4 creates an order to build roofs at house_10. - - create_finalize_order: An administrator creates an order to finalize a house. The administrator doesn't have to be there. Example: administrator_5 creates an order to finalizes house_11. - -Response: the feedback raises some valid points, but not all are correct. Splitting the "create_order" action is indeed better PDDL modelling. Similarly, the "enter_vehicle" and "exit_vehicle" do have to be provided. However, the build_floor action is needed for the domain and should be kept. - -### New Actions -We also create the new actions to allow for workers to travel within vehicles. - -``` -enter_vehicle: A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3. -``` - -``` -exit_vehicle: A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5. -``` - -Lastly, we split the "create_order" action into four pieces, one per order type. - -``` -create_floor_order: An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12. -``` - -``` -create_wall_order: An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12. -``` - -``` -create_roof_order: An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13. -``` - -``` -create_finalize_order: An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14. -``` - -These are all the actions needed for the domain. - -4. Re-Iterated actions into Python dictionary: - -## OUTPUT -{ - 'build_floor: 'A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists.', - 'build_wall': 'A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists.', - 'build_roof': 'A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists.', - 'move_vehicle': 'A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1.', - 'finalise_house': 'The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9.', - 'enter_vehicle': 'A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3.', - 'exit_vehicle': 'A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5.', - 'create_floor_order': 'An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12.', - 'create_wall_order': 'An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12.', - 'create_roof_order': 'An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13.', - 'create_finalize_order': An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14.', -} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example1.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example1.txt new file mode 100644 index 0000000..88c0536 --- /dev/null +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example1.txt @@ -0,0 +1,198 @@ +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport the workers. + +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. + +## Types +- object: Everything is an object + - worker: Human workers which do things + - administrator: Workers who can create orders for other workers + - general_worker: Workers who can perform a variety of tasks, if there is an order for it + - order: Instructions to general_workers to perform something. Created by administrators + - vehicle: Used to transport workers. + - location: Places where workers and machines can be + - house: What is constructed. Can be finalised when all components are built + - depot: Where material is stored and vehicles can be loaded + +## Actions: +### Worker related actions +There are two general types of workers, administrators and general_workers. + +The adminstrators have one task, to create orders. +``` +create_order + +An administrator creates a new order for something. Example: administrator_1 creates a build_floor_order for house_0. +``` + +The other workers can perform a wide array of construction work, given an order. + +They can build floors. +``` +build_floor + +A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists. +``` + +They can build walls. +``` +build_wall + +A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists. +``` + + +They can build roofs. +``` +build_roof + +A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists. +``` + +Those are all the actions the workers can perform directly. + +### Order related actions +The orders don't have any other actions. + +### Vehicle related actions +There are probably a lot of types of vehicles, but to transport things they all have to be able to move. +``` +move_vehicle + +A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1. +``` + +This lets the vehicles move. + +### Material related actions +The materials don't have any other actions assosiated with them. + +### House component related actions +The components can't do anything by themselves. + +### Location related actions +The depot don't have any actions, however the house can be finalised. +``` +finalise_house + +The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9. +``` + +## Feedback +1: Are there any more actions needed for this domain? + Yes. For the vehicles to be able to transport workers we need to add actions to allow workers to step on and off the vehicles, "enter_vehicle" and "exit_vehicle". Definitions are given below. + +2: Should any of the actions be split or combined? + Yes. In PDDL it's not functional to have a single "create_order" action for all parts of the house (floor, walls, roof and finalisation). The results of applying the action have to be simple, so we'll split it into "order_floor" and so on. + +3: Should any of the actions be removed? + Yes. The "build_floor" action should be removed since building floors isn't needed. + +4: Should the actions and constraints be clarified or the examples modified? + No. The action descriptions and constraints are stated. + +My concrete suggestions are the following: + - Add the following two vehicle-related actions: + - enter_vehicle: A worker enters a vehicle while at the vehicle's location. Example: worker_7 enters truck_4 at house_6. + - exit_vehicle: A worker exits a vehicle at the vehicle's location. Example: worker_8 exits truck_5 at house_7. + - Remove the "build_floor" action. + - Remove the "create_order" action. + - Replace the "create_order" action with the following four actions: + - create_floor_order: An administrator creates an order to build a floor at a house. The administrator doesn't have to be there. Example: administrator_2 creates an order the floor at house_8. + - create_wall_order: An administrator creates an order to build walls at a house. The administrator doesn't have to be there. Example: administrator_3 creates an order to build walls at house_9. + - create_roof_order: An administrator creates an order to build a roof at a house. The administrator doesn't have to be there. Example: administrator_4 creates an order to build roofs at house_10. + - create_finalize_order: An administrator creates an order to finalize a house. The administrator doesn't have to be there. Example: administrator_5 creates an order to finalizes house_11. + +## Response +The feedback raises some valid points, but not all are correct. Splitting the "create_order" action is indeed better PDDL modelling. Similarly, the "enter_vehicle" and "exit_vehicle" do have to be provided. However, the build_floor action is needed for the domain and should be kept. + +## Actions + +### Re-Iterated Actions +These are the actions which are kept unchanged from before. + +``` +build_floor + +A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists. +``` + +``` +build_wall + +A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists. +``` + +``` +build_roof + +A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists. +``` + +``` +move_vehicle + +A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1. +``` + +``` +finalise_house + +The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9. +``` + +### New Actions +We also create the new actions to allow for workers to travel within vehicles. + +``` +enter_vehicle + +A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3. +``` + +``` +exit_vehicle + +A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5. +``` + +Lastly, we split the "create_order" action into four pieces, one per order type. + +``` +create_floor_order + +An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12. +``` + +``` +create_wall_order + +An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12. +``` + +``` +create_roof_order + +An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13. +``` + +``` +create_finalize_order + +An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14. +``` + +## OUTPUT +{ + "build_floor": "A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists.", + "build_wall": "A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists.", + "build_roof": "A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists." + "move_vehicle": "A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1.", + "finalise_house": "The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9.", + "enter_vehicle": "A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3.", + "exit_vehicle": "A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5.", + "create_floor_order": "An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12.", + "create_wall_order": "An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12.", + "create_roof_order": "An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13.", + "create_finalize_order": "An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14.", +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt index 77efba9..79689d3 100644 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt @@ -1,7 +1,5 @@ # Role -You will be given a set of which are used for a PDDL domain. You should evaluate if they make up all the actions necessary for the given domain, or if any new actions have to be created or existing actions removed. Describe your thought process and comments your suggestions. Focus only on the actions currently, predicates will be specified at a later date. Be careful not to over complicate any domains, adding actions simply for complexity/completeness when they're not needed for the domain should be avoided, we're making a simplified model. Keep the essentials. If the actions are well defined, simply respond with "No feedback". - -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +You will be given a set of which are used for a PDDL domain. You should evaluate if they make up all the actions necessary for the given domain, or if any new actions have to be created or existing actions removed. Describe your thought process and comments your suggestions. Focus only on the actions currently, predicates will be specified at a later date. Be careful not to over complicate any domains, adding actions simply for complexity/completeness when they're not needed for the domain should be avoided, we're making a simplified model. Keep the essentials. If the actions are well defined, simply respond with "No feedback" under header '# JUDGEMENT'. Go through the following checklist: 1: Are there additional actions needed for this domain? Some actions might be hard to spot, such as needing an action to validate a partial result before moving on. @@ -55,6 +53,7 @@ Currently, there are a couple of trucks at the Chicago depot and we're trying to 6: Should any action examples be modified? In the "move_vehicle" action, the example only illustrates where the vehicle is movin from. It should also include where it is moving to. Hence: Yes. +# JUDGEMENT My concrete suggestions are the following: - Add the following two vehicle-related actions: - enter_vehicle: A worker enters a vehicle while at the vehicle's location. Example: worker_7 enters truck_4 at house_6. @@ -103,6 +102,7 @@ In this domain, the AI agent is a wildlife conservation management system. It mo 6: Should any action examples be modified? The examples are all good. Therefore: No. +# JUDGEMENT I'd advice you change the following: - Remove the "generate_relocation_strategy" action. - Change the description of the following: @@ -142,20 +142,18 @@ I've got a building with five floors and two elevators, and I want you to plan t 6: Should any action examples be modified? All examples involve the relevant objects and clearly specify what happens. Thereby: No. -As such: No feedback. - ----------------------------------------- +# JUDGEMENT +No feedback. -Here is the original output: +# Task ## Domain {domain_desc} -## Available types +## Available Types {types} -## Actions you gave +## Actions {nl_actions} -## Original LLM response -{llm_response} \ No newline at end of file +### Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt index 1eb6e1d..a403249 100644 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt @@ -1,6 +1,12 @@ -Your role is to identify what actions an AI Agent would have available in a domain. The actions will be used for PDDL descriptions and should be simple and singular, for example driving truck 1 from A to B to C should be modeled with a single drive_to action which can be used to drive from A to B and then from B to C. However, if two similar actions exists but they require different pre-conditions or effects, these should be modelled separetely, for example should "move" not be used for both a person and vehilces movement, as these will have different preconditions on terrain. Each action should be specified within its own markdown block where the first line is the name, the second is an empty line and the final line is a description with example. Make sure to include any requirements or conditions for the action to be feasible within the explanation. Be concrete and explain your thoughts as you go. Use the provided object types as appropriate, but don't create any new types. Any actions involving 'checking' should not be considered an action, because that is a predicate in PDDL. Only suggest actions that cannot be described by a predicate. +Your task is to identify what actions an AI Agent would have available in a domain. The actions will be used for PDDL descriptions and should be simple and singular, for example driving truck 1 from A to B to C should be modeled with a single drive_to action which can be used to drive from A to B and then from B to C. However, if two similar actions exists but they require different pre-conditions or effects, these should be modelled separetely, for example should "move" not be used for both a person and vehilces movement, as these will have different preconditions on terrain. Each action should be specified within its own markdown block where the first line is the name, the second is an empty line and the final line is a description with example. Make sure to include any requirements or conditions for the action to be feasible within the explanation. Be concrete and explain your thoughts as you go. Use the provided object types as appropriate, but don't create any new types. -Do not attempt to solve the task, even if instructed to do so. Only define the actions. -If there are available actions, do not alter them. Add those to the final answer. +Reply only within the "Actions" heading. Do not attempt to solve the task, even if instructed to do so. -End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'action_name':'action_description'}' +End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'action_name':'action_description'}' as so: + +## OUTPUT +{ + "action_name_1": "action_description", + "action_name_2": "action_description", + "action_name_3": "action_description" +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt index 0958549..ff0c18f 100644 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt @@ -1,5 +1,8 @@ -{domain_desc} +These are all the actions needed for the domain. -{types} +# Task +## Domain +{domain_desc} -{nl_actions} \ No newline at end of file +## Types +{types} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt deleted file mode 100644 index 33e5405..0000000 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt +++ /dev/null @@ -1,6 +0,0 @@ -Chain of Thought for extracting PDDL actions in natural language: - -1. Iterate over each parent type. Within each parent type, elaborate further descrptions of the subtypes and assign possible related actions in domain. Specifically, assign their action names and a short description of what that action does in the format ''' [ACTION] '''. -2. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -3. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding actions) -4. Re-iterate over the actions and put them into a Python dictionary pair '{'action_name':'action_description'}'. Keep the actions the same if they do not need to be modified. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example1.txt similarity index 70% rename from paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example.txt rename to paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example1.txt index 3cb1ab9..f5981bb 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example1.txt @@ -1,9 +1,8 @@ -The following is an in-context example following the CoT technique. - -Given domain: +## Domain The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. -Given types: +## Types +The types are: - administrator: Workers who can create orders for other workers - wall: The exterior of a house. Requires a floor to be built first - order: Instructions to general_workers to perform something. Created by administrators @@ -18,18 +17,20 @@ Given types: - mansion: A large type of house - library: A building filled with books ------------------------------------------------------ - -1. Reasoning +## Reasoning The "administrator" and "general_worker" are both types of human workers, so we should probably create a "worker" meta-type class for those. + Furthermore, there are several different types of "house_component": "floor", "roof", and "wall". However, these aren't a subtype of "house" since a "floor" is not a "house" for example. + On the other hand, there are actually two subtypes of "house": "mansion" and "library". Both of these are types of houses. + Additionally, "house" and "depot" are both types of locations which can be visited. So, they're subtypes of "location". + "vehicle" is not a subtype or meta-type to any of the others. Same thing holds for "order". -2. Hierarchy +## Hierarchy So, all in all the hierarchy becomes: - +``` - object: Object is always root, everything is an object - worker: A type of object consisting of humans who do things. - administrator: A type of worker. @@ -44,26 +45,30 @@ So, all in all the hierarchy becomes: - house: A type of location. - mansion: A type of house. - library: A type of house. - - depot: A type of location. + - depot: A type of location. +``` + +## Feedback +1: Is any child NOT a subtype of its parent? + No. This is correct. -3. Feedback - 1: Is any child NOT a subtype of its parent? - No. This is correct. +2: Is any subtype NOT a child of its meta-type? + Yes. Depot is a type of location, and as such it should be a subtype and child of location. This has to be corrected. - 2: Is any subtype NOT a child of its meta-type? - Yes. Depot is a type of location, and as such it should be a subtype and child of location. This has to be corrected. +3: Are any new types needed for organisation? + Yes. There should be a meta-type called "construction_equipment" which includes both "house_component" and "vehicle" since these are used to build with. - 3: Are any new types needed for organisation? - Yes. There should be a meta-type called "construction_equipment" which includes both "house_component" and "vehicle" since these are used to build with. +My advice is that you perform the following concrete changes: + - Move the "depot" type to be a subtype of "location". + - Add a "construction_equipment" meta-type with "house_component" and "vehicle" as subtypes. - My advice is that you perform the following concrete changes: - - Move the "depot" type to be a subtype of "location". - - Add a "construction_equipment" meta-type with "house_component" and "vehicle" as subtypes. +Start with a "## Response" header, then re-iterate an updated version of the "## Hierarchy" header. -4. Response: +## Response The feedback is partially correct. Moving the "depot" type is valid and should be done. However, adding "construction_equipment" would group objects which behave too differently. -5. Re-iterate and convert to nested Python dictionary: +## Hierarchy +As such, the corrected hierarchy becomes: ``` - object: Object is always root, everything is an object - worker: A type of object consisting of humans who do things. @@ -82,6 +87,10 @@ The feedback is partially correct. Moving the "depot" type is valid and should b - depot: A type of location. ``` +Organize a dependency tree for the class hierarchy between different objects within a PDDL domain. Do not expand on your reasoning, except as short comments. Each object should appear only once, even if it could belong to several types. Note, that every child should be a subtype of its parent, not physically contained within the parent. You shouldn't create any new types except those needed for organisation of the provided types. + +End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'name':'description'}' as so: + ## OUTPUT { "object": "Object is always root, everything is an object", @@ -93,8 +102,12 @@ The feedback is partially correct. Moving the "depot" type is valid and should b {"general_worker": "A type of worker.", "children": []} ] }, - {"order": "A type of object consisting of instructions.", "children": []}, - {"vehicle": "A type of object consisting of vehicles.", "children": []}, + { + "order": "A type of object consisting of instructions.", "children": [] + }, + { + "vehicle": "A type of object consisting of vehicles.", "children": [] + }, { "house_component": "A type of object consisting of the components of a house.", "children": [ @@ -107,14 +120,16 @@ The feedback is partially correct. Moving the "depot" type is valid and should b "location": "A type of object consisting of places which can be visited.", "children": [ { - "house": "A type of location. ", + "house": "A type of location.", "children": [ {"mansion": "A type of house.", "children": []}, - {"library": "A type of house.", "children": []} + {"library": "A type of house.", "children": []}, ] }, - {"depot": "A type of location.", "children": []} + { + "depot": "A type of location.", "children": [] + } ] } ] -} +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt index 1620fca..8307947 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt @@ -1,6 +1,5 @@ -Your task is to evaluate if a type hierarchy is defined in the best way. You can suggest changing of the structure or adding types. Note that everything is always supposed to be a subtype of the 'object' class. You shouldn't suggest any new types except those needed for organisation of the provided types. - -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +# Role +Your task is to evaluate if a type hierarchy is defined in the best way. You can suggest changing of the structure or adding types. If the hierarchy is optimal, respond with "No feedback" under header '# JUDGEMENT'. Note that everything is always supposed to be a subtype of the "object" class. You shouldn't suggest any new types except those needed for organisation of the provided types. Go through the following checklist: 1: Is any child not a subtype of its parent? For example, "house" is defined as a subtype of "city". Often this is due to the child being physically inside the parent. @@ -28,6 +27,7 @@ I've got a building with five floors and two elevators, and I want you to plan t 3: Are any new types needed for organisation? The types are all distinct, and as such no organisation type is needed. Due to this: No. +# JUDGEMENT Therefore: No feedback. ## Example 2 @@ -56,6 +56,7 @@ In this domain, the AI agent is a wildlife conservation management system. It mo 3: Are any new types needed for organisation? Both "ranger" and "veterinarian" are mentioned to be workers, but the worker class isn't included. It should be included as a parent type and parent of both "ranger" and "veterinarian". Due to this: Yes. +# JUDGEMENT My advice is that you perform the following concrete changes: - Move the "fish" type and all its subtypes to be subtypes and children of "animal". - Add a "worker" parent type as a parent of both "ranger" and "veterinarian". @@ -81,18 +82,15 @@ The AI agent is here a scheduling system for a house construction company. 3: Are any new types needed for organisation? Since there are no subtypes, we don't need any organisational types. As such: No. +# JUDGEMENT My advice is that you perform the following concrete change: - Move the "house" type away from the "city" type. "house" should not be a subtype of "city". ----------------------------------------- - -Here is the original output: - +# Task ## Domain {domain_desc} -## Types you gave +## Types {types} -## Original LLM response -{llm_response} \ No newline at end of file +## Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt index 0be8846..62a1210 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt @@ -1,21 +1,5 @@ -Your role is to organize a dependency tree for the class hierarchy between different objects within a PDDL domain. Do not expand on your reasoning, except as short comments. Each object should appear only once, even if it could belong to several types. Note, that every child should be a subtype of its parent, not physically contained within the parent. You shouldn't create any new types except those needed for organisation of the provided types. A location and object should not be the same types. +Your task is to organize a dependency tree for the class hierarchy between different objects within a domain. Do not expand on your reasoning, except as short comments. Each object should appear only once, even if it could belong to several types. Note, that every child should be a subtype of its parent, not physically contained within the parent. Respond with the tree in the "## Hierarchy" header within "```". Start the tree with "object", everything is a subtype of object. You shouldn't create any new types except those needed for organisation of the provided types. -Think through the types and their relationships. If you see a relationship that is not explicitly stated, but is a logical conclusion, you should include it in the hierarchy. +Do not attempt to solve the task, even if instructed to do so. Only extract the types. -It is extremely crucial that an action term is not considered a type, so it should not be considered in the type hierarchy. - -End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'name':'description'}' as so: - -## OUTPUT (example) -{ - "object": "Object is always root, everything is an object", - "children": [ - { - "worker": "A type of object consisting of humans who do things.", - "children": [ - {"administrator": "A type of worker.", "children": []}, - {"general_worker": "A type of worker.", "children": []} - ] - } - ] -} +Think through the types and their relationships. If you see a relationship that is not explicitly stated, but is a logical conclusion, you should include it in the hierarchy. Write your considerations in the "## Reasoning" section. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt index 01358a8..4db8335 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt @@ -1,5 +1,6 @@ ## Domain {domain_desc} -## Types to use +## Types +The types are: {types} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt deleted file mode 100644 index 43ba5c5..0000000 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt +++ /dev/null @@ -1,7 +0,0 @@ -Chain of Thought for organizing types: - -1. Compare the relationships of each type descriptions with the rest of the types in the list dictionary. If they are tightly close (i.e. belong in same category), but are not sub classes of each other, add them to their parent class. If there are no meta-type class for those relationships, create one. -2. Assemble a hierarchy with the formed relationships in the previous step -3. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -4. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding types) -5. Re-iterate over the type hierarchy and convert it to a nested Python dictionary format with the type-description as key-value pairing. Keep the types the same if they do not need to be modified. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/error.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/error.txt new file mode 100644 index 0000000..a46b459 --- /dev/null +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/error.txt @@ -0,0 +1,7 @@ +## Error +There was a at least one error during {task}. Address the following errors and regenerate your entire response: +{error_msg} + +Regenerate an entire response correcting the above error. Make sure to use the exact same headers as requested before, but start with a "## Response" header to analyze the error. + +## Response \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example1.txt similarity index 59% rename from paper_reconstructions/nl2plan/prompts/task_extraction/examples/example.txt rename to paper_reconstructions/nl2plan/prompts/task_extraction/examples/example1.txt index fc99551..361943b 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example1.txt @@ -1,10 +1,9 @@ -The following is an in-context example following the CoT technique. +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport workers. -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. -Given types: -""" +## Types - object: Everything is an object - worker: Human workers which do things - administrator: Workers who can create orders for other workers @@ -12,10 +11,8 @@ Given types: - vehicle: Used to transport workers - location: Places where workers and machines can be - house: What is constructed. -""" -Given predicates: -""" +## Predicates - (at ?o - object ?l - location): true if the object ?o (which should be a worker or vehicle) is at location ?l - (inside ?w - worker ?v - vehicle): true if the worker ?w is in the vehicle ?v - (wall_order ?h - house): true if there is an order to build a wall at house ?h @@ -26,11 +23,8 @@ Given predicates: - (roof_built ?h - house): true if a roof has been built for house ?h - (finalized ?h - house): true if the house ?h has been completed. - (connected ?l1 - location ?l2 - location): true if there is a road between l1 and l2 allowing travel between them. -""" ------------------------------------------------------ - -1. State object instances, identify the cardinality of each object types: +## Object Instances We assume that there are two trucks since the description said "a couple". ``` truck1 - the first truck at the Chicago depot @@ -52,7 +46,7 @@ emma - general_worker: The first worker, Emma bob - general_worker: The second worker, Bob ``` -2. Identify initial states: +## State Let's start by specifying where everyone is. It's a reasonable assumption that everyone starts at the Chicago depot. ``` (at truck1 chicago_depot): truck1 is at the chicago_depot @@ -77,7 +71,7 @@ Finally, the "connected" predicate states that two locations are connected if th (connected chicago_depot house3): chicago_depot is connected to house3 ``` -3. Identify goal states +## Goal ``` (AND ; all the following should be done (finalised house1) ; house 1 is done @@ -87,34 +81,34 @@ Finally, the "connected" predicate states that two locations are connected if th ) ``` -4. Feedback - 1. Are any necessary objects forgotten? Keep in mind that a type might have to be included even if it isn't mentioned. - The description states that there are "a couple of trucks". This entails that many trucks exist, but only two are defined. Add some more. Therefore: Yes. +## Error +1. Are any necessary objects forgotten? + The description states that there are "a couple of trucks". This entails that many trucks exist, but only two are defined. Add some more. Therefore: Yes. - 2. Are any un-necessary objects included? If things are irrelevant they shouldn't be included. - All the objects which are included are actually described and needed. So: No. +2. Are any un-necessary objects included? + All the objects which are included are actually described and needed. So: No. - 3. Are any objects defined as the wrong type? The objects should of course be defined correctly. - The "house" type is supposed to be used for what is being constructed, the houses built. However, "chicago_depot" is cleraly not being built by us, but is defined as a "house". It should be just a general location. Thereby: Yes. +3. Are any objects defined as the wrong type? + The "house" type is supposed to be used for what is being constructed, the houses built. However, "chicago_depot" is cleraly not being built by us, but is defined as a "house". It should be just a general location. Thereby: Yes. - 4. Are any needed or expected predicates missing from the initalization? Everything has to be defined in the problem file, nothing is assumed. - Naturally, everything needs a starting location and most of the objects are assumed to start at the chicago_depot, which makes sense. However, "bob" lacks a starting position. Hence: Yes. +4. Are any needed or expected predicates missing from the initalization? + Naturally, everything needs a starting location and most of the objects are assumed to start at the chicago_depot, which makes sense. However, "bob" lacks a starting position. Hence: Yes. - 5. Are any unnecessary or incorrect predicates initialised? We should only initialize that which is actually true. - All the predicates which are initiated are valid and needed. As such: No. +5. Are any unnecessary or incorrect predicates initialised? + All the predicates which are initiated are valid and needed. As such: No. - 6. Is anything forgotten from the goal state? Everything we wish to require should be checked. - What is requested is, implicitly, that all the houses be finalized. This is checked, so: No. +6. Is anything forgotten from the goal state? + What is requested is, implicitly, that all the houses be finalized. This is checked, so: No. - 7. Is anything superflous included in the goal? We shouldn't check more things than needed. - The wanted position of the truck is not specified and isn't needed for the task to be considered to be completed. This should be removed. Hence: Yes. +7. Is anything superflous included in the goal? + The wanted position of the truck is not specified and isn't needed for the task to be considered to be completed. This should be removed. Hence: Yes. - 8. Should any predicate be used in a symmetrical manner? For example, if we want to build a road between A and B, the goal should allow either "(road_between A B)" or "(road_between B A)" to make the PDDL robust. This should ALWAYS be done even if this could also be handled in the action. - The "connected" predicate clearly specifies that travel is possible in both directions, which means that (connected A B) should entail (connected B A). - Therefore, each "connected" predicate should be mirrored to clarify that they're connected in both directions. This makes the PDDL more robust. - However, this is already done. As such: No. +8. Should any predicate be used in a symmetrical manner? + The "connected" predicate clearly specifies that travel is possible in both directions, which means that (connected A B) should entail (connected B A). + Therefore, each "connected" predicate should be mirrored to clarify that they're connected in both directions. This makes the PDDL more robust. + However, this is already done. As such: No. -5. My concrete suggestions are the following: +My concrete suggestions are the following: - Add more trucks to the domain. Initialize them to chicago_depot: - (at truck3 chicago_depot) - (at truck4 chicago_depot) @@ -127,12 +121,17 @@ Finally, the "connected" predicate states that two locations are connected if th (finalized house2) ; house 2 is done (finalized house3) ; house 3 is done ) - ``` - Response: the feedback is not entirely correct. Adding more trucks would be too large of an assumption, since the domain task only states "A couple". As such, we leave it with only two trucks. Adding the starting location for Bob as well as removing the goal condition for truck1 is both correct however. I'll make those changes. + ``` +Regenerate an entire response correcting the above error. Make sure to use the exact same headers as requested before, but start with a "## Response" header to analyze the error. + +## Response +The feedback is not entirely correct. Adding more trucks would be too large of an assumption, since the domain task only states "A couple". As such, we leave it with only two trucks. -6. Now I'll reiterate the corrected initialization with the following headers. +Adding the starting location for Bob as well as removing the goal condition for truck1 is both correct however. I'll make those changes. -## OBJECTS +Now I'll reiterate the corrected initialization with the exact same headers. + +## Object Instances The feedback suggested to use more trucks, but this would be wrong since the domain only specifies "A couple". So, we stick with the two trucks. ``` truck1 - the first truck at the Chicago depot @@ -154,7 +153,7 @@ emma - general_worker: The first worker, Emma bob - general_worker: The second worker, Bob ``` -## INITIAL +## State Let's start by specifying where everyone is again. This time, we make sure to include Bob. ``` (at truck1 chicago_depot): truck1 is at the chicago_depot @@ -176,7 +175,7 @@ The connections between the locations are the same bi-directional connections as (connected chicago_depot house3): chicago_depot is connected to house3 ``` -## GOAL +## Goal For the goal, we remove the "truck1" location predicate, but still check that all the houses are finalised. ``` (AND ; all the following should be done @@ -186,4 +185,41 @@ For the goal, we remove the "truck1" location predicate, but still check that al ) ``` -[END OF EXAMPLE] \ No newline at end of file +Thus, we get: + +### OBJECTS +``` +truck1 - the first truck at the Chicago depot +truck2 - the second truck at the Chicago depot +chicago_depot - location: The Chicago depot +house1 - The first house to build +house2 - The second house to build +house3 - The third house to build +jamie - administrator: The administrator Jamie +emma - general_worker: The first worker, Emma +bob - general_worker: The second worker, Bob +``` + +### INITIAL +``` +(at truck1 chicago_depot): truck1 is at the chicago_depot +(at truck2 chicago_depot): truck2 is at the chicago_depot +(at jamie chicago_depot): Jamie is at the depot +(at emma chicago_depot): Emma is at the depot +(at bob chicago_depot): Bob is at the depot +(connected house1 chicago_depot): house1 is connected to the chicago_depot +(connected house2 chicago_depot): house2 is connected to the chicago_depot +(connected house3 chicago_depot): house3 is connected to the chicago_depot +(connected chicago_depot house1): chicago_depot is connected to house1 +(connected chicago_depot house2): chicago_depot is connected to house2 +(connected chicago_depot house3): chicago_depot is connected to house3 +``` + +### GOAL +``` +(AND ; all the following should be done + (finalised house1) ; house 1 is done + (finalised house2) ; house 2 is done + (finalised house3) ; house 3 is done +) +``` \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt index 0894956..a55e9ab 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt @@ -1,7 +1,6 @@ # Role -You are a PDDL expert and will be given the parts of a PDDL problem file to give feedback on. Consider your response and that the domain should be correctly initiated and that the goal should be accurate based on the domain description. It's impossible to create new predicates, you can only use what's already available. Think through your feedback step by step. If the action is well defined, respond with "No feedback". -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +You are a PDDL expert and will be given the parts of a PDDL problem file to give feedback on. Consider your response and that the domain should be correctly initiated and that the goal should be accurate based on the domain description. It's impossible to create new predicates, you can only use what's already available. Think through your feedback step by step. If the action is well defined, respond with "No feedback" under header '# JUDGEMENT'. Use the following checklist: 1. Are any necessary objects missing? Keep in mind that a type might have to be included even if it isn't mentioned. @@ -103,6 +102,7 @@ bob - general_worker: The second worker, Bob Even though this could have been handled by the actions, we can't guarantee that it is and as such we have to mirror all these predicates. Thereby: Yes. +# JUDGEMENT My concrete suggestions are the following: - Add a second truck ("truck2"). Initialize it with the following: - (at truck2 chicago_depot) @@ -217,6 +217,7 @@ ranger2 - ranger: One of the available rangers 8. Should any predicate be used in a symmetrical manner? While the "at" predicate could accept two locations, this is clearly not the intent. Hence: No. +# JUDGEMENT My concrete suggestions are the following: - Remove the "deer4" and "outer4" objects from the domain entirely. They're incorrectly included. - Add at least one more ranger object. For example, "ranger3" could be added an initalized like this: @@ -304,14 +305,13 @@ elevator_2 - elevator: The second elevator in the building. 8. Should any predicate be used in a symmetrical manner? All the predicates are clearly intended to be one-directional, and that is how they're used. So: No. +# JUDGEMENT Based on this, the response is: No feedback. ----------------------------------------- +# Task -Here is the original output: - -## Problem -{problem_desc} +## Domain +{domain_desc} ## Available Types {types} @@ -323,14 +323,13 @@ The following are the available predicates which can be used: ## State This is the state to give feedback on based on the domain and predicates above. -## Objects +### Objects {objects} -## Initial State -{initial_state} +### Initial State +{initial_states} -## Goal State -{goal_state} +### Goal State +{goal_states} -## Original LLM response -{llm_response} \ No newline at end of file +## Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt index 7d7355c..a297162 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt @@ -1,30 +1,26 @@ -Your task is to extract the initial state and the goal state for a PDDL problem based on a domain description and the available predicates. Consider that if a predicate is checked by an action for an object, it should probably somehow be possible to make true or start true. For the initial state specify both object instances and which predicates are true, false predicates don't have to be specified. For the goal, specify the states which need to have specific values regardless if those are true or false. Do it step-by-step and explain your thoughts. Respond with the exact headings provided. You can't assume that any object, regardless of type, already exists. Everything you wish to use should be defined here. Also, remember that any symmetrical predicates likely should be defined both ways. Even if there is one goal state, it must contain the PDDL 'AND' syntax +Your task is to estimate the initial state and the goal state for a PDDL problem based on a domain description and the available actions. Consider that if a predicate is checked by an action for an object, it should probably somehow be possible to make true or start true. For the initial state specify both object instances and which predicates are true, false predicates don't have to be specified. For the goal, specify the states which need to have specific values regardless if those are true or false. Do it step-by-step and explain your thoughts. Respond with the exact headings provided. You can't assume that any object, regardless of type, already exists. Everything you wish to use should be defined here. Also, remember that any symmetrical predicates likely should be defined both ways. -No object types should be of 'object' but their respective types +End your final answer starting with headers (in order) "### OBJECTS" (with no brackets) "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: -The problem you are to extract from is under the header '## Problem description' - -Also it is crucial you follow these checks: - - objects types should be found in types list - - objects name should not be the same as a type name - - object name should not be the same as a predicate name - - objects should only be appointed by its respective type - - all predicates used must have the same parameters stated in its domain file - -Do not, under any circumstance, output the answers in PDDL format. Final answer must be in the following format at the end: -## OBJECTS +### OBJECTS ``` -truck1 - truck +object1 - type_1 +object2 - type_2 +object3 - type_1 ``` -## INITIAL +### INITIAL ``` -(at truck1 chicago_depot): truck1 is at the chicago_depot +(predicate_name object1 object2) ; comment for initial state predicate 1 +(predicate_name object3 object4) ; comment for initial state predicate 2 +(predicate_name object5) ; comment for initial state predicate 3 ``` -## GOAL +### GOAL ``` -(AND ; all the following should be done - (finalised house1) ; house 1 is done +(and + (predicate_name object) ; comment ) -``` \ No newline at end of file +``` + +Even if there is one goal state, it must contain the PDDL 'and' syntax. Each object must be declared separately with their type and not grouped - even if objects share the same type. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt index acb4184..b38e4cf 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt @@ -1,8 +1,12 @@ ## Types +``` {types} +``` ## Predicates +``` {predicates} +``` -## Problem description +## Problem {problem_desc} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt deleted file mode 100644 index ec019ce..0000000 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt +++ /dev/null @@ -1,8 +0,0 @@ -Chain of Thought for extracting PDDL problem file: - -1. Using the given domain description and types, identify object instances and their respective cardinalities -2. Using the given domain description, predicates and extracted object instances, identify the initial states -3. Using the given domain description, objects, and implications of the initial states, identify the goal states -4. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -5. If there are errors, generate a suggestion response -6. Re-iterate over the objects, initial, and goal states. At this point, define them under the capitalized headers as final inputs: '## OBJECTS', '## INITIAL', and '## GOAL' respectively. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example.txt deleted file mode 100644 index 28d0838..0000000 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example.txt +++ /dev/null @@ -1,94 +0,0 @@ -The following is an in-context example following the CoT technique. - -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. - -Given types: -There are no available types. - ------------------------------------------------------ - -1. First, we'll need types for the houses that are built and the depot. We'll also add a general location type to organize this. -``` -- location: Can be visited and travelled between. -- house: Constructed by the company. Are a type of location. -- depot: Contains trucks and likely material for the construction. -``` - -Next, we need to model the vehicles itself. General "vehicles" are mentioned, as are trucks. We'll model both for safety. -``` -- vehicle: Can transport things, such as material or personell, between locattions. -- truck: A type of vehicle for ground transport. -``` - -After that, the workers need to be included. These are: -``` -- jamie: An administrator. -- emma: A worker. -- bob: A worker. -``` - -Lastly, I've repeatedly assumed the existence of construction materials. This is likely needed and useful, so I'll add it in. -``` -- material: Assorted material for constructing houses. Transported by vehicles. -``` - -2. Feedback: - 1: Are there any more types which are needed to model the domain? - No. There is no need to include any more types. - - 2: Are any more types needed for organisation? For example, if both "carbonara" and "sushi" are both included, a "food" meta-type should likely be included as well. - Yes. Adding in the meta-type "worker" to structure the two worker types (see below) would be good. - - 3: Are any of the supposed types actually objects? For example, is a name listed as a type? If so, it should be replaced with the general type. - Yes. Jamie, Emma and Bob are all individual objects (or in this case people). They should be replaced with their types, administrator and general_worker. - - 4: Are any of the types actually actions? If so, they should be removed. - No. Beyond the people mentioned above the types are reasonable. - - 5: Are any of the types actually properties? If so, they should later be modelled with predicates instead and thereby removed. - 6: Is the acting agent itself or the resulting plans included? If only one instance of the agent exists, such as the entire problem modelling behaviour for one robot, it should be removed. - 7: Will any of the included types only ever be used once? If so, it should be removed and modelled implicitly. - 8: Is the acting agent itself or the resulting plans included? The domain might be better modelled in PDDL if some parts are modelled not as objects and types, even if they technically are. - - -3. I'd suggest the following: -- Remove "jamie", "emma" and "bob". -- Add the following: - - worker: A meta-type structuring the specific workers. - - general_worker: A type of worker who can perform a variety of jobs based on orders. - - administrator: A type of worker who can create orders. - -The feedback raises some valid points, but not all are correct. I agree that exchanging "jamie", "emma" and "bob" with "administrator" and "general_worker" is correct. However, modelling "helicopter" and "excavator" would be too much. We shouldn't include more types than is actually needed and useful for the task at hand, and since no helicopters or excavators exist we'll skip those. - -4. Extract types in Python dictionary format - -First, I have to re-iterate all the types I want to keep: -``` -- location: Locations can be visited and travelled between. -- house: Constructed by the company. Are a type of location. -- depot: Contains trucks and likely material for the construction. -- vehicle: Vehicles can transport things, such as material or personel, between locations. -- truck: A type of vehicle for ground transport. -- material: Assorted material for constructing houses. Transported by vehicles. -``` - -Then, I also want to add the new general worker types: -``` -- general_worker: A type of worker who can perform a variety of jobs based on orders. -- administrator: A type of worker who can create orders. -``` - -I will now output all the types that were not found in the given types description. - -## OUTPUT -{ - "location": "Locations can be visited and travelled between.", - "house": "Constructed by the company. Are a type of location.", - "depot": "Contains trucks and likely material for the construction.", - "vehicle": "Vehicles can transport things, such as material or personel, between locations.", - "truck": "A type of vehicle for ground transport.", - "material": "Assorted material for constructing houses. Transported by vehicles.", - "general_worker": "A type of worker who can perform a variety of jobs based on orders.", - "administrator": "A type of worker who can create orders." -} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example1.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example1.txt new file mode 100644 index 0000000..ac5365b --- /dev/null +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example1.txt @@ -0,0 +1,91 @@ +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. + +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. + +## Types +First, we'll need types for the houses that are built and the depot. We'll also add a general location type to organize this. +``` +- location: Locations can be visited and travelled between. +- house: Constructed by the company. Are a type of location. +- depot: Contains trucks and likely material for the construction. +``` + +Next, we need to model the vehicles itself. General "vehicles" are mentioned, as are trucks. We'll model both for safety. +``` +- vehicle: Vehicles can transport things, such as material or personell, between locattions. +- truck: A type of vehicle for ground transport. +``` + +After that, the workers need to be included. These are: +``` +- jamie: An administrator. +- emma: A worker. +- bob: A worker. +``` + +Lastly, I've repeatedly assumed the existence of construction materials. This is likely needed and useful, so I'll add it in. +``` +- material: Assorted material for constructing houses. Transported by vehicles. +``` + +## Feedback +1: Are there any more types which are needed to model the domain? + No. There is no need to include any more types. + +2: Are any more types needed for organisation? + Yes. Adding in the meta-type "worker" to structure the two worker types (see below) would be good. + +3: Are any of the supposed types actually objects? + Yes. Jamie, Emma and Bob are all individual objects (or in this case people). They should be replaced with their types, administrator and general_worker. + +4: Should any of the types be removed? + No. Beyond the people mentioned above the types are reasonable. + +I'd suggest the following: +- Remove "jamie", "emma" and "bob". +- Add the following: + - worker: A meta-type structuring the specific workers. + - general_worker: A type of worker who can perform a variety of jobs based on orders. + - administrator: A type of worker who can create orders. + + +Start with a "## Response" header, then re-iterate an updated version of the "## Types" header. + +## Response +The feedback raises some valid points, but not all are correct. + +I agree that exchanging "jamie", "emma" and "bob" with "administrator" and "general_worker" is correct. + +However, modelling "helicopter" and "excavator" would be too much. We shouldn't include more types than is actually needed and useful for the task at hand, and since no helicopters or excavators exist we'll skip those. + +## Types +First, I have to re-iterate all the types I want to keep: +``` +- location: Locations can be visited and travelled between. +- house: Constructed by the company. Are a type of location. +- depot: Contains trucks and likely material for the construction. +- vehicle: Vehicles can transport things, such as material or personell, between locattions. +- truck: A type of vehicle for ground transport. +- material: Assorted material for constructing houses. Transported by vehicles. +``` + +Then, I also want to add the new general worker types: +``` +- general_worker: A type of worker who can perform a variety of jobs based on orders. +- administrator: A type of worker who can create orders. +``` + +End your final answer starting with "## OUTPUT" and then re-iterate an updated version the Python dictionary pair '{'name':'description'}' as so: + +## OUTPUT +{ + "location": "Locations can be visited and travelled between.", + "house": "Constructed by the company. Are a type of location.", + "depot": "Contains trucks and likely material for the construction.", + "vehicle": "Vehicles can transport things, such as material or personell, between locattions.", + "truck": "A type of vehicle for ground transport.", + "material": "Assorted material for constructing houses. Transported by vehicles.", + "general_worker": "A type of worker who can perform a variety of jobs based on orders.", + "administrator": "A type of worker who can create orders." +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt index b0ce911..8b49aeb 100644 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt @@ -1,8 +1,5 @@ -You are a PDDL expert and your task is to evaluate if a set of types are correct and sufficent for modelling a given domain. - -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. - -Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +# Role +Your are a PDDL expert and your task is to evaluate if a set of types are correct and sufficent for modelling a given domain. If it is, respond with "no feedback" under header '# JUDGEMENT'. If it isn't, provide your thoughts on how to correct the types. Don't model the available actions, but just the types of objects to be used. Go through the following checklist: 1: Are there additional types which are needed to model the domain? @@ -14,6 +11,15 @@ Go through the following checklist: 7: Will any of the included types only ever be used once? If so, it should be removed and modelled implicitly. 8: Is the acting agent itself or the resulting plans included? The domain might be better modelled in PDDL if some parts are modelled not as objects and types, even if they technically are. +End your final answer starting with "## OUTPUT" and then re-iterate an updated version the Python dictionary pair '{'name':'description'}' as so: + +## OUTPUT +{ + "type_1": "description", + "type_2": "description", + "type_3": "description", +} + # Examples ## Example 1 ### Domain @@ -61,6 +67,7 @@ There are some flaws in the extracted types. First of all, you shouldn't include 8: Is the acting agent itself or the resulting plans included? The "road" type is admittedly a type, but it would be more suitable in PDDL to model this as a predicate connection such as "road_between loc1 loc2". As such, this should be removed and saved for later. Answer: Yes. +# JUDGEMENT I'd suggest the following: - Remove "jamie", "emma" and "bob". - Add the following: @@ -110,6 +117,7 @@ In this domain, the AI agent is a wildlife conservation management system. It mo The "starting_positions" type actually describes the initial state. This should later be defined with for example an "at obj loc" predicate in the initial state instead. Similarly, the "target_positions" is better described in the goal state using the same "at obj loc" predicate. +# JUDGEMENT I'd suggest you do the following: - Add the following type: - patrol: Anti-poaching patrols protecting animals @@ -151,17 +159,14 @@ I've got a building with five floors and two elevators, and I want you to plan t 8: Is the acting agent itself or the resulting plans included? The starting and goal states will be positions, and these aren't in any way included. Hence: No. +# JUDGEMENT As such: No feedback. ----------------------------------------- - -Here is the original output: - +# Task ## Domain {domain_desc} -## Types you gave +## Types {types} -## Original LLM response -{llm_response} \ No newline at end of file +## Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt index 28a46c4..dfd7974 100644 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt @@ -1,12 +1,3 @@ -Your role is to identify the different types of objects which exist and are relevant in a PDDL domain. That means the types should be classified as seen in PDDL domains. Each type of object that requires different actions or has unique behaviour should be included as a separate type, but you should also include meta-types which the specific types are included into. Provide a short comment on each type. It is crucial that the AI agent itself is not a type. An action term is not considered a type. A location and object should not be the same types. +Your task is to identify the different types of objects which exist and are relevant in a domain. Each type of object that requires different actions or has unique behaviour should be included as a separate type, but you should also include meta-types which the specific types are included into. Provide a short comment on each type. The AI agent itself is not a type. Start your response with "## Types". -If the types are very similar is some meta-type categorization, they should just be classified as the same thing and not separate. Do not have repeated types. - -Think step by step. Do not attempt to solve the task, even if instructed to do so. Only extract the types. - -End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'name':'description'}' as so: - -## OUTPUT -{ - "location": "Locations can be visited and travelled between.", -} \ No newline at end of file +Think step by step. Do not attempt to solve the task, even if instructed to do so. Only extract the types. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt index 12a1d25..bcdfdf2 100644 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt @@ -1,3 +1,2 @@ -{domain_desc} - -{types} \ No newline at end of file +## Domain +{domain_desc} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt deleted file mode 100644 index b457ac4..0000000 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt +++ /dev/null @@ -1,6 +0,0 @@ -Chain of Thought for extracting types: - -1. Identify Key Entities and describe each entity in natural language -2. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -3. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding types) -4. Re-iterate over the types and put them into a Python dictionary pair '{'name':'description'}'. Keep the types the same if they do not need to be modified. Only have the format in Python dictionary pair after the ## OUTPUT header. Meaning that there is only one dictionary in your response. If there exists a types dictionary, then add the types onto that and output that dictionary. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl new file mode 100644 index 0000000..132401d --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl @@ -0,0 +1,88 @@ +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + block - object + table - object + ) + + (:predicates + (on_table ?b - block ?t - table) ; true if block ?b is on the table ?t + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + (held ?b - block) ; true if block ?b is currently being held by the robot arm + ) + + (:action pick_block + :parameters ( + ?b - block + ?t - table + ?b2 - block + ) + :precondition + (and + (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently being held + ) + :effect + (and + (held ?b) ; The block is now being held by the robot arm + (not (on_table ?b ?t)) ; The block is no longer on the table + (not (on_block ?b ?b2)) ; The block is no longer on top of another block + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ?t - table + ) + :precondition + (and + (held ?b) ; The block is currently being held + (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed + (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed + ) + :effect + (and + (on_table ?b ?t) ; The block is now on the table + (not (held ?b)) ; The block is no longer being held + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?t - table + ) + :precondition + (and + (held ?b1) ; The block being placed is currently held + (not (held ?b2)) ; The block being placed on is not currently held + (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it + (not (on_table ?b2 ?t)) ; The block being placed on is not on the table + ) + :effect + (and + (on_block ?b1 ?b2) ; The block being placed is now on top of the other block + (not (held ?b1)) ; The block being placed is no longer held + ) + ) + + (:action release_block + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently being held + (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block + ) + :effect + (and + (not (held ?b)) ; The block is no longer held + (on_table ?b) ; The block is placed on the table after being released + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt b/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt new file mode 100644 index 0000000..d498594 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt @@ -0,0 +1,167 @@ +STEP ONE: TYPE EXTRACTION + +{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.'} + +-------------------- +STEP TWO: HIERARCHY CONSTRUCTION + +{'object': 'Object is always root, everything is an object', 'children': [{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'children': []}, {'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', 'children': []}]} + +-------------------- +STEP THREE: ACTION EXTRACTION + +{'pick_block': 'The robot arm picks up a block from the table or from on top of another block. Requires the block to be on the table or on another block and not currently being held. Example: robot_arm picks up block_1 from the table.', 'place_on_table': 'The robot arm places a block down on the table. Requires the block to be held and the table to be clear of any blocks directly beneath the block being placed. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. Requires the block to be held and the block being placed on to be clear of any blocks directly beneath it. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases a block it is holding. Requires the block to be held. Example: robot_arm releases block_1.'} + +-------------------- +STEP FOUR: ACTION CONSTRUCTION + +ACTIONS: +{'name': 'pick_block', 'params': OrderedDict([('?b', 'block'), ('?t', 'table'), ('?b2', 'block')]), 'preconditions': '(and\n (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block\n (not (held ?b)) ; The block is not currently being held\n)', 'effects': '(and\n (held ?b) ; The block is now being held by the robot arm\n (not (on_table ?b ?t)) ; The block is no longer on the table\n (not (on_block ?b ?b2)) ; The block is no longer on top of another block\n)'} +{'name': 'place_on_table', 'params': OrderedDict([('?b', 'block'), ('?t', 'table')]), 'preconditions': '(and\n (held ?b) ; The block is currently being held\n (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed\n (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed\n)', 'effects': '(and\n (on_table ?b ?t) ; The block is now on the table\n (not (held ?b)) ; The block is no longer being held\n)'} +{'name': 'place_on_block', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block'), ('?t', 'table')]), 'preconditions': '(and\n (held ?b1) ; The block being placed is currently held\n (not (held ?b2)) ; The block being placed on is not currently held\n (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it\n (not (on_table ?b2 ?t)) ; The block being placed on is not on the table\n)', 'effects': '(and\n (on_block ?b1 ?b2) ; The block being placed is now on top of the other block\n (not (held ?b1)) ; The block being placed is no longer held\n)'} +{'name': 'release_block', 'params': OrderedDict([('?b', 'block')]), 'preconditions': '(and\n (held ?b) ; The block is currently being held\n (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held\n (on_table ?b) ; The block is placed on the table after being released\n)'} + +PREDICATES: +{'name': 'on_table', 'desc': 'true if block ?b is on the table ?t', 'raw': '(on_table ?b - block ?t - table): true if block ?b is on the table ?t', 'params': OrderedDict([('?b', 'block'), ('?t', 'table')]), 'clean': '(on_table ?b - block ?t - table): true if block ?b is on the table ?t'} +{'name': 'on_block', 'desc': 'true if block ?b1 is on top of block ?b2', 'raw': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block')]), 'clean': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b2'} +{'name': 'held', 'desc': 'true if block ?b is currently being held by the robot arm', 'raw': '(held ?b - block): true if block ?b is currently being held by the robot arm', 'params': OrderedDict([('?b', 'block')]), 'clean': '(held ?b - block): true if block ?b is currently being held by the robot arm'} + +-------------------- +STEP FIVE: TASK EXTRACTION + +OBJECTS: +blue_block - block +red_block - block +yellow_block - block +green_block - block +table1 - table +INITIAL STATES: +(on_block blue_block red_block) +(on_block red_block yellow_block) +(on_table yellow_block table1) +(on_table green_block table1) +(clear green_block) +GOAL STATES: +(AND + (on_block red_block green_block) +) + + +PDDL DOMAIN: +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + block - object + table - object + ) + + (:predicates + (on_table ?b - block ?t - table) ; true if block ?b is on the table ?t + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + (held ?b - block) ; true if block ?b is currently being held by the robot arm + ) + + (:action pick_block + :parameters ( + ?b - block + ?t - table + ?b2 - block + ) + :precondition + (and + (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently being held + ) + :effect + (and + (held ?b) ; The block is now being held by the robot arm + (not (on_table ?b ?t)) ; The block is no longer on the table + (not (on_block ?b ?b2)) ; The block is no longer on top of another block + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ?t - table + ) + :precondition + (and + (held ?b) ; The block is currently being held + (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed + (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed + ) + :effect + (and + (on_table ?b ?t) ; The block is now on the table + (not (held ?b)) ; The block is no longer being held + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?t - table + ) + :precondition + (and + (held ?b1) ; The block being placed is currently held + (not (held ?b2)) ; The block being placed on is not currently held + (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it + (not (on_table ?b2 ?t)) ; The block being placed on is not on the table + ) + :effect + (and + (on_block ?b1 ?b2) ; The block being placed is now on top of the other block + (not (held ?b1)) ; The block being placed is no longer held + ) + ) + + (:action release_block + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently being held + (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block + ) + :effect + (and + (not (held ?b)) ; The block is no longer held + (on_table ?b) ; The block is placed on the table after being released + ) + ) +) + +PDDL PROBLEM: +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + blue_block - block + red_block - block + yellow_block - block + green_block - block + table1 - table + ) + + (:init + (on_block blue_block red_block) + (on_block red_block yellow_block) + (on_table yellow_block table1) + (on_table green_block table1) + (clear green_block) + ) + + (:goal + (and + (on_block red_block green_block) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt b/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt new file mode 100644 index 0000000..746607c --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt @@ -0,0 +1 @@ +Input error in translate phase. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl new file mode 100644 index 0000000..d138670 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl @@ -0,0 +1,27 @@ +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + blue_block - block + red_block - block + yellow_block - block + green_block - block + table1 - table + ) + + (:init + (on_block blue_block red_block) + (on_block red_block yellow_block) + (on_table yellow_block table1) + (on_table green_block table1) + (clear green_block) + ) + + (:goal + (and + (on_block red_block green_block) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/domain.pddl b/paper_reconstructions/nl2plan/results/domain.pddl deleted file mode 100644 index 8550a6f..0000000 --- a/paper_reconstructions/nl2plan/results/domain.pddl +++ /dev/null @@ -1,30 +0,0 @@ -(define (domain test_domain) - (:requirements :conditional-effects :disjunctive-preconditions :equality :negative-preconditions :strips :typing :universal-preconditions) - (:types arm - mechanism block table - physical_object) - (:predicates (at ?a - arm ?t - table) (clear ?b - block) (holding ?a - arm ?b - block) (on ?b1 - block ?b2 - block)) - (:action check_clear - :parameters (?a - arm ?b - block) - :precondition (and (at ?a ?t) (not (holding ?a ?b)) (clear ?b)) - :effect (clear ?b) - ) - (:action pickup - :parameters (?a - arm ?b - block ?t - table) - :precondition (and (at ?a ?t) (clear ?b) (not (holding ?a ?b)) (at ?b ?t)) - :effect (and (holding ?a ?b) (not (at ?b ?t)) (not (clear ?b))) - ) - (:action putdown - :parameters (?a - arm ?b - block ?t - table) - :precondition (and (holding ?a ?b) (not (at ?b ?t))) - :effect (and (not (holding ?a ?b)) (at ?b ?t) (clear ?b)) - ) - (:action stack - :parameters (?a - arm ?b1 - block ?b2 - block ?t - table) - :precondition (and (holding ?a ?b1) (clear ?b2) (at ?a ?t)) - :effect (and (not (holding ?a ?b1)) (on ?b1 ?b2) (not (clear ?b2))) - ) - (:action unstack - :parameters (?a - arm ?b1 - block ?b2 - block ?t - table) - :precondition (and (at ?a ?t) (clear ?b1) (not (holding ?a ?b1)) (on ?b1 ?b2)) - :effect (and (holding ?a ?b1) (not (on ?b1 ?b2)) (clear ?b2)) - ) -) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/problem.pddl b/paper_reconstructions/nl2plan/results/problem.pddl deleted file mode 100644 index dd9201d..0000000 --- a/paper_reconstructions/nl2plan/results/problem.pddl +++ /dev/null @@ -1,6 +0,0 @@ -(define (problem test_problem) - (:domain test_domain) - (:objects blue_block green_block red_block yellow_block - block table1 - table) - (:init (clear green_block) (clear yellow_block) (on blue_block red_block) (on green_block table1) (on red_block yellow_block) (on yellow_block table1)) - (:goal (on red_block green_block)) -) \ No newline at end of file diff --git a/paper_reconstructions/p+s/main.py b/paper_reconstructions/p+s/main.py new file mode 100644 index 0000000..a4889b1 --- /dev/null +++ b/paper_reconstructions/p+s/main.py @@ -0,0 +1,210 @@ +""" +Paper: "Structured, flexible, and robust: benchmarking and improving large language models towards more human-like behavior in out-of-distribution reasoning tasks" Collins et al. (2022) +Source code: https://github.com/collinskatie/structured_flexible_and_robust +Run: python3 -m paper_reconstructions.p+s.main + +This framework (Part II of paper) utilizes "Language-of-Thought" (LOT) prompting where thinking operates like formal language. +Mental representations are structured symbolically with rules for logical reasoning and problem-solving. L2P follows this paradigm. +In this paper, they are tasking the LLM to translate natural language initial and goal states to PDDL via few shot prompting. +""" + +from l2p import * +from itertools import combinations + + +def run_parse_and_solve( + model: LLM, + prompt_initial: str, + prompt_goal: str, + problem_path: str, + problem_name: str, + objects: dict[str,str] + ): + """ + Main framework of P+S - translate initial and goal states to PDDL from NL + + Args: + model (LLM): LLM model to run inference + prompt_initial (str): prompt for translating initial state + prompt_goal (str): prompt for translating goal state + problem_path (str): directory of specific problem + problem_name (str): PDDL problem name + objects (dict[str,str]): objects of task file + """ + + # extract initial states + initial_states, _ = task_builder.extract_initial_state( + model=model, + problem_desc="", + prompt_template=prompt_initial, + objects="") + + # extract goal states + goal_states, _ = task_builder.extract_goal_state( + model=model, + problem_desc="", + prompt_template=prompt_goal, + objects="") + + # convert Python components to string + objects_str = task_builder.format_objects(objects) + initial_state_str = task_builder.format_initial(initial_states) + goal_state_str = task_builder.format_goal(goal_states) + + # insert `(noteq)` predicate manually (due to domain from paper) + objects = objects_str.split("\n") + for obj1, obj2 in combinations(objects, 2): # create all combinations + initial_state_str += f"\n(noteq {obj1} {obj2})" + + # take components and generate PDDL task format + pddl_problem = task_builder.generate_task( + "simple-blocks", + problem_name, + objects=objects_str, + initial=initial_state_str, + goal=goal_state_str) + + # write the problem file to respective directory + problem_file = problem_path + f"/{problem_name}.pddl" + with open(problem_file, "w") as f: + f.write(pddl_problem) + + return problem_file + + +def run_problem_01(init_examples, goal_examples): + # PROBLEM 1 + problem_path = "paper_reconstructions/p+s/results/problem_01" + objects_01 = {'sketchbook':'', 'sweatshirt':'', 'keyboard':'', 'novel':''} + + # assemble prompt template for initial and goal state extraction + prompt_initial_01 = PromptBuilder( + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/000.txt")) + + prompt_goal_01 = PromptBuilder( + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/000.txt")) + + # run framework + problem_file = run_parse_and_solve( + model=openai_llm, + prompt_initial=prompt_initial_01.generate_prompt(), + prompt_goal=prompt_goal_01.generate_prompt(), + problem_path=problem_path, + problem_name="problem-01", + objects=objects_01) + + # run FastDownward planner + _, result = planner.run_fast_downward( + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file) + + # write result of plan + with open(problem_path + "/plan.txt", "w") as f: + f.write(result) + + +def run_problem_02(init_examples, goal_examples): + # PROBLEM 2 + problem_path = "paper_reconstructions/p+s/results/problem_02" + objects_02 = {'newspaper':'', 'accordion':'', 'saucepan':'', 'peacoat':''} + + prompt_initial_02 = PromptBuilder( + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/001.txt")) + + prompt_goal_02 = PromptBuilder( + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/001.txt")) + + problem_file = run_parse_and_solve( + model=openai_llm, + prompt_initial=prompt_initial_02.generate_prompt(), + prompt_goal=prompt_goal_02.generate_prompt(), + problem_path=problem_path, + problem_name="problem-02", + objects=objects_02) + + _, result = planner.run_fast_downward( + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file) + + with open(problem_path + "/plan.txt", "w") as f: + f.write(result) + + +def run_problem_03(init_examples, goal_examples): + # PROBLEM 3 + problem_path = "paper_reconstructions/p+s/results/problem_03" + objects_03 = {'mouse-pad':'', 'hacksaw':'', 'saucepan':'', 'raincoat':''} + + # assemble prompt template for initial and goal state extraction + prompt_initial_03 = PromptBuilder( + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/002.txt")) + + prompt_goal_03 = PromptBuilder( + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/002.txt")) + + problem_file = run_parse_and_solve( + model=openai_llm, + prompt_initial=prompt_initial_03.generate_prompt(), + prompt_goal=prompt_goal_03.generate_prompt(), + problem_path=problem_path, + problem_name="problem-03", + objects=objects_03) + + _, result = planner.run_fast_downward( + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file) + + with open(problem_path + "/plan.txt", "w") as f: + f.write(result) + + +if __name__ == "__main__": + + # setup L2P requirements + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + openai_llm = OPENAI(model=engine, api_key=api_key) + planner = FastDownward(planner_path="downward/fast-downward.py") + + # load in few shot examples + folder_path = "paper_reconstructions/p+s/prompts/examples/initial" + init_examples = [] + + for filename in os.listdir(folder_path): + if filename.endswith(".txt"): + file_path = os.path.join(folder_path, filename) + file_content = load_file(file_path) + init_examples.append(file_content) + + folder_path = "paper_reconstructions/p+s/prompts/examples/goal" + goal_examples = [] + + for filename in os.listdir(folder_path): + if filename.endswith(".txt"): + file_path = os.path.join(folder_path, filename) + file_content = load_file(file_path) + goal_examples.append(file_content) + + # load in base templates + ROLE = "Your task is to convert the natural language states into PDDL initial state predicates.\n\n" + ROLE_INITIAL = ROLE + load_file("templates/task_templates/extract_initial.txt") + ROLE_GOAL = ROLE + load_file("templates/task_templates/extract_goal.txt") + DOMAIN_DIR = "paper_reconstructions/p+s/domain.pddl" + + # run problem sets + run_problem_01(init_examples, goal_examples) + run_problem_02(init_examples, goal_examples) + run_problem_03(init_examples, goal_examples) + \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/goal/000.txt b/paper_reconstructions/p+s/problems/goal/000.txt new file mode 100644 index 0000000..49af523 --- /dev/null +++ b/paper_reconstructions/p+s/problems/goal/000.txt @@ -0,0 +1,2 @@ +;The keyboard is on the sketchbook. +;The sweatshirt rests on the table. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/goal/001.txt b/paper_reconstructions/p+s/problems/goal/001.txt new file mode 100644 index 0000000..07c8213 --- /dev/null +++ b/paper_reconstructions/p+s/problems/goal/001.txt @@ -0,0 +1,7 @@ +;There is nothing on the newspaper. +;The accordion rests on the table. +;There is nothing on the saucepan. +;The saucepan rests on the table. +;The newspaper is on the accordion. +;The peacoat rests on the table. +;There is nothing on the peacoat. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/goal/002.txt b/paper_reconstructions/p+s/problems/goal/002.txt new file mode 100644 index 0000000..52bb76e --- /dev/null +++ b/paper_reconstructions/p+s/problems/goal/002.txt @@ -0,0 +1,6 @@ +;The mouse pad rests on the table. +;The saucepan rests on the table. +;There is nothing on the hacksaw. +;The raincoat is on the mouse pad. +;The hacksaw is on the raincoat. +;There is nothing on the saucepan. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/initial/000.txt b/paper_reconstructions/p+s/problems/initial/000.txt new file mode 100644 index 0000000..1585038 --- /dev/null +++ b/paper_reconstructions/p+s/problems/initial/000.txt @@ -0,0 +1,5 @@ +;The sketchbook rests on the table. +;The sweatshirt is on the sketchbook. +;The keyboard is on the sweatshirt. +;The novel is on the keyboard. +;There is nothing on the novel. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/initial/001.txt b/paper_reconstructions/p+s/problems/initial/001.txt new file mode 100644 index 0000000..a76fcda --- /dev/null +++ b/paper_reconstructions/p+s/problems/initial/001.txt @@ -0,0 +1,6 @@ +;The accordion rests on the table. +;The newspaper is on the accordion. +;The saucepan is on the newspaper. +;There is nothing on the saucepan. +;The peacoat rests on the table. +;There is nothing on the peacoat. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/initial/002.txt b/paper_reconstructions/p+s/problems/initial/002.txt new file mode 100644 index 0000000..defd1d4 --- /dev/null +++ b/paper_reconstructions/p+s/problems/initial/002.txt @@ -0,0 +1,7 @@ +;The raincoat rests on the table. +;There is nothing on the raincoat. +;The hacksaw rests on the table. +;There is nothing on the hacksaw. +;The saucepan rests on the table. +;The mouse pad is on the saucepan. +;There is nothing on the mouse pad. \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/goal/example_01.txt b/paper_reconstructions/p+s/prompts/examples/goal/example_01.txt new file mode 100644 index 0000000..0922ab3 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/goal/example_01.txt @@ -0,0 +1,16 @@ +;The phone rests on the table. +;The plate is on the phone. +;The notebook is on the plate. +;The textbook is on the notebook. +;There is nothing on the textbook. + +### GOAL +``` +(and + (ontable phone) + (on plate phone) + (on notebook plate) + (on textbook notebook) + (clear textbook) +) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/goal/example_02.txt b/paper_reconstructions/p+s/prompts/examples/goal/example_02.txt new file mode 100644 index 0000000..93d3c00 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/goal/example_02.txt @@ -0,0 +1,18 @@ +;The newspaper rests on the table. +;The plate is on the newspaper. +;There is nothing on the plate. +;The tissue box rests on the table. +;The textbook is on the tissue box. +;There is nothing on the textbook. + +### GOAL +``` +(and + (ontable newspaper) + (on plate newspaper) + (clear plate) + (ontable tissue-box) + (on textbook tissue-box) + (clear textbook) +) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/goal/example_03.txt b/paper_reconstructions/p+s/prompts/examples/goal/example_03.txt new file mode 100644 index 0000000..5b21fdc --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/goal/example_03.txt @@ -0,0 +1,20 @@ +;The phone rests on the table. +;The plate is on the phone. +;There is nothing on the plate. +;The novel rests on the table. +;There is nothing on the novel. +;The writing pad rests on the table. +;There is nothing on the writing pad. + +### GOAL +``` +(and + (ontable phone) + (on plate phone) + (clear plate) + (ontable novel) + (clear novel) + (ontable writing-pad) + (clear writing-pad) +) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/initial/example_01.txt b/paper_reconstructions/p+s/prompts/examples/initial/example_01.txt new file mode 100644 index 0000000..fb5e883 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/initial/example_01.txt @@ -0,0 +1,14 @@ +;The phone rests on the table. +;The plate is on the phone. +;The notebook is on the plate. +;The textbook is on the notebook. +;There is nothing on the textbook. + +### INITIAL +``` +(ontable phone) +(on plate phone) +(on notebook plate) +(on textbook notebook) +(clear textbook) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/initial/example_02.txt b/paper_reconstructions/p+s/prompts/examples/initial/example_02.txt new file mode 100644 index 0000000..1d82f00 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/initial/example_02.txt @@ -0,0 +1,16 @@ +;The newspaper rests on the table. +;The plate is on the newspaper. +;There is nothing on the plate. +;The tissue box rests on the table. +;The textbook is on the tissue box. +;There is nothing on the textbook. + +### INITIAL +``` +(ontable newspaper) +(on plate newspaper) +(clear plate) +(ontable tissue-box) +(on textbook tissue-box) +(clear textbook) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/initial/example_03.txt b/paper_reconstructions/p+s/prompts/examples/initial/example_03.txt new file mode 100644 index 0000000..9d1e83e --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/initial/example_03.txt @@ -0,0 +1,19 @@ +;The phone rests on the table. +;The plate is on the phone. +;There is nothing on the plate. +;The novel rests on the table. +;There is nothing on the novel. +;The writing pad rests on the table. +;There is nothing on the writing pad. +``` + +### INITIAL +``` +(ontable phone) +(on plate phone) +(clear plate) +(ontable novel) +(clear novel) +(ontable writing-pad) +(clear writing-pad) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/domain.pddl b/paper_reconstructions/p+s/results/domain.pddl new file mode 100644 index 0000000..91da5a7 --- /dev/null +++ b/paper_reconstructions/p+s/results/domain.pddl @@ -0,0 +1,29 @@ +(define (domain simple-blocks) + (:requirements :strips) + (:predicates (on ?x ?y) + (clear ?x) + (ontable ?x) + ) + (:action stack + :parameters (?obj ?oldunder ?newunder) + :precondition + (and (clear ?newunder) (clear ?obj) (on ?obj ?oldunder)) + :effect + (and (not (clear ?newunder)) + (on ?obj ?newunder) + (not (on ?obj ?oldunder)) + (clear ?oldunder))) + (:action unstack + :parameters (?sob ?sunderob) + :precondition (and (on ?sob ?sunderob) (clear ?sob)) + :effect + (and (clear ?sunderob) + (ontable ?sob) + (not (on ?sob ?sunderob)))) + (:action stackfromtable + :parameters (?obj ?newunder) + :precondition (and (clear ?obj) (clear ?newunder) (ontable ?obj)) + :effect + (and (not (clear ?newunder)) + (on ?obj ?newunder) + (not (ontable ?obj))))) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_01/plan.txt b/paper_reconstructions/p+s/results/problem_01/plan.txt new file mode 100644 index 0000000..d1009bc --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_01/plan.txt @@ -0,0 +1,6 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +stack novel keyboard novel (1) +unstack keyboard sweatshirt (1) +unstack sweatshirt sketchbook (1) +stackfromtable keyboard sketchbook (1) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_01/problem-01.pddl b/paper_reconstructions/p+s/results/problem_01/problem-01.pddl new file mode 100644 index 0000000..5d190a0 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_01/problem-01.pddl @@ -0,0 +1,33 @@ +(define + (problem problem-01) + (:domain simple-blocks) + + (:objects + sketchbook + sweatshirt + keyboard + novel + ) + + (:init + (ontable sketchbook) + (on sweatshirt sketchbook) + (on keyboard sweatshirt) + (on novel keyboard) + (clear novel) + (noteq sketchbook sweatshirt) + (noteq sketchbook keyboard) + (noteq sketchbook novel) + (noteq sweatshirt keyboard) + (noteq sweatshirt novel) + (noteq keyboard novel) + ) + + (:goal + (and + (on keyboard sketchbook) + (ontable sweatshirt) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_02/plan.txt b/paper_reconstructions/p+s/results/problem_02/plan.txt new file mode 100644 index 0000000..5ef0726 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_02/plan.txt @@ -0,0 +1,3 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +unstack saucepan newspaper (1) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_02/problem-02.pddl b/paper_reconstructions/p+s/results/problem_02/problem-02.pddl new file mode 100644 index 0000000..4206464 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_02/problem-02.pddl @@ -0,0 +1,39 @@ +(define + (problem problem-02) + (:domain simple-blocks) + + (:objects + newspaper + accordion + saucepan + peacoat + ) + + (:init + (ontable accordion) + (on newspaper accordion) + (on saucepan newspaper) + (clear saucepan) + (ontable peacoat) + (clear peacoat) + (noteq newspaper accordion) + (noteq newspaper saucepan) + (noteq newspaper peacoat) + (noteq accordion saucepan) + (noteq accordion peacoat) + (noteq saucepan peacoat) + ) + + (:goal + (and + (clear newspaper) + (ontable accordion) + (clear saucepan) + (ontable saucepan) + (on newspaper accordion) + (ontable peacoat) + (clear peacoat) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_03/plan.txt b/paper_reconstructions/p+s/results/problem_03/plan.txt new file mode 100644 index 0000000..2a5c18c --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_03/plan.txt @@ -0,0 +1,5 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +unstack mouse-pad saucepan (1) +stackfromtable raincoat mouse-pad (1) +stackfromtable hacksaw raincoat (1) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_03/problem-03.pddl b/paper_reconstructions/p+s/results/problem_03/problem-03.pddl new file mode 100644 index 0000000..bb2f4f1 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_03/problem-03.pddl @@ -0,0 +1,39 @@ +(define + (problem problem-03) + (:domain simple-blocks) + + (:objects + mouse-pad + hacksaw + saucepan + raincoat + ) + + (:init + (ontable raincoat) + (clear raincoat) + (ontable hacksaw) + (clear hacksaw) + (ontable saucepan) + (on mouse-pad saucepan) + (clear mouse-pad) + (noteq mouse-pad hacksaw) + (noteq mouse-pad saucepan) + (noteq mouse-pad raincoat) + (noteq hacksaw saucepan) + (noteq hacksaw raincoat) + (noteq saucepan raincoat) + ) + + (:goal + (and + (ontable mouse-pad) + (ontable saucepan) + (clear hacksaw) + (on raincoat mouse-pad) + (on hacksaw raincoat) + (clear saucepan) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/proc2pddl/proc2pddl.py b/paper_reconstructions/proc2pddl/main.py similarity index 84% rename from paper_reconstructions/proc2pddl/proc2pddl.py rename to paper_reconstructions/proc2pddl/main.py index b2a269d..263403f 100644 --- a/paper_reconstructions/proc2pddl/proc2pddl.py +++ b/paper_reconstructions/proc2pddl/main.py @@ -1,22 +1,11 @@ """ Paper: "PROC2PDDL: Open-Domain Planning Representations from Texts" Zhang et al. (2024) Source code: https://github.com/zharry29/proc2pddl -Run: python3 -m paper_reconstructions.proc2pddl.proc2pddl +Run: python3 -m paper_reconstructions.proc2pddl.main """ -import os, json +import os from l2p import * -from l2p.utils.pddl_planner import FastDownward - - -def load_file(file_path): - with open(file_path, "r") as file: - return file.read().strip() - - -def load_json(file_path): - with open(file_path, "r") as file: - return json.load(file) engine = "gpt-4o-mini" @@ -27,16 +16,16 @@ def load_json(file_path): task_builder = TaskBuilder() feedback_builder = FeedbackBuilder() prompt_builder = PromptBuilder() -planner = FastDownward() +planner = FastDownward(planner_path="downward/fast-downward.py") # annotated original domain header -types = load_json("paper_reconstructions/proc2pddl/prompts/types.json") -predicates = load_json("paper_reconstructions/proc2pddl/prompts/predicates.json") -nl_actions = load_json("paper_reconstructions/proc2pddl/prompts/nl_actions.json") +types = load_file("paper_reconstructions/proc2pddl/prompts/types.json") +predicates = load_file("paper_reconstructions/proc2pddl/prompts/predicates.json") +nl_actions = load_file("paper_reconstructions/proc2pddl/prompts/nl_actions.json") if __name__ == "__main__": - unsupported_keywords = ["object", "pddl", "lisp"] + UNSUPPORTED_KEYWORDS = ["object", "pddl", "lisp"] # retrieve wikihow text domain_desc = load_file("paper_reconstructions/proc2pddl/prompts/wikihow.txt") @@ -91,7 +80,7 @@ def load_json(file_path): pruned_types = { name: description for name, description in types.items() - if name not in unsupported_keywords + if name not in UNSUPPORTED_KEYWORDS } # remove unsupported words # format strings diff --git a/paper_reconstructions/proc2pddl/results/domain.pddl b/paper_reconstructions/proc2pddl/results/domain.pddl index b9bfbce..466edbc 100644 --- a/paper_reconstructions/proc2pddl/results/domain.pddl +++ b/paper_reconstructions/proc2pddl/results/domain.pddl @@ -1,8 +1,8 @@ (define (domain survive_deserted_island) - (:requirements - :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects - ) - (:types + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types item - object water - item wood - item @@ -45,235 +45,237 @@ (cooked ?item - item) ) -(:action go - :parameters ( -?player - human -?from - location -?to - location + (:action go + :parameters ( + ?player - human + ?from - location + ?to - location + ) + :precondition + (and + (at ?player ?from) ; The player is at the current location + (connected ?from ?to) ; The current location is connected to the new location + ) + :effect + (and + (not (at ?player ?from)) ; The player is no longer at the current location + (at ?player ?to) ; The player is now at the new adjacent location + ) ) - :precondition -(and - (at ?player ?from) ; The player is at the current location - (connected ?from ?to) ; The current location is connected to the adjacent location -) - :effect -(and - (not (at ?player ?from)) ; The player is no longer at the current location - (at ?player ?to) ; The player is now at the adjacent location -) -) -(:action get - :parameters ( -?player - human -?item - object -?loc - location + (:action get + :parameters ( + ?player - human + ?item - object + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (at ?item ?loc) ; The item is present in the current location + ) + :effect + (and + (not (at ?item ?loc)) ; The item is no longer in the environment + (inventory ?player ?item) ; The item is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the current location - (at ?item ?loc) ; The item is present in the current location -) - :effect -(and - (inventory ?player ?item) ; The item is now in the player's inventory - (not (at ?item ?loc)) ; The item is no longer in the current location -) -) -(:action get_water - :parameters ( -?player - human -?water - water -?loc - location + (:action get_water + :parameters ( + ?player - human + ?water - water + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (has_water_source ?loc) ; The location has a water source + ) + :effect + (and + (inventory ?player ?water) ; The water is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the current location - (has_water_source ?loc) ; The location has a water source -) - :effect -(and - (inventory ?player ?water) ; The player has water in their inventory -) -) -(:action chop_wood - :parameters ( -?player - human -?wood - wood -?loc - location + (:action chop_wood + :parameters ( + ?player - human + ?wood - wood + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (has_wood ?loc) ; The location has wood + ) + :effect + (and + (inventory ?player ?wood) ; The wood is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the current location - (has_wood ?loc) ; The location has wood available -) - :effect -(and - (inventory ?player ?wood) ; The player has wood in their inventory - (not (has_wood ?loc)) ; The wood is no longer in the current location -) -) -(:action carve_groove - :parameters ( -?player - human -?wood - wood + (:action carve_groove + :parameters ( + ?player - human + ?wood - wood + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + ) + :effect + (and + (groove ?wood) ; The wood now has a groove + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory -) - :effect -(and - (groove ?wood) ; The wood now has a groove made in it -) -) -(:action light_fire - :parameters ( -?player - human -?loc - location + (:action light_fire + :parameters ( + ?player - human + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (can_light_fire ?loc) ; The location is safe for lighting a fire + ) + :effect + (and + (has_fire ?loc) ; A fire is now lit at the location + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the location - (can_light_fire ?loc) ; The location is safe for lighting a fire -) - :effect -(and - (has_fire ?loc) ; A fire is now lit at the location -) -) -(:action build_shelter - :parameters ( -?player - human -?wood - wood -?loc - location + (:action build_shelter + :parameters ( + ?player - human + ?wood - wood + ?loc - location + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + (is_safe ?loc) ; The location is safe to make shelter + ) + :effect + (and + (has_shelter ?loc) ; A shelter is now built at the location + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory - (is_safe ?loc) ; The location is safe for making shelter -) - :effect -(and - (has_shelter ?loc) ; A shelter is now built at the location -) -) -(:action clean_water - :parameters ( -?player - human -?water - water -?loc - location + (:action clean_water + :parameters ( + ?player - human + ?water - water + ?loc - location + ) + :precondition + (and + (inventory ?player ?water) ; The player has untreated water in their inventory + (has_fire ?loc) ; There is a fire lit at the location + ) + :effect + (and + (treated ?water) ; The water is now treated and safe for drinking + ) ) - :precondition -(and - (inventory ?player ?water) ; The player has untreated water in their inventory - (has_fire ?loc) ; There is a fire at the location -) - :effect -(and - (treated ?water) ; The water is now treated and safe for drinking -) -) -(:action drink_water - :parameters ( -?player - human -?water - water + (:action drink_water + :parameters ( + ?player - human + ?water - water + ) + :precondition + (and + (inventory ?player ?water) ; The player has water in their inventory + ) + :effect + (and + (not (inventory ?player ?water)) ; The water is removed from the inventory + (drank ?player) ; The player has consumed the water + ) ) - :precondition -(and - (inventory ?player ?water) ; The player has treated water in their inventory -) - :effect -(and - (drank ?player) ; The player has now drunk the water - (not (inventory ?player ?water)) ; The water is removed from the player's inventory -) -) -(:action find_other_survivors - :parameters ( -?player - human + (:action find_other_survivors + :parameters ( + ?player - human + ) + :precondition + (and + ; The player must navigate to various locations (no specific predicates needed) + ) + :effect + (and + (has_friend ?player) ; The player may have found a survivor + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at a location -) - :effect -(and - (has_friend ?player) ; The player may have found a survivor -) -) -(:action build_raft - :parameters ( -?player - human -?raft - raft + (:action build_raft + :parameters ( + ?player - human + ?wood - wood + ?vines - vines + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + (inventory ?player ?vines) ; The player has vines in their inventory + ) + :effect + (and + (has_escaped ?player) ; The player has built a raft and is ready to escape + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory - (inventory ?player ?vines) ; The player has vines in their inventory -) - :effect -(and - (has_escaped ?player) ; A raft is now built and ready for use -) -) -(:action make_weapon - :parameters ( -?player - human -?wood - wood -?spear - spear + (:action make_weapon + :parameters ( + ?player - human + ?wood - wood + ?rock - rock + ?spear - spear + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + (inventory ?player ?rock) ; The player has a sharp rock in their inventory + ) + :effect + (and + (inventory ?player ?spear) ; The spear is now in the player's inventory + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory -) - :effect -(and - (inventory ?player ?spear) ; A spear is now created and available for use -) -) -(:action hunt_fish - :parameters ( -?player - human -?fish - fish -?loc - location + (:action hunt_fish + :parameters ( + ?player - human + ?fish - fish + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (has_fish ?loc) ; The location has fish + ) + :effect + (and + (inventory ?player ?fish) ; The fish is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at a location - (has_fish ?loc) ; The location has fish -) - :effect -(and - (inventory ?player ?fish) ; The player has fish in their inventory -) -) -(:action cook_fish - :parameters ( -?player - human -?fish - fish -?loc - location + (:action cook_fish + :parameters ( + ?player - human + ?fish - fish + ?loc - location + ) + :precondition + (and + (inventory ?player ?fish) ; The player has fish in their inventory + (has_fire ?loc) ; There is a fire lit at the location + ) + :effect + (and + (cooked ?fish) ; The fish is now cooked and safe for consumption + ) ) - :precondition -(and - (inventory ?player ?fish) ; The player has fish in their inventory - (has_fire ?loc) ; There is a fire at the location -) - :effect -(and - (cooked ?fish) ; The fish is now cooked and ready to eat -) -) ) \ No newline at end of file diff --git a/templates/task_templates/extract_task.txt b/templates/task_templates/extract_task.txt index a3ff29a..c486b68 100644 --- a/templates/task_templates/extract_task.txt +++ b/templates/task_templates/extract_task.txt @@ -1,4 +1,4 @@ -End your final answer starting with headers (in order) "### OBJECTS" "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: +End your final answer starting with headers (in order) "### OBJECTS" (with no brackets) "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: ### OBJECTS ``` @@ -21,4 +21,4 @@ object3 - type_1 ) ``` -Even if there is one goal state, it must contain the PDDL 'and' syntax \ No newline at end of file +Even if there is one goal state, it must contain the PDDL 'and' syntax. Each object must be declared separately with their type and not grouped - even if objects share the same type. \ No newline at end of file diff --git a/tests/test_domain_builder.py b/tests/test_domain_builder.py index cc46bd9..e761dd5 100644 --- a/tests/test_domain_builder.py +++ b/tests/test_domain_builder.py @@ -1,6 +1,6 @@ -import unittest +import unittest, textwrap from l2p.domain_builder import DomainBuilder -from l2p.utils import * +from l2p.utils.pddl_parser import load_file from .mock_llm import MockLLM @@ -48,6 +48,7 @@ def test_extract_type(self): self.assertIn("Max retries exceeded", str(context.exception)) def test_extract_type_hierarchy(self): + mock_llm_1 = MockLLM( [load_file("tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/01.txt")] ) @@ -112,10 +113,6 @@ def test_extract_type_hierarchy(self): ) self.assertIn("Max retries exceeded", str(context.exception)) - # TODO: implement rest of test domain builder functions - def test_extract_nl_actions(self): - pass - def test_extract_pddl_action(self): pass @@ -135,8 +132,70 @@ def test_extract_predicates(self): pass def test_generate_domain(self): - pass + + domain = "test_domain" + types = "robot location" + predicates = "(at ?r - robot ?l - location)\n(connected ?l1 ?l2 - location)" + actions = [ + { + "name": "move", + "params": {"?r": "robot", "?l1": "location", "?l2": "location"}, + "preconditions": "(and (at ?r ?l1) (connected ?l1 ?l2))", + "effects": "(and (not (at ?r ?l1)) (at ?r ?l2))", + }, + { + "name": "pick", + "params": {"?r": "robot", "?l": "location"}, + "preconditions": "(and (at ?r ?l) (not (holding ?r)))", + "effects": "(holding ?r)", + }, + ] + requirements = [":strips", ":typing"] + + expected_output = textwrap.dedent("""\ + (define (domain test_domain) + (:requirements + :strips :typing) + + (:types + robot location + ) + + (:predicates + (at ?r - robot ?l - location) + (connected ?l1 ?l2 - location) + ) + + (:action move + :parameters ( + ?r - robot + ?l1 - location + ?l2 - location + ) + :precondition + (and (at ?r ?l1) (connected ?l1 ?l2)) + :effect + (and (not (at ?r ?l1)) (at ?r ?l2)) + ) + + (:action pick + :parameters ( + ?r - robot + ?l - location + ) + :precondition + (and (at ?r ?l) (not (holding ?r))) + :effect + (holding ?r) + ) + ) + """).strip() + + result = self.domain_builder.generate_domain(domain=domain, types=types, predicates=predicates, actions=actions, requirements=requirements) + + self.assertEqual(result.strip(), expected_output.strip()) if __name__ == "__main__": unittest.main() +