DEV Community

Devanshu Biswas
Devanshu Biswas

Posted on

Maieutic prompting: reason as a tree you can audit, not a chain you must trust — and prune the contradiction a vote never sees

Ask a model a deceptively simple question — "Is a whale a fish?" — and a single chain of thought can wander into the intuitive-but-wrong answer: it lives in water, it swims, so it's a fish. Chain-of-thought has no self-check; one bad step sails straight through. Self-consistency samples many chains and votes, which fixes random slips but not a shared wrong intuition — a vote measures agreement, not truth. I built an interactive demo of a third option that beats both, and the tree and the pruning are real JavaScript, not a canned animation. Here is the idea.

Explain both ways, then recurse into a tree

Maieutic prompting (from the Greek for the Socratic "midwife" method) doesn't ask "what's the answer?" It asks the model to explain the proposition as true, and separately as false. An explanation surfaces the premises the conclusion rests on. Then the recursive move: treat each premise as a new proposition and explain it both ways too, down to a fixed depth. What you get is not a chain but a tree of explanations bottoming out in simple, checkable claims.

async function grow(prop, depth) {
  const node = { prop, children: [] };
  if (depth === 0) return node;                 // stop at max depth
  for (const side of ["TRUE", "FALSE"]) {
    const expl = await llm(`${prop}\nThis is ${side} because`);
    for (const premise of extractPremises(expl))
      node.children.push(await grow(premise, depth - 1)); // <-- recurse
  }
  return node;                                   // a real explanation TREE
}
Enter fullscreen mode Exit fullscreen mode

Logical integrity is the key filter

For every node, ask the model to defend it as true and as false. If it firmly holds one side and can't honestly argue the other — it hedges, refuses, or contradicts itself — the node is logically integral, a trustworthy anchor you can treat almost like a hard fact. If it happily argues both, it's shaky and gets a low weight. "A whale is a mammal" defends only one way; "anything that lives in water is a fish" flips under pressure. Integrity is how the method separates real facts from the model's careless over-generalisations.

Build a consistency graph, then solve MAX-SAT

Next, ask whether pairs of propositions are consistent or contradictory. Contradictions become edges, and now the tree is also a graph of logical constraints: nodes weighted by integrity, edges marking incompatibilities. In the whale tree there's a sharp one — the shaky "anything in water is a fish" directly contradicts the integral pair "a whale is a mammal" + "mammals are not fish." Both can't be true. That collision is exactly the signal a single chain, or a vote, never produces.

Resolving it is weighted satisfiability. Each node is a variable, integral nodes are near-hard constraints (high weight), shaky ones are soft. For each contradiction, the side backed by more integrity weight wins; the loser — and the subtree built on it — is pruned.

function resolve(nodes, edges) {
  const weight = n => n.integral ? 100 : 5;      // integrity = constraint weight
  for (const e of edges.filter(e => e.type === "contradict")) {
    const loser = weight(e.a) < weight(e.b) ? e.a : e.b;
    prune(loser);                                // mark loser + descendants
    pruneAncestorsThatDependedOn(loser);         // the branch collapses
  }
  return nodes.filter(n => n.state === "active"); // consistent survivors
}
Enter fullscreen mode Exit fullscreen mode

Why pruning is not local

Losing a premise isn't a local edit — the explanation built on top of it collapses too. When "anything in water is a fish" is pruned, the whole "argues TRUE" branch that leaned on it goes red, because its conclusion no longer has a leg to stand on. Even a true, integral fact caught in that branch ("whales live in water") no longer implies "fish" once the false bridge is gone. What remains is the logically consistent subtree, every survivor compatible with every other.

The survivors all point one way — that's the answer, and they are its rationale, an auditable trail instead of a black-box verdict. The demo grows the real tree (root + two explanations + five premises), runs the contradiction traversal, weights the integral facts against the shaky premise, and reads "not a fish, it's a mammal" off what's left.

The catch is cost. Maieutic multiplies calls — explain both ways × recurse × integrity probes — so it's not for lookups or open-ended generation. Spend it on hard true/false, commonsense, and logical questions where correctness and a defensible reason are worth the price, and where the model may be unreliable at the leaves but its logic is still checkable.

Grow the tree and prune it live:
https://dev48v.infy.uk/prompt/day42-maieutic.html

Top comments (0)