Skip to main content

enabled

Function enabled 

Source
pub fn enabled(
    model: &Model,
    action: &Pred,
    nonstuttering: Option<ExprId>,
    state: &State,
) -> Result<bool, EnabledError>
Expand description

Whether action has a successor from state: ENABLED action, or with nonstuttering, ENABLED <<action>>_nonstuttering, which is the enabledness that WF/SF refer to. nonstuttering is an expression in action’s scope.

use std::sync::Arc;
use dive_model::Pred;
use dive_value::Value;
let src = "---- MODULE M ----\nEXTENDS Naturals\nVARIABLE x\nInit == x = 0\nNext == x < 2 /\\ x' = x + 1\n====\n";
let analysis = dive_sema::analyze_source("M.tla", src, &Default::default());
let ir = Arc::new(dive_ir::lower(&analysis)?);
let cfg = dive_config::parse("INIT Init\nNEXT Next\n").into_config().unwrap();
let model = dive_model::bind(ir, &cfg, &dive_model::BindOptions::tlc())?;
let next = model.next.clone().unwrap();
assert!(dive_trace::enabled::enabled(&model, &next, None, &Arc::from([Some(Value::from(1))]))?);
assert!(!dive_trace::enabled::enabled(&model, &next, None, &Arc::from([Some(Value::from(2))]))?);

§Errors

A foreign or malformed model context, state or predicate; an evaluation error or refusal during the search, including composition outside the pure bounded TLA slice (crate::COMPOSITION_UNSUPPORTED); and a string or model value created after binding (crate::RUNTIME_NAMES_UNSUPPORTED), whatever the result.