Skip to content

Commit a3c3e0a

Browse files
committed
feat: added is valid
1 parent 267c6e1 commit a3c3e0a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

crates/move-prover-boogie-backend/src/boogie_backend/bytecode_translator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5371,6 +5371,10 @@ impl<'env> FunctionTranslator<'env> {
53715371
srcs[0]
53725372
);
53735373
emitln!(self.writer(), "assume (forall i:int :: InRangeVec($quantifier_temp_vec, i) ==> ReadVec($quantifier_temp_vec, i) == (if {}({}) then 1 else 0));", fun_name, cr_args(&format!("i + $t{}", srcs[0])));
5374+
emitln!(
5375+
self.writer(),
5376+
"assume $IsValid'vec'u64''($quantifier_temp_vec);"
5377+
);
53745378
emitln!(self.writer(), "$t{} := $0_vec_$sum'u64'($quantifier_temp_vec, 0, LenVec($quantifier_temp_vec));", dests[0]);
53755379
}
53765380
QuantifierType::SumMap => {

crates/move-prover-boogie-backend/src/boogie_backend/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use move_stackless_bytecode::{
2222
dynamic_field_analysis::{self, NameValueInfo},
2323
function_target_pipeline::{FunctionTargetsHolder, FunctionVariant},
2424
mono_analysis::{self, MonoInfo, PureQuantifierHelperInfo},
25+
stackless_bytecode::QuantifierHelperType,
2526
verification_analysis,
2627
};
2728

@@ -514,7 +515,12 @@ impl QuantifierHelperInfo {
514515
"v, start, end".to_string()
515516
};
516517

517-
let dst_elem_boogie_type = if matches!(info.qht, QuantifierHelperType::FindIndices) {
518+
let dst_elem_boogie_type = if matches!(
519+
info.qht,
520+
QuantifierHelperType::FindIndex
521+
| QuantifierHelperType::FindIndices
522+
| QuantifierHelperType::RangeCount
523+
) {
518524
&Type::Primitive(PrimitiveType::U64)
519525
} else if matches!(info.qht, QuantifierHelperType::Filter) {
520526
&params_types[info.li].skip_reference()

crates/move-prover-boogie-backend/src/boogie_backend/prelude/native.bpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,9 @@ function $RangeCountQuantifierHelper_{{FN}}({{QP}}): Vec ({{RT}});
999999
axiom (forall {{QP}}:: {$RangeCountQuantifierHelper_{{FN}}({{QA}})}
10001000
(
10011001
var res := $RangeCountQuantifierHelper_{{FN}}({{QA}});
1002-
LenVec(res) == (if start <= end then end - start else 0) &&
1003-
(forall i: int :: InRangeVec(res, i) ==> ReadVec(res, i) == (if {{FN}}({{EAB}}(i + start){{EAA}}) then 1 else 0))
1002+
(LenVec(res) == (if start <= end then end - start else 0)) &&
1003+
(forall i: int :: InRangeVec(res, i) ==> ReadVec(res, i) == (if {{FN}}({{EAB}}(i + start){{EAA}}) then 1 else 0)) &&
1004+
$IsValid'vec'u64''(res)
10041005
)
10051006
);
10061007
{%- endif %}

0 commit comments

Comments
 (0)