Skip to content

How sure is a pass?

A property ran 100 tries and every one passed. How sure are you that the code is right?

The green tick alone can’t say: it’s silent on every input that wasn’t tried. So when a property follows a model or a spec, or runs on threads, proptastic says how sure a pass is, under the line that says what passed:

how sure: 0 of 100 tries failed, so under 3% of inputs drawn this way fail it (95% confidence)

This page works out what that line claims, and what it leaves out, on one small rule with a bug in it. Each step runs the same test again: with more tries, then with other years, then against a model that names the rule’s cases, and last on every year. Every output below is a run the docs build makes, with the seed 0x5eed, and each picture shows the years that run drew. The code is compiled and run by that build too: the calendar, the model and every test on this page are in src/docs/java/howsure in proptastic’s repository, so you can run them yourself.

Every fourth year is a leap year, but a century isn’t, unless it’s a multiple of 400. That’s why 2000 had a 29 February and 1900 didn’t. This calendar forgets the last part:

/** Which years have a 29 February. */
final class Calendar {
/** Every fourth year is a leap year, but a century isn't. */
static boolean isLeap(int year) {
return year % 4 == 0 && year % 100 != 0;
}
}

So it’s wrong about 400, 800, 1200 and every 400th year up to 2800: 7 years in 3,000. The runs below don’t know that, and a green test wouldn’t tell you.

The test follows a model of the rule, as Follow a model does for a trading desk: a small program, written to be obviously right, that proptastic runs beside the code and asks about each year. The model knows the rule’s four cases:

/** The rule's four cases, each with whether it's a leap year. */
enum Case {
COMMON("not a multiple of 4", false),
LEAP("a multiple of 4, not of 100", true),
CENTURY("a multiple of 100, not of 400", false),
EVERY_400TH("a multiple of 400", true);
final String about;
final boolean leap;
Case(String about, boolean leap) {
this.about = about;
this.leap = leap;
}
}
/** Which case a year is, written as the rule is said. */
static Case decide(int year) {
if (year % 400 == 0) {
return Case.EVERY_400TH;
}
if (year % 100 == 0) {
return Case.CENTURY;
}
return year % 4 == 0 ? Case.LEAP : Case.COMMON;
}

For now it tells proptastic only whether a year is a leap year, as the outcomes leap and common. The years come from a domain, the years 1 to 3,000:

/** Years from 1 to 3,000. */
static Domain<Integer> years() {
return integers().atLeast(1).atMost(3_000);
}
@Test
void calendarFollowsTheModel() {
forAll(years()).follows(LeapYearModel.process(), Calendar::isLeap);
}

The next four steps run this one test, with PROPTASTIC_TRIES saying how many tries it makes.

Terminal window
PROPTASTIC_TRIES=10 ./gradlew test \
--tests 'LeapYearTest.calendarFollowsTheModel'
Terminal window
followed model Calendar.isLeap on 10 tries (Java) · outcomes leap 5 · common 5
how sure: 0 of 10 tries failed, so under 26% of inputs drawn this way fail it (95% confidence)
why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/

The first line says what passed: the calendar gave the model’s answer for 10 years, 5 of them leap years. The second says how sure that is. None of 10 tries failed, so fewer than 26% of the years proptastic draws can fail.

Here are the years it drew, a hundred to a row, year 1 at the top left. Shaded are the years 1,101 to 3,000, where about 26% of draws land. Were the calendar wrong on every one of them, 10 tries would all miss them only 5 times in 100, so a bug that common would almost surely have shown. That’s the bound: a failure as common as 26% gets past 10 tries only by bad luck.

10 triesA grid of the years 1 to 3,000, a hundred to a row. 8 of them are filled: the years 10 tries drew, crowded at the first few years and at 3,000. The years 1,101 to 3,000 are shaded, and 3 of the tries landed in them, marked in the accent colour.24, drawn 3 times282696755155624142470

10 tries: 8 different years. Say the code failed on every shaded year, 1,101 to 3,000, where about 26% of draws land: 10 tries would all miss them at most 5 times in 100. These landed there 3 times.

