Skip to main content

Problem

Struct Problem 

Source
pub struct Problem { /* private fields */ }
Expand description

A theorem proving problem consisting of axioms and an optional conjecture.

A Problem is constructed by adding axioms (assumed to be true) and optionally a conjecture (the statement to be proved). The problem is then solved by calling Problem::solve, which invokes the Vampire theorem prover.

§Examples

§Basic Usage

use vampire_prover::{Function, Predicate, Problem, ProofRes, Options, forall};

let mortal = Predicate::new("mortal", 1);
let human = Predicate::new("human", 1);
let socrates = Function::constant("socrates");

let result = Problem::new(Options::new())
    .with_axiom(human.with(socrates))
    .with_axiom(forall(|x| human.with(x) >> mortal.with(x)))
    .conjecture(mortal.with(socrates))
    .solve();

assert_eq!(result, ProofRes::Proved);

§Without Conjecture

You can also create problems without a conjecture to check satisfiability:

use vampire_prover::{Function, Predicate, Problem, Options};

let p = Predicate::new("P", 1);
let x = Function::constant("x");

let result = Problem::new(Options::new())
    .with_axiom(p.with(x))
    .with_axiom(!p.with(x))  // Contradiction
    .solve();

// This should be unsatisfiable

Implementations§

Source§

impl Problem

Source

pub fn new(options: Options) -> Self

Creates a new empty problem with the given options.

§Arguments
  • options - Configuration options for the prover
§Examples
use vampire_prover::{Problem, Options};
use std::time::Duration;

// Default options
let problem = Problem::new(Options::new());

// With timeout
let problem = Problem::new(Options::new().timeout(Duration::from_secs(5)));
Source

pub fn with_axiom(self, f: Formula) -> Self

Adds an axiom to the problem.

Axioms are formulas assumed to be true. The prover will use these axioms to attempt to prove the conjecture (if one is provided).

This method consumes self and returns a new Problem, allowing for method chaining.

§Arguments
  • f - The axiom formula to add
§Examples
use vampire_prover::{Function, Predicate, Problem, Options, forall};

let p = Predicate::new("P", 1);
let q = Predicate::new("Q", 1);

let problem = Problem::new(Options::new())
    .with_axiom(forall(|x| p.with(x)))
    .with_axiom(forall(|x| p.with(x) >> q.with(x)));
Source

pub fn conjecture(self, f: Formula) -> Self

Sets the conjecture for the problem.

The conjecture is the statement that the prover will attempt to prove from the axioms. A problem can have at most one conjecture.

This method consumes self and returns a new Problem, allowing for method chaining.

§Arguments
  • f - The conjecture formula
§Examples
use vampire_prover::{Function, Predicate, Problem, Options, forall};

let p = Predicate::new("P", 1);
let q = Predicate::new("Q", 1);

let problem = Problem::new(Options::new())
    .with_axiom(forall(|x| p.with(x) >> q.with(x)))
    .conjecture(forall(|x| q.with(x)));  // Try to prove this
Source

pub fn solve(self) -> ProofRes

Solves the problem using the Vampire theorem prover.

This method consumes the problem and invokes Vampire to either prove the conjecture from the axioms, find a counterexample, or determine that the result is unknown.

§Returns

A ProofRes indicating whether the conjecture was proved, found to be unprovable, or whether the result is unknown (due to timeout, memory limits, or incompleteness).

§Examples
use vampire_prover::{Function, Predicate, Problem, ProofRes, Options, forall};

let p = Predicate::new("P", 1);
let x = Function::constant("x");

let result = Problem::new(Options::new())
    .with_axiom(p.with(x))
    .conjecture(p.with(x))
    .solve();

assert_eq!(result, ProofRes::Proved);

Trait Implementations§

Source§

impl Clone for Problem

Source§

fn clone(&self) -> Problem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Problem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.