Skip to content

Commit 8520696

Browse files
Gate quantifiers behind an experimental feature (#4141)
This PR put Quantifiers under unstable features. User must use the flag "-Z quantifiers" to enable it. Resolves #4134 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Carolyn Zech <[email protected]>
1 parent bd51c78 commit 8520696

14 files changed

+24
-3
lines changed

kani_metadata/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ pub enum UnstableFeature {
9999
/// Allow replacing certain items with stubs (mocks).
100100
/// See [RFC-0002](https://model-checking.github.io/kani/rfc/rfcs/0002-function-stubbing.html)
101101
Stubbing,
102+
/// Enable quantifiers [RFC 10](https://model-checking.github.io/kani/rfc/rfcs/0010-quantifiers.html)
103+
Quantifiers,
102104
/// Automatically check that uninitialized memory is not used.
103105
UninitChecks,
104106
/// Enable an unstable option or subcommand.

library/kani_core/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,11 @@ macro_rules! kani_intrinsics {
627627
assert!(cond, "{}", msg);
628628
}
629629

630+
#[crate::kani::unstable_feature(
631+
feature = "quantifiers",
632+
issue = 2546,
633+
reason = "experimental quantifiers"
634+
)]
630635
#[inline(never)]
631636
#[kanitool::fn_marker = "ForallHook"]
632637
pub fn kani_forall<T, F>(lower_bound: T, upper_bound: T, predicate: F) -> bool
@@ -636,6 +641,11 @@ macro_rules! kani_intrinsics {
636641
predicate(lower_bound)
637642
}
638643

644+
#[crate::kani::unstable_feature(
645+
feature = "quantifiers",
646+
issue = 2546,
647+
reason = "experimental quantifiers"
648+
)]
639649
#[inline(never)]
640650
#[kanitool::fn_marker = "ExistsHook"]
641651
pub fn kani_exists<T, F>(lower_bound: T, upper_bound: T, predicate: F) -> bool

tests/expected/quantifiers/assert_with_exists_fail.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-flags: -Z quantifiers
34

45
#[kani::proof]
56
fn exists_assert_harness() {

tests/expected/quantifiers/assert_with_exists_pass.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-flags: -Z quantifiers
34

45
#[kani::proof]
56
fn exists_assert_harness() {

tests/expected/quantifiers/assert_with_forall_fail.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-flags: -Z quantifiers
34

45
#[kani::proof]
56
fn forall_assert_harness() {

tests/expected/quantifiers/assert_with_forall_pass.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-flags: -Z quantifiers
34

45
#[kani::proof]
56
fn forall_assert_harness() {

tests/expected/quantifiers/assume_with_exists_fail.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-flags: -Z quantifiers
34

45
#[kani::proof]
56
fn exists_assume_harness() {

tests/expected/quantifiers/contracts_fail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3-
// kani-flags: -Zfunction-contracts
3+
// kani-flags: -Zfunction-contracts -Z quantifiers
44

55
/// Copy only first 7 elements and left the last one unchanged.
66
#[kani::ensures(|ret| { unsafe{

tests/expected/quantifiers/quantifier_with_no_external_variable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3-
3+
// kani-flags: -Z quantifiers
44
/// Quantifier with no external variable in the closure
55
66
#[kani::proof]

tests/kani/Quantifiers/array.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-flags: -Z quantifiers
34

45
#[kani::proof]
56
fn vec_assert_forall_harness() {

0 commit comments

Comments
 (0)