Terminal window
PROPTASTIC_TRIES=100 ./gradlew test \
--tests 'LeapYearTest.calendarFollowsTheModel'
Terminal window
followed model Calendar.isLeap on 100 tries (Java) · outcomes leap 28 · common 72
how sure: 0 of 100 tries failed, so under 3% of inputs drawn this way fail it (95% confidence)
why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/

The same test with the same seed draws the same years, so the first 10 of these 100 are the 10 above. With more tries the bound falls to 3%. The shaded years shrink to 2,701 to 2,999, about 3% of draws, which 100 tries would all miss only 5 times in 100.

100 triesA grid of the years 1 to 3,000, a hundred to a row. 58 of them are filled: the years 100 tries drew, crowded at the first few years and at 3,000. The years 2,701 to 2,999 are shaded, and 2 of the tries landed in them, marked in the accent colour.1, drawn 11 times2, drawn 8 times3, drawn 6 times4, drawn 13 times13141826375967707280, drawn twice8395107113134, drawn twice145160175186191220229232, drawn twice28240843744947750252054269669975576080382610941442153315561560178019171999234424142433247025542606273128773000, drawn 6 times

100 tries: 58 different years. Say the code failed on every shaded year, 2,701 to 2,999, where about 3.1% of draws land: 100 tries would all miss them at most 5 times in 100. These landed there twice.

The dots crowd the first few years and the last. That’s how proptastic draws: small values and each end most often, as that’s where bugs tend to be, and any value the rest of the time. Year 3,000, the far end, is drawn one try in 16.

Terminal window
PROPTASTIC_TRIES=1000 ./gradlew test \
--tests 'LeapYearTest.calendarFollowsTheModel'
Terminal window
followed model Calendar.isLeap on 1,000 tries (Java) · outcomes leap 219 · common 781
how sure: 0 of 1,000 tries failed, so under 0.3% of inputs drawn this way fail it (95% confidence)
why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/

Under 0.3% now, and the shaded years are down to 29.

1,000 triesA grid of the years 1 to 3,000, a hundred to a row. 460 of them are filled: the years 1,000 tries drew, crowded at the first few years and at 3,000. The years 2,971 to 2,999 are shaded, and 0 of the tries landed in them, marked in the accent colour.1, drawn 88 times2, drawn 81 times3, drawn 85 times4, drawn 67 times5, drawn twice68, drawn 4 times9, drawn 4 times12, drawn twice1314, drawn 4 times15161718, drawn twice192124, drawn twice252627, drawn 3 times29303132, drawn twice343537, drawn 3 times38394042, drawn 3 times4345, drawn 3 times48, drawn twice49505153, drawn twice5455, drawn twice5658, drawn twice59, drawn twice61, drawn 3 times62, drawn 3 times6364, drawn twice65, drawn twice676870, drawn twice7172, drawn 3 times73, drawn twice74, drawn 3 times7577, drawn 3 times78, drawn twice7980, drawn 4 times81, drawn twice8283, drawn 3 times8586, drawn twice87, drawn twice88, drawn 3 times89, drawn 6 times9091, drawn 3 times93, drawn twice94, drawn twice95, drawn twice96, drawn 3 times98, drawn twice99100, drawn twice101, drawn twice102, drawn twice103, drawn 4 times105106107, drawn twice108, drawn twice111112113, drawn 3 times114, drawn twice115, drawn twice118120121, drawn 4 times122123, drawn twice125126127128129, drawn twice130, drawn twice131, drawn twice132133134, drawn twice135, drawn twice136137138139140, drawn 3 times141, drawn twice142144, drawn 3 times145, drawn twice147148149, drawn 3 times151, drawn 3 times152154, drawn twice156, drawn twice157158159, drawn twice160161, drawn twice163, drawn twice164166169170, drawn twice172, drawn 3 times173, drawn twice175176, drawn twice177178, drawn twice179, drawn twice180181, drawn twice182, drawn 3 times183184, drawn twice186, drawn 5 times187189, drawn twice190, drawn twice191, drawn twice192, drawn twice193, drawn twice194195197199201, drawn 3 times202, drawn 3 times203204206207208211212, drawn twice213, drawn 3 times215216217, drawn twice219220, drawn 3 times222223, drawn twice224, drawn 3 times226, drawn twice227228, drawn twice229, drawn twice230, drawn twice231, drawn twice232, drawn 3 times233234235, drawn twice236238, drawn 3 times240243, drawn twice244245246, drawn 3 times248, drawn 3 times249, drawn twice250, drawn 3 times251252, drawn twice253254255, drawn twice259278282300325, drawn twice329337340346370402408436437438449455456470472477478484488489493502508511520523525542, drawn twice559569586595620623627646, drawn twice650662666, drawn twice670691696699710716746753755, drawn twice756757760775780788803816826851854869890921924927941944948956974984100110051018103810411043106910701071109411181122112411291154126312651288130513131322133713381339134613491360137213751387139113921396139814141434144214471460147314881490150315041514151515161519152215321533154215441556156015751576158316011618163316461660166316721684170217041717172017211742174617541764177717801794180418101845184718561857186719101911, drawn twice1917194319511955, drawn 3 times19811990199920112014201520262031203820432047206520672069209521012105, drawn twice2120212221232124214821542156215921602177218421852207223122472264, drawn twice2272228622902319232623292334234423552393241424192433, drawn twice24352458246624682470247724982501250425092520254525482554257725892591259825992600, drawn twice26032606263026402663271427272731, drawn twice2768281728182819282028212831285328642873287728842885289228982921292729282931293629583000, drawn 57 times

1,000 tries: 460 different years. Say the code failed on every shaded year, 2,971 to 2,999, where about 0.31% of draws land: 1,000 tries would all miss them at most 5 times in 100. These landed there 0 times.

Say some share p of the inputs drawn would fail. One try passes with chance 1 - p, and n tries in a row with chance (1 - p)^n. The bound is the share at which that chance falls to 5%, 1 - 0.05^(1/n): any larger share would let every try pass less than 5% of the time, so, at 95% confidence, the share is smaller. It comes out close to 3/n, which medicine calls the rule of three, from trials in which nothing went wrong (Hanley and Lippman-Hand, 1983):

Tries The bound, exactly 3/n The line says
10 25.9% 30% under 26%
100 2.95% 3% under 3%
1,000 0.299% 0.3% under 0.3%

Ten times the tries, a tenth the bound. Under 20 tries 3/n is a poor guess, so the line prints the exact share, rounded up so that “under” stays true. Only random tries count: an .example(…) or a corpus entry was chosen, not drawn, so it says nothing of how rare a failure is.

PROPTASTIC_EXPLAIN=1 prints this working under the line, for the run in front of you:

Terminal window
followed model Calendar.isLeap on 1,000 tries (Java) · outcomes leap 219 · common 781
how sure: 0 of 1,000 tries failed, so under 0.3% of inputs drawn this way fail it (95% confidence)
the tries: 1,000, drawn at random, and none failed. Examples and corpus
entries were chosen, not drawn, so they aren't counted.
the bound: if 0.299% of inputs drawn this way failed, all 1,000 tries would
pass only 5% of the time, and less often if more failed. So, at 95%
confidence, under 0.299% fail, shown rounded up as 0.3%. That's
1 - 0.05^(1/1000), about 3/1000: the rule of three.
drawn this way: from this property's domains, which draw small values and
each domain's edges most often. The bound says nothing of inputs they
never draw, nor of how often real use meets any input.
edge cases: a value outside the domains, or one they seldom draw, may never
have been tried: widen them, or add it with .edges(…) or .example(…).
shrinking: only runs after a failure, so it has no part in a pass.
why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/

Without it, the first how sure: line in a run is followed by why: and the address of this page.

The calendar is wrong, and it passed 1,000 tries. Here are those 1,000 tries again, with the 7 years it gets wrong ringed:

