Research Notes

Tax situations as named rules: a symbolic model for finding the lowest lawful tax

October 22, 2026 · white paper · patent pending

Consider a software consultant in San Jose who works for herself. In 2025 she billed $180,000 and spent $30,000 running her business, so her Schedule C shows $150,000 of profit, and her preparer, or the software she uses, asks for these numbers and produces a correct return. It is worth noting, however, that this return is only one of several correct returns she could have filed. Had she formed an LLC early in the year and elected to be taxed as an S corporation, part of her profit would have been paid to her as salary and the rest would have flowed to her as a distribution, and her payroll tax would have been quite different. Had she opened a SEP-IRA before the filing deadline, she could have put away about a fifth of her net earnings and deferred the tax on it. As we will see below, the gap between the return she filed and the best of these alternatives is about $16,000 in a single year.

None of this is news to a good preparer, because the tax code gives the taxpayer choices on purpose, and each choice is lawful, changes the tax and interacts with the others in ways that are tedious to work out by hand. Preparation software asks for the facts and fills in the return that the user describes, so the lowest tax a taxpayer could lawfully pay is found, when it is found at all, through the experience and diligence of the preparer. In our white paper we describe a model that carries out this search. Let a tax situation be the facts of one taxpayer for one year, and let a rule be a named statement of one provision of the law, giving when it applies, what it changes, its limits and its citation. The model writes every rule for a year in a small language that we call Bell-Tax, matches the taxpayer's situation against all of the rules, and produces every lawful scenario as a complete return that our tax engine computes.

Download the white paper (PDF, 18 pages)

A name is a value

Bell-Tax grew out of Bell, the short-voice-prompt language of our Tesseract-Prime assistant. In Bell a user records a short name such as “morning” and binds it to a text, and since a name can be used wherever a step can, a user who has recorded “open mail” and “read inbox” can record “morning” as those two names in a row. Bell-Tax keeps this idea and adds what a tax language requires, namely typed facts, arithmetic with limits and phase-outs, elections, options with costs, loops, guards and an objective. A rule that refers to another rule by name uses it as a predicate or as a value, and the reader can look it up in the same way that a reader of the Code looks up a cross-reference:

RULE child_age_test (p) CITE "IRC 152(c)(3)"
  = FACT p.age < 19 OR (FACT p.age < 24 AND FACT p.full_time_student == YES)
    OR FACT p.permanently_disabled == YES
END

RULE qualifying_child (p) CITE "IRC 152(c)"
  = child_relationship(p) AND child_age_test(p) AND child_residence_test(p)
    AND NOT FACT p.provided_over_half_own_support == YES
    AND NOT FACT p.filed_joint_return == YES
END

RULE salt_cap CITE "IRC 164(b)(6) as amended by P.L. 119-21"
  = MAX(PHASEOUT(40000, FACT return.magi, 500000, 30%), 10000)
END

Evaluating a named rule is called resolution, and it works the way a Prolog query does. Consider a single parent with two children: Asha, who is 22 and not a student, and Ravi, who is 16 and for whom we do not yet know how many months he lived at home. To decide whether the parent can file as head of household, the resolver follows the names down until every branch rests on a fact, and when it needs a fact that it does not have, it stops and returns the question attached to that fact:

?- head_of_household_eligible

head_of_household_eligible()  [IRC 2(b)]
  any_qualifying_person()  [IRC 2(b)(1)(A)]
    count_qualifying_children()  [IRC 152(c)]
      qualifying_child(Asha)  [IRC 152(c)]
        child_relationship(Asha)  [IRC 152(c)(2)]
        child_age_test(Asha)  [IRC 152(c)(3)]
      qualifying_child(Ravi)  [IRC 152(c)]
        child_relationship(Ravi)  [IRC 152(c)(2)]
        child_age_test(Ravi)  [IRC 152(c)(3)]
        child_residence_test(Ravi)  [IRC 152(c)(1)(B)]

unknown fact  Ravi.months_lived_with_taxpayer
ASK           How many months of 2025 did this person live with you?

