Skip to main content

Crate use_logic

Crate use_logic 

Source
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.

Rust 1.95.0+ Edition 2024 Boolean helpers License MIT or Apache-2.0

§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 algebra
implication, equivalence, and exclusive_or make truth-table intent explicit at the call site.
Derived gates
nand and nor cover the two common universal gate helpers directly.
Three-input majority
majority covers simple voting and quorum logic without leaving boolean space.
Helper groupPrimary itemsBest fit
Binary relationsimplication, equivalence, exclusive_orTruth-table oriented code that should stay readable without ad hoc boolean expressions
Gate helpersnand, norBoolean-algebra code that wants named derived operations
Majority logicmajoritySmall 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.

ScenarioUse use-logic directly?Why
You only need named boolean helpersYesThe crate stays smaller than the facade and keeps boolean intent explicit
You want small majority or truth-table helpers without a broader predicate frameworkYesThe API already covers the common binary and three-input cases directly
You also need geometry, combinatorics, or other math domainsUsually nouse-math can unify the concrete surfaces behind features

§Scope

  • The current surface is intentionally small and concrete.
  • Helpers stay as const fn over bool rather 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.