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
impl Proof
Sourcepub fn add_axiom(&mut self, conclusion: impl Into<String>) -> ProofNodeId
pub fn add_axiom(&mut self, conclusion: impl Into<String>) -> ProofNodeId
Add an axiom to the proof
Sourcepub fn add_inference(
&mut self,
rule: impl Into<String>,
premises: Vec<ProofNodeId>,
conclusion: impl Into<String>,
) -> ProofNodeId
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
Sourcepub fn add_inference_with_args(
&mut self,
rule: impl Into<String>,
premises: Vec<ProofNodeId>,
args: Vec<String>,
conclusion: impl Into<String>,
) -> ProofNodeId
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
Sourcepub fn get_node(&self, id: ProofNodeId) -> Option<&ProofNode>
pub fn get_node(&self, id: ProofNodeId) -> Option<&ProofNode>
Get a proof node by ID
Sourcepub fn update_conclusion(
&mut self,
id: ProofNodeId,
new_conclusion: impl Into<String>,
) -> bool
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.
Sourcepub fn roots(&self) -> &[ProofNodeId]
pub fn roots(&self) -> &[ProofNodeId]
Get the root nodes
Sourcepub fn root(&self) -> Option<ProofNodeId>
pub fn root(&self) -> Option<ProofNodeId>
Get the primary root (last added root)
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the node count (alias for len())
Sourcepub fn leaf_nodes(&self) -> Vec<ProofNodeId>
pub fn leaf_nodes(&self) -> Vec<ProofNodeId>
Get all leaf nodes (axioms - nodes with no premises)
Sourcepub fn premises(&self, node_id: ProofNodeId) -> Option<&[ProofNodeId]>
pub fn premises(&self, node_id: ProofNodeId) -> Option<&[ProofNodeId]>
Get the premises of a node (if it’s an inference)
Sourcepub fn stats(&self) -> ProofStats
pub fn stats(&self) -> ProofStats
Get proof statistics
Sourcepub fn write<W: Write>(&self, writer: W) -> Result<()>
pub fn write<W: Write>(&self, writer: W) -> Result<()>
Write the proof in a human-readable format
Sourcepub fn to_string_repr(&self) -> String
pub fn to_string_repr(&self) -> String
Convert to string
Sourcepub fn add_axioms(
&mut self,
conclusions: impl IntoIterator<Item = impl Into<String>>,
) -> Vec<ProofNodeId>
pub fn add_axioms( &mut self, conclusions: impl IntoIterator<Item = impl Into<String>>, ) -> Vec<ProofNodeId>
Add multiple axioms at once and return their IDs
Sourcepub fn find_nodes_by_rule(&self, rule: &str) -> Vec<ProofNodeId>
pub fn find_nodes_by_rule(&self, rule: &str) -> Vec<ProofNodeId>
Find all nodes with a specific rule
Sourcepub fn find_nodes_by_conclusion(&self, conclusion: &str) -> Vec<ProofNodeId>
pub fn find_nodes_by_conclusion(&self, conclusion: &str) -> Vec<ProofNodeId>
Find all nodes with a specific conclusion
Sourcepub fn get_children(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>
pub fn get_children(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>
Get all direct children (premises) of a node
Sourcepub fn get_parents(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>
pub fn get_parents(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>
Get all direct parents (dependents) of a node
Sourcepub fn is_ancestor(
&self,
ancestor: ProofNodeId,
descendant: ProofNodeId,
) -> bool
pub fn is_ancestor( &self, ancestor: ProofNodeId, descendant: ProofNodeId, ) -> bool
Check if one node is an ancestor of another
Sourcepub fn get_all_ancestors(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>
pub fn get_all_ancestors(&self, node_id: ProofNodeId) -> Vec<ProofNodeId>
Get all ancestors of a node (all nodes it depends on)
Sourcepub fn count_rule(&self, rule: &str) -> usize
pub fn count_rule(&self, rule: &str) -> usize
Count nodes of a specific rule type
Sourcepub fn set_metadata(&mut self, node_id: ProofNodeId, metadata: ProofMetadata)
pub fn set_metadata(&mut self, node_id: ProofNodeId, metadata: ProofMetadata)
Set metadata for a proof node.
Sourcepub fn get_metadata(&self, node_id: ProofNodeId) -> Option<&ProofMetadata>
pub fn get_metadata(&self, node_id: ProofNodeId) -> Option<&ProofMetadata>
Get metadata for a proof node.
Sourcepub fn get_metadata_mut(
&mut self,
node_id: ProofNodeId,
) -> Option<&mut ProofMetadata>
pub fn get_metadata_mut( &mut self, node_id: ProofNodeId, ) -> Option<&mut ProofMetadata>
Get mutable metadata for a proof node.
Sourcepub fn remove_metadata(&mut self, node_id: ProofNodeId) -> Option<ProofMetadata>
pub fn remove_metadata(&mut self, node_id: ProofNodeId) -> Option<ProofMetadata>
Remove metadata for a proof node.
Sourcepub fn has_metadata(&self, node_id: ProofNodeId) -> bool
pub fn has_metadata(&self, node_id: ProofNodeId) -> bool
Check if a node has metadata.
Sourcepub fn nodes_with_tag(&self, tag: &str) -> Vec<ProofNodeId>
pub fn nodes_with_tag(&self, tag: &str) -> Vec<ProofNodeId>
Get all nodes with a specific tag.
Sourcepub fn nodes_with_priority(&self, priority: Priority) -> Vec<ProofNodeId>
pub fn nodes_with_priority(&self, priority: Priority) -> Vec<ProofNodeId>
Get all nodes with a specific priority.
Sourcepub fn nodes_with_difficulty(&self, difficulty: Difficulty) -> Vec<ProofNodeId>
pub fn nodes_with_difficulty(&self, difficulty: Difficulty) -> Vec<ProofNodeId>
Get all nodes with a specific difficulty.
Sourcepub fn nodes_with_strategy(&self, strategy: Strategy) -> Vec<ProofNodeId>
pub fn nodes_with_strategy(&self, strategy: Strategy) -> Vec<ProofNodeId>
Get all nodes with a specific strategy.
Sourcepub fn get_or_create_metadata(
&mut self,
node_id: ProofNodeId,
) -> &mut ProofMetadata
pub fn get_or_create_metadata( &mut self, node_id: ProofNodeId, ) -> &mut ProofMetadata
Get or create metadata for a node.