It is instructive to notice what was not asked. Asha fails the age test, so no further fact about her is read, and in particular nobody asks where she lived. For Ravi the residence test needs the one unknown fact, so exactly one question is asked, and it is asked because a rule needed its answer. Thus the interview is generated by the rules themselves, as the sequence of facts that resolution actually reaches for this particular taxpayer.

An agent's answer can be a rule

Some facts are judgments, such as whether a receipt is a business expense or what a reasonable salary is for an occupation. A language model is good at judgments of this kind, and it is unreliable at arithmetic that nobody checks, so Bell-Tax lets a rule call a named agent and requires, with EXPECT RULE IN (...), that the agent answer with the name of one of the listed rules. The resolver then continues by resolving the rule that the agent named, with the same inputs:

AGENT receipt_reader
  MODEL "vision-language model, zero data retention"
  ROLE "Read one receipt or invoice and say which provision governs it."
  TOOLS (document_text, document_image)
END

RULE receipt_treatment (r) CITE "IRC 162; IRC 262; IRC 274(n); IRC 263(a); IRC 280A"
  = AGENT(receipt_reader, "Which of these provisions governs this receipt?", FACT r.text)
    EXPECT RULE IN (business_meal, business_supply, home_office_cost, rental_repair,
                    rental_improvement, personal_expense) CONFIRM
END

RULE business_meal (r) CITE "IRC 274(n)(1)" = 50% * FACT r.amount END

RULE rental_improvement (r) CITE "IRC 263(a); IRC 168(c); Rev. Proc. 87-57 Table A-6"
  = FACT r.amount * TABLE("macrs_residential_27_5_first_year", FACT r.month_placed_in_service)
END

RULE personal_expense (r) CITE "IRC 262" = 0 END
?- receipt_treatment("Dinner with client, Acme Corp", 180.00)
  assumed (AGENT receipt_reader, to confirm): ... -> business_meal
  business_meal(Dinner with client)  [IRC 274(n)(1)]
= 90.00

?- receipt_treatment("New roof, 12 Elm St rental", 14,000.00)
  assumed (AGENT receipt_reader, to confirm): ... -> rental_improvement
  rental_improvement(New roof)  [IRC 263(a); IRC 168(c); Rev. Proc. 87-57 Table A-6]
= 233.38

?- receipt_treatment("Groceries", 96.40)
  assumed (AGENT receipt_reader, to confirm): ... -> personal_expense
  personal_expense(Groceries)  [IRC 262]
= 0.00

The agent's contribution is the choice of provision on each line marked “assumed”, and the amounts come from the rules. The $90.00 is the 50% limit of §274(n)(1) applied to a $180 dinner, and the $233.38 is 1.667% of $14,000, which is the first-year rate for residential rental property placed in service in July, since a new roof is an improvement whose cost the law spreads over the building's 27.5-year life. Note that every agent answer is recorded as an assumed fact together with which agent answered, what it was asked and what it was given, that an answer outside the listed rules goes to the user instead, and that CONFIRM asks the user to accept the answer before the return is final. Since the rule an agent names may itself call an agent, a chain of such choices can run to any depth, and it ends, as every resolution does, at facts.

Options, loops and scenarios

The law gives the taxpayer two kinds of choice. An ELECT is a choice made on the return itself, such as the standard or the itemized deduction, and an OPTION is an action the taxpayer could take in the world, such as forming a company, which has a cost and may only postpone the tax it saves. It is worth reading the S corporation option line by line. It is offered only above $60,000 of profit, where the payroll savings can cover the cost of running a corporation; the wage agent is asked for the market wage in the taxpayer's metro area, and the salary is that wage or 40% of profit, whichever is larger; and the employer's payroll tax, a $42 unemployment tax and $1,200 of administration make up the cost.

