Skip to content

Commit

Permalink
Don't store duplicate outbound premises
Browse files Browse the repository at this point in the history
  • Loading branch information
bpandreotti committed May 16, 2024
1 parent 1e491e3 commit f031c82
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions carcara/src/ast/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ pub fn proof_list_to_node(commands: Vec<ProofCommand>) -> Rc<ProofNode> {
commands: std::vec::IntoIter<ProofCommand>,
accumulator: Vec<Rc<ProofNode>>,
args: Vec<AnchorArg>,
outbound_premises: Vec<Rc<ProofNode>>,
outbound_premises: IndexSet<Rc<ProofNode>>,
}

let mut stack: Vec<Frame> = vec![Frame {
commands: commands.into_iter(),
accumulator: Vec::new(),
args: Vec::new(),
outbound_premises: Vec::new(),
outbound_premises: IndexSet::new(),
}];

let new_root_proof = loop {
Expand All @@ -159,7 +159,7 @@ pub fn proof_list_to_node(commands: Vec<ProofCommand>) -> Rc<ProofNode> {
for p in &premises {
if p.depth() < stack.len() - 1 {
let frame = stack.last_mut().unwrap();
frame.outbound_premises.push(p.clone());
frame.outbound_premises.insert(p.clone());
}
}

Expand All @@ -186,7 +186,7 @@ pub fn proof_list_to_node(commands: Vec<ProofCommand>) -> Rc<ProofNode> {
commands: s.commands.into_iter(),
accumulator: Vec::new(),
args: s.args,
outbound_premises: Vec::new(),
outbound_premises: IndexSet::new(),
};
stack.push(frame);
continue;
Expand All @@ -202,14 +202,14 @@ pub fn proof_list_to_node(commands: Vec<ProofCommand>) -> Rc<ProofNode> {
for p in &frame.outbound_premises {
if p.depth() < stack.len() - 1 {
let frame = stack.last_mut().unwrap();
frame.outbound_premises.push(p.clone());
frame.outbound_premises.insert(p.clone());
}
}

ProofNode::Subproof(SubproofNode {
last_step: frame.accumulator.pop().unwrap(),
args: frame.args,
outbound_premises: frame.outbound_premises,
outbound_premises: frame.outbound_premises.into_iter().collect(),
})
}
};
Expand Down

0 comments on commit f031c82

Please sign in to comment.