Skip to main content

Function

Struct Function 

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

A function symbol in first-order logic.

Functions represent operations that take terms as arguments and produce new terms. They have a fixed arity (number of arguments). A function with arity 0 is called a constant and represents a specific object in the domain.

§Examples

use vampire_prover::Function;

// Create a constant (0-ary function)
let socrates = Function::constant("socrates");

// Create a unary function
let successor = Function::new("succ", 1);

// Create a binary function
let add = Function::new("add", 2);

Implementations§

Source§

impl Function

Source

pub fn new(name: &str, arity: u32) -> Self

Creates a new function symbol with the given name and arity.

Calling this method multiple times with the same name and arity will return the same function symbol. It is safe to call this with the same name but different arities - they will be treated as distinct function symbols.

§Arguments
  • name - The name of the function symbol
  • arity - The number of arguments this function takes
§Examples
use vampire_prover::Function;

let mult = Function::new("mult", 2);
assert_eq!(mult.arity(), 2);

// Same name and arity returns the same symbol
let mult2 = Function::new("mult", 2);
assert_eq!(mult, mult2);

// Same name but different arity is a different symbol
let mult3 = Function::new("mult", 3);
assert_ne!(mult.arity(), mult3.arity());
Source

pub fn arity(&self) -> u32

Returns the arity (number of arguments) of this function.

§Examples
use vampire_prover::Function;

let f = Function::new("f", 3);
assert_eq!(f.arity(), 3);
Source

pub fn constant(name: &str) -> Term

Creates a constant term (0-ary function).

This is a convenience method equivalent to Function::new(name, 0).with([]). Constants represent specific objects in the domain.

§Arguments
  • name - The name of the constant
§Examples
use vampire_prover::Function;

let socrates = Function::constant("socrates");
let zero = Function::constant("0");
Source

pub fn with(&self, args: impl IntoTermArgs) -> Term

Applies this function to the given arguments, creating a term.

This method accepts multiple argument formats for convenience:

  • Single term: f.with(x)
  • Array: f.with([x, y])
§Panics

Panics if the number of arguments does not match the function’s arity.

§Examples
use vampire_prover::{Function, Term};

let add = Function::new("add", 2);
let x = Term::new_var(0);
let y = Term::new_var(1);

// Multiple arguments:
let sum = add.with([x, y]);

// Single argument:
let succ = Function::new("succ", 1);
let sx = succ.with(x);

Trait Implementations§

Source§

impl Clone for Function

Source§

fn clone(&self) -> Function

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 Function

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Hash for Function

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Function

Source§

fn eq(&self, other: &Function) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Function

Source§

impl Eq for Function

Source§

impl StructuralPartialEq for Function

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.