The years it gets wrongThe grid of years with the 460 years 1,000 tries drew filled, and the 7 years the rule gets wrong, every 400th, ringed in the accent colour in the right-hand column. No filled year is ringed.1, drawn 88 times2, drawn 81 times3, drawn 85 times4, drawn 67 times5, drawn twice68, drawn 4 times9, drawn 4 times12, drawn twice1314, drawn 4 times15161718, drawn twice192124, drawn twice252627, drawn 3 times29303132, drawn twice343537, drawn 3 times38394042, drawn 3 times4345, drawn 3 times48, drawn twice49505153, drawn twice5455, drawn twice5658, drawn twice59, drawn twice61, drawn 3 times62, drawn 3 times6364, drawn twice65, drawn twice676870, drawn twice7172, drawn 3 times73, drawn twice74, drawn 3 times7577, drawn 3 times78, drawn twice7980, drawn 4 times81, drawn twice8283, drawn 3 times8586, drawn twice87, drawn twice88, drawn 3 times89, drawn 6 times9091, drawn 3 times93, drawn twice94, drawn twice95, drawn twice96, drawn 3 times98, drawn twice99100, drawn twice101, drawn twice102, drawn twice103, drawn 4 times105106107, drawn twice108, drawn twice111112113, drawn 3 times114, drawn twice115, drawn twice118120121, drawn 4 times122123, drawn twice125126127128129, drawn twice130, drawn twice131, drawn twice132133134, drawn twice135, drawn twice136137138139140, drawn 3 times141, drawn twice142144, drawn 3 times145, drawn twice147148149, drawn 3 times151, drawn 3 times152154, drawn twice156, drawn twice157158159, drawn twice160161, drawn twice163, drawn twice164166169170, drawn twice172, drawn 3 times173, drawn twice175176, drawn twice177178, drawn twice179, drawn twice180181, drawn twice182, drawn 3 times183184, drawn twice186, drawn 5 times187189, drawn twice190, drawn twice191, drawn twice192, drawn twice193, drawn twice194195197199201, drawn 3 times202, drawn 3 times203204206207208211212, drawn twice213, drawn 3 times215216217, drawn twice219220, drawn 3 times222223, drawn twice224, drawn 3 times226, drawn twice227228, drawn twice229, drawn twice230, drawn twice231, drawn twice232, drawn 3 times233234235, drawn twice236238, drawn 3 times240243, drawn twice244245246, drawn 3 times248, drawn 3 times249, drawn twice250, drawn 3 times251252, drawn twice253254255, drawn twice259278282300325, drawn twice329337340346370402408436437438449455456470472477478484488489493502508511520523525542, drawn twice559569586595620623627646, drawn twice650662666, drawn twice670691696699710716746753755, drawn twice756757760775780788803816826851854869890921924927941944948956974984100110051018103810411043106910701071109411181122112411291154126312651288130513131322133713381339134613491360137213751387139113921396139814141434144214471460147314881490150315041514151515161519152215321533154215441556156015751576158316011618163316461660166316721684170217041717172017211742174617541764177717801794180418101845184718561857186719101911, drawn twice1917194319511955, drawn 3 times19811990199920112014201520262031203820432047206520672069209521012105, drawn twice2120212221232124214821542156215921602177218421852207223122472264, drawn twice2272228622902319232623292334234423552393241424192433, drawn twice24352458246624682470247724982501250425092520254525482554257725892591259825992600, drawn twice26032606263026402663271427272731, drawn twice2768281728182819282028212831285328642873287728842885289228982921292729282931293629583000, drawn 57 times

The years it gets wrong: The 7 years the rule gets wrong, ringed. About 0.071% of draws land on one, under the bound of 0.3%, and none of these 1,000 tries did.

The line didn’t lie. About 0.079% of the years proptastic draws are ones the calendar gets wrong, and that’s under 0.3%. A bound says how rare a failure could still be, never that there’s none, and a bug this rare gets past 1,000 tries about half the time. This run was one of those. Run on:

Terminal window
PROPTASTIC_TRIES=10000 ./gradlew test \
--tests 'LeapYearTest.calendarFollowsTheModel'
Terminal window
does not follow model Calendar.isLeap (Java)
model Calendar.isLeap said true, code said false (outcome leap)
calendarFollowsTheModel failed after 3,298 tries (seed 0x5eed)
shrunk counterexample: year = 400
pin it: .example(400)
rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'LeapYearTest.calendarFollowsTheModel'

