🧠 AI PROMPT PATTERN DIFFICULTY: Archmage Behavioral

The Chain-of-Thought Oracle: Distributed State Proof Rite

Unwind the probability waves of generative latent space into formal step-by-step proofs of distributed consensus, CAP edge-cases, and linearizability.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method (Behavioral)
ARCANUM SCHOOL: Divination // Step-by-Step Unwinding of Probability Waves
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// NEURAL PROMPT DIRECTIVE //
You are a formal verification theorem prover and distributed systems auditor. Prove or disprove whether the following protocol guarantees Linearizability and Fault Tolerance under an asynchronous network with crash-recovery failures: [DESCRIBE PROTOCOL & STATE TRANSITIONS]. Execute the four sacred rites of the Template Method: RITE 1: FORMAL STATE INVARIANTS - Explicitly declare all state invariants that must be upheld across every epoch. RITE 2: ADVERSARIAL TRACE RECONSTRUCTION - Construct an execution sequence with message delays, leader partitions, and concurrent writes designed to break the invariant. RITE 3: COUNTER-EXAMPLE OR FORMAL INDUCTION - Either produce the minimal violating trace or provide an inductive proof of safety. RITE 4: REMEDIATION SIGIL - If vulnerable, provide the exact state machine transition patch required to preserve linearizability.

The Lineage to the Gang of Four

In the Gang of Four canon:

  • Template Method: Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.
  • Command: Encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

When querying Large Language Models on complex mathematical, cryptographic, or distributed systems proofs, naive prompts ask for the conclusion upfront: “Is this Raft implementation linearizable?”

Because autoregressive models predict the next token based strictly on preceding tokens, demanding the conclusion immediately forces the model to guess the final answer before generating the reasoning tokens needed to verify it!

The Chain-of-Thought Oracle applies the Template Method:

  1. It prescribes a rigid four-stage invariant skeleton.
  2. It forbids jumping to conclusions until each intermediate mathematical step is calculated.
  3. It uses tokens as scratchpad memory, exponentially increasing the accuracy of formal reasoning.

The Spell Formula

Cast this incantation to formally audit distributed state machines, replication topologies, or consensus protocols:

You are a formal verification theorem prover and distributed systems auditor.
Prove or disprove whether the following protocol guarantees Linearizability, Safety, and Liveness under an asynchronous network with crash-recovery failures:

[INSERT PROTOCOL SPECIFICATION, STATE TRANSITION RULES, AND REPLICATION SCHEME]

EXECUTE THE FOUR SACRED RITES OF THE TEMPLATE METHOD:

RITE 1: FORMAL STATE INVARIANTS
Declare all mathematical invariants that MUST hold true across all client sessions, epochs, and leader terms (e.g., Single-Leader Invariant, State Machine Safety, Log Matching).

RITE 2: ADVERSARIAL TRACE RECONSTRUCTION
Construct a worst-case execution trace featuring:
- Asymmetric network partitions (Node A sees B, but B cannot see A).
- Arbitrary message drops, re-orderings, and network replay attacks.
- Crash-recovery with partial uncommitted log states and stale lease terms.

RITE 3: COUNTER-EXAMPLE OR INDUCTIVE PROOF
Evaluate whether the Adversarial Trace shatters any invariant from Rite 1:
- If vulnerable: Produce the minimal execution trace sequence violating safety.
- If safe: Provide an inductive proof by contradiction showing why no violating trace exists.

RITE 4: THE REMEDIATION SIGIL
If an invariant shattered in Rite 3, provide the exact state machine transition patch (fence tokens, term monotonicity checks, or generation IDs) to restore linearizability.

Arcane Lore: Divining the Unseen Path

In the ancient temples of Delphi, the Oracle did not shout prophecies on a whim. The priestess sat upon the bronze tripod over the chasm, inhaled the sacred vapors, followed the four sacred invocations, and unspooled the golden thread of fate knot by knot.

In neural computing, the tokens in an LLM’s context window are that golden thread. When you enforce the Template Method, you guide the needle of computation along the path of logical certainty.

Runic Tags: #ai-prompts #gof-patterns #template-method #distributed-systems #formal-verification