Let the input words be , let be their common length, let be the finite alphabet, and let contain the dictionary words of length . Unequal input lengths immediately make the puzzle impossible because a mutation preserves length. A word ladder search problem can use the state space , with initial state ; including handles an input word not itself in the dictionary.
At word , an action is a position–letter pair with , and , permitted precisely when replacing by gives . The search transition model returns that , and the goal test is . If , the empty sequence is accepted; if and , no transition can reach .
Assign each permitted transition cost . A search node at search depth has
Thus minimizing path cost is exactly minimizing the number of mutations. Uniform-cost search, with repeated states handled by graph search and the goal test on selection, finds a shortest word ladder if one exists. Because all costs are equal, breadth-first search gives the same optimal-length guarantee.
The proposed Hamming distance is both an admissible heuristic and a consistent heuristic. Write
Every position differing from the target must change at least once along any successful word ladder. One mutation changes only one position, so every solution from has at least steps. This proves , including an unreachable target with . Dictionary restrictions may force extra changes, but cannot remove that lower bound.
Adjacent words differ in one position, so their Hamming distances to differ by at most one. Since every transition costs one,
These are exactly the consistent heuristic conditions. Equivalently, allowing all length- words gives a relaxation heuristic whose exact distance is the Hamming distance; restoring the dictionary can only increase the minimum required number of steps.
The difficulty is representing dictionary membership and the one-letter relationship in positive conjunctive STRIPS preconditions; a finite dictionary nevertheless admits an exact encoding. Pure STRIPS does not provide string indexing, a “differs in one position” operator, arbitrary disjunctive tests or a procedure that calls a dictionary lookup. Those relationships must be represented by ground facts or compiled into ground actions.
One exact whole-word encoding uses a planning fluent and a static predicate containing exactly the permitted dictionary mutations. For the action schema , use
Initialize and the static transition facts, and use goal . Only one fact is true initially. Each applicable ground action deletes it and adds exactly its permitted successor, so mathematical induction proves that exactly one current-word fact remains true and that every plan is a legal word ladder. Conversely, every legal word ladder directly supplies a plan. An isolated non-dictionary start is handled as in (c). A shortest plan has the fewest mutations.
This encoding moves the hard lexical relationship into preprocessing. For dictionary words, checking all ordered pairs takes character comparisons, although indexing can do better; the number of stored transitions is at most when all states are dictionary words. The STRIPS representation is finite, but its size and preprocessing cost matter.
A position-based representation instead uses planning fluents . Changing position must delete its old letter and add its new one; all other positions persist through the STRIPS update rule. Merely requiring each position to contain a letter admits non-dictionary strings. A disjunction over all dictionary words is not a positive conjunctive STRIPS precondition. It can be compiled into separate ground actions, each requiring every letter of a valid source word and changing one position to reach a valid destination. This again enumerates lexical cases and can be large. Arbitrary letter changes followed by an unconstrained “validate” action are unsound: several illegal intermediate strings could otherwise lead to a legal goal. Legality must hold after every mutation, not only at the endpoint.