Skip to main content

Proof

Struct Proof 

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

A proof tree with explicit node tracking.

This structure maintains a DAG (Directed Acyclic Graph) of proof steps, allowing for efficient premise tracking and proof compression.

Implementations§

Source§

impl Proof

Source

pub fn new() -> Self

Create a new empty proof

Source

pub fn add_axiom(&mut self, conclusion: impl Into<String>) -> ProofNodeId

Add an axiom to the proof

Source

pub fn add_inference( &mut self, rule: impl Into<String>, premises: Vec<ProofNodeId>, conclusion: impl Into<String>, ) -> ProofNodeId

Add an inference step to the proof

Source

pub fn add_inference_with_args( &mut self, rule: impl Into<String>, premises: Vec<ProofNodeId>, args: Vec<String>, conclusion: impl Into<String>, ) -> ProofNodeId

Add an inference step with arguments

Source

pub fn get_node(&self, id: ProofNodeId) -> Option<&ProofNode>

Get a proof node by ID

Source

pub fn update_conclusion( &mut self, id: ProofNodeId, new_conclusion: impl Into<String>, ) -> bool

Update the conclusion of a proof node.

Returns true if the node was found and updated, false otherwise. This is useful for proof simplification and transformation.

Source

pub fn nodes(&self) -> &[ProofNode]

Get all proof nodes

Source

pub fn roots(&self) -> &[ProofNodeId]

Get the root nodes

Source

pub fn root(&self) -> Option<ProofNodeId>

Get the primary root (last added root)

Source

pub fn root_node(&self) -> Option<&ProofNode>

Get the primary root node

Source

pub fn len(&self) -> usize

Get the number of nodes

Source

pub fn depth(&self) -> u32

Get the maximum depth of the proof tree

Source

pub fn node_count(&self) -> usize

Get the node count (alias for len())

Source

pub fn leaf_nodes(&self) -> Vec<ProofNodeId>

Get all leaf nodes (axioms - nodes with no premises)

Source

pub fn premises(&self, node_id: ProofNodeId) -> Option<&[ProofNodeId]>

Get the premises of a node (if it’s an inference)

Source

pub fn is_empty(&self) -> bool

Check if the proof is empty

Source

pub fn clear(&mut self)

Clear the proof

Source

pub fn stats(&self) -> ProofStats

Get proof statistics

Source

pub fn write<W: Write>(&self, writer: W) -> Result<()>

Write the proof in a human-readable format

Source

pub fn to_string_repr(&self) -> String

Convert to string

Source

pub fn add_axioms( &mut self, conclusions: impl IntoIterator<Item = impl Into<String>>, ) -> Vec<ProofNodeId>

Add multiple axioms at once and return their IDs

Source

pub fn find_nodes_by_rule(&self, rule: &str) -> Vec<ProofNodeId>

Find all nodes with a specific rule

Source

pub fn find_nodes_by_conclusion(&self, conclusion: &str) -> Vec<ProofNodeId>

Find all nodes with a specific conclusion

Source

pub fn get_children(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>

Get all direct children (premises) of a node

Source

pub fn get_parents(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>

Get all direct parents (dependents) of a node

Source

pub fn is_ancestor( &self, ancestor: ProofNodeId, descendant: ProofNodeId, ) -> bool

Check if one node is an ancestor of another

Source

pub fn get_all_ancestors(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>

Get all ancestors of a node (all nodes it depends on)

Source

pub fn count_rule(&self, rule: &str) -> usize

Count nodes of a specific rule type

Source

pub fn set_metadata(&mut self, node_id: ProofNodeId, metadata: ProofMetadata)

Set metadata for a proof node.

Source

pub fn get_metadata(&self, node_id: ProofNodeId) -> Option<&ProofMetadata>

Get metadata for a proof node.

Source

pub fn get_metadata_mut( &mut self, node_id: ProofNodeId, ) -> Option<&mut ProofMetadata>

Get mutable metadata for a proof node.

Source

pub fn remove_metadata(&mut self, node_id: ProofNodeId) -> Option<ProofMetadata>

Remove metadata for a proof node.

Source

pub fn has_metadata(&self, node_id: ProofNodeId) -> bool

Check if a node has metadata.

Source

pub fn nodes_with_tag(&self, tag: &str) -> Vec<ProofNodeId>

Get all nodes with a specific tag.

Source

pub fn nodes_with_priority(&self, priority: Priority) -> Vec<ProofNodeId>

Get all nodes with a specific priority.

Source

pub fn nodes_with_difficulty(&self, difficulty: Difficulty) -> Vec<ProofNodeId>

Get all nodes with a specific difficulty.

Source

pub fn nodes_with_strategy(&self, strategy: Strategy) -> Vec<ProofNodeId>

Get all nodes with a specific strategy.

Source

pub fn get_or_create_metadata( &mut self, node_id: ProofNodeId, ) -> &mut ProofMetadata

Get or create metadata for a node.

Trait Implementations§

Source§

impl Clone for Proof

Source§

fn clone(&self) -> Proof

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 Proof

Source§

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

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

impl Default for Proof

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Proof

§

impl RefUnwindSafe for Proof

§

impl Send for Proof

§

impl Sync for Proof

§

impl Unpin for Proof

§

impl UnsafeUnpin for Proof

§

impl UnwindSafe for Proof

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.