The same years again, carried on, and try 3,298 drew one of the 7, which shrinking took down to 400. More tries make the bound smaller, but never zero: no number of tries says the code is right.

The bound is about the years proptastic drew, drawn as its domains draw them, which is why the line says drawn this way. Change the domain and the same line is about other years.

Say the app is only used this century, so the test draws this century’s years:

/** The years the app is used in: this century's. */
static Domain<Integer> yearsThisCentury() {
return integers().atLeast(2001).atMost(2099);
}
@Test
void thisCentury() {
var model = LeapYearModel.process();
forAll(yearsThisCentury()).tries(1_000).follows(model, Calendar::isLeap);
}
Terminal window
thisCentury passed 1,000 tries · this draws 99 values: .exhaustively() checks them all
followed model Calendar.isLeap on 1,000 tries (Java) · outcomes leap 228 · common 772
how sure: 0 of 1,000 tries failed, so under 0.3% of inputs drawn this way fail it (95% confidence)
why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/

The same line, just as sure, and just as true: of the years 2001 to 2099, none fail. But they all sit in one row, and none is a century, where every one of the calendar’s mistakes is:

Years this centuryThe grid of years with only part of one row filled, the years 2001 to 2099. The right-hand column, the centuries, is shaded, and the 7 years the rule gets wrong are ringed in it. None of them is filled.2001, drawn 89 times2002, drawn 75 times2003, drawn 87 times2004, drawn 88 times2005, drawn 6 times2006, drawn 5 times2007, drawn 3 times2008, drawn 4 times2009, drawn 4 times2010, drawn 4 times2011, drawn 4 times2012, drawn 8 times2013, drawn 8 times2014, drawn 9 times2015, drawn 5 times2016, drawn 11 times2017, drawn 4 times2018, drawn 8 times2019, drawn 4 times2020, drawn 5 times2021, drawn 7 times2022, drawn 6 times2023, drawn 9 times2024, drawn 4 times2025, drawn 5 times2026, drawn 7 times2027, drawn 9 times2028, drawn 5 times2029, drawn 6 times2030, drawn 7 times2031, drawn 3 times2032, drawn 6 times2033, drawn 5 times2034, drawn 6 times2035, drawn 6 times2036, drawn 5 times2037, drawn 7 times2038, drawn 6 times2039, drawn 10 times2040, drawn 3 times2041, drawn 7 times2042, drawn twice2043, drawn 12 times2044, drawn 6 times2045, drawn 8 times2046, drawn 4 times2047, drawn 6 times2048, drawn 7 times2049, drawn 4 times2050, drawn 10 times2051, drawn 9 times2052, drawn 4 times2053, drawn 5 times2054, drawn 8 times2055, drawn 4 times2056, drawn 7 times2057, drawn 9 times2058, drawn 7 times2059, drawn 5 times2060, drawn twice2061, drawn 3 times20622063, drawn 9 times2064, drawn 6 times2065, drawn 8 times2066, drawn 9 times2067, drawn 10 times2068, drawn 4 times2069, drawn 3 times2070, drawn 7 times2071, drawn 7 times2072, drawn 6 times2073, drawn 9 times2074, drawn 8 times2075, drawn 8 times2076, drawn 9 times2077, drawn 8 times2078, drawn 5 times2079, drawn 6 times2080, drawn 10 times2081, drawn 7 times2082, drawn 3 times2083, drawn 8 times2084, drawn 6 times2085, drawn 5 times2086, drawn 4 times2087, drawn 5 times2088, drawn 8 times2089, drawn 3 times2090, drawn 4 times2091, drawn 5 times2092, drawn 6 times2093, drawn 6 times2094, drawn 7 times2095, drawn 9 times2096, drawn 8 times2097, drawn 5 times2098, drawn 5 times2099, drawn 81 times

Years this century: 1,000 tries of the years 2001 to 2099: 99 different years, all in one row. The shaded column, the centuries, is never drawn, so neither is a year the rule gets wrong.

