-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move UnboxedFormula in a separate module for convenience features
- Loading branch information
1 parent
6f0e915
commit 2573625
Showing
6 changed files
with
101 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod unbox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::syntax_tree::fol::{ | ||
AtomicFormula, BinaryConnective, Formula, Quantification, UnaryConnective, | ||
}; | ||
|
||
pub enum UnboxedFormula { | ||
AtomicFormula(AtomicFormula), | ||
UnaryFormula { | ||
connective: UnaryConnective, | ||
formula: Formula, | ||
}, | ||
BinaryFormula { | ||
connective: BinaryConnective, | ||
lhs: Formula, | ||
rhs: Formula, | ||
}, | ||
QuantifiedFormula { | ||
quantification: Quantification, | ||
formula: Formula, | ||
}, | ||
} | ||
|
||
impl UnboxedFormula { | ||
pub fn rebox(self) -> Formula { | ||
match self { | ||
Self::AtomicFormula(f) => Formula::AtomicFormula(f), | ||
Self::UnaryFormula { | ||
connective, | ||
formula, | ||
} => Formula::UnaryFormula { | ||
connective, | ||
formula: Box::new(formula), | ||
}, | ||
Self::BinaryFormula { | ||
connective, | ||
lhs, | ||
rhs, | ||
} => Formula::BinaryFormula { | ||
connective, | ||
lhs: Box::new(lhs), | ||
rhs: Box::new(rhs), | ||
}, | ||
Self::QuantifiedFormula { | ||
quantification, | ||
formula, | ||
} => Formula::QuantifiedFormula { | ||
quantification, | ||
formula: Box::new(formula), | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use crate::syntax_tree::fol::Formula; | ||
|
||
use self::fol::UnboxedFormula; | ||
|
||
pub mod fol; | ||
|
||
pub trait Unbox { | ||
type Unboxed; | ||
|
||
fn unbox(self) -> Self::Unboxed; | ||
} | ||
|
||
impl Unbox for Formula { | ||
type Unboxed = UnboxedFormula; | ||
|
||
fn unbox(self) -> UnboxedFormula { | ||
match self { | ||
Self::AtomicFormula(f) => UnboxedFormula::AtomicFormula(f), | ||
Self::UnaryFormula { | ||
connective, | ||
formula, | ||
} => UnboxedFormula::UnaryFormula { | ||
connective, | ||
formula: *formula, | ||
}, | ||
Self::BinaryFormula { | ||
connective, | ||
lhs, | ||
rhs, | ||
} => UnboxedFormula::BinaryFormula { | ||
connective, | ||
lhs: *lhs, | ||
rhs: *rhs, | ||
}, | ||
Self::QuantifiedFormula { | ||
quantification, | ||
formula, | ||
} => UnboxedFormula::QuantifiedFormula { | ||
quantification, | ||
formula: *formula, | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod convenience; | ||
pub mod formatting; | ||
pub mod parsing; | ||
pub mod simplifying; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters