Documentation
¶
Overview ¶
Package prop (Propositional Logic) provides utilities for building and evaluating logical propositions.
Index ¶
- type Predicate
- func AllOf[T any](ps ...Predicate[T]) Predicate[T]
- func And[T any](p1, p2 Predicate[T]) Predicate[T]
- func AnyOf[T any](ps ...Predicate[T]) Predicate[T]
- func Eq[T comparable](x T) Predicate[T]
- func False[T any]() Predicate[T]
- func Gt[T cmp.Ordered](x T) Predicate[T]
- func Gte[T cmp.Ordered](x T) Predicate[T]
- func Lt[T cmp.Ordered](x T) Predicate[T]
- func Lte[T cmp.Ordered](x T) Predicate[T]
- func Not[T any](p Predicate[T]) Predicate[T]
- func Or[T any](p1, p2 Predicate[T]) Predicate[T]
- func True[T any]() Predicate[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Predicate ¶
Predicate is a function that takes a value and decides if it meets a condition. In formal terms, it represents a boolean-valued function f: T → Bool that tests whether a value of type T satisfies a given condition.
func AllOf ¶
AllOf creates a condition that is satisfied when all input conditions are satisfied. When given no conditions, returns a condition that is always satisfied. Formally, it returns the n-ary logical conjunction (∧) of the provided predicates, representing f(x) = p₁(x) ∧ p₂(x) ∧ ... ∧ pₙ(x).
func And ¶
And creates a condition that is satisfied only when both input conditions are satisfied. Formally, it returns the logical conjunction (∧) of predicates p1 and p2, representing f(x) = p1(x) ∧ p2(x).
func AnyOf ¶
AnyOf creates a condition that is satisfied when any of the input conditions are satisfied. When given no conditions, returns a condition that is never satisfied. Formally, it returns the n-ary logical disjunction (∨) of the provided predicates, representing f(x) = p₁(x) ∨ p₂(x) ∨ ... ∨ pₙ(x).
func Eq ¶
func Eq[T comparable](x T) Predicate[T]
Eq creates a condition that checks if a value matches the target value exactly. Formally, it returns a predicate that tests for equality with value x, representing f(y) = (x == y).
func False ¶
False creates a condition that is never satisfied. Formally, it returns a predicate that represents the constant function f(x) = false.
func Gte ¶
Gte creates a predicate that checks if the value is greater than or equal to the given value.
func Lte ¶
Lte creates a predicate that checks if the value is less than or equal to the given value.
func Not ¶
Not creates a condition that is satisfied when the original condition is not. Formally, it returns the logical complement (¬) of predicate p, representing f(x) = ¬p(x).