No number of tries from this domain finds the bug, and nothing in the line says so. Random testing’s own theory warns of this: a bound like this carries over to real use only as far as the inputs are drawn as real use would draw them (Richard Hamlet, Random Testing, 1994). It’s true of what was drawn, and silent on the rest.

The first line has been saying something the bound can’t: which of the model’s outcomes came up, and how often. A model that names only leap and common is content with this century’s years, as both came up. So let the model name the rule’s four cases, which it already tells apart, and follow that:

@Test
void thisCenturyByRule() {
var model = LeapYearModel.byRule();
forAll(yearsThisCentury()).tries(1_000).follows(model, Calendar::isLeap);
}
model Calendar.isLeap's outcome century (a multiple of 100, not of 400) never came up in 1,000 tries (seed 0x5eed), so following it said nothing of that case: widen the domains, or say why it can't with .unreachable("century", "…")
rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'LeapYearTest.thisCenturyByRule'

A run that never reached one of the model’s cases fails, since it said nothing of that case: here, the centuries. Where the bound says how rare a failure could be among what was drawn, the outcomes say whether each case was drawn at all.

To reach them, go back to the years 1 to 3,000 and give the domain edges of its own, a century and a multiple of 400 among them, so each is drawn often:

/** Years from 1 to 3,000, with the rule's edges drawn one try in 8. */
static Domain<Integer> yearsAndCenturies() {
return years().edges(100, 400, 1900, 2000);
}
@Test
void everyCase() {
var model = LeapYearModel.byRule();
forAll(yearsAndCenturies()).tries(1_000).follows(model, Calendar::isLeap);
}
Terminal window
does not follow model Calendar.isLeap (Java)
model Calendar.isLeap said true, code said false (outcome every-400th)
everyCase failed after 4 tries (seed 0x5eed)
shrunk counterexample: year = 400
pin it: .example(400)
rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'LeapYearTest.everyCase'

Found in 4 tries, where the plain years took 3,298. With the rule written whole:

/** Every fourth year, but not a century, unless it's every 400th. */
static boolean isLeap(int year) {
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
}
Terminal window
followed model Calendar.isLeap on 1,000 tries (Java) · outcomes common 624 · leap 200 · century 122 · every-400th 54
how sure: 0 of 1,000 tries failed, so under 0.3% of inputs drawn this way fail it (95% confidence)
why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/

Now the two lines say two things together: every case of the rule came up, the 400th years 54 times, and of the years drawn this way, fewer than 0.3% can fail.

There are only 3,000 years, so there’s no need to draw them: try every one, as examples, and .tries(0) for no random tries after them.

@Test
void everyYear() {
var everyYear = IntStream.rangeClosed(1, 3_000).boxed().toList();
forAll(years())
.examples(everyYear)
.tries(0)
.follows(LeapYearModel.process(), FixedCalendar::isLeap);
}
Terminal window
followed model Calendar.isLeap on 3,000 tries (Java) · outcomes leap 727 · common 2,273

There’s no how sure: line. Nothing was drawn, so nothing was left to chance and there’s no bound to state: the line counts every year, and each passed.

Every yearThe grid of years with every one of its 3,000 years filled.

Every year: All 3,000 years, each checked once: nothing drawn, so nothing left to chance, and no bound to state.

A proof covers every input too, by argument rather than by running them, and for domains far too big to run. A model written in Lean can carry one, such as a theorem that the rule holds for every year, and a pass names the theorems its model proved. From design to code builds one.

A test of code on threads is both kinds of run. Each run’s steps are drawn, as a try’s year is. Then proptastic runs those steps on every schedule, each order the threads could interleave in, with up to two preemptions, as this page ran every year. So a pass on threads says two things:

Terminal window
passed on 2 threads, 101 runs (every schedule with up to 2 preemptions: 3,906) · no deadlock · each fits an order of its steps, one at a time
how sure: 0 of 100 runs failed, so under 3% of runs drawn this way fail it (95% confidence)
why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/

