Prompt Engineering Tutorial and Prompt PracticePrompt Library
Rhyming Proofs
Poem with rhymes prompt example
CHAPTER PROMPT DECISION
01Prompt problem
Poem with rhymes prompt example
02Reviewable output
A reusable prompt, example set, evaluation record or safety rule with its task boundary preserved.
03Definition of done
Run at least one representative case, inspect the result and record what still requires human review.
TL;DR
- This is a "proof + poetry"
creativitytest: every line must rhyme while expressing the proof of "infinitely many primes." - Good for: generation under heavy format constraints (rhymes/meter/structure), and embedding logical content in artistic expression.
- Risk: the rhymes land but the proof isn't rigorous. Require key argument steps to be explicitly included, and do a
self-check.
Background
This prompt tests an LLM's natural language and creative capabilities by prompting it to write a proof of infinitude of primes in the form of a poem.
How to Apply
Split the constraints and spell them out:
- Logic constraint: Must express the Euclid-style core construction and contradiction
- Form constraint: Every line rhymes; specify line count range; whether to split into stanzas
If you care more about proof correctness, require a 3-5 line "plain explanation" at the end of the output.
How to Iterate
- Specify the rhyme scheme (e.g., AABB or ABAB) to reduce model randomness
- Specify line count (e.g., 8-12 lines) to avoid rambling
- Add
self-check: list which lines correspond to which proof steps - Have the model output the proof outline first, then the poem (two-pass)
Self-check Rubric
- Does it satisfy the rhyme constraint (every line rhymes)?
- Are all key proof steps present and logically sound?
- Are there any math errors or bait-and-switch reasoning?
- Is the output readable, with no conflicting constraints?
Practice
Exercise: using the same format constraints, rewrite the proof of another simple result (e.g., "sum of two even numbers is even") and have the model output:
- poem
- 3-line plain explanation
- proof steps mapping to line numbers
Prompt
Can you write a proof that there are infinitely many primes, with every line that rhymes?
Code / API
OpenAI (Python)
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[
{
"role": "user",
"content": "Can you write a proof that there are infinitely many primes, with every line that rhymes?",
}
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
)
Fireworks (Python)
import fireworks.client
fireworks.client.api_key = "<FIREWORKS_API_KEY>"
completion = fireworks.client.ChatCompletion.create(
model="accounts/fireworks/models/mixtral-8x7b-instruct",
messages=[
{
"role": "user",
"content": "Can you write a proof that there are infinitely many primes, with every line that rhymes?",
}
],
stop=["<|im_start|>", "<|im_end|>", "<|endoftext|>"],
stream=True,
n=1,
top_p=1,
top_k=40,
presence_penalty=0,
frequency_penalty=0,
prompt_truncate_len=1024,
context_length_exceeded_behavior="truncate",
temperature=0.9,
max_tokens=4000,
)