RULE scorp_option CITE "IRC 1361; IRC 1362; IRC 1366; IRC 3111" {
  IF FACT return.schedule_c_net > 60000 AND FACT taxpayer.entity_type == "none" THEN {
    LET market = AGENT(wage_researcher, "Median annual wage for this occupation and metro area",
                       FACT taxpayer.occupation, FACT taxpayer.metro_area) EXPECT money CONFIRM
    LET salary = MAX(market, 40% * FACT return.schedule_c_net)
    LET employer_fica = 7.65% * salary
    LET k1 = FACT return.schedule_c_net - salary - employer_fica - 42 - 1200
    OPTION form_llc_elect_s "Form an LLC and elect S-corporation status (Form 2553)"
      COST employer_fica + 42 + 1200 {
      SET FORM "W-2" LINE "1" = salary
      SET FORM "Schedule K-1 (1120-S)" LINE "1" = k1
      SET FACT return.schedule_c_net = 0
      SET FACT return.k1_final = k1
      SET FACT taxpayer.entity_type = "s_corp"
      USE form_1120s
    }
  } END
} END

SET FORM writes a line of the scenario's return, while SET FACT changes the scenario's facts, and the second matters more than it might first appear. Once the business is an S corporation it has no Schedule C, so any rule that reads Schedule C profit, such as the SEP-IRA option, sees zero in that scenario and is not offered there.

One might ask why a tax language needs a loop that runs until convergence, and the answer is that the law itself contains a circular computation. The self-employed health insurance deduction lowers income, which raises the premium tax credit, which in turn lowers the premiums that are left to deduct, and Rev. Proc. 2014-41 resolves the circularity by iteration. Bell-Tax has REPEAT ... UNTIL ... LIMIT for this, with a required limit so that every program terminates. For a taxpayer with $58,000 of income before the deduction and $9,600 of premiums, the two values move toward each other from opposite sides and agree to the dollar after six passes:

RULE sehi_and_ptc CITE "IRC 162(l); IRC 36B; Rev. Proc. 2014-41 sec. 4" {
  LET d = 0
  REPEAT {
    LET ptc = MIN(premium_tax_credit(FACT return.agi_before_sehi - d), FACT return.premiums)
    LET d_next = MIN(FACT return.premiums - ptc, FACT return.schedule_c_net - FACT return.se_tax / 2)
    LET delta = d_next - d
    LET d = d_next
  } UNTIL delta < 1 AND delta > -1 LIMIT 25 END
  SET FORM "Schedule 1" LINE "17" = d
  SET FORM "8962" LINE "24" = ptc
} END
pass   premium tax credit   SE health deduction
   1             3,685.67              5,914.33
   2             4,677.77              4,922.23
   3             4,519.46              5,080.54
   4             4,544.94              5,055.06
   5             4,540.84              5,059.16
   6             4,541.50              5,058.50

When the resolver reaches an election or an option, it forks, and each branch becomes a scenario that is evaluated on its own copy of the facts. If one rule writes a fact that another rule reads, the writer runs first, in the way that stratified Datalog orders its rules, so each option is tested on the facts left by the options before it. A choice that interacts with nothing, such as the deduction once the options are fixed, is settled inside each scenario by taking the better branch, which keeps the number of scenarios small. Each scenario's form lines then go to the same engine that computes returns in production at Tesseract-Tax Cloud, so every scenario is a complete return that could be filed as it stands, and guards with citations remove the scenarios that would not survive an examination before an objective ranks the rest.

The consultant's four returns

For the consultant, the resolver enumerated sixteen branches, settled the deduction inside each one to leave eight, and found four distinct returns. Their totals for 2025, computed by our production engine, are as follows, where Federal includes self-employment tax for the sole proprietor, CA includes California's S corporation tax, and Deferred is the retirement contribution on which tax is postponed:

ScenarioFederalCAFICACostsTotalDeferred
S corporation + solo 401(k)11,3865,7756,1207,36230,64343,500
Schedule C + SEP-IRA32,9666,1270039,09227,881
S corporation20,2939,9606,1207,36243,7350
Schedule C (as filed today)37,8728,7190046,5910

