Repository navigation
defk-rt2.7: Defk.Facts owns the range-facts scope; the provers stop reading the compiler's env - #65
Merged
Merged
Conversation
…eading the compiler's env The facts scope (Facts.bind/2, narrow/3, facts_of/2) keeps each i64 and array binding's facts by C variable and rides in env.facts; env.atoms and the provers' scan of env.vars are gone. The range arithmetic of the overflow check and the bitwise operators moves behind Facts (add_range, sub_range, bnot_facts, u64_bsr_facts). The facts tests read the access decision from the report, with one end-to-end C check per file, and facts_test tests the scope. Generated C byte-identical.
DanielLuning
pushed a commit
that referenced
this pull request
Oct 20, 2026
… env.facts; env.atoms gone; range arithmetic behind Facts; tests read bounds notes (bounds_proven?/2), one C check per file; dump_c byte-identical; mix ci green."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Defk.Factsnow owns the range-facts scope. Before, the compiler kept i64 facts twice (on the binding and inenv.atoms), and the provers read the compiler's env:env.atomsfor i64 atoms and a scan ofenv.varsfor array lengths.Facts.scope/0,bind/2,narrow/3(a relation in) andfacts_of/2. The scope keeps each i64 and array binding's facts by C variable. The env carries it under one key,env.facts.check/4,fits_i64?/2andresidual/5take the scope instead of the env.env.atoms,atom_facts/2and the fake carrier forFacts.narroware gone.holds/2and the per-atom narrowing are now private.put_var/3, the two array-copy sites, the kernel entry and the inline env each bind once into the scope. A nested block hands its scope out with its bindings.Facts(add_range/2,sub_range/2,bnot_facts/1,u64_bsr_facts/2).add,negandbnotare private.narrow/3: it callsFacts.narrow/3, then gives each binding whose entry changed the scope's facts. This keeps a binding's facts the same as its scope entry. These 15 lines stay in the compiler next torelation/3andguarded/4, because only the compiler knowsenv.vars.TestKit.bounds_proven?/2: there are bounds notes, and all are:dropped) where they read the C with a regex. One end-to-end C check stays per file (mix2,rolling_diff,scores).facts_testgains three scope tests: binding by C variable, a relation narrowing its newest atom so that the prover sees it, and a product narrowing its newer factor.Results
mix dump_cof all 108 modules is byte-identical tomainat 68c82a0. The only difference is the known path-hashed/* defk:loop scale_keep/2 */key inDefk.ReportTest.Gen.c.How it was checked
mix cion the laptop (macOS) passed: 2297 tests, Credo found no issues, Dialyzer reported 0 errors. After that run, only a comment changed (format and compile checked again).mix dump_cwithoutccon an untouchedmaincheckout and on the branch, compared withdiff -r -I '^#define DEFK_HEADER_HASH '.Touches a promised surface? No:
Defk.Factsis internal (@moduledoc false). NoCHANGELOG.mdentry.Touches
test/stability/? No.