Skip to content

Conversation

@maditaP
Copy link

@maditaP maditaP commented Oct 30, 2025

This adds a command (get-pre-models) to check whether there are non-trivial models for the preexpectations. For coprocs, this means models where the pre evaluates to < infinity, and for procs, models where the pre evaluates to > 0.
The implementation is very similar to that of the verify command.

Note: BoolVcProveTask is used here not for a verification task, but for a formula that will be checked for satisfiability. This should be refactored at some point.

Copy link
Collaborator

@Philipp15b Philipp15b left a comment

Choose a reason for hiding this comment

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

I think this looks great! I have a bunch of (mostly) minor comments.

pub fn from_source_unit(
mut source_unit: SourceUnit,
depgraph: &mut DepGraph,
is_get_model_task: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This anonymous boolean flag is definitely problematic. Especially because it changes the whole interpretation and guarantees about this object. I recommend:

  • Renaming this struct to something like CoreHeyvlTask (and renaming the file and variable names accordingly)
  • Having two separate constructors for this object; one is basically the old from_source_unit (maybe called from_proc_verify), the other would be smth like from_proc_pre_model).
  • Possibly refactor a bit so that the common code is in common functions (esp. the bit about depgraphs).

Ok(result.prove_result)
}

pub fn run_smt_check_sat<'tcx>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

A short comment would be great.

.local_scope()
.add_assumptions_to_prover(&mut prover);

// Add the verification condition
Copy link
Collaborator

Choose a reason for hiding this comment

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

A short comment explaining that the verification condition is intentionally added as an assumption instead of an assertion as usually done for verification would be great.

Copy link
Author

Choose a reason for hiding this comment

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

I am not sure I understand this correctly.
add_assumption adds the value as an assert to the solver. And there is no add_assertion function (or something like it) in the prover struct, as far as I can tell. Maybe the function should be renamed?

Copy link
Collaborator

@Philipp15b Philipp15b Nov 3, 2025

Choose a reason for hiding this comment

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

The alternative would be add_provable (which I meant by add_assertion). But I think you want add_assumption.

}

// connect the preexpectations through the correct operator
let mut build_expr = proc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just use a reduce? That seems much simpler and less error-prone

// Unfolding (applies substitutions)
quant_task.unfold(options, &limits_ref, &tcx)?;

// TODO: How to deal with inf/sup quantifier?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess if the SMT encoder is properly used, then sup/inf will be correctly encoded. Most likely the SMT solver would fail to terminate though.

}
};

// Create a Boolean verification task with the comparison
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think a BoolVcProveTask was intended to be used only in the context of verification (i.e. vc == top/bot), but the operations should be sound here as well, because they're all equivalence transformations (I think).

Please make a note of this in the PR description, I'll refactor that at some point :)

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.

2 participants