❯ /meterbill — billing rules synthesized from English
No human wrote these billing rules.
Each rule below started as a plain-English sentence a product manager might write. An LLM proposed a structured spec; the nsynth synthesizer searched program space bottom-up for a program reproducing the examples; then the nCPU requirements pipeline checked it against held-out cases and an independent reference. The calculators you can type into are running those synthesized, verified programs verbatim — 8 of 8 rules earned certification and went live.
“We charge twelve dollars per seat per month. Given the number of seats on an account, return the monthly seat charge in dollars.”
fn seat_cost(x: i64) -> i64 {
if 0 != x {
return (12 * x);
}
return 0;
}“Customers who prepay for a year get two months free: take their monthly rate, multiply by ten, and that is the annual prepay price. Given the monthly rate in dollars, return the yearly price in dollars.”
fn annual_prepay(x: i64) -> i64 {
if 0 != x {
return (10 * x);
}
return 0;
}“Every account includes fifty gigabytes of storage at no cost. Beyond that we bill five dollars for each additional gigabyte; accounts at or under the fifty-gigabyte limit pay nothing. Given the gigabytes used, return the storage overage charge in dollars.”
fn storage_overage(x: i64) -> i64 {
if 50 < x {
return ((-50 + x) * 5);
}
return 0;
}“The first one hundred minutes of calls each month are free. Every minute after that costs two cents. Given the total minutes used, return the call cost in cents.”
fn call_cost(x: i64) -> i64 {
if 100 < x {
return ((-100 + x) * 2);
}
return 0;
}“Each support ticket we resolve within an hour earns the customer a five dollar credit, but the credit is capped at ten fast tickets per month — fast tickets beyond the tenth earn nothing extra. Given the number of tickets resolved within an hour, return the credit in dollars.”
fn support_credit(x: i64) -> i64 {
if 10 < x {
return 50;
}
return (5 * x);
}“Customers earn one loyalty point for every dollar they spend. On top of that, any portion of a purchase above one hundred dollars earns a second point per dollar. Given a purchase amount in whole dollars, return the loyalty points earned.”
fn loyalty_points(x: i64) -> i64 {
if 100 < x {
return ((-100 + x) + x);
}
return x;
}“API calls are billed in tiers: the first one thousand calls each month are free, the next nine thousand calls cost two cents each, and every call beyond ten thousand costs one cent each. Given the number of calls, return the bill in cents.”
fn api_bill(x: i64) -> i64 {
if x <= 1000 {
return 0;
}
if x <= 10000 {
return ((2 * x) + -2000);
}
return (x + 8000);
}“Each account pays twelve dollars per seat per month, plus storage: the first fifty gigabytes are included, and every gigabyte beyond that costs five dollars. Given the number of seats and the gigabytes used, return the monthly bill in dollars.”
fn team_bill(a: i64, b: i64) -> i64 {
if b <= 50 {
return (12 * a);
}
return (((12 * a) + (5 * b)) + -250);
}api_bill is a two-breakpoint tiered schedule — three affine pieces, genuinely harder than a single threshold. The synthesizer now recovers it directly, from examples alone: a piecewise-affine solver detects where the slope changes and places each breakpoint at the exact integer where the adjoining pieces meet, so the thresholds 1000 and 10000 come straight out of the data and the program is correct across the whole domain (0 mismatches over 0..40000), not just on the samples. Earlier it could only be fit with overfits — (x/1001)·2000, x % 10001 — that passed a sparse holdout but were wrong between points; a downgrade-only sweep gate refused to certify those, so the worst case was an honest refusal, never a wrong shipped rule. On a generated probe of random tiered rules, this took the engine's exact-on-unseen rate from 32% to 78%. Anything it still cannot prove exactly is held back, shown uncertified, never executed.
Generated by demos/requirements_app/build_meterbill.py in the nCPU repo. The function bodies in synthesized.ts are the literal transpiler output — re-running the demo regenerates both this page's data and the standalone meterbill.html.