-
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.
AllFunctions store BoolFnExt + Connective
- Loading branch information
Showing
4 changed files
with
74 additions
and
37 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 |
---|---|---|
@@ -1,27 +1,46 @@ | ||
//! Print truth tables for all the binary functions. | ||
#![allow(clippy::wildcard_imports)] | ||
|
||
use prop_logic::connective::*; | ||
use prop_logic::{connective::*, two_powers, CheckedArray}; | ||
|
||
fn print_stat<const ARITY: usize>(f: &dyn StoredBoolFn<ARITY>) | ||
where | ||
TruthTable<ARITY>: std::fmt::Display, | ||
two_powers::D: CheckedArray<ARITY>, | ||
{ | ||
print!("{}", f.notation()); | ||
let alternate: Vec<_> = f | ||
.alternate_notations() | ||
.into_iter() | ||
.flatten() | ||
.map(|n| n.to_string()) | ||
.collect(); | ||
if alternate.is_empty() { | ||
println!(); | ||
} else { | ||
println!(" (aka {alternate:?})"); | ||
} | ||
|
||
let table = f.get_truth_table(); | ||
println!("{table}"); | ||
} | ||
|
||
fn main() { | ||
println!("=== NULLARY ==="); | ||
for f in NULLARY_FUNCTIONS.iter() { | ||
let table = f.get_truth_table(); | ||
println!("{table}"); | ||
print_stat(f); | ||
println!(); | ||
} | ||
|
||
println!("=== UNARY ==="); | ||
for f in UNARY_FUNCTIONS.iter() { | ||
let table = f.get_truth_table(); | ||
println!("{table}"); | ||
print_stat(f); | ||
println!(); | ||
} | ||
|
||
println!("=== BINARY ==="); | ||
for f in BINARY_FUNCTIONS.iter() { | ||
let table = f.get_truth_table(); | ||
println!("{table}"); | ||
print_stat(f); | ||
println!(); | ||
} | ||
} |
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
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