Skip to content

Minimize Montana separate-filing tax and keep joint filing on ties - #10840

Draft
MaxGhenis wants to merge 9 commits into
mainfrom
fix-mt-medical-credit-allocation
Draft

MaxGhenis wants to merge 9 commits into
mainfrom
fix-mt-medical-credit-allocation

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Minimize Montana's separate-column tax when a capital gain credit exhausts one column's liability. Keep joint filing when separate savings fall within one cent plus float32 roundoff, and apply that comparison to the 2021 rebate base and tax before refundable credits.

Spouses may choose joint or separate Montana filing. Couples who file jointly federally may allocate jointly paid expenses not attributable to one spouse in any proportion (2022 Form 2 instructions, PDF page 11). Residents may claim a nonrefundable credit equal to 2% of net capital gains (page 43).

The medical chooser adds two closed-form candidates: the shares where each spouse exhausts their capital gain credit. It inverts the existing rate schedule and accounts for the existing dependent-exemption allocation, without a numerical search or simulation branches. Zero-credit columns add no eligible candidate. The new zero-credit YAML case preserves the former balancing share when both columns owe zero.

For example, in 2022 the head earns $10,000 of wages and $10,000 of long-term gains, the spouse earns $20,000, and their child has $25,000 of medical bills. The former candidate set chooses the equal split and combined line 20 of $65.70. A 10,001-share calculation reaches $3.70 at 0.2632, a $62.00 gap. The new candidate reaches that point: head taxable income $9,500 uses the $200 credit, while the spouse pays 1% of $370.

Invariants and validation

  • The chosen share stays between zero and one. In exact arithmetic, the candidate set contains a minimum under the existing dependent-exemption convention; the chooser retains its sequential cent-tie comparisons.
  • Over generated cases with up to $80,000 AGI per spouse and deterministic $100,000 witnesses, combined line 20 stays within $0.05 of an independent 1,001-share grid. Label swaps and added bills use that tested tolerance. Float32 error grows with amounts, so this dollar bound does not extend to every possible income.
  • Without capital gain credits, the chooser retains its former candidate set and comparisons. After separate filing ends, the head share keeps its default.
  • Filing comparisons retain joint filing unless savings exceed $0.01 plus float32 precision times max(sum(abs(columns)), abs(joint)). The rebate base and tax before refundable credits use the same comparison.
  • Other states and years from 2024 retain their existing filing calculations.

test_mt_medical_credit_split_properties.py checks the grid, accounting at the chosen share, label swaps, and added bills. Its deterministic witnesses cover 2021–2023 and credit thresholds below and above the last rate bracket. test_mt_filing_choice_invariants.py checks filing ties, label swaps, rebate-base accounting and the 2024 cutoff. Its helper properties check nominal cent ties through $100,000 per column, including negative columns, and distinguish $0.009 from $0.011 savings through $2,000 per column. The YAML files cover worked households, both sides of credit exhaustion, offsetting columns at cent ties, an unmarried filer, and the 2021 rebate cap.

Local single-file checks passed: 7 medical-share YAML cases, 13 filing YAML cases, 3 rebate YAML cases, 6 income-tax YAML cases, 6 existing split-property tests, 4 new credit-property tests and 3 new filing-property tests. make format passed.

Eight mutants failed targeted assertions across the staged checks:

  • Removing credit candidates: 2 failures.
  • Omitting dependent exemptions: 2 failures.
  • Restoring the strict filing comparison: 3 failures.
  • Restoring the strict rebate comparison: 2 failures.
  • Removing float32 roundoff: 3 failures.
  • Ignoring refund cancellation: 1 failure.
  • Enabling zero-credit candidates: 1 failure.
  • Omitting credit extrapolation above the last bracket: 1 failure.

After restoration, all 4 credit-property tests and all 3 filing-property tests passed again. The final property and mutant runs used 4 GB and 900-second caps. Draft PR CI jobs remain skipped.

Microsimulation impact

To be measured before merge.

Methodology choices

  • Preserve Count dependents' medical bills in Montana's separate-filing medical deduction #10276's assumption that spouses jointly paid dependents' bills. Hold other deductions fixed and retain the existing dependent-exemption allocation convention.
  • Continue minimizing tax before refundable credits, as in Count dependents' medical bills in Montana's separate-filing medical deduction #10276. Couples filed their 2021 returns before the later rebate law. Minimizing line 20 can reduce the 2021 rebate and raise tax after that rebate.
  • Preserve joint filing on exact ties and extend it to differences within one cent plus float32 roundoff. Taxpayers may choose either method. The itemizing election retains its separate larger-deduction fallback.
  • Compare savings in float64. Allow float32 precision times the larger of the separate columns' summed absolute taxes and the absolute joint tax for input rounding. Count negative columns by their absolute amounts so refunds cannot hide rounding exposure. At larger tax amounts, float32 inputs can leave savings just above one cent unresolved; preserve joint filing within that uncertainty.
  • Preserve the medical chooser's sequential cent-tie convention. Its tests allow $0.05 for accumulated ties and float32 arithmetic.
  • Apply the filing tolerance to all three repeated comparisons. In 2021, changing the rebate base can move the rebate by more than one cent when a spouse reaches its cap; the rebate YAML checks this case.
  • Both filing alternatives subtract the same refundable-credit total for the final election. The rebate base and tax before refundable credits compare line 20.
  • Add no inputs or parameters. The inverse uses the common rate schedule only while the capital-gain-credit regime applies; later capital-gains rates retain their existing path.
  • Test the credit rule in 2021–2023. The historical companion verifies 2017–2020 parameter history; pre-2017 carryback remains unverified.

Overlap with open work

Companion draft PR #10847 addresses the other #10276 follow-ups. The two PRs edit separate files and can merge independently.

#10002 and #9888 change Montana itemized deductions. This PR touches neither their files nor mt_non_medical_itemized_deductions_indiv. Their component-list edits still need to move into that variable when they merge main.

The credit-aware split reduces some historical liabilities before refundable credits; net 2021 tax can rise or fall through the rebate cap. The filing tolerance changes near-tie elections in 2022–2023 and can change the 2021 rebate. The #10276 audit records that the default dataset starts in 2024, so it cannot estimate the affected 2017–2023 population.

axiom: extend TheAxiomFoundation/rulespec-us#1520 with credit-exhaustion and filing-tie companion cases.

🤖 Generated with Claude Code

MaxGhenis and others added 9 commits November 12, 2026 01:03
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis changed the title Minimize Montana tax at capital gain credit boundaries Minimize Montana separate-filing tax and keep joint filing on ties Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant