pub enum VerifyExpr {
Show 18 variants
Int(i64),
Bool(bool),
Var(String),
Binary {
op: VerifyOp,
left: Box<VerifyExpr>,
right: Box<VerifyExpr>,
},
Not(Box<VerifyExpr>),
ForAll {
vars: Vec<(String, VerifyType)>,
body: Box<VerifyExpr>,
},
Exists {
vars: Vec<(String, VerifyType)>,
body: Box<VerifyExpr>,
},
Apply {
name: String,
args: Vec<VerifyExpr>,
},
ApplyInt {
name: String,
args: Vec<VerifyExpr>,
},
BitVecConst {
width: u32,
value: u64,
},
BitVecBinary {
op: BitVecOp,
left: Box<VerifyExpr>,
right: Box<VerifyExpr>,
},
BitVecExtract {
high: u32,
low: u32,
operand: Box<VerifyExpr>,
},
BitVecConcat(Box<VerifyExpr>, Box<VerifyExpr>),
AtState {
state: Box<VerifyExpr>,
expr: Box<VerifyExpr>,
},
Transition {
from: Box<VerifyExpr>,
to: Box<VerifyExpr>,
},
Select {
array: Box<VerifyExpr>,
index: Box<VerifyExpr>,
},
Store {
array: Box<VerifyExpr>,
index: Box<VerifyExpr>,
value: Box<VerifyExpr>,
},
Iff(Box<VerifyExpr>, Box<VerifyExpr>),
}Expand description
Expression AST for verification.
This IR is designed to be easily encodable into Z3 ASTs.
Variants§
Int(i64)
Integer literal
Bool(bool)
Boolean literal
Var(String)
Variable reference
Binary
Binary operation
Not(Box<VerifyExpr>)
Logical negation
ForAll
Universal quantifier: forall x: T. P(x)
Exists
Existential quantifier: exists x: T. P(x)
Apply
Uninterpreted function application (the “catch-all”)
Used for predicates, modals, temporals, etc. that we can’t directly encode semantically. Z3 treats these as opaque functions and reasons about them structurally.
Examples:
Mortal(socrates)->Apply { name: "Mortal", args: [Var("socrates")] }Possible(P)->Apply { name: "Possible", args: [P] }
ApplyInt
Uninterpreted INT-valued function application: Int^n → Int.
For function symbols in TERM position — sum(a, b) (the Link-lattice
join ⊕), GovernmentOf(x), has(x, y) — where VerifyExpr::Apply
(which encodes as Int^n → Bool) would be ill-sorted.
BitVecConst
Bitvector constant with explicit width.
BitVecBinary
Bitvector binary operation.
BitVecExtract
Bitvector bit extraction: operand[high:low].
BitVecConcat(Box<VerifyExpr>, Box<VerifyExpr>)
Bitvector concatenation.
AtState
Expression evaluated at a specific state (for BMC unrolling).
Transition
State transition relation: from → to.
Select
Array select: array[index].
Store
Array store: array[index] := value.
Iff(Box<VerifyExpr>, Box<VerifyExpr>)
Biconditional: left ↔ right. Used for Z3 equivalence queries.
Implementations§
Source§impl VerifyExpr
impl VerifyExpr
Sourcepub fn var(name: impl Into<String>) -> Self
pub fn var(name: impl Into<String>) -> Self
Create a variable reference.
§Examples
use logicaffeine_verify::VerifyExpr;
let x = VerifyExpr::var("x");
let counter = VerifyExpr::var("counter");Sourcepub fn int(n: i64) -> Self
pub fn int(n: i64) -> Self
Create an integer literal.
§Examples
use logicaffeine_verify::VerifyExpr;
let five = VerifyExpr::int(5);
let negative = VerifyExpr::int(-42);Sourcepub fn bool(b: bool) -> Self
pub fn bool(b: bool) -> Self
Create a boolean literal.
§Examples
use logicaffeine_verify::VerifyExpr;
let truth = VerifyExpr::bool(true);
let falsity = VerifyExpr::bool(false);Sourcepub fn binary(op: VerifyOp, left: VerifyExpr, right: VerifyExpr) -> Self
pub fn binary(op: VerifyOp, left: VerifyExpr, right: VerifyExpr) -> Self
Sourcepub fn not(expr: VerifyExpr) -> Self
pub fn not(expr: VerifyExpr) -> Self
Create a negation.
§Examples
use logicaffeine_verify::VerifyExpr;
// ¬p
let not_p = VerifyExpr::not(VerifyExpr::var("p"));
// ¬(x > 5)
let not_gt = VerifyExpr::not(
VerifyExpr::gt(VerifyExpr::var("x"), VerifyExpr::int(5))
);Sourcepub fn apply(name: impl Into<String>, args: Vec<VerifyExpr>) -> Self
pub fn apply(name: impl Into<String>, args: Vec<VerifyExpr>) -> Self
Create an uninterpreted function application.
Use this for predicates, modals, temporals, and other constructs that cannot be directly encoded semantically. Z3 treats these as opaque functions and reasons about them structurally.
§Examples
use logicaffeine_verify::VerifyExpr;
// Mortal(socrates)
let mortal = VerifyExpr::apply("Mortal", vec![VerifyExpr::var("socrates")]);
// Possible(P) for modal logic
let possible_p = VerifyExpr::apply("Possible", vec![VerifyExpr::var("P")]);
// Before(e1, e2) for temporal relations
let before = VerifyExpr::apply("Before", vec![
VerifyExpr::var("e1"),
VerifyExpr::var("e2"),
]);Sourcepub fn apply_int(name: impl Into<String>, args: Vec<VerifyExpr>) -> Self
pub fn apply_int(name: impl Into<String>, args: Vec<VerifyExpr>) -> Self
Create an uninterpreted INT-valued function application (Int^n → Int)
for function symbols in term position, e.g. the lattice join
sum(a, b).
Sourcepub fn forall(vars: Vec<(String, VerifyType)>, body: VerifyExpr) -> Self
pub fn forall(vars: Vec<(String, VerifyType)>, body: VerifyExpr) -> Self
Create a universal quantifier.
§Examples
use logicaffeine_verify::{VerifyExpr, VerifyType};
// ∀x: Object. Mortal(x) → Human(x)
let all_mortals_are_human = VerifyExpr::forall(
vec![("x".to_string(), VerifyType::Object)],
VerifyExpr::implies(
VerifyExpr::apply("Mortal", vec![VerifyExpr::var("x")]),
VerifyExpr::apply("Human", vec![VerifyExpr::var("x")]),
),
);Sourcepub fn exists(vars: Vec<(String, VerifyType)>, body: VerifyExpr) -> Self
pub fn exists(vars: Vec<(String, VerifyType)>, body: VerifyExpr) -> Self
Create an existential quantifier.
§Examples
use logicaffeine_verify::{VerifyExpr, VerifyType};
// ∃x: Object. Mortal(x)
let something_is_mortal = VerifyExpr::exists(
vec![("x".to_string(), VerifyType::Object)],
VerifyExpr::apply("Mortal", vec![VerifyExpr::var("x")]),
);Sourcepub fn eq(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn eq(left: VerifyExpr, right: VerifyExpr) -> Self
Equality: left == right.
§Examples
use logicaffeine_verify::VerifyExpr;
let x_equals_10 = VerifyExpr::eq(VerifyExpr::var("x"), VerifyExpr::int(10));Sourcepub fn gt(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn gt(left: VerifyExpr, right: VerifyExpr) -> Self
Greater than: left > right.
§Examples
use logicaffeine_verify::VerifyExpr;
let x_gt_5 = VerifyExpr::gt(VerifyExpr::var("x"), VerifyExpr::int(5));Sourcepub fn lt(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn lt(left: VerifyExpr, right: VerifyExpr) -> Self
Less than: left < right.
§Examples
use logicaffeine_verify::VerifyExpr;
let x_lt_100 = VerifyExpr::lt(VerifyExpr::var("x"), VerifyExpr::int(100));Sourcepub fn gte(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn gte(left: VerifyExpr, right: VerifyExpr) -> Self
Greater than or equal: left >= right.
§Examples
use logicaffeine_verify::VerifyExpr;
let x_gte_0 = VerifyExpr::gte(VerifyExpr::var("x"), VerifyExpr::int(0));Sourcepub fn lte(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn lte(left: VerifyExpr, right: VerifyExpr) -> Self
Less than or equal: left <= right.
§Examples
use logicaffeine_verify::VerifyExpr;
let x_lte_max = VerifyExpr::lte(VerifyExpr::var("x"), VerifyExpr::var("max"));Sourcepub fn neq(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn neq(left: VerifyExpr, right: VerifyExpr) -> Self
Inequality: left != right.
§Examples
use logicaffeine_verify::VerifyExpr;
let x_neq_0 = VerifyExpr::neq(VerifyExpr::var("x"), VerifyExpr::int(0));Sourcepub fn and(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn and(left: VerifyExpr, right: VerifyExpr) -> Self
Conjunction: left && right.
§Examples
use logicaffeine_verify::VerifyExpr;
// x > 0 && x < 100
let in_range = VerifyExpr::and(
VerifyExpr::gt(VerifyExpr::var("x"), VerifyExpr::int(0)),
VerifyExpr::lt(VerifyExpr::var("x"), VerifyExpr::int(100)),
);Sourcepub fn or(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn or(left: VerifyExpr, right: VerifyExpr) -> Self
Disjunction: left || right.
§Examples
use logicaffeine_verify::VerifyExpr;
// x < 0 || x > 100
let out_of_range = VerifyExpr::or(
VerifyExpr::lt(VerifyExpr::var("x"), VerifyExpr::int(0)),
VerifyExpr::gt(VerifyExpr::var("x"), VerifyExpr::int(100)),
);Sourcepub fn implies(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn implies(left: VerifyExpr, right: VerifyExpr) -> Self
Material implication: left → right.
§Examples
use logicaffeine_verify::VerifyExpr;
// Mortal(x) → Human(x)
let mortals_are_human = VerifyExpr::implies(
VerifyExpr::apply("Mortal", vec![VerifyExpr::var("x")]),
VerifyExpr::apply("Human", vec![VerifyExpr::var("x")]),
);Sourcepub fn bv_binary(op: BitVecOp, left: VerifyExpr, right: VerifyExpr) -> Self
pub fn bv_binary(op: BitVecOp, left: VerifyExpr, right: VerifyExpr) -> Self
Create a bitvector binary operation.
Sourcepub fn iff(left: VerifyExpr, right: VerifyExpr) -> Self
pub fn iff(left: VerifyExpr, right: VerifyExpr) -> Self
Biconditional: left ↔ right.
Trait Implementations§
Source§impl Clone for VerifyExpr
impl Clone for VerifyExpr
Source§fn clone(&self) -> VerifyExpr
fn clone(&self) -> VerifyExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VerifyExpr
impl Debug for VerifyExpr
Source§impl<'de> Deserialize<'de> for VerifyExpr
impl<'de> Deserialize<'de> for VerifyExpr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for VerifyExpr
impl PartialEq for VerifyExpr
Source§fn eq(&self, other: &VerifyExpr) -> bool
fn eq(&self, other: &VerifyExpr) -> bool
self and other values to be equal, and is used by ==.