Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fine Grained Module Definitions #661

Merged
merged 1 commit into from
Jan 14, 2025
Merged

Conversation

Cameron-Low
Copy link
Contributor

@Cameron-Low Cameron-Low commented Nov 28, 2024

The goal of this PR is to introduce a new mechanism that permits the user to create a new module by slightly tweaking an existing module definition.

At present the draft has the following features:

  • Introduce new module variables.
  • Introduce new local variables.
  • Delete/Modify/Add statements at particular code positions
  • Delete branches (match support is not currently working fully)
  • Modify branch conditions
  • Insert new branches around a chunk of code
  • Modify the return expression

Syntax (needs work) :

module N = M with {
  var x : t (* add new module variable *)
  proc f [
     var y  : s (* add new local variable *)
     cp +/-/~ { s } (* insert after/insert before/modify a statement *)
     cp -  (* delete a statement *)
     cp + ( e ) (* insert new if statement with condition `e` surrounding the suffix code block *)
     cp - ./?/#cstr (* delete all other branches except true/false/cstr *)
  ] res ~ ( e ) (* change the return expression *)
}

@fdupress
Copy link
Member

Can you please edit the message above to add syntax for each of the transformations? This will help in reviewing, independently of also creating a wiki page.

@fdupress fdupress force-pushed the fine-grained-module-defs branch from 84ab24d to b588f39 Compare November 29, 2024 11:12
@Cameron-Low Cameron-Low marked this pull request as ready for review December 5, 2024 17:12
@Cameron-Low
Copy link
Contributor Author

This is now ready for review. I've made a wiki page to document the features present.

@Cameron-Low Cameron-Low requested review from strub and fdupress December 5, 2024 17:13
Copy link
Member

@fdupress fdupress left a comment

Choose a reason for hiding this comment

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

This looks good to me. It does affect the non-interactive readability of scripts, so kind of increases the priority of proof documentation features.

As it stands, nothing forces usage, so this is fine to merge in order to allow engagement with the tool and user communities.

src/ecMatching.ml Show resolved Hide resolved
src/ecMatching.ml Outdated Show resolved Hide resolved
src/ecMatching.mli Outdated Show resolved Hide resolved
src/ecTyping.ml Outdated Show resolved Hide resolved
src/ecTyping.ml Outdated Show resolved Hide resolved
src/ecTyping.ml Outdated Show resolved Hide resolved
src/ecTyping.ml Outdated Show resolved Hide resolved
src/ecTyping.ml Show resolved Hide resolved
src/ecTyping.ml Outdated Show resolved Hide resolved
src/ecTyping.ml Outdated Show resolved Hide resolved
@strub
Copy link
Member

strub commented Dec 17, 2024

I only have minor comments (see above). Also, squash your commits. But overall, we are good to go.

@Cameron-Low Cameron-Low force-pushed the fine-grained-module-defs branch 2 times, most recently from bd7f71b to c6fc91a Compare January 10, 2025 13:09
@strub strub force-pushed the fine-grained-module-defs branch 2 times, most recently from 161c2ec to b96d5b0 Compare January 14, 2025 07:05
This commit introduces a new mechanism that permits the user to create
a new module by slightly tweaking an existing module definition.

It has the following operations:

 - Introduce new module variables.
 - Introduce new local variables.
 - Delete/Modify/Add statements at particular code positions
 - Delete branches (match support is not currently working fully)
 - Modify branch conditions
 - Insert new branches around a chunk of code
 - Modify the return expression

Syntax:

```
module N = M with {
  var x : t (* add new module variable *)
  proc f [
     var y  : s (* add new local variable *)
     cp +/-/~ { s } (* insert after/insert before/modify a statement *)
     cp -  (* delete a statement *)
     cp + ( e ) (* insert new if statement with condition `e` surrounding the suffix code block *)
     cp - ./?/#cstr (* delete all other branches except true/false/cstr *)
  ] res ~ ( e ) (* change the return expression *)
}
```
@Cameron-Low Cameron-Low force-pushed the fine-grained-module-defs branch from b96d5b0 to db10952 Compare January 14, 2025 12:04
@Cameron-Low Cameron-Low merged commit e335db0 into main Jan 14, 2025
15 checks passed
@Cameron-Low Cameron-Low deleted the fine-grained-module-defs branch January 14, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants