Learn R Programming

lfl (version 2.0)

algebra: Algebra for Fuzzy Sets

Description

Compute triangular norms (t-norms), triangular conorms (t-conorms), residua, bi-residua, and negations.

Usage

algebra(name, stdneg = FALSE, ...)

is.algebra(a)

goedel.tnorm(...)

lukas.tnorm(...)

goguen.tnorm(...)

pgoedel.tnorm(...)

plukas.tnorm(...)

pgoguen.tnorm(...)

goedel.tconorm(...)

lukas.tconorm(...)

goguen.tconorm(...)

pgoedel.tconorm(...)

plukas.tconorm(...)

pgoguen.tconorm(...)

goedel.residuum(x, y)

lukas.residuum(x, y)

goguen.residuum(x, y)

goedel.biresiduum(x, y)

lukas.biresiduum(x, y)

goguen.biresiduum(x, y)

invol.neg(x)

strict.neg(x)

Arguments

name

The name of the algebra to be created. Must be one of: "goedel", "lukasiewicz", "goguen" (or an unambiguous abbreviation).

stdneg

TRUE if to force the use of a "standard" negation (i.e. involutive negation). Otherwise, the appropriate negation is used in the algebra (e.g. strict negation in Goedel and Goguen algebra and involutive negation in Lukasiewicz algebra).

...

For t-norms and t-conorms, these arguments are numeric vectors of values to compute t-norms or t-conorms from. Values outside the \([0,1]\) interval cause an error. NA values are also permitted.

For the algebra() function, these arguments are passed to the factory functions that create the algebra. (Currently unused.)

a

An object to be checked if it is a valid algebra (i.e. a list returned by the algebra function).

x

Numeric vector of values to compute a residuum or bi-residuum from. Values outside the \([0,1]\) interval cause an error. NA values are also permitted.

y

Numeric vector of values to compute a residuum or bi-residuum from. Values outside the \([0,1]\) interval cause an error. NA values are also permitted.

Value

Functions for t-norms and t-conorms (such as goedel.tnorm) return a numeric vector of size 1 that is the result of the appropriate t-norm or t-conorm applied on all values of all arguments.

Element-wise versions of t-norms and t-conorms (such as pgoedel.tnorm) return a vector of results after applying the appropriate t-norm or t-conorm on argument in an element-wise (i.e. by indices) way. The resulting vector is of length of the longest argument (shorter arguments are recycled).

Residua and bi-residua functions return a numeric vector of length of the longest argument (shorter argument is recycled).

strict.neg and invol.neg compute negations and return a numeric vector of the same size as the argument x.

algebra returns a list of functions of the requested algebra: "n" (negation), "t" (t-norm), "pt" (element-wise t-norm), "c" (t-conorm), "pc" (element-wise t-conorm), "r" (residuum), "b" (bi-residuum), "s" (supremum), "ps" (element-wise supremum), "i" (infimum), and "pi" (element-wise infimum).

Details

goedel.tnorm, lukas.tnorm, and goguen.tnorm compute the Goedel, Lukasiewicz, and Goguen triangular norm (t-norm) from all values in the arguments. If the arguments are vectors they are combined together firstly so that a numeric vector of length 1 is returned.

pgoedel.tnorm, plukas.tnorm, and pgoguen.tnorm compute the same t-norms, but in an element-wise manner. I.e. the values with indices 1 of all arguments are used to compute the t-norm, then the second values (while recycling the vectors if they do not have the same size) so that the result is a vector of values.

goedel.tconorm, lukas.tconorm, goguen.tconorm, are similar to the previously mentioned functions, exept that they compute triangular conorms (t-conorms). pgoedel.tconorm, plukas.tconorm, and pgoguen.tconorm are their element-wise alternatives.

goedel.residuum, lukas.residuum, and goguen.residuum compute residua (i.e. implications) and goedel.biresiduum, lukas.biresiduum, and goguen.biresiduum compute bi-residua. Residua and bi-residua are computed in an element-wise manner, for each corresponding pair of values in x and y arguments.

invol.neg and strict.neg compute the involutive and strict negation, respectively.

Let \(a\), \(b\) be values from the interval \([0, 1]\). The realized functions can be defined as follows:

  • Goedel t-norm: \(min\{a, b\}\);

  • Goguen t-norm: \(ab\);

  • Lukasiewicz t-norm: \(max\{0, a+b-1\}\);

  • Goedel t-conorm: \(max\{a, b\}\);

  • Goguen t-conorm: \(a+b-ab\);

  • Lukasiewicz t-conorm: \(min\{1, a+b\}\);

  • Goedel residuum (standard Goedel implication): \(1\) if \(a \le b\) and \(b\) otherwise;

  • Goguen residuum (implication): \(1\) if \(a \le b\) and \(b/a\) otherwise;

  • Lukasiewicz residuum (standard Lukasiewicz implication): \(1\) if \(a \le b\) and \(1-a+b\) otherwise;

  • Involutive negation: \(1-x\);

  • Strict negation: \(1\) if \(x=0\) and \(0\) otherwise.

Bi-residuum \(B\) is derived from t-norm \(T\) and residuum \(R\) as follows: $$B(a, b) = T(R(a, b), R(b, a)).$$

The arguments have to be numbers from the interval \([0, 1]\). Values outside that range cause an error. NaN values are treated as NAs.

If some argument is NA or NaN, the result is NA.

algebra returns a named list of functions that together form Goedel, Goguen, or Lukasiewicz algebra:

  • "goedel": strict negation and Goedel t-norm, t-conorm, residuum, and bi-residuum;

  • "goguen": strict negation and Goguen t-norm, t-conorm, residuum, and bi-residuum;

  • "lukasiewicz": involutive negation and Lukasiewicz t-norm, t-conorm, residuum, and bi-residuum. Moreover, algebra returns supremum and infimum functions computed as maximum and minimum, respectively.

is.algebra tests whether the given a argument is a valid algebra, i.e. a list returned by the algebra function.

Examples

Run this code
# NOT RUN {
    # direct and element-wise version of functions
    goedel.tnorm(c(0.3, 0.2, 0.5), c(0.8, 0.1, 0.5))  # 0.1
    pgoedel.tnorm(c(0.3, 0.2, 0.5), c(0.8, 0.1, 0.5)) # c(0.3, 0.1, 0.5)

    # algebras
    x <- runif(10)
    y <- runif(10)
    a <- algebra('goedel')
    a$n(x)     # negation
    a$t(x, y)  # t-norm
    a$pt(x, y) # element-wise t-norm
    a$c(x, y)  # t-conorm
    a$pc(x, y) # element-wise t-conorm
    a$r(x, y)  # residuum
    a$b(x, y)  # bi-residuum
    a$s(x, y)  # supremum
    a$ps(x, y) # element-wise supremum
    a$i(x, y)  # infimum
    a$pi(x, y) # element-wise infimum

    is.algebra(a) # TRUE
# }

Run the code above in your browser using DataLab