| name | gpd-limiting-cases |
| description | Systematically identify and verify all relevant limiting cases for a result or phase |
| argument-hint | [phase number or file path] |
| context_mode | project-aware |
| allowed-tools | ["read_file","write_file","shell","grep","glob","ask_user"] |
<codex_runtime_notes>
Codex shell compatibility:
- When shell steps call the GPD CLI, use /Users/charlie/.gpd/venv/bin/python -m gpd.runtime_cli --runtime codex --config-dir ./.codex --install-scope local instead of the ambient
gpd on PATH.
- If you intentionally need the repo environment, keep the runtime pin:
GPD_ACTIVE_RUNTIME=codex uv run gpd ....
</codex_runtime_notes>
<codex_questioning>
- Ask each user-facing question exactly once.
- Present options once.
- Do not restate the prompt or add meta narration.
</codex_questioning>
Systematically identify all relevant limiting cases for a physics result and verify that each limit is correctly recovered. This is the single most powerful verification tool in theoretical physics.
Why a dedicated command: Checking limiting cases ad hoc misses limits. A systematic audit ensures every physically meaningful limit is checked. When a result fails a known limit, the error is localized: something in the derivation breaks in that regime, which dramatically narrows the search space for debugging.
The principle: Every new result must reduce to known results in appropriate limits. If it doesn't, the new result is wrong (or the known result is wrong, which is rare but possible). There are no exceptions to this principle.
Target: $ARGUMENTS
Interpretation:
- If a number (e.g., "3"): check limits for all results in phase 3
- If a file path: check limits for results in that file
- If empty: prompt for target
Load known framework:
cat .gpd/research-map/FORMALISM.md 2>/dev/null | grep -A 20 "Known Limiting Cases"
cat .gpd/research-map/VALIDATION.md 2>/dev/null | grep -A 30 "Limiting Cases"
<execution_context>
Systematically identify all relevant limiting cases for a physics result and verify that each limit is correctly recovered. This is the single most powerful verification tool in theoretical physics.
Called from $gpd-limiting-cases command. Produces LIMITING-CASES.md report.
Every new result must reduce to known results in appropriate limits. If it doesn't, the new result is wrong (or the known result is wrong, which is rare but possible). There are no exceptions to this principle.
0. Load Project Context
Load project state and conventions to identify applicable limits:
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"
fi
- If init succeeds (non-empty JSON with
state_exists: true): Extract convention_lock for unit system and sign conventions. Extract intermediate_results from state for previously verified expressions. Extract active approximations and their validity ranges — these define the limits to check.
- If init fails or
state_exists is false (standalone usage): Proceed with explicit convention declarations required from user via ask_user.
Active approximations from the project state directly inform which limits are most important to verify (e.g., if a perturbative approximation is active, the free-theory limit g→0 is mandatory).
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 checking limits"
echo "$CONV_CHECK"
fi
Limiting case checks depend on conventions — e.g., the sign of k^2 = m^2 vs k^2 = -m^2 in the non-relativistic limit depends on metric signature.
1. Identify the Result(s) to Check
Scan the target for the main physics results:
grep -n "result\|final\|=.*\\\\frac\|=.*\\\\sqrt\|=.*\\\\sum\|=.*\\\\int\|E\s*=\|Z\s*=\|sigma\s*=\|Gamma\s*=" "$TARGET_FILE" 2>/dev/null
grep -n "\\\\label\|\\\\tag\|# Eq\." "$TARGET_FILE" 2>/dev/null
For each result, identify:
- What physical quantity it represents
- What parameters it depends on
- What the physical system is
2. Identify All Relevant Limits
For each result, systematically enumerate limits organized by physics domain:
Universal Limits (check for every result)
| Limit | Parameter | Expected Behavior |
|---|
| Free theory | coupling g -> 0 | Reduce to non-interacting result |
| Classical | hbar -> 0 | Reduce to classical expression |
| Static | omega -> 0 or v -> 0 | Reduce to time-independent result |
| Single particle | N -> 1 | Reduce to one-body problem |
Thermodynamic Limits
| Limit | Parameter | Expected Behavior |
|---|
| High temperature | T -> infinity (beta -> 0) | Classical equipartition |
| Low temperature | T -> 0 (beta -> infinity) | Ground state dominance |
| Thermodynamic | N -> infinity, V -> infinity, N/V fixed | Intensive quantities well-defined |
| Ideal gas | interactions -> 0 | PV = NkT or quantum ideal gas |
| Dilute | density -> 0 | Ideal gas behavior |
Quantum Mechanical Limits
| Limit | Parameter | Expected Behavior |
|---|
| Non-relativistic | v/c -> 0 or E << mc^2 | Schrodinger equation |
| Semiclassical | large quantum numbers | Correspondence principle |
| Weak field | perturbation -> 0 | Unperturbed result + linear correction |
| Strong field | perturbation -> infinity | Known strong-coupling result (if exists) |
| Harmonic | anharmonicity -> 0 | Equally spaced levels |
Field Theory Limits
| Limit | Parameter | Expected Behavior |
|---|
| Tree level | hbar -> 0 or g -> 0 | Classical field theory |
| Free field | all couplings -> 0 | Free propagators, no scattering |
| Non-relativistic | p << mc | Schrodinger field theory |
| Low energy | E << Lambda | Effective field theory |
| Large N | N -> infinity | Saddle point / mean field |
| Abelian | gauge group -> U(1) | QED-like result |
Condensed Matter Limits
| Limit | Parameter | Expected Behavior |
|---|
| Continuum | lattice spacing a -> 0 | Continuum field theory |
| Single-site | hopping -> 0 | Atomic limit |
| Mean-field | d -> infinity | Saddle point exact |
| Non-interacting | U -> 0 | Band structure |
| Half-filling | n = 1 | Particle-hole symmetry |
Gravitational / Relativistic Limits
| Limit | Parameter | Expected Behavior |
|---|
| Newtonian | weak field, slow motion | Newton's gravity |
| Flat spacetime | G -> 0 | Special relativity |
| Non-relativistic | v << c | Galilean invariance |
| Schwarzschild | spherical symmetry | Known exact solution |
| Cosmological | large scales | FRW metric |
Spatial / Geometric Limits
| Limit | Parameter | Expected Behavior |
|---|
| 1D | d = 1 | Often exactly solvable |
| 2D | d = 2 | Special features (BKT, conformal symmetry) |
| Large distance | r -> infinity | Asymptotic behavior (decay, scattering) |
| Short distance | r -> 0 | UV behavior, contact terms |
| Infinite volume | L -> infinity | No finite-size effects |
3. Select Applicable Limits
Not all limits apply to every result. Select based on:
- What parameters does the result depend on? Only limits involving those parameters are relevant.
- What is the physical system? Domain-specific limits apply.
- What is known? Only check limits where the answer is independently established.
Present the selected limits:
## Limiting Cases for {Result Name}
Selected {N} applicable limits:
| # | Limit | Parameter | Known Result | Source |
|---|-------|-----------|--------------|--------|
| 1 | {limit} | {param -> value} | {known expression} | {textbook/paper} |
| 2 | ... | ... | ... | ... |
Ask the user once using a single compact prompt block if:
- Unsure which limits are known for this system
- Multiple conventions for the known result exist
- Need user to provide the expected limiting expression
4. Verify Each Limit
For each selected limit:
4a. Analytical verification (preferred)
- Write out the full expression
- Take the limit analytically (Taylor expand, set parameter to limiting value)
- Simplify
- Compare with known result
- Check: Do they match exactly? If not, what is the discrepancy?
4b. Numerical verification (when analytical is intractable)
import numpy as np
def result_function(params):
"""The result being checked."""
...
def known_limit(params):
"""The known limiting expression."""
...
param_values = [1.0, 0.1, 0.01, 0.001, 0.0001]
for val in param_values:
computed = result_function({..., limit_param: val})
expected = known_limit({..., limit_param: val})
ratio = computed / expected
rel_error = abs(computed - expected) / abs(expected)
print(f"param={val:.0e} computed={computed:.10f} expected={expected:.10f} ratio={ratio:.10f} rel_err={rel_error:.2e}")
4c. Classify the result
| Status | Meaning |
|---|
| EXACT MATCH | Analytical limit reproduces known result identically |
| NUMERICAL MATCH | Converges to known result within numerical precision |
| CORRECT ORDER | Leading term matches; subleading terms expected to differ |
| DISCREPANCY | Does not match -- error in derivation or in known result identification |
| DIVERGENT | Limit does not exist (may be physical or may indicate error) |
| CANNOT CHECK | Limit is intractable analytically and numerically |
5. Diagnose Failures
For any limit that fails:
-
Characterize the discrepancy:
- Wrong by a constant factor? (Suggests normalization or combinatorial error)
- Wrong sign? (Suggests convention mismatch or parity error)
- Wrong functional form? (Suggests wrong starting point or missed contribution)
- Divergent where finite expected? (Suggests regularization issue)
-
Localize the error:
- At which step in the derivation does the limit first fail?
- Binary search: check intermediate expressions in the same limit
-
Suggest cause:
- Common: missing factor of 2 from spin, wrong Fourier convention, missing Jacobian
- Domain-specific: missing symmetry factor, wrong boundary condition, missed diagram
6. Generate Report
Write LIMITING-CASES.md:
---
target: { phase or file }
date: { YYYY-MM-DD }
results_checked: { N }
limits_checked: { M }
limits_passed: { K }
limits_failed: { F }
status: all_passed | failures_found
---
# Limiting Cases Report
## Results Analyzed
| # | Result | Expression | Location |
| --- | ------ | ------------ | ----------- |
| 1 | {name} | {brief form} | {file:line} |
## Limits Verified
| # | Result | Limit | Parameter | Expected | Obtained | Status |
| --- | -------- | ------------ | ---------------- | -------- | ---------- | ----------- |
| 1 | {result} | {limit name} | {param -> value} | {known} | {computed} | MATCH |
| 2 | {result} | {limit name} | {param -> value} | {known} | {computed} | DISCREPANCY |
## Failed Limits
### Failure {N}: {Result} in {Limit}
- **Parameter:** {param -> value}
- **Expected:** {expression from known result}
- **Obtained:** {expression from our result in this limit}
- **Discrepancy:** {factor of 2, wrong sign, wrong power, etc.}
- **Likely cause:** {what went wrong}
- **Location of error:** {where in the derivation the limit first fails}
## Summary
- Results checked: {N}
- Total limits applicable: {M}
- Passed: {K}
- Failed: {F}
- Cannot check: {C}
- {Overall assessment}
Singular Limit Handling
Many physics limits are singular: the result is qualitatively different depending on the order in which limits are taken, or the limiting expression is distributional rather than pointwise convergent. These require special treatment.
Non-Commuting Limits
When two parameters approach limits simultaneously, the order matters. The result can change qualitatively.
Protocol:
- Take limit A first, then limit B: compute lim_B lim_A f(A, B)
- Take limit B first, then limit A: compute lim_A lim_B f(A, B)
- Compare: if results differ, the limits do not commute
- Identify the physical regime: which ordering corresponds to the physical situation?
- Document both orderings and state which one is used and why
Common non-commuting limits:
- Thermodynamic limit (N → ∞) vs zero temperature (T → 0): SSB only appears if N → ∞ taken first
- Infrared limit (k → 0) vs massless limit (m → 0): IR divergences depend on ordering
- Continuum limit (a → 0) vs infinite volume (L → ∞): finite-size artifacts vs discretization artifacts
- External field → 0 vs volume → ∞: spontaneous magnetization requires V → ∞ first
Distributional Limits
When the limiting expression involves delta functions or other distributions, pointwise comparison is meaningless.
Protocol:
- Do not compare functions pointwise; compare their action on test functions
- Compute moments: integral x^n f_epsilon(x) dx for several n
- Verify moments converge to the expected values of the limiting distribution
- For delta-function limits: verify normalization (integral f_epsilon dx → 1) and localization (width → 0)
- Check that derivatives of the limiting distribution match: f_epsilon' should approach delta' in the distributional sense
Examples:
- sin(Nx)/(pi*x) → delta(x) as N → ∞ (Dirichlet kernel)
- (1/sqrt(2pisigma^2)) exp(-x^2/(2*sigma^2)) → delta(x) as sigma → 0
- epsilon/(x^2 + epsilon^2)/pi → delta(x) as epsilon → 0 (Lorentzian representation)
Stokes Phenomena
Asymptotic expansions can change form discontinuously as the direction of approach in the complex plane varies.
Protocol:
- Identify the anti-Stokes lines where exponentially small terms switch on/off
- Track the Stokes multiplier (typically ±i) across each anti-Stokes line
- Verify the asymptotic expansion in each sector of the complex plane independently
- Check: the exact function is continuous across Stokes lines, even though its asymptotic representation changes
- For physical problems: determine which sector of the complex plane the physical parameter lies in
Common contexts:
- WKB approximation near turning points
- Airy function asymptotics (oscillatory vs exponentially decaying sectors)
- Gamma function asymptotics (Stirling's formula plus exponentially small corrections)
- Resurgent asymptotics in quantum mechanics and QFT
Thermodynamic Limit Subtleties
The limit N → ∞, V → ∞ with N/V fixed introduces subtleties that can invalidate naive interchange of limits with differentiation or integration.
Protocol:
- Verify that the free energy density f = F/V has a well-defined limit as V → ∞
- Check that differentiation commutes with the thermodynamic limit: does (∂f/∂T)_V computed at finite V converge to the derivative of the limiting f?
- At phase transitions: the free energy is non-analytic in the thermodynamic limit but analytic at finite V. Finite-size rounding near T_c must be accounted for
- For first-order transitions: the Maxwell construction (equal-area rule) applies only in the thermodynamic limit; at finite V, metastable states have finite lifetime
- For spontaneous symmetry breaking: the order parameter is zero at finite V (by symmetry) but nonzero in the thermodynamic limit. Take V → ∞ before removing the symmetry-breaking field
Ensure output directory exists:
mkdir -p .gpd/analysis
Save to:
- Phase target:
${phase_dir}/LIMITING-CASES.md
- File target:
.gpd/analysis/limits-{slug}.md
7. Present Results and Route
If all pass:
## Limiting Cases: All {M} limits verified
{Result} correctly reduces to known expressions in all checked limits.
Confidence: HIGH
If failures found:
## Limiting Cases: {F}/{M} limits failed
{List failures with discrepancy character}
Suggested next steps:
- `$gpd-debug` -- investigate the failing limit(s)
- `$gpd-dimensional-analysis` -- check for dimensional errors near the failure
- Review derivation at {location} where the limit first diverges from expectation
Commit the report:
PRE_CHECK=$(/Users/charlie/.gpd/venv/bin/python -m gpd.runtime_cli --runtime codex --config-dir ./.codex --install-scope local pre-commit-check --files "${OUTPUT_PATH}" 2>&1) || true
echo "$PRE_CHECK"
/Users/charlie/.gpd/venv/bin/python -m gpd.runtime_cli --runtime codex --config-dir ./.codex --install-scope local commit \
"docs: limiting cases verification — ${phase_slug:-standalone}" \
--files "${OUTPUT_PATH}"
Where ${OUTPUT_PATH} is the path where LIMITING-CASES.md was written.
LIMITING-CASES.md written with full verification results.
<success_criteria>
</execution_context>
Pre-flight check:
CONTEXT=$(/Users/charlie/.gpd/venv/bin/python -m gpd.runtime_cli --runtime codex --config-dir ./.codex --install-scope local --raw validate command-context limiting-cases "$ARGUMENTS")
if [ $? -ne 0 ]; then
echo "$CONTEXT"
exit 1
fi
Follow the limiting-cases workflow: @./.codex/get-physics-done/workflows/limiting-cases.md
For comprehensive verification (dimensional analysis + limiting cases + symmetries + convergence), use $gpd-verify-work.
<success_criteria>