It is worth looking at where the savings come from. The S corporation alone saves $2,856, and three effects pull against one another to produce that figure: the payroll tax on an $80,000 salary, $6,120 from each side, replaces most of the $21,194 of self-employment tax; the §199A deduction is roughly halved, because only the K-1 income qualifies; and California charges the S corporation 1.5% of its income, with an $800 minimum. The SEP-IRA saves $7,499 this year, but $27,881 of the contribution behind that saving will be taxed when it is withdrawn, and the S corporation with a solo 401(k) is the lowest at $30,643, with $43,500 likewise deferred. Since money in a retirement plan is taxed when it comes out, the model reports the deferred amount beside the total so that the user can weigh the two.

The $80,000 salary is the wage agent's answer, which raises the question of whether the user should actually be asked about it. To find out, we re-evaluated the S corporation scenario across a range of salaries with the same engine. At $60,000, $80,000 and $100,000 its totals are $40,474, $43,735 and $47,180, against $46,591 for the sole proprietorship, so the S corporation wins only for salaries below about $96,700. If the plausible range of salaries for her occupation reaches that point, the salary decides the recommendation and the user is asked to confirm it, and if the range stays well below, the assumption is reported with its margin and the user is not troubled with it.

Beyond tax

Nothing in the language is specific to tax except the rule packs, and any body of rules that decides outcomes from facts, allows choices and admits actions with costs can be written in the same way. Clinical guidelines become rule packs whose guards are contraindications, an identification key in botany becomes a chain of agent questions in which each answer names the next couplet, and a statute becomes a rule pack like any other. To show this, we wrote three small packs from other fields and ran them through the same resolver:

?- rhythm(patient)
  assumed (AGENT ecg_reader, to confirm): Which rhythm is this? -> atrial_fibrillation
  atrial_fibrillation(patient)
    anticoagulation_indicated(patient)
      cha2ds2_vasc(patient) = 3; anticoagulation_indicated = YES
  ELECT agent_choice: doac | warfarin  (GUARD mechanical_valve applies)

?- couplet_1(leaf)
  assumed (AGENT leaf_reader): Are the leaf lobes pointed with bristle tips... -> couplet_3
  couplet_3(leaf)
    assumed (AGENT leaf_reader): Is the leaf underside pale and densely hairy... -> quercus_bicolor
= Quercus bicolor

?- deposit_cap(lease)
  small_landlord(lease)  [Cal. Civ. Code 1950.5(c)(4), AB 12 (2023)]
= 6,000.00

Limits

We would like to be plain about what the model cannot do. It is only as complete as its rule packs, so a provision that has not been written is a scenario that will not be found, and writing the rules for one year is a large body of work, although most of each year inherits from the year before. The enumeration grows exponentially with the number of interacting options, which is manageable for an individual and will need further search methods for a business with many entities. Agent answers are assumptions, and confining them to listed rules, recording where they came from and asking the user to confirm the ones that matter reduce the risk of a wrong one without removing it. The strategies that the model finds are well known to practitioners, and our contribution is the representation and the machinery that find them from the facts, check them and produce the returns. For all of these reasons the model makes recommendations, and the taxpayer and the preparer remain responsible for the return that is filed.

The white paper covers the language in more detail, reviews the prior work from Sergot's Prolog program for the British Nationality Act and Catala to the IRS Fact Graph, and walks through all five worked examples with their rule listings and traces. The method is the subject of U.S. Provisional Patent Application No. 64/181,729.

Download the white paper (PDF, 18 pages)

The signature

The PDF is digitally signed by KnotTheory.ai Inc. and carries a timestamp from FreeTSA, so any change to the file after signing invalidates the signature. The certificate is our own, which means that a PDF reader reports the signer as unknown until the certificate is trusted. To check it, download our signing certificate, confirm that its SHA-256 fingerprint is

1E:4C:26:93:30:B9:8D:E3:B5:A4:A0:64:DC:CC:13:92:CF:99:D5:F9:BC:8C:B5:23:C7:25:C8:B7:06:FB:C1:B0,

and add it as a trusted certificate in your reader.

← All posts