# Template-Free Dynamic Invariant Detection

DevFeed: [Template-Free Dynamic Invariant Detection](<https://devfeed.tech/articles/template-free-dynamic-invariant-detection-107369.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.38130>)

Author: Erfan Arvan, Michael D. Ernst, Martin Kellogg

Published: 2026-10-30T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [llm-reasoning](<https://devfeed.tech/topics/llm-reasoning.md>)

Tags: [cs-se](<https://devfeed.tech/tags/cs-se.md>), [delta](<https://devfeed.tech/tags/delta.md>), [detection](<https://devfeed.tech/tags/detection.md>), [infinite](<https://devfeed.tech/tags/infinite.md>), [instrumentation](<https://devfeed.tech/tags/instrumentation.md>), [invariant](<https://devfeed.tech/tags/invariant.md>), [java](<https://devfeed.tech/tags/java.md>), [large-language-model](<https://devfeed.tech/tags/large-language-model.md>), [llm](<https://devfeed.tech/tags/llm.md>), [loops](<https://devfeed.tech/tags/loops.md>), [oca](<https://devfeed.tech/tags/oca.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [property-based-testing](<https://devfeed.tech/tags/property-based-testing.md>), [template](<https://devfeed.tech/tags/template.md>)

## AI overview

Oca uses an LLM to propose dynamic invariants beyond Daikon's fixed templates; in tests on open-source Java projects, 28% of Oca's held invariants called project-specific methods. The added expressiveness can introduce side effects or hangs, so Oca evaluates one invariant per thread at a time, monitors and retries stalled runs with growing time budgets, and uses delta debugging to isolate and disable side-effecting candidates. In the reported comparison, manual inspection found an 18% false-positive rate for Oca versus 76% for Daikon. Used as property-based testing properties, the invariants exposed 9 of 25 real bugs versus 4 for Daikon. Oca also used 566 minutes and 27 GB of disk, compared with Daikon's 2,817 minutes and 827 GB. These are results from the described project evaluation.

## Source excerpt

arXiv:2610.38130v1 Announce Type: new Abstract: A dynamic invariant detector proposes invariants, such as method pre- and postconditions, and rules out those that do not hold at run time. Traditional detectors propose invariants from a fixed library of templates, which limits their expressiveness. A large language model (LLM) can propose invariants instead of, or in addition to, template-derived ones. With the right prompt and context choices, we found that this idea can both improve the invariants' expressiveness and reduce the cost of inferring the invariants. Greater expressiveness brings complications: an LLM-proposed invariant can execute arbitrary code during invariant evaluation, causing side effects or infinite loops. Our novel instrumentation strategies mitigate these problems. We wrap each candidate and evaluate only one invariant per thread at a time, so nested invariant evaluations cannot trigger one another indefinitely. To recover from non-nested hangs, we monitor each run for stalls and retry it under a growing time budget. Because we cannot prove a candidate side-effect-free in advance, we use delta debugging over the invariants evaluated during a failing test to isolate and disable a side-effecting candidate without discarding the rest of the run. We compared our implementation, Oca, to the popular template-based Daikon invariant detector on real open-source Java projects. Oca produces more expressive invariants: on average, 28% of its held invariants call a project-specific method, which Daikon's templates cannot express. Its invariants are more often valid, with a false-positive rate of 18% in a manual inspection, vs. 76% for Daikon, and more useful: as properties for property-based testing, they exposed 9 of 25 real bugs, compared with 4 for Daikon. Oca also costs less, using 566 minutes and 27 GB of disk, compared with 2,817 minutes and 827 GB for Daikon.