Skip to content

Pulse tests: do not define KRML_HOME for CI; add divergent or decreases clauses#750

Merged
tahina-pro merged 3 commits into
FStarLang:masterfrom
tahina-pro:_taramana_pulse_div
Jul 23, 2026
Merged

Pulse tests: do not define KRML_HOME for CI; add divergent or decreases clauses#750
tahina-pro merged 3 commits into
FStarLang:masterfrom
tahina-pro:_taramana_pulse_div

Conversation

@tahina-pro

@tahina-pro tahina-pro commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

This branch tracks two recent F* changes so that KaRaMeL's Pulse test suite
(build-and-test-pulse) keeps building and passing against F* master:

Changes

1. CI: do not use KRML_HOME (follows FStarLang/FStar#4349)

.github/workflows/ci.yml — the test-pulse job no longer needs KRML_HOME. The current test/pulse/Makefile uses the proper Karamel executable for KRML_EXE.

2. test/pulse: adapt to the Pulse stt/stt_div split (follows FStarLang/FStar#4358)

Root cause. After #4358, a while loop (or fn rec) with no decreases
measure is a divergent (stt_div) computation. A plain fn must be
terminating (stt), so it can no longer contain a measure-free loop and now
fails with:

Error 228: Cannot compose computations in this divergent block:
  - This computation has effect: 'stt_div'
  - The continuation has effect: 'stt'

This broke Inline.fst, InlineLoopCond.fst, Goto.fst and Break.fst.

Fix. Following the same conventions F* used to migrate its own Pulse
libraries and examples in #4358:

  • Genuinely non-terminating loops are marked divergent fn.
  • Terminating loops get a decreases measure (placed after the
    invariant/ensures clauses) so they stay plain terminating fns.
File · function Loop nature Fix
InlineLoopCond.test, InlineLoopCond.test_ok Infinite — immutable condition, empty body divergent fn
Break.break_continue_and_return Infinite — a continue path never advances the counter divergent fn
Break.simple_break Terminating (break-only body) decreases (if !k then 1 else 0)
Break.find_zero_with_break Terminating count up to sz decreases (SizeT.v sz - SizeT.v (!i))
Goto.find_zero Terminating count up to sz decreases (SizeT.v sz - SizeT.v (!i))
Inline.tst Terminating count up to uu__k bound invariant pure (v (!i) <= v uu__k) + decreases (v uu__k - v (!i))

Testing

make -kj$(nproc) test-pulse (the exact CI target) passes from a clean state:
all CHECK, EXTRACT, KRML and DIFF steps succeed.

Extraction is unaffected — stt_div extracts like stt — so the generated C
is unchanged and no *.expected.c files needed updating.

Notes

  • No changes outside .github/workflows/ci.yml and test/pulse/.

tahina-pro and others added 3 commits July 16, 2026 12:09
F* PR 4358 splits Pulse's `stt` into terminating `stt` (`fn`) and
possibly-divergent `stt_div` (`divergent fn`). A measure-free `while`
loop is now divergent, so a plain `fn` containing one fails with
Error 228 ("Cannot compose computations in this divergent block").

Fix the affected pulse extraction tests:
- Genuinely non-terminating loops are marked `divergent fn`:
  InlineLoopCond.test and .test_ok (immutable condition, empty body)
  and Break.break_continue_and_return (a `continue` path that never
  advances the counter).
- Terminating loops get a `decreases` measure to stay plain `fn`:
  Inline.tst, Break.simple_break, Break.find_zero_with_break and
  Goto.find_zero (adding a bound invariant to Inline.tst as needed).

Extraction is unaffected (stt_div extracts like stt), so the expected
C output is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ec80b304-3585-492b-9f51-c0c9f8b9358f
@tahina-pro tahina-pro changed the title Pulse tests: Use KRML_EXE for CI; add divergent or decreases clauses Pulse tests: do not define KRML_HOME for CI; add divergent or decreases clauses Jul 16, 2026
@tahina-pro
tahina-pro merged commit 2309d84 into FStarLang:master Jul 23, 2026
16 checks passed
@tahina-pro

Copy link
Copy Markdown
Member Author

Thanks Jonathan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants