Skip to content

Commit

Permalink
Merge branch 'master' into tobias/simplifications_part1
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJHansen authored Dec 17, 2024
2 parents 0f5604c + ecc2fa5 commit 346c0bd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/syntax_tree/fol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ impl SymbolicTerm {
SymbolicTerm::Symbol(_) | SymbolicTerm::Variable(_) => IndexSet::new(),
}
}

pub fn substitute(self, var: Variable, term: SymbolicTerm) -> Self {
match self {
SymbolicTerm::Variable(s) if var.name == s && var.sort == Sort::Symbol => term,
_ => self,
}
}
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
Expand Down Expand Up @@ -202,6 +209,14 @@ impl GeneralTerm {
"cannot substitute general term `{term}` for the integer variable `{var}`"
),
},
GeneralTerm::SymbolicTerm(t) if var.sort == Sort::Symbol => match term {
GeneralTerm::SymbolicTerm(term) => {
GeneralTerm::SymbolicTerm(t.substitute(var, term))
}
_ => panic!(
"cannot substitute general term `{term}` for the symbolic variable `{var}`"
),
},
t => t,
}
}
Expand Down

0 comments on commit 346c0bd

Please sign in to comment.