Skip to content

Commit

Permalink
Add absurdum elimination
Browse files Browse the repository at this point in the history
  • Loading branch information
Mroik committed May 7, 2024
1 parent 42dce9b commit be4b675
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ enum State {
enum AbsurdumState {

Check warning on line 98 in src/app.rs

View workflow job for this annotation

GitHub Actions / tests

enum `AbsurdumState` is never used
IntroduceGetAssumption1,
IntroduceGetAssumption2(usize),
EliminateGetAssumption,
EliminateGetProposition(usize),
}

#[derive(PartialEq)]
Expand Down
26 changes: 26 additions & 0 deletions src/fitch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,21 @@ impl Fitch {
true
}

pub fn eliminate_absurdum(&mut self, absurdum: usize, introduce: &Rc<Proposition>) -> bool {
match self.statements.get(absurdum) {
Some((level, m))
if m.unwrap() == &Proposition::new_absurdum() && *level <= self.current_level =>
{
self.statements.push((
self.current_level,
FitchComponent::Deduction(introduce.clone()),
));
true
}
_ => false,
}
}

pub fn introduce_not(&mut self, sub_proof: usize) -> bool {
match self.get_subproof_result(sub_proof) {
None => return false,
Expand Down Expand Up @@ -545,6 +560,17 @@ mod tests {
);
}

#[test]
fn eliminate_absurdum() {
let mut fitch = Fitch::new();
let t0 = Proposition::new_absurdum();
let t1 = Proposition::new_term("A");
fitch.add_assumption(&t0);
let ris = fitch.eliminate_absurdum(0, &t1);
assert!(ris);
assert_eq!(fitch.statements.last().unwrap().1.unwrap(), &t1);
}

#[test]
fn introduce_not() {
let mut fitch = Fitch::new();
Expand Down

0 comments on commit be4b675

Please sign in to comment.