Perform a rigorous physics derivation with systematic verification at each step
Codex shell compatibility:
gpd on PATH.GPD_ACTIVE_RUNTIME=codex uv run gpd ....
</codex_runtime_notes>Provide the equation or topic to derive as an argument (e.g., $gpd-derive-equation "effective mass from self-energy"). If no argument is given, you will be asked what to derive.
<execution_context>
<!-- [included: derive-equation.md] --> <purpose> Perform a rigorous physics derivation with systematic verification at each step. Handles the complete derivation pipeline: stating assumptions, establishing notation, performing algebraic manipulations, verifying intermediate results, checking limits, and documenting the full chain of reasoning. <process> <step name="load_context"> **Pre-Step: Load Project Context** <step name="state_problem"> **Step 0: State What We Are Deriving** <step name="establish_framework"> **Step 1: Establish Framework** </step> <step name="derive_step_by_step"> **Step 2: Perform the Derivation** </step> <step name="verify_intermediate"> **Step 3: Verify Intermediate Results** </step> <step name="state_result"> **Step 4: State the Final Result** </step> <step name="document_derivation"> **Step 5: Create Derivation Document**This workflow ensures that derivations are not just correct in their final form but verifiably correct at every intermediate step, with all assumptions explicit and all approximations justified. </purpose>
<core_principle> A derivation is a chain of logical steps from assumptions to conclusion. Every link in the chain must be verifiable. A derivation that skips steps, hides assumptions, or handwaves through approximations is not a derivation -- it is a plausibility argument.
The derivation contract: Given these assumptions and these definitions, the following result follows by mathematical necessity. No step relies on physical intuition (intuition motivates, it doesn't prove). No step invokes "it can be shown that" without showing it. No approximation is made without stating what is neglected and estimating the error. </core_principle>
<derivation_standards>
Assumptions are stated explicitly before the derivation begins.
Notation is defined before use.
Each step follows logically from the previous.
Approximations are justified and bounded.
Intermediate results are checked.
The result is clearly stated and interpreted.
</derivation_standards>
Load project state and conventions before beginning any derivation:
INIT=$(/Users/charlie/.gpd/venv/bin/python -m gpd.runtime_cli --runtime codex --config-dir ./.codex --install-scope local init phase-op --include state,config)
if [ $? -ne 0 ]; then
echo "ERROR: gpd initialization failed: $INIT"
# STOP — display the error to the user and do not proceed.
fi
state_exists: true): Extract convention_lock for metric signature, Fourier transform convention, and index ranges. Extract active approximations and their validity ranges. Load any previously established notation from STATE.md.state_exists is false (standalone usage): Proceed with explicit convention declarations required from user in Step 1. All conventions must be stated explicitly before any derivation begins.This is the most critical workflow to have convention context. Derivations without locked conventions risk sign errors, missing factors of 2pi, and metric signature inconsistencies that propagate silently through all subsequent steps.
Convention verification (if project exists):
CONV_CHECK=$(/Users/charlie/.gpd/venv/bin/python -m gpd.runtime_cli --runtime codex --config-dir ./.codex --install-scope local --raw convention check 2>/dev/null)
if [ $? -ne 0 ]; then
echo "WARNING: Convention verification failed — review before deriving"
echo "$CONV_CHECK"
fi
If the convention lock is empty but prior phases exist, this is an error — conventions should have been established. </step>
Before any calculation, write:
## Derivation Objective
**Goal:** Derive [expression/relation/equation] for [physical system/quantity].
**Starting point:** [Lagrangian/Hamiltonian/action/equation that is given, not derived here]
**Expected result:** [If known, the expression we expect to obtain. If unknown, the general form expected from dimensional analysis or symmetry arguments.]
**Method:** [Variational/perturbative/exact/saddle-point/RG/etc.]
This forces clarity about what is being assumed and what is being derived. </step>
Number each assumption:
## Assumptions
A1. [Physical assumption]: [justification, regime of validity]
A2. [Physical assumption]: [justification]
A3. [Mathematical assumption]: [when this might fail]
...
If a convention lock exists (loaded in pre-step), verify that the conventions you declare match the project lock. Run the 5-point checklist from shared-protocols.md:
If any convention differs from the lock, STOP. Either the lock needs updating (via gpd convention set) or the derivation must use the locked convention. Never derive with one convention and combine with locked results using another.
## Definitions
| Symbol | Meaning | Dimensions | Defined by |
| -------- | ------- | -------------- | ------------------------ |
| {symbol} | {name} | {[dimensions]} | {equation or convention} |
## Conventions
<!-- ASSERT_CONVENTION: natural_units={from lock}, metric_signature={from lock}, fourier_convention={from lock} -->
- Metric signature: {from convention_lock, or declared explicitly if standalone}
- Fourier transform: {from convention_lock, or declared explicitly if standalone}
- Index ranges: {Greek = spacetime 0..3, Latin = spatial 1..3, etc.}
- Operator ordering: {normal, Weyl, time, etc.}
- Coupling definition: {from convention_lock if set}
- Renormalization scheme: {from convention_lock if set}
The ASSERT_CONVENTION comment is machine-readable. The verifier and consistency checker scan for it to validate against the project lock. Include it in EVERY derivation file.
Write the starting expression explicitly with all indices, factors, and conventions visible:
## Starting Point
The action for [system] is:
$$
S[\phi] = \int d^4x \, \mathcal{L}(\phi, \partial_\mu \phi)
$$
where $\mathcal{L}$ is given by Eq. (X) of [reference], with [our convention for signs/normalization].
**Dimensional check:** [S] = [dimensionless in natural units] = [energy * time in SI]. CHECK: ...
For each step in the derivation:
State what mathematical operation you are performing:
Show enough intermediate algebra that each step can be verified independently. The appropriate level of detail:
After each major step (not every line, but every conceptually distinct operation):
ASSERT_CONVENTION header for any convention used in this step. This catches convention drift mid-derivation — the most common source of silent sign errors and missing factors of 2pi.Document the check:
**Check:** [LHS] has dimensions [energy^2 / length], [RHS] = [coupling^2] \* [field^2] / [length] = [energy^2 / length]. CONSISTENT.
<!-- ASSERT_CONVENTION: metric_signature=mostly_minus, fourier_convention=physics -->
**Convention used:** Fourier convention exp(-ikx) applied in integration by parts (consistent with lock).
If any convention in the ASSERT_CONVENTION line differs from the Step 1 declaration or the project lock, STOP immediately — a convention has drifted mid-derivation. Resolve before continuing.
When making an approximation:
**Approximation (using A2):** We expand the exponential to first order:
$$
e^{-\beta V} \approx 1 - \beta V + O(\beta^2 V^2)
$$
**Validity:** This requires $\beta V \ll 1$, i.e., $V \ll k_B T$. In our regime (T > T_c, V ~ J), this gives $J/k_B T < 0.1$, so the neglected term is $O(10^{-2})$.
**Error bound:** The leading correction is $\frac{1}{2}(\beta V)^2 \leq \frac{1}{2}(0.1)^2 = 0.005$, contributing at most 0.5% error to the final result.
At natural checkpoints in the derivation (after completing a major sub-calculation), perform verification:
Check dimensions of the intermediate result. This should be routine by now -- if it's not consistent, the error is in the last few steps.
Test the intermediate result in known limits:
**Limit check (g -> 0):**
Setting g = 0 in Eq. (7):
$$
\Sigma(p) \big|_{g=0} = 0
$$
CORRECT: The self-energy vanishes in the free theory.
**Limit check (p -> 0):**
Setting p = 0 in Eq. (7):
$$
\Sigma(0) = -\frac{g^2}{16\pi^2} m^2 \ln\frac{\Lambda^2}{m^2}
$$
CONSISTENT with standard result (Peskin & Schroeder, Eq. 10.28).
Verify that intermediate results respect required symmetries:
For complicated algebraic expressions, evaluate both sides of a key equation at random numerical parameter values:
# Spot-check: evaluate LHS and RHS of Eq. (7) at random parameters
import numpy as np
# Random physical parameters
g, m, p, Lambda = 0.3, 1.5, 2.7, 100.0
LHS = self_energy_LHS(g, m, p, Lambda)
RHS = self_energy_RHS(g, m, p, Lambda)
print(f"LHS = {LHS:.10e}")
print(f"RHS = {RHS:.10e}")
print(f"Relative diff = {abs(LHS - RHS) / abs(LHS):.2e}")
# Should be < machine epsilon if algebra is correct
When combining this derivation's results with expressions from prior phases:
If the project has a convention lock, run the cross-phase consistency check:
/Users/charlie/.gpd/venv/bin/python -m gpd.runtime_cli --runtime codex --config-dir ./.codex --install-scope local --raw convention check 2>/dev/null
Any convention drift between phases must be resolved before combining results.
## Result
Under assumptions A1-A{N}, the [quantity] is given by:
$$
\boxed{
[final expression]
}
$$
**Dimensions:** [verify]
**Regime of validity:** [where this holds]
### Interpretation
[Physical meaning of the result in 2-3 sentences. What does this expression tell us about the physics?]
### Limiting Cases Verified
| Limit | Expected | Obtained | Status |
| ------- | ------------ | ------------ | ------ |
| {limit} | {expression} | {expression} | MATCH |
### Connection to Known Results
- Reduces to [known result] when [condition] (Eq. X of [reference])
- Extends [previous result] by including [new physics]
- Resolves discrepancy between [ref A] and [ref B] by [explanation]
Write a complete, self-contained derivation document:
---