Skip to main content

datalog_structural_model/termination/
verdict.rs

1//! [`WeakAcyclicity`] — the certificate returned for a weakly acyclic program.
2
3use super::criterion::TerminationCriterion;
4use super::edge::ArgumentPosition;
5
6/// Evidence that a program satisfies [`TerminationCriterion::WeaklyAcyclic`].
7#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
8#[serde(deny_unknown_fields)]
9pub struct WeakAcyclicity {
10    pub(super) positions: usize,
11    pub(super) special_edges: usize,
12    pub(super) skolem_depth: usize,
13    pub(super) deepest: Option<ArgumentPosition>,
14}
15
16impl WeakAcyclicity {
17    /// The criterion this evidence proves.
18    #[must_use]
19    pub fn criterion(&self) -> TerminationCriterion {
20        TerminationCriterion::WeaklyAcyclic
21    }
22
23    /// Number of distinct predicate positions in the graph.
24    #[must_use]
25    pub fn positions(&self) -> usize {
26        self.positions
27    }
28
29    /// Number of value-inventing edges, all acyclic.
30    #[must_use]
31    pub fn special_edges(&self) -> usize {
32        self.special_edges
33    }
34
35    /// The largest number of value-inventing edges on any path: an upper
36    /// bound on how deeply invented values can nest.
37    #[must_use]
38    pub fn skolem_depth(&self) -> usize {
39        self.skolem_depth
40    }
41
42    /// The smallest position reaching [`Self::skolem_depth`], when it is
43    /// greater than zero.
44    #[must_use]
45    pub fn deepest(&self) -> Option<&ArgumentPosition> {
46        self.deepest.as_ref()
47    }
48}