-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bool fn trait): began impl BooleanFunction for Expression with i…
…ter methods
- Loading branch information
1 parent
68c68f7
commit a030f42
Showing
2 changed files
with
75 additions
and
0 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,74 @@ | ||
use crate::expressions::iterators::{ | ||
ExpressionDomainIterator, ExpressionImageIterator, ExpressionRelationIterator, | ||
ExpressionSupportIterator, | ||
}; | ||
use crate::expressions::Expression; | ||
use crate::traits::{BooleanFunction, BooleanValuation, Evaluate, GatherLiterals}; | ||
use std::collections::{BTreeMap, BTreeSet}; | ||
use std::fmt::Debug; | ||
|
||
impl<T: Debug + Clone + Eq + Ord> BooleanFunction<T> for Expression<T> { | ||
type DomainIterator = ExpressionDomainIterator; | ||
type RangeIterator = ExpressionImageIterator<T>; | ||
type RelationIterator = ExpressionRelationIterator<T>; | ||
type SupportIterator = ExpressionSupportIterator<T>; | ||
|
||
fn inputs(&self) -> BTreeSet<T> { | ||
self.gather_literals() | ||
} | ||
|
||
fn essential_inputs(&self) -> BTreeSet<T> { | ||
self.inputs() | ||
.into_iter() | ||
.filter(|input| { | ||
let true_valuation = BTreeMap::from([(input.clone(), true)]); | ||
let false_valuation = BTreeMap::from([(input.clone(), false)]); | ||
self.evaluate(&true_valuation) != self.evaluate(&false_valuation) | ||
}) | ||
.collect() | ||
} | ||
|
||
fn domain(&self) -> Self::DomainIterator { | ||
self.into() | ||
} | ||
|
||
fn image(&self) -> Self::RangeIterator { | ||
self.into() | ||
} | ||
|
||
fn relation(&self) -> Self::RelationIterator { | ||
self.into() | ||
} | ||
|
||
fn support(&self) -> Self::SupportIterator { | ||
self.into() | ||
} | ||
|
||
fn restrict(&self, _valuation: &BooleanValuation<T>) -> Self { | ||
todo!() | ||
} | ||
|
||
fn substitute(&self, _mapping: BTreeMap<T, Self>) -> Self { | ||
todo!() | ||
} | ||
|
||
fn existential_quantification(&self, _variables: BTreeSet<T>) -> Self { | ||
todo!() | ||
} | ||
|
||
fn universal_quantification(&self, _variables: BTreeSet<T>) -> Self { | ||
todo!() | ||
} | ||
|
||
fn derivative(&self, _variables: BTreeSet<T>) -> Self { | ||
todo!() | ||
} | ||
|
||
fn is_equivalent(&self, _other: Self) -> bool { | ||
todo!() | ||
} | ||
|
||
fn is_implied_by(&self, _other: Self) -> bool { | ||
todo!() | ||
} | ||
} |
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,4 +1,5 @@ | ||
mod bit; | ||
mod boolean_function; | ||
mod display; | ||
mod evaluate; | ||
mod gather_literals; | ||
|