MVL documentation pages

Lukasiewicz

Lukasiewicz is a many valued logic system. Originally defined by Jan Lukasiewicz (Polish: [ˈjan wukaˈɕɛvitʂ]) in the 20th century for 3 valued logic, Lukasiewicz later expanded his system to support arbitrary n valued logic and infinite valued logic.

Lukasiewicz logics consists of values in the range [0, 1]. If the logic system is finite, then the set of values in the range [0, 1] is finite and are equal distances apart at n / (m - 1), where m is the total number of logic values, and n is the index.

Lukasiewicz defines the following operators, given below alongside their MVL equivalents:

  • implication (implies, →)

  • negation (not_, !)

  • equivalence (equivalent, ↔)

  • weak conjunction (w_and, &)

  • strong conjunction (s_and, &&)

  • weak disjunction (w_or, |)

  • strong disjunction (s_or, ||)

as well as propositional constants 0 and 1.

Lukasiewicz logic defines the only value which is «true» to be 1, and so evaluating any other lukasiewicz value as a python bool will evaluate to False.

class mvl.lukasiewicz.LogicSystem(n_values: int, logic_value_class: Callable)

A class for creating logical systems and the associated logical values, and for converting numerical values into LogicValues.

n_values

The number of values in the LogicSystem. Equal to len(LogicSystem.values).

Type

int

values

The ordered list of logic values in the logical system.

Type

List[LogicValue]

mvl(f: float) → mvl.lukasiewicz.LogicValue

Given a float, returns the associated logic value in the current system, if one exists.

class mvl.lukasiewicz.LogicValue(val: float)

A representation of a general lukasiewicz-goedel logic value.

Lukasiewicz and goedel logic values span over the interval [0, 1], and can be finite or infinite in length (but for practical reasons, the latter is not implemented using classes).

name

An alternative name for the logic value, used in the representation of the class. See __repr__.

Type

str

class_name

The name of the class, used in its representation. See __repr__. Equal to ‘LogicValue’

Type

str

class mvl.lukasiewicz.LukasiewiczLogicValue(val: float)

A type of LogicValue. LukasiewiczLogicValues are considered to be “true” (in a 2 valued boolean sense) iff their float representation is 1.

name

An alternative name for the logic value, used in the representation of the class. See __repr__.

Type

str

class_name

The name of the class, used in its representation. See __repr__. Equal to ‘LukasiewiczLogicValue’.

Type

str

class mvl.lukasiewicz.PriestLogicValue(val: float)

A type of LogicValue. PriestLogicValues are considered to be “true” (in a 2 valued boolean sense) iff their float representation not 0.

name

An alternative name for the logic value, used in the representation of the class. See __repr__.

Type

str

class_name

The name of the class, used in its representation. See __repr__. Equal to ‘PriestLogicValue’.

Type

str

mvl.lukasiewicz.equivalent(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Lukasiewicz’s «equivalence» operator. This operator (↔, not to be confused with the biconditional «iff») is defined by:

a ↔ b = 1 - | a - b |

Parameters
Returns

a ↔ b

Return type

LogicValue

mvl.lukasiewicz.implies(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Lukasiewicz’s «implies» operator. This operator (→) is defined by:

a → b = min {1, 1 - a + b}

Parameters
Returns

a → b

Return type

LogicValue

mvl.lukasiewicz.not_(a: Union[SupportsFloat, str, bytes, bytearray]) → float

Lukasiewicz’s «not» operator. This operator (!) is defined by:

! a := 1 - a

Parameters
Returns

! a

Return type

LogicValue

mvl.lukasiewicz.s_and(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Lukasiewicz’s «strong and» operator. This operator (&&) is defined by:

a && b := max {0, a + b - 1}

Parameters
Returns

a && b

Return type

LogicValue

mvl.lukasiewicz.s_or(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Lukasiewicz’s «strong or» operator. This operator (||) is defined by:

a || b := min {1, a + b}

Parameters
Returns

a || b

Return type

LogicValue

mvl.lukasiewicz.w_and(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Lukasiewicz’s «weak and» operator. This operator (&) is defined by:

a & b := min {a, b}

Parameters
Returns

a & b

Return type

LogicValue

mvl.lukasiewicz.w_or(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Lukasiewicz’s «weak or» operator. This operator (|) is defined by:

a | b := max {a, b}

Parameters
Returns

a | b

Return type

LogicValue

Goedel

Goedel defined many valued logics in 1932 very similarly to Lukasiewicz, using truth values in the range [0, 1] at positions n / (m - 1) for finite logic systems (where m is the total number of logic values, and n is the index), and across the continuous interval [0, 1] for infinite logic systems.

Goedel logics provide only 4 logical operators:

  • conjunction (and_, &)

  • disjunction (or_, |)

  • implication (implies, →)

  • negation (not_, !)

Goedel logics are completely axiomatisable, meaning that one can define a logical calculus in which all tautologies are provable.

mvl.goedel.and_(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Goedel’s «and» operator. This operator (&) is defined by:

a & b := min {a, b}

Parameters
Returns

a & b

Return type

LogicValue

mvl.goedel.implies(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Goedel’s «implies» operator. This operator (→) is defined by:

a → b :=
1 if a <= b
b otherwise
Parameters
Returns

a → b

Return type

LogicValue

mvl.goedel.not_(a: Union[SupportsFloat, str, bytes, bytearray]) → float

Goedel’s «not» operator. This operator (!) is defined by:

! a :=
1 if a == 0
0 otherwise
Parameters
Returns

! a

Return type

LogicValue

mvl.goedel.or_(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

Goedel’s «or» operator. This operator (|) is defined by:

a | b := max {a, b}

Parameters
Returns

a | b

Return type

LogicValue

Product logic

Product logic applies over the range [0, 1], for finite or infinite logic systems. It also defines 4 logical operators:

  • 2 conjunction operators (mult_, *) (and_, &)

  • implication (implies, →)

  • negation (not_, !)

mvl.product.and_(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

One of the 2 «conjunction» operators provided in product logic (&), defined by:

a & b := a * (a → b)

Parameters
Returns

a & b (≡ a * (a → b))

Return type

LogicValue

mvl.product.implies(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

The «implied» operator provided in product logic (→), defined by:

a → b :=
1 if a <= b
b / a otherwise
Parameters
Returns

a * b

Return type

LogicValue

mvl.product.mult(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

One of the 2 «conjunction» operators provided in product logic (*), defined by:

a * b := ab

Parameters
Returns

a * b

Return type

LogicValue

mvl.product.not_(a: Union[SupportsFloat, str, bytes, bytearray]) → float

The «not» operator provided in product logic (!), defined by:

! a := a → 0

Because ∀a .[a >= 0] this function is equivalent to float(a == 0), and is implemented as such.

Parameters
Returns

! a (≡ a → b)

Return type

LogicValue

Post logic

Post logics only work on finite valued systems. Like lukasiewicz logics, they use logic values n / (m - 1) (where m is the total number of logic values, and n is the index) over the interval [0, 1].

In contrast to the above logic systems, post logic values need knowledge of how many logic values are in use inside the system that they are a part of. This is due to the implementation of the negation (not_, !) operator (see below).

This means that the way that Post logic values are initialized is slightly more specific, and requires an index (: int) and a max_index (: int) to be passed in when creating LogicValues.

Hence:

PostLukasiewiczLogicValue(1, 3)  # Will work.
PostLukasiewiczLogicValue(1 / 3)  # Wont work (due to insufficient arguments).
class mvl.post.PostLukasiewiczLogicValue(index: int, max_index: int)
class mvl.post.PostPriestLogicValue(index: int, max_index: int)
mvl.post.not_(a: mvl.lukasiewicz.LogicValue) → float

Post’s «not» operator (!), defined by:

! a :=
1 if a == 0
a - 1 / (m - 1) otherwise

where m is the number of logic values in the system.

There are a few things to note about this operator, as it behaves differently to other functions in the MVL package. Because of this, you need to use it a little differently too.

Unlike the other MVL modules, post.not_ will not work on floats. It will only work when it is provided with a valid LogicValue.

Parameters
Returns

! a

Return type

LogicValue

Kleene

Kleene logic is a 3 valued logic system. It uses 3 logic values: «false»; «unknown»; and «true», abbreviated as «f», «u», and «t» respectively.

Kleene logic uses lukasiewicz’s definition of truth: the only truth value is 1 (the logic value «true» (t)). This distinguishes it from priest logic (see below).

mvl.kleene.f = LukasiewiczLogicValue.False

The kleene logic value «False».

mvl.kleene.kleene = <mvl.lukasiewicz.LogicSystem object>

A 3 valued LogicSystem which uses the values «False»; «Unknown»; and «True». Kleene logic systems are like lukasiewicz logic systems in that «True» is considered the only truth value.

mvl.kleene.t = LukasiewiczLogicValue.True

The kleene logic value «True».

mvl.kleene.u = LukasiewiczLogicValue.Unknown

The kleene logic value «Unknown».

Bochvar

Bochvar logic (also known as «kleene’s weak 3 valued logic») is a 3 valued logic system. It uses 3 logic values: «false»; «unknown»; and «true», abbreviated as «f», «u», and «t» respectively.

Like kleene logic, the only truth value in bochvar logic is 1.

Bochvar logic uses different definitions of and_; or_; and implies, compared to normal kleene logic. These tables can be found below.

In general, bochvar logic treats the unknwown value (u) as «contagious». The presence of u in any operator will cause the result to be u, regardless of any other variables in the expression.

mvl.bochvar.and_(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

The and operator used by Bochvar. This operator (and; &) has the truth table:

a & b

a

f

u

t

b

f

t

u

f

u

t

u

f

t

f

u

f

Parameters
Returns

a & b

Return type

LogicValue

mvl.bochvar.bochvar = <mvl.lukasiewicz.LogicSystem object>

A 3 valued LogicSystem which uses the values «False»; «Unknown»; and «True». Bochvar logic systems are like lukasiewicz and kleene logic systems in that «True» is considered the only truth value, but use different logical operators.

mvl.bochvar.f = LukasiewiczLogicValue.False

The bochvar logic value «False».

mvl.bochvar.implies(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

The implication operator used by Bochvar. This operator (->; →) has the truth table:

a → b

a

f

u

t

b

f

t

u

f

u

u

u

u

t

t

u

t

Parameters
Returns

a → b

Return type

LogicValue

mvl.bochvar.or_(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

The or operator used by Bochvar. This operator (or; |) has the truth table:

a | b

a

f

u

t

b

f

t

u

t

u

u

u

u

t

t

u

f

Parameters
Returns

a | b

Return type

LogicValue

mvl.bochvar.t = LukasiewiczLogicValue.True

The bochvar logic value «True».

mvl.bochvar.u = LukasiewiczLogicValue.Unknown

The bochvar logic value «Unknown».

Priest

Priest logic is a 3 valued logic system. It uses 3 logic values: «false»; «unknown»; and «true», abbreviated as «f», «u», and «t» respectively.

Priest logic does not lukasiewicz’s definition of truth. Instead, it uses PriestLogicValues, where all non-zero truth values are said to be truth values. This distinguishes it from kleene logic (see above).

mvl.priest.f = PriestLogicValue.False

The priest logic value «False».

mvl.priest.priest = <mvl.lukasiewicz.LogicSystem object>

A 3 valued LogicSystem which uses the values «False»; «Unknown»; and «True». Priest logic systems define all non-zero logic values as truth values. «Unknown» and «True» are both truth values in this 3 valued system. Other than this, priest logic systems use the same definitions and operators as kleene logic systems.

mvl.priest.t = PriestLogicValue.True

The priest logic value «True».

mvl.priest.u = PriestLogicValue.Unknown

The priest logic value «Unknown».

3 valued logic operators

This module describes the various operators used by different 3 valued logic systems. There is lots of overlap between different systems of logic (particularly kleene and priest logic, and lukasiewicz logic). Logic systems often define the same operators, sometimes under different names. In order to support reuse throughout the code base, this module was created as a common repository for logic operators used in various different 3 valued logic systems.

mvl.tvl_operators.iff(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

The bicondition operator used by Kleene and Priest. This operator (<->; ↔) has the truth table:

a ↔ b

a

f

u

t

b

f

t

u

f

u

u

u

u

t

f

u

t

Parameters
Returns

a ↔ b

Return type

LogicValue

mvl.tvl_operators.implies(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

The implication operator used by Kleene and Priest. This operator (->; →) has the truth table:

a → b

a

f

u

t

b

f

t

t

t

u

u

u

t

t

f

u

t

Parameters
Returns

a → b

Return type

LogicValue

mvl.tvl_operators.xor(a: Union[SupportsFloat, str, bytes, bytearray], b: Union[SupportsFloat, str, bytes, bytearray]) → float

The xor operator used by Kleene and Priest. This operator has the truth table:

a xor b

a

f

u

t

b

f

f

u

t

u

u

u

u

t

t

u

f

Parameters
Returns

a xor b

Return type

LogicValue

Indices and tables