BitMagic-C++
|
Functions for three-valued logic (Kleene) https://en.wikipedia.org/wiki/Three-valued_logic. More...
Functions | |
template<class BV > | |
void | bm::init_kleene (BV &bv_value, const BV &bv_null) |
Initialized the value bit-vector so that it always returns 0 (false) for the unknown. More... | |
template<class BV > | |
int | bm::get_value_kleene (const BV &bv_value, const BV &bv_null, typename BV::size_type idx) BMNOEXCEPT |
Return Kleene logic value based on value and known vectors. More... | |
template<class BV > | |
void | bm::set_value_kleene (BV &bv_value, BV &bv_null, typename BV::size_type idx, int val) |
Set Kleene logic value based on value and known vectors. More... | |
template<class BV > | |
void | bm::invert_kleene (BV &bv_value, const BV &bv_null) |
Kleene NEG operation. More... | |
template<class BV > | |
void | bm::or_kleene (BV &bv_value1, BV &bv_null1, const BV &bv_value2, const BV &bv_null2) |
Kleene OR(vect1, vect2) (vect1 |= vect2) 1 OR Unk = 1 (known) More... | |
template<class BV > | |
void | bm::or_kleene (BV &bv_value_target, BV &bv_null_target, const BV &bv_value1, const BV &bv_null1, const BV &bv_value2, const BV &bv_null2) |
3-way Kleene OR: target := OR(vect1, vect2) (target := vect1 | vect2) 1 OR Unk = 1 (known) More... | |
template<class BV > | |
void | bm::and_kleene (BV &bv_value1, BV &bv_null1, const BV &bv_value2, const BV &bv_null2) |
Kleene AND(vect1, vect2) (vect1 &= vect2) 0 AND Unk = 0 (known) More... | |
template<class BV > | |
void | bm::and_kleene (BV &bv_value_target, BV &bv_null_target, const BV &bv_value1, const BV &bv_null1, const BV &bv_value2, const BV &bv_null2) |
3-way Kleene target:=AND(vect1, vect2) (target:= vect1 & vect2) 0 AND Unk = 0 (known) More... | |
int | bm::and_values_kleene (int a, int b) BMNOEXCEPT |
Reference function for Kleene logic AND (for verification and testing) More... | |
int | bm::or_values_kleene (int a, int b) BMNOEXCEPT |
Reference function for Kleene logic OR (for verification and testing) More... | |
Functions for three-valued logic (Kleene) https://en.wikipedia.org/wiki/Three-valued_logic.
void bm::and_kleene | ( | BV & | bv_value1, |
BV & | bv_null1, | ||
const BV & | bv_value2, | ||
const BV & | bv_null2 | ||
) |
Kleene AND(vect1, vect2) (vect1 &= vect2) 0 AND Unk = 0 (known)
bv_value1 | - [in, out] values bit-vector |
bv_null1 | - [in, out] not NULL (known) bit-vector |
bv_value2 | - [in] values bit-vector |
bv_null2 | - [in] not NULL (known) bit-vector |
Definition at line 213 of file bm3vl.h.
Referenced by Set3VL_AndDemo().
void bm::and_kleene | ( | BV & | bv_value_target, |
BV & | bv_null_target, | ||
const BV & | bv_value1, | ||
const BV & | bv_null1, | ||
const BV & | bv_value2, | ||
const BV & | bv_null2 | ||
) |
3-way Kleene target:=AND(vect1, vect2) (target:= vect1 & vect2) 0 AND Unk = 0 (known)
bv_value_target | - [out] values bit-vector |
bv_null_target | - [out] not NULL (known) bit-vector |
bv_value1 | - [in] values bit-vector |
bv_null1 | - [in] not NULL (known) bit-vector |
bv_value2 | - [in] values bit-vector |
bv_null2 | - [in] not NULL (known) bit-vector |
|
inline |
int bm::get_value_kleene | ( | const BV & | bv_value, |
const BV & | bv_null, | ||
typename BV::size_type | idx | ||
) |
Return Kleene logic value based on value and known vectors.
bv_value | - [in] values bit-vector |
bv_null | - [in] knowns bit-vector |
idx | - [in] index of value to extract and return |
Definition at line 70 of file bm3vl.h.
Referenced by Set3VL_ValueDemo().
void bm::init_kleene | ( | BV & | bv_value, |
const BV & | bv_null | ||
) |
Initialized the value bit-vector so that it always returns 0 (false) for the unknown.
3-value logics in BitMagic is built on two bit-vectors: value-bit-vector and NULL bit-vector. Value vector contains '1s' for the true known elements. bm::init_3vl makes sure this is true by running bv_value = bv_value AND bv_null logical operation. NULL bit-vector represents NOT NULL (known) values as 1s
bv_value | - [in, out] values bit-vector |
bv_null | - [in] not NULL (known) bit-vector |
Definition at line 54 of file bm3vl.h.
Referenced by Set3VL_ValueDemo2().
void bm::invert_kleene | ( | BV & | bv_value, |
const BV & | bv_null | ||
) |
Kleene NEG operation.
True becomes false and vice verse, but unknowns remain unknown false if we look directly into bv_value vector. This oprtaion does NOT produce unknown true values.
bv_value | - [in, out] values bit-vector |
bv_null | - [in] not NULL (known) bit-vector |
Definition at line 135 of file bm3vl.h.
Referenced by Set3VL_InvertDemo().
void bm::or_kleene | ( | BV & | bv_value1, |
BV & | bv_null1, | ||
const BV & | bv_value2, | ||
const BV & | bv_null2 | ||
) |
Kleene OR(vect1, vect2) (vect1 |= vect2) 1 OR Unk = 1 (known)
bv_value1 | - [in, out] values bit-vector |
bv_null1 | - [in, out] not NULL (known) bit-vector |
bv_value2 | - [in] values bit-vector |
bv_null2 | - [in] not NULL (known) bit-vector |
Definition at line 151 of file bm3vl.h.
Referenced by Set3VL_ORDemo().
void bm::or_kleene | ( | BV & | bv_value_target, |
BV & | bv_null_target, | ||
const BV & | bv_value1, | ||
const BV & | bv_null1, | ||
const BV & | bv_value2, | ||
const BV & | bv_null2 | ||
) |
3-way Kleene OR: target := OR(vect1, vect2) (target := vect1 | vect2) 1 OR Unk = 1 (known)
bv_value_target | - [out] target values bit-vector |
bv_null_target | - [out] target not NULL (known) bit-vector |
bv_value1 | - [in] values bit-vector |
bv_null1 | - [in] not NULL (known) bit-vector |
bv_value2 | - [in] values bit-vector |
bv_null2 | - [in] not NULL (known) bit-vector |
|
inline |
void bm::set_value_kleene | ( | BV & | bv_value, |
BV & | bv_null, | ||
typename BV::size_type | idx, | ||
int | val | ||
) |
Set Kleene logic value based on value and known vectors.
bv_value | - [out] values bit-vector |
bv_null | - [out] knowns bit-vector |
idx | - [in] index of value to extract and return |
val | - [in] value which can be: (−1: false; 0: unknown; +1: true) |
Definition at line 96 of file bm3vl.h.
References BM_ASSERT.
Referenced by GenerateDemoVector(), Set3VL_AndDemo(), Set3VL_ORDemo(), and Set3VL_ValueDemo().