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

No clear CEC functionality or cached operation #3803

Closed
TomMD opened this issue Dec 31, 2024 · 3 comments
Closed

No clear CEC functionality or cached operation #3803

TomMD opened this issue Dec 31, 2024 · 3 comments
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@TomMD
Copy link

TomMD commented Dec 31, 2024

I'm looking for some sort of CEC (like ABC's) and caching behavior to make CI PR runs cheap.

Should I dig and write documentation as I discover or are these features simply not there at present?

@TomMD TomMD added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Dec 31, 2024
@TomMD
Copy link
Author

TomMD commented Dec 31, 2024

Related to the CEC ask, long ago I used CEC and SAW to prove C code was equivalent before and after a change. This was possible because I could mangle the symbols after LLVM IR generation completed for compilation of each artifact pre and post compilation. Kani's use of Rust's MIR means the same solution isn't useable, but notionally there isn't much difference. Do you see obvious issues with using Kani to a similar end?

@zhassan-aws
Copy link
Contributor

Hi @TomMD. Kani can be used for verifying the equivalence of two Rust functions. For example if you functions f1 and f2 that take, say an i32 and a char and return a bool:

fn f1(i: i32, c: char) -> bool

then you can write a harness to check their equivalence:

#[kani::proof]
fn check_f1_f2_equiv() {
    let i: i32 = kani::any();
    let c: char = kani::any();
    let b1 = f1(i, c);
    let b2 = f2(i, c);
    assert_eq!(b1, b2);
}

If the assertion passes, then f1 and f2 produce the same output value for all inputs.

Is this what you're looking for?

Regarding caching, if the source files didn't change, Kani won't recompile them. Perhaps saving the build artifacts across CI runs could help with the runtime?

@TomMD
Copy link
Author

TomMD commented Jan 12, 2025

The caching is good to know about, thanks.

As for lack of CEC in particular, yes we can get functional equivalence in another way but it is slower for many interesting cases. IIRC (and I might not), it was CEC that could reasonably prove the new and old libsodium SHA512 function's equivalent while naive SAT embedding could not in a timely manner. It seems there is no support for ABC and thus the answer is 'no' in this case. Thanks.

@TomMD TomMD closed this as completed Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants