reasoning_one_shot = [
    "Please extract the last letters of the given words.\nQuestion:\nTake the last letters of each words in \"Toward Success\" and concatenate them.\n\nAnswer:\nFirst, please extract the necessary information and rewrite the question using labels.\n\n#1. Take the last letter of the word \"Toward\".\n#2. Take the last letter of the word \"Success\".\n#3. Concatenate the last letters of the words sequentially\n\nNext, we add the necessary knowledge from the question if needed.\n\n#4. There are two words and \"Success\" is after \"Toward\".\n\nFinally, please solve the problem step by step with reference to the question and reasoning process:\n\n#5. (by #1, #3) Step 1: Taking the last letter of the word \"Toward\" and concatenate the latter.\nThe last letter of the word \"Toward\" is \"d\".\nThe concatenated last letters are \"d\".\n\n#6. (by #2, #3, #4, #5) Step 2: Taking the last letter of the word \"Success\" and concatenate the latter.\nThe last letter of the word \"Success\" is \"s\".\nBased on the commonsense, there are two words and \"Success\" is after \"Toward\".\nThe concatenated last letters are \"ds\".\n\n#7. (by #3, #6) Step 3: Provide the final answer of the concated letter.\nTherefore, the answer is \"ds\"."
]

condition_forward_verification_one_shot = [
    "Here is a set of details:\n#1. Take the last letter of the word \"Toward\".\n#2. Take the last letter of the word \"Success\".\n#3. Concatenate the last letters of the words sequentially.\n\nNext, we add the necessary knowledge from the question if needed\n:#4. There are two words and \"Toward\" is after \"Success\".\n\nBased on these details, here is a reasoning process:\n#5 (by #2, #3): Step 1: Taking the last letter of the word \"Success\" and concatenate the latter.\nThe last letter of the word \"Success\" is \"s\".\nThe concatenated last letters are \"s\".\n\nStep #6 (by #1, #3, #4, #5): Step 2: Taking the last letter of the word \"Toward\" and concatenate the latter.\nThe last letter of the word \"Toward\" is \"d\".\nBased on the commonsense, there are two words and \"Toward\" is after \"Success\".\nThe concatenated last letters are \"sd\".\n\nStep #7 (by #3, #6): Step 3: Provide the final answer of the concatenated letter.\nTherefore, the answer is \"sd\".\n\nDouble-check the logical references, and verify the correctness of any common knowledge used. End with \"yes\" or \"no\" for whether the condition check passes.\n\nAnswer:\n\nConditions check\nObjective: Confirm that the word-level references in each step align with the stated details or valid prior conclusions, and ensure that common knowledge (e.g. order of words) is properly applied.\nRule: Any step that incorrectly extracts, orders, or uses unsupported assumptions about the given words will fail the check.\n\n\"Success\" (from Step #5) comes from #2 (verified)\nLast letter \"s\" (from Step #5) is correct (verified)\n\"Toward\" (from Step #6) comes from #1 (verified)\nLast letter \"d\" (from Step #6) is correct (verified)\nStep #4 introduces incorrect common knowledge: \"Toward\" is **after** \"Success\" — this contradicts the actual word order in the phrase \"Toward Success\" (error)\n Step #6 uses the wrong order from #4 to produce \"sd\" instead of \"ds\" (error)\nFinal answer in Step #7 depends on the flawed logic (error)\n\nResult: Due to incorrect common knowledge in #4 and misordered concatenation, the answer is \"no\", the condition check fails."]

