Expand description
§use-logic
Small boolean algebra helpers for `RustUse`.
Explicit implication, equivalence, exclusive-or, NAND, NOR, and majority helpers without a larger predicate framework.
§Install
[dependencies]
use-logic = "0.0.1"§Foundation
use-logic provides a deliberately small boolean-helper surface. The crate currently exposes explicit helpers for material implication, equivalence, exclusive-or, NAND, NOR, and three-input majority logic. The API stays close to plain bool instead of wrapping truth values in extra types that do not add invariants.
Binary boolean algebraimplication, equivalence, and exclusive_or make truth-table intent explicit at the call site.
|
Derived gatesnand and nor cover the two common universal gate helpers directly.
|
Three-input majoritymajority covers simple voting and quorum logic without leaving boolean space.
|
| Helper group | Primary items | Best fit |
|---|---|---|
| Binary relations | implication, equivalence, exclusive_or | Truth-table oriented code that should stay readable without ad hoc boolean expressions |
| Gate helpers | nand, nor | Boolean-algebra code that wants named derived operations |
| Majority logic | majority | Small vote or quorum rules over three predicates |
§When to use directly
Choose use-logic directly when predicate and boolean-structure helpers are the only surface you need and you want to keep that concern narrower than the umbrella facade.
| Scenario | Use use-logic directly? | Why |
|---|---|---|
| You only need named boolean helpers | Yes | The crate stays smaller than the facade and keeps boolean intent explicit |
| You want small majority or truth-table helpers without a broader predicate framework | Yes | The API already covers the common binary and three-input cases directly |
| You also need geometry, combinatorics, or other math domains | Usually no | use-math can unify the concrete surfaces behind features |
§Scope
- The current surface is intentionally small and concrete.
- Helpers stay as
const fnoverboolrather than introducing wrapper types without added invariants. - Set operations and algebraic structures belong in adjacent focused crates.
§Examples
§Binary boolean helpers
use use_logic::{equivalence, exclusive_or, implication};
assert!(implication(false, true));
assert!(!implication(true, false));
assert!(equivalence(true, true));
assert!(exclusive_or(true, false));§Derived gates and majority logic
use use_logic::{majority, nand, nor};
assert!(!nand(true, true));
assert!(nor(false, false));
assert!(majority(true, true, false));
assert!(!majority(true, false, false));§Status
use-logic is a concrete pre-1.0 crate in the RustUse docs surface. The API remains intentionally small while adjacent set and algebra crates continue to grow around it.
Logic utilities for RustUse.
Modules§
- prelude
- Common ergonomic imports for
use-logic.
Functions§
- equivalence
- Returns whether two boolean values are logically equivalent.
- exclusive_
or - Returns the exclusive-or of two boolean values.
- implication
- Returns the material implication
left -> right. - majority
- Returns whether at least two of three inputs are
true. - nand
- Returns the NAND of two boolean values.
- nor
- Returns the NOR of two boolean values.