Skip to content

Commit 2866207

Browse files
committed
mc: rename to-jani subcommand to mc
we keep the old name available as an alias
1 parent f4fca79 commit 2866207

File tree

5 files changed

+37
-32
lines changed

5 files changed

+37
-32
lines changed

src/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl SourceUnit {
374374
/// Encode the source unit as a JANI file if requested.
375375
pub fn write_to_jani_if_requested(
376376
&self,
377-
options: &crate::JaniOptions,
377+
options: &crate::ModelCheckingOptions,
378378
tcx: &TyCtx,
379379
) -> Result<Option<PathBuf>, VerifyError> {
380380
if let Some(jani_dir) = &options.jani_dir {

src/main.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl Cli {
9292
match &self.command {
9393
Command::Verify(verify_options) => Some(&verify_options.debug_options),
9494
Command::Lsp(verify_options) => Some(&verify_options.debug_options),
95-
Command::ToJani(to_jani_options) => Some(&to_jani_options.debug_options),
95+
Command::Mc(mc_options) => Some(&mc_options.debug_options),
9696
Command::ShellCompletions(_) => None,
9797
Command::Other(_vec) => unreachable!(),
9898
}
@@ -103,8 +103,9 @@ impl Cli {
103103
pub enum Command {
104104
/// Verify HeyVL files with Caesar.
105105
Verify(VerifyCommand),
106-
/// Convert HeyVL files to JANI files.
107-
ToJani(ToJaniCommand),
106+
/// Model checking via JANI, can run Storm directly.
107+
#[clap(visible_alias = "to-jani")]
108+
Mc(ToJaniCommand),
108109
/// Run Caesar's LSP server.
109110
Lsp(VerifyCommand),
110111
/// Generate shell completions for the Caesar binary.
@@ -124,7 +125,7 @@ pub struct VerifyCommand {
124125
pub rlimit_options: ResourceLimitOptions,
125126

126127
#[command(flatten)]
127-
pub jani_options: JaniOptions,
128+
pub model_checking_options: ModelCheckingOptions,
128129

129130
#[command(flatten)]
130131
pub opt_options: OptimizationOptions,
@@ -148,7 +149,7 @@ pub struct ToJaniCommand {
148149
pub rlimit_options: ResourceLimitOptions,
149150

150151
#[command(flatten)]
151-
pub jani_options: JaniOptions,
152+
pub model_checking_options: ModelCheckingOptions,
152153

153154
#[command(flatten)]
154155
pub debug_options: DebugOptions,
@@ -209,7 +210,7 @@ pub enum RunWhichStorm {
209210

210211
#[derive(Debug, Default, Clone, Args)]
211212
#[command(next_help_heading = "JANI Output Options")]
212-
pub struct JaniOptions {
213+
pub struct ModelCheckingOptions {
213214
/// Export declarations to JANI files in the provided directory.
214215
#[arg(long)]
215216
pub jani_dir: Option<PathBuf>,
@@ -259,7 +260,7 @@ pub struct JaniOptions {
259260
pub storm_timeout: Option<u64>,
260261
}
261262

262-
impl JaniOptions {
263+
impl ModelCheckingOptions {
263264
pub fn storm_timeout(&self) -> Option<Duration> {
264265
self.storm_timeout.map(Duration::from_secs)
265266
}
@@ -449,7 +450,7 @@ async fn main() -> ExitCode {
449450

450451
match options.command {
451452
Command::Verify(options) => run_cli(options).await,
452-
Command::ToJani(options) => run_to_jani_main(options),
453+
Command::Mc(options) => run_model_checking_main(options),
453454
Command::Lsp(options) => run_server(options).await,
454455
Command::ShellCompletions(options) => run_generate_completions(options),
455456
Command::Other(_) => unreachable!(),
@@ -779,8 +780,8 @@ fn verify_files_main(
779780
}
780781

781782
// write to JANI if requested
782-
to_jani_main(
783-
&options.jani_options,
783+
run_model_checking(
784+
&options.model_checking_options,
784785
&mut source_units,
785786
server,
786787
&limits_ref,
@@ -949,16 +950,16 @@ fn verify_files_main(
949950
Ok(num_failures == 0)
950951
}
951952

952-
fn run_to_jani_main(options: ToJaniCommand) -> ExitCode {
953+
fn run_model_checking_main(options: ToJaniCommand) -> ExitCode {
953954
let (user_files, server) = match mk_cli_server(&options.input_options) {
954955
Ok(value) => value,
955956
Err(value) => return value,
956957
};
957-
let res = to_jani_loader(&options, user_files, &server).map(|_| true);
958+
let res = model_checking_main(&options, user_files, &server).map(|_| true);
958959
finalize_verify_result(server, &options.rlimit_options, res)
959960
}
960961

961-
fn to_jani_loader(
962+
fn model_checking_main(
962963
options: &ToJaniCommand,
963964
user_files: Vec<FileId>,
964965
server: &Mutex<dyn Server>,
@@ -973,8 +974,8 @@ fn to_jani_loader(
973974
let timeout = Instant::now() + options.rlimit_options.timeout();
974975
let mem_limit = options.rlimit_options.mem_limit();
975976
let limits_ref = LimitsRef::new(Some(timeout), Some(mem_limit));
976-
to_jani_main(
977-
&options.jani_options,
977+
run_model_checking(
978+
&options.model_checking_options,
978979
&mut source_units,
979980
server_lock.deref_mut(),
980981
&limits_ref,
@@ -983,8 +984,8 @@ fn to_jani_loader(
983984
)
984985
}
985986

986-
fn to_jani_main(
987-
options: &JaniOptions,
987+
fn run_model_checking(
988+
options: &ModelCheckingOptions,
988989
source_units: &mut Vec<Item<SourceUnit>>,
989990
server: &mut dyn Server,
990991
limits_ref: &LimitsRef,

src/mc/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::{
3030
procs::proc_verify::verify_proc,
3131
tyctx::TyCtx,
3232
version::caesar_version_info,
33-
JaniOptions,
33+
ModelCheckingOptions,
3434
};
3535

3636
use self::{
@@ -125,7 +125,7 @@ impl JaniConversionError {
125125
}
126126

127127
pub fn proc_to_model(
128-
options: &JaniOptions,
128+
options: &ModelCheckingOptions,
129129
tcx: &TyCtx,
130130
proc: &ProcDecl,
131131
) -> Result<Model, JaniConversionError> {
@@ -231,7 +231,7 @@ fn check_calculus_annotation(proc: &ProcDecl) -> Result<(), JaniConversionError>
231231
/// Translate variable declarations, including local variable declarations, as
232232
/// well as input and output parameters.
233233
fn translate_var_decls(
234-
options: &JaniOptions,
234+
options: &ModelCheckingOptions,
235235
expr_translator: &ExprTranslator<'_>,
236236
proc: &ProcDecl,
237237
) -> Result<(Vec<ConstantDeclaration>, Vec<VariableDeclaration>), JaniConversionError> {

src/mc/run_storm.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use z3rro::util::PrettyRational;
1818
use crate::{
1919
ast::{Diagnostic, Label, Span},
2020
resource_limits::LimitsRef,
21-
JaniOptions, RunWhichStorm,
21+
ModelCheckingOptions, RunWhichStorm,
2222
};
2323

2424
pub type StormResult = Result<StormOutput, StormError>;
@@ -40,9 +40,9 @@ pub fn storm_result_to_diagnostic(result: &StormResult, span: Span) -> Diagnosti
4040
.with_code(NumberOrString::String("model checking".to_owned())),
4141
},
4242
Err(err) => Diagnostic::new(ReportKind::Error, span)
43-
.with_message(format!("Error running Storm: {}", err))
43+
.with_message(err)
4444
.with_label(Label::new(span))
45-
.with_code(NumberOrString::String("model checking".to_owned())),
45+
.with_code(NumberOrString::String("storm".to_owned())),
4646
}
4747
}
4848

@@ -75,7 +75,7 @@ pub enum StormError {
7575
///
7676
/// Panics if `options.run_storm` is `None`.
7777
pub fn run_storm(
78-
options: &JaniOptions,
78+
options: &ModelCheckingOptions,
7979
mut jani_file: &Path,
8080
properties: Vec<String>,
8181
limits_ref: &LimitsRef,
@@ -194,7 +194,7 @@ pub fn run_storm(
194194
}
195195

196196
fn parse_property_results(
197-
options: &JaniOptions,
197+
options: &ModelCheckingOptions,
198198
properties: Vec<String>,
199199
output: &str,
200200
) -> IndexMap<String, StormValue> {
@@ -207,7 +207,11 @@ fn parse_property_results(
207207
.collect()
208208
}
209209

210-
fn find_property_result(options: &JaniOptions, output: &str, property: &str) -> StormValue {
210+
fn find_property_result(
211+
options: &ModelCheckingOptions,
212+
output: &str,
213+
property: &str,
214+
) -> StormValue {
211215
const RESULT_TEXT: &str = "Result (for initial states):";
212216

213217
let search_string = format!("Model checking property \"{}\"", property);

website/docs/model-checking.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ Caesar does not automatically update these images.
7676
To update the `:ci` image for example, run `docker pull movesrwth/storm:ci`.
7777
</small>
7878

79-
The above flag can be used with Caesar's `to-jani` command:
79+
The above flag can be used with Caesar's `mc` command:
8080
For example:
8181
```bash
82-
caesar to-jani --run-storm path example.heyvl
82+
caesar mc --run-storm path example.heyvl
8383
```
8484
The result will look like this:
8585
```
@@ -93,10 +93,10 @@ Furthermore, you can set the `--no-verify` flag to only run model checking and n
9393

9494
### Option B: Generating JANI Manually {#generating-jani-manually}
9595

96-
To export JANI files for the model checker, run Caesar with the `to-jani` subcommand and the `--jani-dir DIR` option to instruct it to save all translateable (co)procs to `.jani` files in the directory `DIR`:
96+
To export JANI files for the model checker, run Caesar with the `mc` subcommand and the `--jani-dir DIR` option to instruct it to save all translateable (co)procs to `.jani` files in the directory `DIR`:
9797

9898
```bash
99-
caesar to-jani example.heyvl --jani-dir DIR
99+
caesar mc example.heyvl --jani-dir DIR
100100
```
101101

102102
The output JANI files will have the following structure that you can use:
@@ -163,7 +163,7 @@ proc geo_mc(init_c: UInt) -> (c: UInt, cont: Bool) // added input parameter init
163163
With Caesar, we could run the following command to approximate the expected reward for the program with `init_c = 5` with 10000 states:
164164

165165
```bash
166-
caesar to-jani --run-storm <VALUE> example.heyvl --storm-constants init_c=5 --storm-state-limit 10000
166+
caesar mc --run-storm <VALUE> example.heyvl --storm-constants init_c=5 --storm-state-limit 10000
167167
```
168168
And we get a result like this:
169169
```

0 commit comments

Comments
 (0)