The first line is exact: every schedule within the bound was run, 3,906 of them, and none was sampled. The second is the rule of three again, over the runs, whose steps were drawn: under 3% of runs drawn this way fail. Schedules with more preemptions, like years outside a domain, are in neither. A spec checked by TLC is exact the same way, over every state its constants allow, as From design to code shows. A spec followed by TLC traces isn’t: TLC judges every step the runs took, and the runs are drawn, so its pass is sure as a pass on runs is.

The line says Which means To say more
0 of 1,000 tries the random tries that passed; examples and corpus entries aren’t counted more tries
under 0.3% the exact bound, 1 - 0.05^(1/n), rounded up more tries: ten times as many, a tenth the bound
of inputs drawn this way over your domains’ draws, not real use, and not inputs they never draw wider domains, edges
(95% confidence) a bound worked out this way is too small at most one run in 20 more tries
the outcomes on the line above each of the model’s cases came up a model that names its cases

None of it says the code is right. Trying every input of a small domain does, for that domain, and so does a proof. Short of that, the line says how rare a failure could still be among what was drawn, and the outcomes say what was drawn.

require asks a different question of the same tries: not how rare a failure could be, but whether a case came up often enough. It’s held to more than 95% confidence, as a wrong answer fails a build or passes a gap. It calls a share too rare, or enough, only when the chance of that call being wrong is under one in a billion, PROPTASTIC_CERTAINTY, drawing more tries until it can, up to 64 times those asked:

The tries Asked for The line What a run says
7.1% of 800 20% 18% too rare: it fails
8.9% of 6,400 10% 9% incomplete: it can’t tell, and says so
42% of 100 10% 9% enough

The line is nine tenths of the share asked for, so a share drawn at exactly what was asked is told as enough in a bounded number of tries, never failed by chance. The chance is worked out with Chernoff’s bound on a count of independent tries, which holds for any number of them, and split across the run’s looks, at most 7, so a run that looks again after each doubling is no less sure. Still unsure at the end, the share is incomplete, never a silent pass: the run says so, with how sure it got, and PROPTASTIC_INCOMPLETE=fail fails it.

proptastic explain puts a property’s last run on one card: how sure its pass is, in the long form above, worked from its event’s numbers, and its model’s outcomes, with its counterexample, corpus and proposals:

Terminal window
proptastic explain followsTheLeapYearRule
✓ PASSED CalendarTest#followsTheLeapYearRule
┌─ src/test/java/calendar/CalendarTest.java:13
│
13 │ forAll(integers().atLeast(1).atMost(3_000))
│
last run: passed 100 tries · seed 0x3a78b1c526b4abf0 · local profile · 17ms
started: 2026-12-03T07:02:19.397Z
how sure: 0 of 100 tries failed, so under 3% of inputs drawn this way fail it (95% confidence)
the tries: 100, drawn at random, and none failed. Examples and corpus
entries were chosen, not drawn, so they aren't counted.
the bound: if 2.95% of inputs drawn this way failed, all 100 tries would
pass only 5% of the time, and less often if more failed. So, at 95%
confidence, under 2.95% fail, shown rounded up as 3%. That's
1 - 0.05^(1/100), about 3/100: the rule of three.
drawn this way: from this property's domains, which draw small values and
each domain's edges most often. The bound says nothing of inputs they
never draw, nor of how often real use meets any input.
edge cases: a value outside the domains, or one they seldom draw, may never
have been tried: widen them, or add it with .edges(…) or .example(…).
shrinking: only runs after a failure, so it has no part in a pass.
model: Calendar.isLeap (command)
outcomes: leap 21 (21%) · common 79 (79%)
counterexample: none saved
corpus: 2 inputs kept, 1 stale
proposals: none
Next: proptastic explain 'CalendarTest#followsTheLeapYearRule' leap
About this property ───────────────────────────────────────────
id: calendar.CalendarTest#followsTheLeapYearRule(), as the manifest names it
domains: integers[1,3000]
corpus key: calendar.CalendarTest#followsTheLeapYearRule(), the directory its inputs are kept in
runs under: test, in the build's root

proptastic explain has the rest.

Privacy