Skip to content

Commit 441cc04

Browse files
committed
mc: add --jani-no-constants flag
1 parent b9fa9aa commit 441cc04

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ pub struct JaniOptions {
208208
#[arg(long)]
209209
pub jani_skip_quant_pre: bool,
210210

211+
/// Declare procedure inputs as JANI variables, not constants.
212+
#[arg(long)]
213+
pub jani_no_constants: bool,
214+
211215
/// By default, Caesar assigns arbitrary initial values to output variables.
212216
/// This means that the model does not reflect the possible effects of
213217
/// initial values of output variables on the program. Usually, this is not

src/mc/mod.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ pub fn proc_to_model(
185185
}
186186

187187
// Declare the proc inputs as model parameters
188-
// TODO: add an option to instead declare the proc parameters as
189-
// (indeterminate) inputs to the automaton
190188
model.constants.extend(constants);
191189

192190
// Make all of the automaton's variables public so they can be accessed by
@@ -239,15 +237,25 @@ fn translate_var_decls(
239237
) -> Result<(Vec<ConstantDeclaration>, Vec<VariableDeclaration>), JaniConversionError> {
240238
let mut vars = translate_local_decls(expr_translator, proc)?;
241239

242-
// we declare proc inputs as constants, not variables
240+
// by default, proc inputs are translated as constants
243241
let mut constants = vec![];
244242
for param in proc.inputs.node.iter() {
245-
constants.push(ConstantDeclaration {
246-
name: Identifier(param.name.to_string()),
247-
typ: translate_type(&param.ty, param.span)?,
248-
value: None,
249-
comment: None,
250-
});
243+
if !options.jani_no_constants {
244+
constants.push(ConstantDeclaration {
245+
name: Identifier(param.name.to_string()),
246+
typ: translate_type(&param.ty, param.span)?,
247+
value: None,
248+
comment: None,
249+
});
250+
} else {
251+
vars.push(VariableDeclaration {
252+
name: Identifier(param.name.to_string()),
253+
typ: translate_type(&param.ty, param.span)?,
254+
transient: false,
255+
initial_value: None,
256+
comment: None,
257+
});
258+
}
251259
}
252260

253261
// proc outputs are normal variables

website/docs/model-checking.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ The input parameters of the program are translated by Caesar to constants in the
176176
* For the [Caesar's Storm backend](#caesars-storm-backend) can fix values with the `--storm-constants <name>=<value>,...,<name>=<value>` command-line flag.
177177
* Storm itself uses the `--constants <name>=<value>,...,<name>=<value>` command-line flag.
178178

179+
Caesar can also be instructed to translate inputs to variables instead of constants with the `--jani-no-constants` flag.
180+
179181
**State Limits to Approximate Infinite-State Models.**
180182
Storm can be used with a state limit so that the model generation will stop its exploration at some number of states.
181183
This will yield a correct *under*-approximation of the expected reward.

0 commit comments

Comments
 (0)