Class TruthTableMinimizer

Namespace
LogicalOptimizer
Assembly
LogicalOptimizer.Minimization.dll

Exact two-level minimization: Quine–McCluskey prime implicant generation followed by an exact minimum cover search (essential primes + branch-and-bound, greedy fallback past a work limit). Cost order: total literals, then term count. Minterm bit convention: bit j of a minterm index is the value of variables[j] (variables are expected in sorted order).

public static class TruthTableMinimizer
Inheritance
TruthTableMinimizer
Inherited Members

Methods

MinimalPos(IReadOnlyList<string>, IReadOnlyCollection<int>, IReadOnlyCollection<int>?, long?, CancellationToken)

Minimal product-of-sums: the complement's minimal SOP negated via De Morgan.

public static AstNode MinimalPos(IReadOnlyList<string> variables, IReadOnlyCollection<int> onSet, IReadOnlyCollection<int>? dontCareSet = null, long? pairComparisonLimit = null, CancellationToken cancellationToken = default)

Parameters

variables IReadOnlyList<string>
onSet IReadOnlyCollection<int>
dontCareSet IReadOnlyCollection<int>
pairComparisonLimit long?
cancellationToken CancellationToken

Returns

AstNode

MinimalPosWithStatus(IReadOnlyList<string>, IReadOnlyCollection<int>, IReadOnlyCollection<int>?, long?, CancellationToken, int)

Like MinimalPos(IReadOnlyList<string>, IReadOnlyCollection<int>, IReadOnlyCollection<int>?, long?, CancellationToken) but also reports whether the minimum cover search of the complement completed: when ProvenMinimal is true the returned POS is provably minimal in (total literals, then clause count); when false the clause set is sound but the exact search hit coverStepLimit before proving optimality (mirrors MinimalSopWithStatus(IReadOnlyList<string>, IReadOnlyCollection<int>, IReadOnlyCollection<int>?, long?, CancellationToken, int) so the POS path is no longer silently unproven).

public static (AstNode Expression, bool ProvenMinimal) MinimalPosWithStatus(IReadOnlyList<string> variables, IReadOnlyCollection<int> onSet, IReadOnlyCollection<int>? dontCareSet = null, long? pairComparisonLimit = null, CancellationToken cancellationToken = default, int coverStepLimit = 200000)

Parameters

variables IReadOnlyList<string>
onSet IReadOnlyCollection<int>
dontCareSet IReadOnlyCollection<int>
pairComparisonLimit long?
cancellationToken CancellationToken
coverStepLimit int

Returns

(AstNode Expression, bool ProvenMinimal)

MinimalSop(IReadOnlyList<string>, IReadOnlyCollection<int>, IReadOnlyCollection<int>?, long?, CancellationToken)

Minimal sum-of-products for the function given by its ON-set (and optional don't-care set) over 2^variables.Count minterms.

public static AstNode MinimalSop(IReadOnlyList<string> variables, IReadOnlyCollection<int> onSet, IReadOnlyCollection<int>? dontCareSet = null, long? pairComparisonLimit = null, CancellationToken cancellationToken = default)

Parameters

variables IReadOnlyList<string>

Sorted variable names; bit j of a minterm is variables[j].

onSet IReadOnlyCollection<int>

Minterms where the function is 1.

dontCareSet IReadOnlyCollection<int>

Minterms whose value is unspecified.

pairComparisonLimit long?

Optional work budget for prime-implicant generation; when exceeded a ComputationBudgetExceededException is thrown so callers can fall back to heuristic simplification (dense functions near 12 variables can otherwise cost seconds).

cancellationToken CancellationToken

Cooperative cancellation, observed throughout: prime generation (per level and within dense pairing loops), covering-table reduction (per row/column pass) and the branch-and-bound cover search (periodically per node).

Returns

AstNode

MinimalSopWithStatus(IReadOnlyList<string>, IReadOnlyCollection<int>, IReadOnlyCollection<int>?, long?, CancellationToken, int)

Like MinimalSop(IReadOnlyList<string>, IReadOnlyCollection<int>, IReadOnlyCollection<int>?, long?, CancellationToken) but also reports whether the minimum cover search completed: when ProvenMinimal is true the returned SOP is provably minimal in (total literals, then term count); when false the cover is sound but the exact search hit coverStepLimit before proving optimality.

public static (AstNode Expression, bool ProvenMinimal) MinimalSopWithStatus(IReadOnlyList<string> variables, IReadOnlyCollection<int> onSet, IReadOnlyCollection<int>? dontCareSet = null, long? pairComparisonLimit = null, CancellationToken cancellationToken = default, int coverStepLimit = 200000)

Parameters

variables IReadOnlyList<string>
onSet IReadOnlyCollection<int>
dontCareSet IReadOnlyCollection<int>
pairComparisonLimit long?
cancellationToken CancellationToken
coverStepLimit int

Returns

(AstNode Expression, bool ProvenMinimal)