logic_forward_verification_one_shot = [
    "Here is a set of details:\n#1. Take the last letter of the word \"Toward\".\n#2. Take the last letter of the word \"Success\".\n#3. Concatenate the last letters of the words sequentially.\n#4. There are two words and \"Toward\" is before \"Success\".\n\nBased on these details, here is a reasoning process:\nStep #5 (by #1 #3): Step 1: Taking the last letter of the word \"Toward\" and concatenate the latter.\nThe letter extracted from the word \"Toward\" is \"r\".\nThe concatenated last letters are \"r\".\n\nStep #6 (by #2 #3 #4 #5): Step 2: Taking the last letter of the word \"Success\" and concatenate the latter.\nThe last letter of the word \"Success\" is \"s\".\nThe concatenated last letters are \"rs\".\n\nStep #7 (by #3 #6): Step 3: Provide the final answer of the concatenated letter.\nTherefore, the answer is \"rs\".\n\nNow let’s verify the reasoning processing and analyze its consistency. End with \"yes\" or \"no\" for whether the reasoning check passes.\n\nAnswer:\nReasoning check:\nObjective: Check whether the reasoning process is consistent\nRule: Any inconsistent step makes the check fails\n Step #5: Extracts the letter \"r\" from the word \"Toward\". This is incorrect—the last letter of \"Toward\" is \"d\", not \"r\" (unverified).\n Step #6: Correctly extracts \"s\" from \"Success\" and concatenates it with the previous result. Based on Step #5’s output, it forms \"rs\". This step is internally consistent but based on prior error (unverified).\n Step #7: Simply restates the result from Step #6. This is consistent but inherits the earlier mistake (unverified).\n\nIn summary:\n1. The initial letter extraction from \"Toward\" is incorrect.\n2. Later steps are consistent, but based on flawed logic.\nResult: Based on the check, the answer is \"no\", the reasoning check fails."]

backward_verification_one_shot = [
    "Here is a set of details:\n\nStep 1: Identify the number of letters in each word.\nStep 2: Extract the first letter of each word.\nStep 3: Concatenate the first letters together.\nStep 4: Output the resulting string.\n\nThe original question is: What are the last letters of each word in the phrase \"Bright Future\"?\n\nNow, please disregard the original question and focus on the provided reasoning steps. Use these steps to infer and guess the original question. The guessed question should not be output.\n\nEnd with \"yes\" or \"no\" for whether the backward check passes.\n\nAnswer:\nBackward check:\nObjective: Check whether the guessed question is semantically similar to the original question.\nRule: Any semantic difference causes the validation to fail.\n Analysis #1: The reasoning steps involve identifying word lengths, extracting **first** letters, and concatenating them — this clearly focuses on the beginning of words.\nAnalysis #2: A plausible guessed question could be: What are the **first letters** of each word in the phrase \"Bright Future\"?\nAnalysis #3: Comparing this guessed question with the original question — which asks about **last** letters — we find a clear semantic mismatch.\n\nResult: Based on the check, the answer is \"no\", the reasoning check fails."
]

reasoning_beginning_guide = "\n\nAnswer:\nFirst, let's extract the necessary information and rewrite the question using labels.\n\n"

condition_beginning_guide = "\n\nDouble-check the numeric references, and verify the correctness of any common knowledge used. End with \"yes\" or \"no\" for whether the condition check passes.\n\nAnswer:\n\nConditions check\nObjective: Confirm that the numbers and references in each step align with the stated details or valid prior conclusions, and ensure that common knowledge is properly applied.\nRule: Any condition reference without support or misused common knowledge from the given information will fail the check.\n"

logic_beginning_guide = "\n\nNow let’s verify the reasoning processing and analyze its consistency. End with \"yes\" or \"no\" for whether the reasoning check passes.\n\nAnswer:\nReasoning check:\nPurpose: Check whether the reasoning process is consistent\nRule: Any inconsistent step makes the check fails\n"

backward_beginning_guide = "\n\nNow, please disregard the original question and focus on the provided reasoning steps. Use these steps to infer and guess the original question. The guessed question should not be output.\n\nEnd with \"yes\" or \"no\" for whether the backward check passes.\n\nAnswer:\nBackward check:\nObjective: Check whether the guessed question is semantically similar to the original question.\nRule: Any semantic difference causes the validation to fail.\n"

# Prompts dictionary
prompts = {
    "commonsense_enhanced_generation": (reasoning_one_shot, reasoning_beginning_guide),
    "conditions_check": (condition_forward_verification_one_shot, condition_beginning_guide),
    "logic_check": (logic_forward_verification_one_shot, logic_beginning_guide),
    "backward_verification": (backward_verification_one_shot, backward_beginning_guide),
}

# Prompt generation function
def prompt_fn(question, mode):
    prompt, guide = prompts[mode]
    return "\n".join(prompt) + question + guide