Skip to content

Conversation

@bauereiss
Copy link
Contributor

Add a Lem implementation of the concurrency interface v2 and use it when translation Sail specs targeting that interface. For detecting the interface parameters, we reuse the code also used by the Rocq interface. This requires not removing the outcome and instantiation declarations during rewriting, which needs a tweak to the monomorphisation rewrite to accept those declarations without throwing an error; we just ignore those declarations during monomorphisation for now (additional definitions generated by the outcome instantiation rewrite continue to be handled).

let instantiate target ast =
(* Some backends will need the instantiations to hook up to a particular interface *)
let keep_original_defs = String.compare target "coq" == 0 in
let keep_original_defs = String.compare target "coq" == 0 || String.compare target "lem" == 0 in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I don't love hard-coding target specific behaviours into rewrites like this. I think the cleaner thing to do would be to add a flag to the target struct in target.ml that can be set by Target.register similar to the supports_abstract_types flag. Then here we would use Target.get and query that flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had a go at this, but hit a dependency cycle Outcome_rewrites -> Target -> Rewrites -> Outcome_rewrites. I guess we could do some refactoring, or maybe just adding a boolean flag to the outcomes rewrite using Bool_rewriter is simpler?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not worth refactoring it for now then

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although a boolean flag on the rewrite might be better if it's easy to do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems easy, I've pushed a commit.

@github-actions
Copy link

github-actions bot commented Nov 18, 2025

Test Results

   16 files     36 suites   0s ⏱️
1 006 tests 1 003 ✅  3 💤 0 ❌
4 857 runs  4 815 ✅ 42 💤 0 ❌

Results for commit 8c034c4.

♻️ This comment has been updated with latest results.

[
("move_termination_measures", []);
("instantiate_outcomes", [String_arg "lean"]);
("instantiate_outcomes", [String_arg "lean"; Bool_arg false]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When rebasing, you'll want to change this because Lean now supports v2.

Suggested change
("instantiate_outcomes", [String_arg "lean"; Bool_arg false]);
("instantiate_outcomes", [String_arg "lean"; Bool_arg true]);

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.

3 participants