FUZZY SETS FOR ADA
version 4.1
by Dmitry A. Kazakov

(mailbox@dmitry-kazakov.de)
[Home]

This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

As a special exception, if other files instantiate generics from this unit, or you link this unit with other files to produce an executable, this unit does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Public License.

Download fuzzy_4_1.tgz (tar + gzip, Windows users may use WinZip) [Download]

The current version was tested with the GNAT 3.15p compiler. It includes distributions of string edit, interval arithmetic and simple components packages. It provides implementations of:

See also changes log.

Quick reference:

Confidence factors (truth values)
Fuzzy sets
Intuitionistic_fuzzy sets
Fuzzy logic
Fuzzy numbers
Linguistic variables
Sets of linguistic variables


[TOC][Next]

1. Truth values

The type Confidence is defined in the package Confidence_Factors. A value of the type Confidence indicates the level of certainty  that an element belongs to the fuzzy set. An instance of Confidence can be viewed as a number in [0,1]. The value 0 corresponds to false of Boolean logic. The value 1 is an equivalent of true. The package Confidence_Factors has the constant Resolution that defines the granularity of Confidence. The following operations are defined on the instances of Confidence:

function "not" (Left : Confidence) return Confidence;
function "and" (Left, Right : Confidence) return Confidence;
function "mod" (Left, Right : Confidence) return Confidence;
function "or"  (Left, Right : Confidence) return Confidence;
function "rem" (Left, Right : Confidence) return Confidence;
function "xor" (Left, Right : Confidence) return Confidence;
function "+"   (Left, Right : Confidence) return Confidence;
function "-"   (Left, Right : Confidence) return Confidence;
function "*"  ... -- predefined by the language

These operations are defined as follows:

Operation  Name  Definition
Complement not 1 - x = x
Fuzzy and and min (x, y) = x&y
Truncation mod x if x > y, otherwise 0
Fuzzy or or max (x, y) = xy
Rounding rem x if x < y, otherwise 1
Fuzzy xor (distance) xor max (min (x, 1 - y), min (1 - x, y)) = (x&y) ∨ (x&y)
Distance - | x - y |
Probabilistic or + x + y - x · y
Probabilistic and * x · y

Notes about xor. Fuzzy xor can be defined in two ways equivalent in crisp logic: (x&y) ∨ (x&y) and (xy) & (xy). These two definitions stay equivalent when x and y become fuzzy, despite the fact that x&x might be greater than 0 and xx be less than 1. It can be shown that:

(x&x) ∨ (y&y) ≤ (x&y) ∨ (x&y) = (xy) & (xy) ≤ (xx) & (y∨y).

The upper and lower bounds here characterize fuzziness of the arguments. For x=y xor reaches its lower bound x&x = x xor x. For x=y xor reaches its upper bound: x xor x = xx.

[Back][TOC][Next]

1.1. String I/O of truth values

The child package Confidence_Factors.Edit defines I/O operations on Confidence.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Confidence
          );

This procedure gets a confidence factor from the string Source. The factor can be given either in a numeric form or as true or false (case insensitive). The process starts from Source (Pointer). Upon successful completion Pointer is advanced to the first unmatched character. The following exceptions are propagated out of the procedure:

Exceptions
Constraint_Error The factor is not in the range 0..1
Data_Error Syntax error in the number
End_Error There is no confidence factor in the string
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value (Source : String) return Confidence;

This function gets a confidence factor from the string Source. The whole string should be matched. Otherwise the exception Data_Error is propagated. The following exceptions are propagated out of the procedure:

Exceptions
Constraint_Error The factor is not in the range 0..1
Data_Error Syntax error in the number
End_Error There is no confidence factor in the string

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Confidence;
             Field       : Natural := 0;
             Justify     : Strings_Edit.Alignment := Strings_Edit.Left;
             Fill        : Character := ' '
          );

This procedure places the confidence factor specified by the parameter Value into the output string Destination. True and false (Confidence'Last, Confidence'First) are put as 1 and 0, correspondingly. Other values are put in a fixed point numeric format. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is
no room for the output

function Image (Value : Confidence) return String;

This function is used to convert Confidence to String. 

function To_Confidence (Value : Boolean) return Confidence;

This function is used to convert a Boolean value to Confidence.


[Back][TOC][Next]

2. Fuzzy sets

A fuzzy set mathematically is a function mapping its domain to [0,1]. So a fuzzy set A over some domain set D is A: D→[0,1]. For any domain value x∈D it gives a confidence factor (or else a level of truth) telling how possible is that x belongs to A, i.e. A(x) = PA|{x} = Px∈A. Customary the membership function of A is distinguished from the set and notated as μA(x), but we will not do it. Though the meaning of A(x) was defined as a possibility, it is both a necessity that x belongs to A. This is because for fuzzy sets we postulate that PA|{x} = NA|{x} = Nx∈A. Which is equivalent to a definition of the fuzzy set complement as A(x) = 1-A(x).

The type Set is defined in the package Fuzzy. It represents a fuzzy set over an interval of integer numbers. A more natural approach would be to define fuzzy sets with the domain of any discrete type. Unfortunately it would make the package generic, with the consequence that it would be almost impossible to use it for things like fuzzy decision trees. So I chose the following definition of the type Set:

type Set is array (Integer range <>) of Confidence;

The package Fuzzy defines various operations on the instances of Set.

[Back][TOC][Next]

2.1. Tests

Confidence of an element can be obtained either by using the predefined array indexing operation or by the function Is_In:

function Is_In (Point : Integer; A : Set) return Confidence;

The function Is_In does not raise an exception even if Point is not in A'Range, in which case it returns 0.

[Back][TOC][Next]

2.2. Operations producing a new set

function "not" (A : Set) return Set;

function "and" (A, B : Set) return Set;
   function
"and" (A : Set; B : Confidence) return Set;
   function
"and" (A : Confidence; B : Set) return Set;

function
"mod" (A, B : Set) return Set;
   function
"mod" (A : Set; B : Confidence) return Set;
   function
"mod" (A : Confidence; B : Set) return Set;

function
"or" (A, B : Set) return Set;
   function
"or" (A : Set; B : Confidence) return Set;
   function
"or" (A : Confidence, B : Set) return Set;

function
"xor" (A, B : Set) return Set;
   function
"xor" (A : Set; B : Confidence) return Set;
   function
"xor" (A : Confidence; B : Set) return Set;

function
"rem" (A, B : Set) return Set;
   function
"rem" (A : Set; B : Confidence) return Set;
   function
"rem" (A : Confidence; B : Set) return Set;

function
"+" (A, B : Set) return Set;
   function
"+" (A : Set; B : Confidence) return Set;
   function
"+" (A : Confidence; B : Set) return Set;

function
"-" (A, B : Set) return Set;
   function
"-" (A : Set; B : Confidence) return Set;
   function
"-" (A : Confidence; B : Set) return Set;

function
"*" (A, B : Set) return Set;
   function
"*" (A : Set; B : Confidence) return Set;
   function
"*" (A : Confidence; B : Set) return Set;

These operations are defined per point as follows from the table:

Operation  Name  Definition
Complement not 1 - ai = ai
Fuzzy and (intersection ∩) and min (ai, bi) = ai&bi
Truncation (α-cut) mod ai if ai > bi, otherwise 0
Fuzzy or (union ∪) or max (ai, bi) = aibi
Fuzzy xor (distance) xor max (min (ai, 1 - bi), min (1 - ai, bi)) = (ai&bi)∨(ai&bi) = (aibi)&(aibi)
Rounding rem ai if ai < bi, otherwise 1
Distance - | ai - bi |
Probabilistic or + ai + bi - ai · bi
Probabilistic and * ai · bi

When both parameters are sets then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters  is of the type Confidence then the result is computed as if it would be a set with all elements having the membership function equal to the value of the parameter.

The package also provides in-place variants for the set operations above:

procedure Not_At (A : in out Set);
procedure Add_At (A : in out Set; B : Set);
   procedure Add_At (A : in out Set; B : Confidence);
procedure And_At (A : in out Set; B : Set);
   procedure And_At (A : in out Set; B : Confidence);
   procedure And_At (A : in out Set; B : Set; C : Confidence);
procedure Diff_At (A : in out Set; B : Set);
   procedure Diff_At (A : in out Set; B : Confidence);
procedure Mod_At (A : in out Set; B : Set);
   procedure Mod_At (A : in out Set; B : Confidence);
procedure Mul_At (A : in out Set; B : Set);
   procedure Mul_At (A : in out Set; B : Confidence);
procedure Or_At (A : in out Set; B : Set);
   procedure Or_At (A : in out Set; B : Confidence);
   procedure Or_At (A : in out Set; B : Set; C : Confidence);
procedure Rem_At (A : in out Set; B : Set);
   procedure Rem_At (A : in out Set; B : Confidence);
procedure Xor_At (A : in out Set; B : Set);
   function Xor_At (A : in out Set; B : Confidence);

In-place variants can be more efficient. The procedure And_At with three parameters A, B, C is an equivalent to A and (B or C). The procedure Or_At with three parameters does A or (B and C).

Some properties of α-cuts:

Inversion of ∪:   x (A mod B)(x)≤C(x) <=> A(x)≤(B∪C)(x)
Association with ∪:   (A∪B) mod C = (A mod C)∪(B mod C)
    A mod (B∪C) = (A mod B)∩(A mod C)
Association with ∩:   (A∩B) mod C = (A mod C)∩(B mod C)
    A mod (B∩C) = (A mod B)∪(A mod C)
Absorption:   (A∩B) mod (A∩C) = (A∩B) mod C
de Morgan's rule:   A mod B = A rem B

Properties of xor:

Equivalent definitions:   (A&B) ∨ (A&B)   =  (A∨B) & (AB)
Lower bound:   x (A xor B)(x) ((A&A) ∨ (B&B))(x)
Upper bound:   x (A xor B)(x) ((A∨A) & (B∨B))(x)
Measure of non-contradiction:   A xor A = A&A
Measure of excluded middle:   A xor A = A∨A

[Back][TOC][Next]

2.3. Possibility theory

The following functions compute the possibility and necessity of fuzzy events. They return the result of Confidence type:

function Possibility (A, B : Set) return Confidence;
function Possibility (A    : Set) return Confidence;
function Necessity   (A, B : Set) return Confidence;
function Necessity   (A    : Set) return Confidence;

The functions are defined as follows:

Function Notation Definition
Conditional possibility (how possible is A if B), PA|B Possibility (A, B)
Max
i
 min (ai, bi)  =  PA∩B
Possibility (how possible is A if true), PA Possibility (A)
Max
i
 ai  =  PA
Conditional necessity (how necessary is A if B), NA|B Necessity (A, B)
Min
i
 max (ai, 1-bi)  =  NA∪B
Necessity (how necessary is A if true), NA Necessity (A)
Min
i
 ai  =  NA

The parameters must have the domains of same size (same cardinality). For an empty set, the possibility is defined as 0 (false), the necessity is defined as 1 (true). Otherwise the exception Constraint_Error is propagated.

Conditional possibilities and necessities. The most important results about the possibility and necessity are:

NA|B = PA|B
PA|B = PB|A
NA|B = NB|A
PA|B ≥ NA|B if ∃x B(x)=1 (B is normal)
PA∪B|C  =  PA|C∨PB|C       NA∪B|C  ≥  NA|C∨NB|C
PA∩B|C PA|C&PB|C   NA∩B|C = NA|C&PB|C
PA|B∪C = PA|B∨PA|C   NA|B∪C = NA|B&NA|C
PA|B∩C PA|B&PA|C   NA|B∩C NA|B∨NA|C

Fuzzy inclusion. NB|A is a fuzzy equivalent of A⊆B. This follows from the definition of ⊆ for crisp sets ∀x x∈A=>x∈B. Which is same as

Inf
x
 (x∈A=>x∈B)  =  Inf
x
 (x∈Ax∈B)  =  Inf
x
 A(x)∨B(x)  =  NB|A

Thus for crisp sets A⊆B = NB|A, so it would be naturally to assume that it is also so for fuzzy sets, i.e. that A⊆B = NA∪B = NB|A. In other words A⊆B can be defined as a measure of A∪B. Note that this definition differs from the traditional one: ∀x A(x) ≤ B(x), which is unsatisfactory for several reasons. First of all, it should be obvious that a subset relation of fuzzy sets cannot be crisp, because the sets are not crisp. Then the traditional definition is inconsistent with the very meaning of the membership function of a fuzzy set. Indeed, consider a singleton A={a}, i.e. ∀xa A(x)=0, A(a)=1. Then according to the traditional definition, we would have {a}⊆B = (1≤B(a)), which contradicts to our intuition expecting {a}⊆B = a∈B = B(a). NB|A is consistent in this respect:, because NB|{a} = B(a).

The properties of fuzzy ⊆ as an order relation are:

[Back][TOC][Next]

2.4. Distance to point

function Distance (Point : Integer; A : Set) return Natural;

The function calculates the distance between the domain point Point and the nearest point of the domain which confidence level in the set Set is not 0. If the set is empty the function returns Natural'Last.

[Back][TOC][Next]

2.5. String I/O with numeric indices

The child package Fuzzy.Edit provides the string I/O for fuzzy sets with the domain set elements specified in a numeric form.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Set
          );

This procedure inputs a fuzzy set from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the set. The set syntax:

<fuzzy_set>  ::=  <item> [,<fuzzy_set>]
<item> ::= <index> [{..|...} <index>] [:<level>]
<index> ::= A domain point specification
<level> ::= A confidence factor specification

Spaces and tabs can be used as delimiters. The domain point specification is an integer number. The confidence factor can be given either in numeric form or as true or false (case insensitive). A trailing commas and colons are ignored and not matched. Examples: 

1,2,6..9   The set contains 1,2,6,7,8,9 with the factor 1 (true)
1:0,2:0.3,3..5:1   The set contains 2 with 0.3 and 3,4,5 with 1
Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String;
            First  : Integer;
            Last   : Integer
         )  return Set;

This function gets a fuzzy set from the string Source. The set is defined over First..Last. The set in the string can be surrounded by spaces and tabs. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Set;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

This procedure  places the set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Constraint_Error Value is an empty array
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image (Value : Set) return String;

This function converts the parameter Value to string. Constraint_Error is propagated if Value is an empty array.

[Back][TOC][Next]

2.6. Generic string I/O

The child package Fuzzy.Generic_Edit provides string I/O with user-defined I/O routines for the domain set elements (the package Fuzzy.Edit is instantiates Fuzzy.Generic_Edit). The package speification starts as:

generic
   type User_Data (<>) is limited private;
   with procedure Get ...
   with procedure Put ...
package Fuzzy.Generic_Edit is ...

Here the generic formal parameters are some type User_Data and two procedures Get and Put. An object of User_Data is passed as the parameter to all procedures of the package. It can be used to keep a description of the domain set elements, such as a list of its names etc. The formal procedures provide I/O for the domain set ranges.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             Value   : out Set
          );

This user-defined procedure gets a range of the domain set values from the string Source. The process starts from Source (Pointer). Pointer is then advanced to the string position following the range. The result is From..To, which is an interval of indices in Set (a fuzzy set). The range syntax is usually:

<value> [{..|...}<value>]

Spaces and tabs may surround ellipsis. Ellipsis may be built of two two or three dots. The syntax of <value> depends on the implementation.

Expected exceptions
Constraint_Error A value is out of range or illegal range
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             From        : Integer;
             To          : Integer;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

This user-defined procedure places a range of the domain set values specified by the parameters From..To into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then the fill character. If the range From..To contains only one point the syntax <value> should be used. Otherwise, the syntax of output is normally <value>..<value>.

Expected exceptions
Constraint_Error Illegal range
Layout_Error Pointer is not in Destination'Range or there is no room for the output

The package defines the following subroutines:

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             Value   : out Set
          );

This procedure gets a fuzzy set from the string Source. The set has the following syntax:

<fuzzy_set>  ::=  <item> [,<fuzzy_set>]
<item> ::= <range> [:<level>]
<level> ::= A confidence factor specification

Here the syntax of <range> is defined by the formal procedure Get. Commas and colons may be surrounded by spaces and tabs. Trailing comma or colon is ignored and not matched.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String;
            Data   : User_Data;
            First  : Integer;
            Last   : Integer
         )  return Set;

This function gets a fuzzy set from the string Source. The set is defined over First..Last. The set in the string can be surrounded by spaces and tabs. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             Value       : Set;
             Field       : Natural := 0;
             Justify     : Strings_Edit.Alignment := Strings_Edit.Left;
             Fill        : Character := ' '
          );

This procedure places the fuzzy set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer).

Exceptions
Constraint_Error Value is an empty array
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image (Data : User_Data; Value : Set) return String;

The function converts the parameter Value to string. Constraint_Error is propagated if Value is an empty array.

[Back][TOC][Next]

2.7. Abstract string I/O

The child package Fuzzy.Abstract_Edit provides an instantiation of Fuzzy.Generic_Edit with an abstract tagged type substituted for the parameter User_Data of  Fuzzy.Generic_Edit. The type is also called User_Data:

type User_Data is abstract tagged limited null record;

The advantage of using an abstract tagged type is that one can simply derive from it to get a new functionality without an instantiation of Fuzzy.Generic_Edit. The package defines Get and Put of Fuzzy.Generic_Edit through dispatching abstract procedures of User_Data:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             From    : out Value_Index;
             To      : out Value_Index
          )  is abstract;

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             From        : Value_Index;
             To          : Value_Index;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          )  is abstract;

Here Value_Index is

type Value_Index is new Positive;

It is an index type to reference the domain set values. The first value of the domain set has the index 1. An implementation of Get should input a contiguous range of domain set values and return the result through From and To. An implementation of Put should output a range of value From..To. Both may use the exceptions described in Fuzzy.Generic_Edit for their generic counterparts.

procedure Get_Max_Range
          (  Data : User_Data;
             From : out Integer;
             To   : out Integer
          )  is abstract;

The abstract procedure Get_Max_Range is used to get the expected range of a fuzzy set when it is returned as a result and thus unknown.

The package defines class-wide Get, Value, Put and Image which can be used for any descendant of User_Data:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data'Class;
             Value   : out Set;
             To      : out Integer
          );

function Value
         (  Source : String;
            Data   : User_Data'Class
         )  return Set;

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data'Class;
             Value       : Set;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

function Image (Data : User_Data'Class; Value : Set) return String;

[Back][TOC][Next]

2.8. String I/O with named indices

The child package Fuzzy.Abstract_Edit.Named provides subroutines for string I/O of the sets having domains of named elements. The package defines the type Domain_Description:

type Domain_Description is new User_Data with private;

An instance of the type describes a domain sets, which elements are named. A name of an element has to be unique. The valid names defined by the package Name_Tables:

with Ada.Strings.Maps;           use Ada.Strings.Maps;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
with Tables.Names;

package Name_Tables is
   pragma Elaborate_Body (Name_Tables);

   Capitals   : Character_Set := Letter_Set;
   Singletons : Character_Set := To_Set (" _");
   Name_Body  : Character_Set := Alphanumeric_Set or Singletons;
   Non_Breaks : Character_Set := Alphanumeric_Set;

The variables Capitals, Singletons, Name_Body and Non_Breaks determine the valid names and the way they are recognized:

When matched, names are case-insensitive, chains of spaces and tabs are equivalent to one space. The following operations are defined on Domain_Description:

procedure Add
          (  Domain : in out Domain_Description;
             Name   : String;
             Index  : Integer
          );

This procedure adds a new element named Name under Index to Domain. Elements should be added in an order keeping the set of indices contiguous. Otherwise, Constraint_Error is propagated. Name_Error is propagated when Name matches the name of an existing element of Domain.

procedure Copy
          (  Source : Domain_Description;
             Target : in out Domain_Description
          );

This procedure is used to copy a domain set description.

procedure Erase (Domain : in out Domain_Description);

This procedure removes all elements from Domain.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             From    : out Integer;
             To      : out Integer
          );

This procedure inputs a range of domain elements from Source. A range is specified as <name>[..<name>]. Spaces and tabs may surround ellipsis. Range validity is not checked. Trailing ellipsis is an error, so Data_Error is propagated in this case. End_Error is propagated if nothing matched.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Domain  : Domain_Description;
             Index   : out Integer
          );

This procedure parses the string Source. If a name of an element from Domain is successfully matched starting from Source (Pointer), Pointer is advanced to the position following the matched name and Index is set to respond to the domain value associated with the variable.

Exceptions
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Get_Cardinality (Domain : Domain_Description)
   return Natural;

This function returns the number of elements in Domain.

function Get_Index
         (  Domain : Domain_Description;
            Name   : String
         )  return Integer;

This function returns the index of the element of Domain having the name Name. It is the same index as in Add. End_Error is propagated if thereis no such element.

function Get_Name
         (  Domain : Domain_Description;
            Index  : Integer
         )  return String;

This function returns the name of the element which index is Index. Constraint_Error is propagated if Index is illegal.

procedure Get_Max_Range
          (  Domain : Domain_Description;
             First  : out Integer;
             Last   : out Integer
          );

This procedure returns the actual index range of Domain. The range is always contiguous.

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Domain      : Domain_Description;
             From        : Integer;
             To          : Integer;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

This procedure places a range From..To of Domain element into the string Destination. For this names of the elements are used.

[Back][TOC][Next]

2.9. Basic string I/O

The child package Fuzzy.Basic_Edit provides basic subroutine for string I/O.

type Delimiter_Type is (Arrow, Ellipsis, Comma, Colon, Semicolon);

procedure Get_Delimiter
          (  Source    : String;
             Pointer   : in out Integer;
             Success   : out Boolean;
             Delimiter : Delimiter_Type
          );

This procedure is used to skip one of the delimiters {->|:|,|;|..|...} and  surrounding it spaces and tabs in String. Pointer is changed only a delimiter was found. The parameter Delimiter specifies what should be recognized.

Exceptions
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

procedure Get_Weight
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Confidence;
             Default : Confidence := Confidence'Last
          );

This procedure is used to get the weight of a domain point value in the form [:<possibility>]. If no colon present, Default is set into Value.

Exceptions
Data_Error Syntax error or value is not in 0..1
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

[Back][TOC][Next]

3. Fuzzy logic

A fuzzy logical value x is a pair (Px, Nx). The component Px is the possibility that the value is true. The component Nx is the necessity of that. Both are measured in confidence factors. Fuzzy logical values are also known as intuitionistic propositions. Fuzzy logic continues the four-valued logic of J. M. Dunn and N. D. Belnap Jr. on the fuzzy case. The following table summarizes the properties of fuzzy logical values:

Property  Description  Comment
Complementarity Px = Nx The possibility of the complement is the complement of necessity
Consistency Px ≥ Nx The possibility shall be always greater than or equal to the necessity. Otherwise the value is self-contradictory. As in conventional logic no contradiction and thus no self-contradictory values may arise when legal logical operations (and, or, xor, not) are applied to non-contradictory values.
Normality Px=1 ∨ Nx=0 It is desirable but not mandatory to have only normal fuzzy logical values. The property of normality is an equivalent to x x of the conventional logic. In other words, either x or its complement should be certainly possible.
Certainty Px = Nx Fuzzy logic on certain normal values is an equivalent to the conventional logic. Certain true is represented as the pair (1,1). Certain false is represented as the pair (0,0). Absolute uncertainty is represented as the pair (1,0). Absolute contradiction is represented as (0,1).

The following picture explains the meaning of the possibility and necessity components of a fuzzy logical value:

logical values

A complementary view on a fuzzy logical value is the set view. A logical value can be thought as a fuzzy set over B={true, false}, i.e. [0,1]B. In which case the confidence factor of true is the possibility that the value is true. The confidence factor of false is the possibility that the value is false. Its complement is the necessity that the value is true. Some of logical operations are defined in terms of sets. For instance the fuzzy implication is defined as set inclusion.

Most important algebraic results of the fuzzy logic are:

Associativity:    (x & y) & z = x & (y & z)
Commutativity: x & y = y & x
Distributivity: (x & y) ∨ z = (xz) & (yz)
de Morgan's theorems: x & y = xy

The results of conventional logic that do not hold:

x & x is not false     All that one can said is that the possibility Px&x and the necessity Nx&x are less than or equal to ones of both x and x
xx is not true Here the possibility and the necessity are only greater than or equal to ones of both x and x

The certainty of a logical value determines how close these results are to ones of conventional logic. Certainty is a confidence factor in [0,1]. 0 corresponds to an absolutely uncertain logical value. 1 corresponds to either true or false of conventional logic.

Combining evidences. Fuzzy logic can be applied to combining evidences, which might be fuzzy and contradictory. Let two logical values x and y were obtained from two evidences p and q. So if x and y both describe some event s then x = (Ps|p, Ns|p), y = (Ps|q, Ns|q). There are two ways to combine the evidences p and q. A pessimistic one is to consider how s depends on pq. An optimistic combination is pq. The pessimistic combination of x and y is x*y = (Ps|pq, Ns|pq). It can be shown that Ps|pqmin (Ps|p, Ps|q) and Ns|pqmax (Ns|p, Ns|q). The optimistic combination of x and y is  x+y = (Ps|pq, Ns|pq) = (max (Ps|p, Ps|q), min (Ns|p, Ns|q)). The combinations + and * are sometimes called consensus and gullibility. The difference in their behavior is that the pessimistic combination treats any discrepancy as a contradiction, while the optimistic one treats it as rather an uncertainty. Thus, true * false is contradictory, while true + false is uncertain.

Fuzzy implication. The fuzzy implication x=>y is defined in terms of sets: x=>y = ~xy. Here ~x is the complement of x. Thus x=>y is (max (Px, Py), max (Nx, Ny)). Note that it differs from xy. The difference can be illustrated on the case when both x and y are uncertain. In this case xy is also uncertain, while x=>y is true (uncertainty implies uncertainty). On certain arguments xy and x=>y are same.

Fuzzy inclusion (revisited). The pair (PB|A, NB|A) characterizes A as a subset of B vs. B. It can be viewed as a continuation of the fuzzy ⊆ to [0,1]B. We will use A⊆B notation for both of them. If A⊆B is certain true, then A is a subset of B in the traditional sense: ∀x A(x) ≤ B(x). At the same time if a normal A is a subset of B in the "crisp" sense: ∀x A(x)=0 ∨ 1=B(x), then A⊆B is true. From this we could say that A⊆B <=> normal A is a subset of B and also A⊆B <=> normal A is a subset of B. Further, if A is normal then A⊆B is never contradictory. Other properties of ⊆ are:

PA⊆B PBA   NA⊆B = NBA
PA⊆B = NA⊆B   NA⊆B = PA⊆B
P{a}⊆B  = a∈B = B(a)   N{a}⊆B = a∈B = B(a)
P(A∪B)⊆C  = PA⊆C∨PB⊆C       N(A∪B)⊆C  =  NA⊆C&NB⊆C
P(A∩B)⊆C PA⊆C&PB⊆C   N(A∩B)⊆C NA⊆C∨NB⊆C
PA⊆(B∪C) = PA⊆B∨PA⊆C   NA⊆(B∪C) NA⊆B∨NA⊆C
PA⊆(B∩C) PA⊆B&PA⊆C   NA⊆(B∩C) = NA⊆B&NA⊆C

Fuzzy xor. For fuzzy logic both definitions of xor stay equivalent: (A&B) ∨ (A&B) = (A∨B) & (AB). Similarly to the fuzzy-xor the lower and upper bounds of xor are (A&A) ∨ (B&B) and (A∨A) & (B∨B) correspondingly. Here comparison is made in the sense: A≤B if both PA≤PB and NA≤NB. The bounds are reached for A xor A = A&A and A xor A = A∨A.

Type and operations. The type Fuzzy_Boolean is defined in the child package Fuzzy.Logic:

type Fuzzy_Boolean is record
   Possibility : Confidence;
   Necessity   : Confidence;
end record;

The following operations are defined for Fuzzy_Boolean:

function "not" (Left : Fuzzy_Boolean) return Fuzzy_Boolean;

function "and" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "and" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "and" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function "or" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "or" (Left : Fuzzy_Boolean; Right : Boolean)  return Fuzzy_Boolean;
   function "or" (Left : Boolean; Right : Fuzzy_Boolean)  return Fuzzy_Boolean;

function "xor" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "xor" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "xor" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function "*" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "*" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "*" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function "+" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "+" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "+" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function
">=" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function ">=" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function ">=" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function
"<=" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "<=" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "<=" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function
Certainty (Left : Fuzzy_Boolean) return Confidence;

The type Boolean can be used as any of the arguments in the dyadic operations. The operations are defined as follows from the table:

Operation on x, y  Name  Definition
Complement not Px = Nx Nx = Px
Fuzzy and (&) and Px&y= Px&Py Nx&y= Nx&Ny
Fuzzy or (∨) or Pxy= Px∨Py Nxy= Nx∨Ny
Fuzzy xor xor (x&y) ∨ (x&y) = (xy) & (xy)
Combination (∩) * Px*y= Px&Py Nx*y= Nx∨Ny
Combination (∪) + Px+y= Px∨Py Nx+y= Nx&Ny
Implication (=>) >= Px=>y= Px∨Py Nx=>y= Nx∨ Ny
Implication (<=) <= Px<=y= Py=>x Nx<=y= Ny=>x
Certainty Certainty 1 - | Px - Nx |

The package also defines the following four constants. Certain_True, Certain_False, Uncertain, Contradictory. They correspond to the answers: yes, no, maybe (both true and false, I don't know), none (neither true nor false). The following table summarizes the behavior of some fuzzy operations:

x y x and y (&) x or y () x xor y x * y x + y x=>y not x
false false false false false false false true true
false true false true true contradictory uncertain true true
false uncertain false uncertain uncertain false uncertain true true
false contradictory false contradictory contradictory contradictory false true true
true false false true true contradictory uncertain false false
true true true true false true true true false
true uncertain uncertain true uncertain true uncertain uncertain false
true contradictory contradictory true contradictory contradictory true contradictory false
uncertain false false uncertain uncertain false uncertain contradictory uncertain
uncertain true uncertain true uncertain true uncertain true uncertain
uncertain uncertain uncertain uncertain uncertain uncertain uncertain true uncertain
uncertain contradictory false true false contradictory uncertain contradictory uncertain
contradictory false false contradictory contradictory contradictory false uncertain contradictory
contradictory true contradictory true contradictory contradictory true true contradictory
contradictory uncertain false true false contradictory uncertain uncertain contradictory
contradictory contradictory contradictory contradictory contradictory contradictory contradictory true contradictory

function To_Fuzzy (Left : Boolean) return Fuzzy_Boolean;

This function converts the argument to the corresponding fuzzy logical value.

function Is_In (A, B : Set) return Fuzzy_Boolean;

This function compares two fuzzy sets and returns a fuzzy logical value. The result is defined as (PB|A, NB|A). It raises Constraint_Error if the arguments have different cardinality.


[Back][TOC][Next]

4. Fuzzy numbers

Most generally a fuzzy number is just a fuzzy set over the corresponding numeric set. For instance the set of fuzzy real numbers is [0,1]R, where R is the set of real numbers. Though such a general definition faces difficulties with both implementation and interpretation of the results. Therefore, several constraints are applied to the distribution of the confidence factors over the domain set (a set of numbers). The first one is the requirement of normality, i.e. that at least one number x of the domain have the confidence 1. The second is that the distribution has to be monotonically ascending before x and monotonically descending after it. The second requirement means that all so-called alpha-cuts of the fuzzy set are intervals. So a fuzzy number can be represented by a set of nested intervals:

{ [ai, bi] | i>j ⇒ [ai, bi]⊆ [aj, bj] }

The deeper an interval is nested the higher is the confidence factor associated with it. Thus a fuzzy number X can be represented as:

X =   U
i
 [ai, bi] Pi

where i>j ⇒ Pi≥Pj and [ai, bi] Pi is a fuzzy set which membership function is zero outside [ai, bi] and Pi inside it. Thus a fuzzy number looks like:

fuzzy number model

The number of intervals representing a number is limited by some reasonable number. The current implementation of fuzzy numbers is based on the interval arithmetic package.

Arithmetical operations on fuzzy numbers are defined as follows. If @ is an operation defined on crisp numbers like +, -, *, / etc, then the corresponding fuzzy number operation X@Y is defined as:

PzX@Y = Sup
x
@y = z
PxX&PyY  =  Sup
x
@y = z
X(x)&Y(y)

Here PxX is the confidence that the fuzzy number X has the value x. For example, the possibility that some z belongs to X+Y is a convolution of the membership functions over all x, y such that x+y=z. Fuzzy arithmetic is a continuation of both crisp and interval arithmetic. So for singletons we have {x}+{y}={x+y}.

When fuzzy numbers have form:

X =   U
i
 [ai, bi] Pi      Y U
i
 [ci, di] Pi

then because operations on intervals are inclusion-monotonic:

X@Y U
i
 [ai, bi]@[ci, di] Pi

This allows an O(n) implementation of fuzzy arithmetic, where n is the number of alpha-cuts, i.e. the resolution of the confidence factors.

Relational operations on fuzzy numbers results in fuzzy logical values. Let @ be a relational operation >, ≥, ≤, < defined on crisp numbers, then the corresponding fuzzy number operation X@Y is defined as:

Component Definition
Possibility PX@Y  
PX@Y Sup
x
@y
PxX&PyY
Necessity NX@Y
NX@Y = Inf
x
@y
PxXPyY  = P X@Y

The necessity component is essential here. For example if we consider an interval [1,2] then certainly [1,2] is greater than 0, so P[1,2] > 0=N[1,2] > 0=1. But P[1,2] > 1.5=1 while N[1,2] > 1.5=0. Indicating that it is uncertain whether [1,2] is greater than 1.5.

[Back][TOC][Next]

4.1. Plain fuzzy numbers

The generic child package Fuzzy.Numbers implements fuzzy numbers. It defines the type Fuzzy_Number. The package has the following generic parameters:

Its specification starts as:

generic
   type Interval_Index is (<>);
   type Interval_Map is array (Interval_Index) of Confidence;
   type Number is private;
   type Interval is private;
   To_Confidence : Interval_Map;
   with function From (Left : Interval) return Number is <>;
   with function Is_In (Left, Right : Interval) return Boolean is <>;
   with function Is_In (Left : Number; Right : Interval)
      return Boolean is <>;
   with function To (Left : Interval) return Number is <>;
   with function To_Interval (Left : Number) return Interval is <>;
   with function To_Interval (Left, Right : Number)
      return Interval is <>;
   with function "abs" (Left : Interval) return Interval is <>;
   with function "+" (Left, Right : Interval) return Interval is <>;
   with function "+" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "+" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "-" (Left : Interval) return Interval is <>;
   with function "-" (Left, Right : Interval) return Interval is <>;
   with function "-" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "-" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "*" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "*" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "*" (Left, Right : Interval) return Interval is <>;
   with function "/" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "/" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "/" (Left, Right : Interval) return Interval is <>;
   with function "**" (Left : Interval; Right : Natural) return Interval is <>;
   with function ">" (Left : Interval; Right : Number)
      return Logical is <>;
   with function ">" (Left : Number; Right : Interval)
      return Logical is <>;
   with function ">" (Left, Right : Interval) return Logical is <>;
   with function ">=" (Left : Number; Right : Number)
      return Boolean is <>;
   with function ">=" (Left : Interval; Right : Number)
      return Logical is <>;
   with function ">=" (Left : Number; Right : Interval)
      return Logical is <>;
   with function ">=" (Left, Right : Interval) return Logical is <>;
   with function "&" (Left, Right : Interval) return Boolean is <>;
package Fuzzy.Numbers is ...

Though it might look extremely complex it is in fact easy to instantiate because most of the formal parameters have reasonable defaults.

The generic child package Fuzzy.Numbers.Edit provides I/O operations on fuzzy numbers. It has two generic parameters:

Integer and floating point fuzzy numbers. There are two generic packages specializing Fuzzy.Numbers. The package Fuzzy.Integers implements integer fuzzy numbers (the type Fuzzy_Integer). The package Fuzzy.Floats implements floating-point fuzzy numbers (the type Fuzzy_Float). They have the following generic parameters:

There are generic specializations of the package Fuzzy.Numbers.Edit for integer (Fuzzy.Integers.Edit) and floating-point numbers (Fuzzy.Floats.Edit).

All imprecise operations on floating-point fuzzy yield a value that contains the precise result.

Non-generic packages for standard types. There are also non-generic instantiations of Fuzzy.Integers and Fuzzy.Floats. They are Fuzzy_Integers and Fuzzy_Floats. Fuzzy.Edit.Integers and Fuzzy.Edit.Floats are non-generic I/O packages instantiated from Fuzzy.Integers.Edit and Fuzzy.Floats.Edit.

4.1.1. Interval mapping

The generic parameters Interval_Index, Interval_Map, To_Confidence are used define a mapping of the intervals representing a fuzzy number to the confidence factors.

type Interval_Index is (<>);
type Interval_Map is array (Interval_Index) of Confidence;
To_Confidence : Interval_Map;

Interval_Index is a discrete type determining the number of intervals used to represent a fuzzy number. Interval_Map is an array type of confidence factors indexed by Interval_Index. To_Confidence is an instance of the array. For each value of Interval_Index it has the corresponding confidence factor. The array elements shall ascend. The last element of the array shall be of Confidence'Last. The package Fuzzy.Index_Map provides an interval mapping used for in the packages Fuzzy_Integers and Fuzzy_Floats.

The function Get_Interval in Fuzzy_Number can be used to obtain an interval of a fuzzy number by its index:

function Get_Interval
         (  Value : Fuzzy_Number;
            Index : Interval_Index
         )  return Interval;

The result is [ai, bi] of Value, where i is specified by the parameter Index. The confidence level of the interval can be obtained as To_Confidence (Index). Note that intervals are enumerated in ascending order. The last interval has the confidence Confidence'Last.

4.1.2. Arithmetic operations

The following operations are defined on the type Fuzzy_Number:

function "abs" (Left : Fuzzy_Number) return Fuzzy_Number;
function "+"   (Left : Fuzzy_Number) return Fuzzy_Number;
function "-"   (Left : Fuzzy_Number) return Fuzzy_Number;
function "**"  (Left : Fuzzy_Number; Right : Natural) return Fuzzy_Number;

function "+" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "+" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "+" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "+" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "+" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

function "-" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "-" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "-" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "-" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "-" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

function "*" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "*" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "*" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "*" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "*" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

function "/" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "/" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "/" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "/" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "/" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

These operations are defined as described above.

4.1.3. Possibility theory

The following functions compute the possibility and necessity of fuzzy numbers as events. They return the result of Confidence type:

function Possibility (Left, Right : Fuzzy_Number) return Confidence;
   function Possibility (Left : Fuzzy_Number; Right : Number  ) return Confidence;
   function Possibility (Left : Fuzzy_Number; Right : Interval) return Confidence;
   function Possibility (Left : Number;   Right : Fuzzy_Number) return Confidence;
   function Possibility (Left : Interval; Right : Fuzzy_Number) return Confidence;

function Necessity (Left, Right : Fuzzy_Number) return Confidence;
   function Necessity (Left : Fuzzy_Number; Right : Number  ) return Confidence;
   function
Necessity (Left : Fuzzy_Number; Right : Interval) return Confidence;
   function Necessity (Left : Number;   Right : Fuzzy_Number) return Confidence;
   function
Necessity (Left : Interval; Right : Fuzzy_Number) return Confidence;

These functions tell how possible or necessary is the fuzzy event represented by the left argument under the condition represented by the right argument. They are defined in terms of fuzzy sets:

Function Definition Meaning
Possibility
PX|Y Sup
x
 PxX&PxY
How possible is X if Y
Necessity
NX|Y Inf
x
 PxXPxY  = PX|Y
How necessary is X if Y

When Left is a number then Possibility (Left, Right) is the value of the confidence distribution of Right in Left. If the right argument is an interval then the possibility is the maximum of the confidence distribution on the interval. The necessity is then the minimum of the distribution.

4.1.4. Membership and inclusion relations

The membership and inclusion tests return a result of Fuzzy_Boolean type:

function Is_In (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Boolean;
   function Is_In (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function Is_In (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Boolean;

The result tells how possible and necessary is that Left is included in Right. It is defined in terms of possibility and necessity:

Component Definition
Possibility PXY   PXY = PY|X
Necessity NXY NXY = NY|X

Note that this definition assumes normality of the fuzzy sets involved. For fuzzy numbers it means that at least one number of the domain is fully possible. Observe that if the requirement is not satisfied the result is as expected contradictory, i.e. the necessity is greater than the possibility.

4.1.5. Equality and equivalence

The equality and inequality operations are:

function "=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Boolean;
   function
"=" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"=" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Boolean;

function
"/=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
"/=" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"/=" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Boolean;

The equality operation is defined in terms of inclusion X = Y is X Y & Y X:

Component Definition
Possibility PX=Y  PX|Y
Necessity NX=Y NX|Y&NY|X

See notes about normality of the numbers.

function Equal (Left, Right : Fuzzy_Number) return Boolean;

This function returns true if Left and Right are equivalent as sets, i.e.∀x PxLeft = PxRight.

4.1.6. Relational operations

The relational operations are:

function ">" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Boolean;
   function
">" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

function
">=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
">=" (Left : Number,   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">=" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

function
"<=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
"<=" (Left : Number,   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<=" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

function
"<" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
"<" (Left : Number,   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

4.1.7. Conversions

The following functions are used to convert numbers and intervals to fuzzy numbers:

function To_Fuzzy (Left : Number)   return Fuzzy_Number;
function To_Fuzzy (Left : Interval) return Fuzzy_Number;

[Back][TOC][Next]

4.2. Dimensioned fuzzy numbers

Dimensioned fuzzy values represent physical values inaccurate measured or known. A dimensioned fuzzy number is a fuzzy numeric value with attached dimension to it. The generic package Fuzzy.Measures provides an implementation of dimensioned fuzzy values:

generic
   with package
Fuzzy_Floats is new Fuzzy.Floats (<>);
   with package Float_Measures is
      new
Standard.Measures (Fuzzy_Floats.Number);
   with package Interval_Measures is
      new
Intervals.Measures
          (  Float_Measures,
             Fuzzy_Floats.Float_Intervals
          );
package Fuzzy.Measures is
   ...

The package has the following formal parameters:

A non-generic instantiation of Fuzzy.Measures for the standard type Float is named Fuzzy_Measures.

The package Fuzzy.Measures defines the type Fuzzy_Measure:

type Fuzzy_Measure (SI : Unit := Units.Base.Unitless) is record
  
Gain   : Fuzzy_Float;
   Offset : Number'Base := 0.0;
end record
;

The discriminant SI and the field Offset determine the dimension of the value as they do in the type Measure. The field Gain + Offset yields the numeric fuzzy value in the unit specified by the discriminant SI. The operations defined on the type Fuzzy_Measure are designed to be computation errors-safe in the sense that the outcome of any operation contains the precise result. In particular, for necessity and possibility it means that they are estimated from below and above correspondingly.

function Get_Unit (Value : Fuzzy_Measure) return Unit;

This function returns the SI measurement unit of the argument.

4.2.1. Arithmetic operations

function "abs" (Left : Fuzzy_Measure) return Fuzzy_Measure;
function "+"   (Left : Fuzzy_Measure) return Fuzzy_Measure;
function "-"   (Left : Fuzzy_Measure) return Fuzzy_Measure;
function "**"  (Left : Fuzzy_Measure; Right : Natural) return Fuzzy_Measure;

function "+" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "+" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Measure;
   function "+" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Measure;
   function "+" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "+" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Measure;

function "-" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "-" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Measure;
   function "-" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Measure;
   function "-" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "-" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Measure;

function "*" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Number          ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Interval        ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Fuzzy_Float     ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Measure;
   function "*" (Left : Number;           Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Interval;         Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Float;      Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Measure;          Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "*" (Left : Interval_Measure; Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Float; Right : Measure           ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Float; Right : Interval_Measure  ) return Fuzzy_Measure;

function "/" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Number          ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Interval        ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Fuzzy_Float     ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Measure;
   function "/" (Left : Number;           Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Interval;         Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Float;      Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Measure;          Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "/" (Left : Interval_Measure; Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Float; Right : Measure           ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Float; Right : Interval_Measure  ) return Fuzzy_Measure;

Binary additive operations "+" and "-" accept as one of the arguments:

Multiplicative binary operations "*" and "/" accept as one of the arguments:

Further they accept a plain fuzzy number as one parameter and:

as another. The result in all cases a dimensioned fuzzy number. The exception Unit_Error (defined in Units) is propagated on all unit errors as described in Measures. Constraint_Error is propagated out of multiplicative operations "*", "/" and exponentiation "**" when the dimension of the result cannot be represented because of a base unit power overflow.

4.2.2. Possibility theory

The following functions compute the possibility and necessity of fuzzy numbers as events. They return the result of Confidence type:

function Possibility (Left, Right : Fuzzy_Measure) return Confidence;
   function Possibility (Left : Fuzzy_Measure; Right : Measure) return Confidence;
   function Possibility (Left : Fuzzy_Measure; Right : Interval_Measure) return Confidence;
   function Possibility (Left : Measure;          Right : Fuzzy_Measure) return Confidence;
   function Possibility (Left : Interval_Measure; Right : Fuzzy_Measure) return Confidence;

function Necessity (Left, Right : Fuzzy_Measure) return Confidence;
   function Necessity (Left : Fuzzy_Measure; Right : Measure) return Confidence;
   function
Necessity (Left : Fuzzy_Measure; Right : Interval_Measure) return Confidence;
   function Necessity (Left : Measure;          Right : Fuzzy_Measure) return Confidence;
   function
Necessity (Left : Interval_Measure; Right : Fuzzy_Measure) return Confidence;

One of the parameters can be a dimensioned number or interval. Parameters may have different units in which case the possibility and necessity are both 0. When the parameters are differently shifted the possibility is estimated from above and necessity from below due to possible computation errors while shifting. Unit_Error is propagated when arguments have incompatible units.

4.2.3. Inclusion and other relational operations

The following functions are used to compare numbers. They return a result of Fuzzy_Boolean type:

function Is_In (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Boolean;
   function Is_In (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function Is_In (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Boolean;
   function
"=" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"=" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"/=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
"/=" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"/=" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
">" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Boolean;
   function
">" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
">=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
">=" (Left : Measure,          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">=" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"<=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
"<=" (Left : Measure,          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<=" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"<" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
"<" (Left : Measure,          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

One of the arguments can be a dimensioned value or a dimensioned interval. The results are defined in the same way as they are for plain fuzzy numbers (see 4.1.5, 4.1.6, 4.1.7). Arguments may have different shifts. The functions outcome of a function contains the precise result in the sense that the possibility component of it is always an upper and the necessity one is a lower estimation of the corresponding precise values. Unit_Error is propagated out of ">", ">=", "<", "<=" when arguments have incompatible units. For Is_In, "=", "/=" it is legal to compare values of different dimension.

function Equal (Left, Right : Fuzzy_Measure) return Boolean;

This function returns true if Left and Right are identical.

4.2.4. Conversions

function Convert (Value : Fuzzy_Measure; Scale : Measure)
   return Fuzzy_Measure;

This function is used to convert Value to the measurement units specified by the parameter Scale. When offsets of Value and Scale are same this is null operation. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

function Get_Value (Value : Fuzzy_Measure) return Fuzzy_Float;

This function returns SI equivalent of its argument. The result is a plain fuzzy number of the type Fuzzy_Floats.Fuzzy_Float.

function Get_Value_As (Value : Fuzzy_Measure; Scale : Measure)
   return Fuzzy_Float;

This function returns Scale equivalent of Value. The result is a plain fuzzy number of the type Fuzzy_Floats.Fuzzy_Float. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

function Normalize (Value : Fuzzy_Measure) return Fuzzy_Measure;

This function returns unshifted equivalent of its argument. For example when applied to a fuzzy value of Celsius degrees the result will be an equivalent value  in Kelvin.

function Shift (Value : Fuzzy_Measure; Shift : Number'Base)
   return Fuzzy_Measure;

This function returns an equivalent of Value. The offset of the result is determined by the parameter Shift.

function To_Fuzzy_Measure (Left : Number          ) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Measure         ) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Interval        ) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Interval_Measure) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Fuzzy_Float     ) return Fuzzy_Measure;

These function convert a number, dimensioned number, interval or dimensioned interval to the corresponding dimensioned fuzzy number.

 

[Back][TOC][Next]

4.3. String I/O

4.3.1. Integer I/O

The child package Fuzzy.Integers.Edit defines I/O operations on Fuzzy_Integer. It is a generic package. The parameter is an instantiation of the package Strings_Edit.Integer_Edit with the same numeric type.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy_Integer;
             Base    : NumberBase := 10;
          );

This procedure inputs a fuzzy integer number from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the set. The set syntax:

<fuzzy_number>  ::=  <interval> [,<fuzzy_number>]
<interval> ::= <index> [{..|...}<index>] [:<level>]
<index> ::= An integer number, specified according to the parameter Base
<level> ::= A confidence factor specification

Spaces and tabs can be used as delimiters. Trailing commas and colons are not matched causing no error. The confidence factor can be given either in numeric form or as true or false (case insensitive). The intervals with higher confidence factors shall be subintervals of all ones with lower confidence. If an interval of same confidence factor appears twice, the latter appearance shall include the former one. The result returned via Value includes the input, if the confidence factors cannot be directly mapped .At least one integer number shall have confidence 1. If one of these conditions is not satisfied, Constraint_Error is propagated. Examples: 

1   The number 1
2..5 The interval [2, 5]
2..5:0.1, 2..4:0.3, 3:1   The number: 2:0.1, 3:1, 4:0.3, 5:0.1
Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function
Value
         (  Source : String
            Base   : NumberBase := 10;
         )  return Fuzzy_Integer;

This function gets a fuzzy integer from the string Source. The number in the string can be surrounded by spaces and tabs. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error There is no set in the string
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy_Integer;
             Base        : NumberBase := 10;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places the number specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value : Fuzzy_Integer
            Base  : NumberBase := 10;
         )  return String;

This function converts the parameter Value to string.

There is a non-generic instantiation of the package for Integer which can be referred as Fuzzy.Edit.Integers.

4.3.2. Floating-point I/O

The child package Fuzzy.Floats.Edit defines I/O operations on Fuzzy_Float. It is a generic package. The parameter is an instantiation of the package Strings_Edit.Float_Edit with the same numeric type.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy_Float;
             Base    : NumberBase := 10;
          );

This procedure inputs a fuzzy floating-point number from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the set. The set syntax:

<fuzzy_number>  ::=  <interval> [,<fuzzy_number>]
<interval> ::= <index> [{..|...}<index>] [:<level>]
<index> ::= A floating-point number, specified according to the parameter Base
<level> ::= A confidence factor specification

Spaces and tabs can be used as delimiters. Trailing commas and colons are not matched causing no error. The confidence factor can be given either in numeric form or as true or false (case insensitive). The intervals with higher confidence factors shall be subintervals of all ones with lower confidence. If an interval of same confidence factor appears twice, the latter appearance shall include the former one. The result returned via Value includes the input, if the confidence factors cannot be directly mapped .At least one number shall have confidence 1. If one of these conditions is not satisfied, Constraint_Error is propagated. Examples: 

1   The number 1.0
2.3..5.1 The interval [2.3, 5.1]
2..5:0.1, 2..4:0.3, 3:1   The number: [2.0, 3.0[:0.1, 3.0:1, ]3.0, 4.0]:0.3, ]4.0, 5]:0.1
Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String
            Base   : NumberBase := 10;
         )  return Fuzzy_Float;

This function gets a fuzzy integer from the string Source. The number in the string can be surrounded by spaces and tabs. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy_Float;
             Base        : NumberBase := 10;
             RelSmall    : Positive   := MaxSmall;
             AbsSmall    : Integer    := -MaxSmall;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places the number specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1. The parameters RelSmall and AbsSmall determine the precision used to output the interval bounds. For detailed description see the specification of Strings_Edit.Float_Edit package.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value    : Fuzzy_Float
            Base     : NumberBase := 10;
            RelSmall : Positive   := MaxSmall;
            AbsSmall : Integer    := -MaxSmall
         )  return String;

This procedure converts the parameter Value to string.

There is a non-generic instantiation of the package for Float which can be referred as Fuzzy.Edit.Floats.


[Back][TOC][Next]

5. Intuitionistic fuzzy sets

The intuitionistic fuzzy sets were introduced by K. T. Atanassov. They generalize the notion of a fuzzy set by treating membership as a fuzzy logical value rather than a single truth value. For an intuitionistic set the logical value has to be consistent (in the sense γA(x) + μA(x) ≥ 1). However, for the sake of genericity we will drop this constraint allowing contradictory sets as well. We also will use a complement of the complement-set instead of the set itself. It is very important to distinguish two different, though complementary, views on the meaning of an intuitionistic set, which we will call classifications and properly speaking sets.

Proper intuitionistic sets. A fuzzy intuitionistic set A over the domain set D, is A: D→[0,1]2.  It is a function which for any domain value x∈D gives a fuzzy logical value telling whether x belongs to A. One can view an intuitionistic A as a pair of plain fuzzy sets: (A↑, A↓). Here ∀x∈D A↑(x) = PxA, A↓(x) = NxA. In other words the set  A↑ (or the upper set) tells how possible is that the domain value x belongs to A. The lower set A↓ tells how it is necessary. Observe that for a plain fuzzy set A both sets are same, because Px∈A = Nx∈A = A(x), or equivalently PxA + Px∈A = 1. So the membership function of the complement-set can be obtained from one of the fuzzy set. This is untrue for intuitionistic sets: PxA = 1-NxA ≠ 1-PxA. An intuitionistic set is non-contradictory if PxA - NxA ≥ 0.

It can be helpful to consider elements of D as maybe imaginary, fuzzy sets (or classes) over some original domain Ω different from D. The following example illustrates the case:

intuitionistic sets

Let the domain set of some fuzzy set A is being split into a set of intervals {x}i, which then are used as the new domain set. For this new domain one cannot build any fuzzy set corresponding to A, because the membership function of A may take different values on the intervals. So an intuitionistic fuzzy A over the new domain is used instead. For an interval x the upper set of A gives the upper bound of the membership function of A in the interval, the lower set gives the lower bound:

PA|x  ≤  PxA  =   A↑(x)
NA|x NxA = A↓(x)

or equivalently that imaginary A(x)∈[A↓(x), A↑(x)]. This estimation property is the whole idea behind intuitionistic fuzzy sets. An intuitionistic set estimates, or else is an image of some other fuzzy set which original domain is unavailable for some reason. The elements of D are not necessarily intervals. In the most general case they are just some fuzzy sets. If x∈D is normal, i.e. reaches 1 on the original domain, then A↓(x) ≤ A↑(x), i.e. A is non-contradictory.

Intuitionistic classifications. A classification A into the domain set D, is A: D→[0,1]2.  Note that it is formally an intuitionistic fuzzy set, but its membership function has a different meaning. Unlikely to a proper intuitionistic fuzzy set here ∀x∈D:

Px|A  =  PAx  =   A↑(x)
Nx|A = NAx = A↓(x)

The upper set of a classification is same as one of the proper intuitionistic fuzzy set. It is because Px|A = PA|x. But their lower sets differ. If elements of D are viewed as classes, then ∀x∈D A↑(x) = Px|A is the possibility that some observed A is a subset of the class x. A↓(x) = Nx|A is a necessity of that. If A is a singleton in the original domain then PA∈x = NA∈x. Further, A↓(x) ≤ A↑(x), if A is normal. As a rule, the true classification of the prototype set A is unknown, so A only estimates it: A↓(x) ≤ Nx|A ≤ Px|AA↑(x). This is the estimation property for classifications.

Classifications vs. proper sets. It is very important to clearly distinguish intuitionistic fuzzy classifications and proper intuitionistic fuzzy sets. A classification expresses is-a relations. A proper set does has-all relations. Input data are usually given in terms of classifications. When we say that the temperature is hot, we mean a classification of the actual temperature, telling how possible is that the temperature belongs to the set of hot temperatures and how it is necessary. When we say that a bird has the wings, the beak and the feathers, we convey a proper set. This set classifies the particular pair of wings as a part the bird. Note that "birds have wings, beak and feather" is again a classification of birds, because it actually means that any bird is a winged thing, a thing with a beak and feathers. Proper sets represent knowledge rather than just arbitrary observations. A noticeable difficulty is that for inference we often require A has [all] B instead of A is [in] B, because the latter tells nothing about A. Observe also a direct analogy between proper intuitionistic sets and classifications, on one hand, and a posteriori and conditional probabilities on the other.

Operations. The operations on the sets and classifications are defined to preserve the fundamental estimation property:

Operation in
the original domain
Proper set Classification
Possibility Necessity Possibility Necessity
Complement A A A - -
Intersection, A∩B A↑∩B A↓∩B A↑∩B A↓∪B
Union, A∪B A↑∪B A↓∪B A↑∪B A↓∩B
Subset of, A⊆B PB↑|A NB↓|A - -

Note that neither complement nor inclusion can be defined for classifications. For proper sets the definition of inclusion AB conforms to the estimation property in the sense:

PA⊆B  ≤  PAB
NA⊆B  ≥  NAB

We also have AB = AB for sets. Note that AB does not use the lower set A↓. This fact raises a question whether we could get an advantage of knowing A↓. First let us summarize the relationship between AB and AB from one side and conditional possibilities and necessities from another:

A vs. B Possibility Necessity
AB PB↑|A NB↓|A
AB PB↑|A NB↓|A

The values shown in the table above are fundamental in the sense that all others can be obtained as a combination of these four:

A vs. B Possibility Necessity A vs. B Possibility Necessity
AB PB↑|A NB↓|A BA PB↑|A 1-PB↑|A
AB PB↑|A NB↓|A BA 1-NB↓|A NB↓|A
AB 1-NB↓|A 1-PB↑|A BA PB↑|A 1-PB↑|A
AB 1-NB↓|A 1-PB↑|A BA 1-NB↓|A NB↓|A

Now let's note that unlikely to sharp sets, for the fuzzy ones AB does not imply BA, more precisely, it does it only when AB is certain true. We could define a symmetric inclusion AB as AB & BA, which would take BA into account and would have the desired property AB = BA. The symmetric inclusion will use A↓. Note that for the symmetric inclusion Px∈A does not equal to {x}≤A. However in a realistic case it probably will. Another property the symmetric inclusion does not have is that AB ≠ AB. An equivalence relation could be defined in terms of symmetric inclusions: AB = AB & BA. It has the properties AB = BA = AB. The following table summarizes some of interesting variants of intuitionistic comparisons resulting in fuzzy logical values:

A vs. B Possibility Necessity Meaning
AB PB↑|A NB↓|A A is in B (A is a subset of B)
AB PB↑|A NB↓|A The complement of A is in B
AB min (PB↑|A, 1-NB↓|A) NB↓|A A is in B and its complement contains B
AB min (PB↑|A, 1-NB↓|A) 1-PB↑|A A contains B and its complement is in B
AB min (PB↑|A, 1-NB↓|A) min (NB↓|A, 1-PB↑|A) A is B

[Back][TOC][Next]

5.1. Type and operations

The package Fuzzy.Intuitionistic provides an implementation of intuitionistic fuzzy sets.

The type Set is defined as:

type Set (Cardinality : Positive) is record
   Possibility : Fuzzy.Set (1..Cardinality);
   Necessity   : Fuzzy.Set (1..Cardinality);
end record;

The following operations defined on Set:

function "not" (A : Set) return Set;

function "and" (A, B : Set) return Set;
   function "and" (A : Set; B : Fuzzy.Set) return Set;
   function "and" (A : Fuzzy.Set; B : Set) return Set;
   function
"and" (A : Set; B : Confidence ) return Set;
   function
"and" (A : Confidence;  B : Set) return Set;

function
"or" (A, B : Set) return Set;
   function
"or" (A : Set; B : Fuzzy.Set) return Set;
   function
"or" (A : Fuzzy.Set; B : Set) return Set;
   function
"or" (A : Set; B : Confidence ) return Set;
   function
"or" (A : Confidence;  B : Set) return Set;

function
"xor" (A, B : Set) return Set;
   function
"xor" (A : Set; B : Fuzzy.Set) return Set;
   function
"xor" (A : Fuzzy.Set; B : Set) return Set;
   function
"xor" (A : Set; B : Confidence ) return Set;
   function
"xor" (A : Confidence;  B : Set) return Set;

These operations are defined as follows from the table:

Operation  Name 
Complement A not
Intersection AB and
Union AB or
xor-distance (AB)∪(AB) xor

When the parameters are both ether a fuzzy set or an intuitionistic set then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter. When a parameter is a set, then the result is computed as if the possibility and the necessity components were equal to the set.

The variants with the first argument used as an accumulator:

procedure Not_At (A : in out Set);

procedure And_At (A : in out Set; B : Set);
   procedure And_At (A : in out Set; B : Fuzzy.Set);
   procedure And_At (A : in out Set; B : Confidence);

procedure Or_At (A : in out Set; B : Set);
   procedure Or_At (A : in out Set; B : Fuzzy.Set);
   procedure Or_At (A : in out Set; B : Confidence);

procedure Xor_At (A : in out Set; B : Set);
   procedure Xor_At (A : in out Set; B : Fuzzy.Set);
   procedure Xor_At (A : in out Set; B : Confidence);

The comparisons:

function Is_In (A, B : Set) return Fuzzy_Boolean;
   function
Is_In (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
Is_In (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
Is_In (A : Set; B : Integer) return Fuzzy_Boolean;
   function
Is_In (A : Integer; B : Set) return Fuzzy_Boolean;

function
">=" (A, B : Set) return Fuzzy_Boolean;
   function
">=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
">=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
">=" (A : Set; B : Integer) return Fuzzy_Boolean;

function
"<=" (A, B : Set) return Fuzzy_Boolean;
   function
"<=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
"<=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
"<=" (A : Set; B : Integer) return Fuzzy_Boolean;

function
"=" (A, B : Set) return Fuzzy_Boolean;
   function
"=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
"=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
"=" (A : Set; B : Integer) return Fuzzy_Boolean;

function
"/=" (A, B : Set) return Fuzzy_Boolean;
   function
"/=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
"/=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
"/=" (A : Set; B : Integer) return Fuzzy_Boolean;

They are defined as:

Operation  Name 
Membership AB Is_In
Symmetric inclusion AB <=
Symmetric inclusion AB >=
Equality AB =
Inequality /=

When both parameters are sets then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters is Integer, then it specifies Set which consists of the domain point specified by the parameter value (singleton). Certain_False is returned when the parameter's value is out of 1..Cardinality. When a parameter is a set, then the result is computed as if the possibility and the necessity components were equal to the set.

The type Classification is defined as:

type Classification is new Set;

The following operations defined on Classification:

function "and" (A, B : Classification) return Classification;
   function "and" (A : Classification; B : Fuzzy.Set) return Classification;
   function "and" (A : Fuzzy.Set; B : Classification) return Classification;
   function
"and" (A : Classification; B : Confidence ) return Classification;
   function
"and" (A : Confidence;  B : Classification) return Classification;
function
"or" (A, B : Classification) return Classification;
   function
"or" (A : Classification; B : Fuzzy.Set) return Classification;
   function
"or" (A : Fuzzy.Set; B : Classification) return Classification;
   function
"or" (A : Classification; B : Confidence ) return Classification;
   function
"or" (A : Confidence;  B : Classification) return Classification;

These operations are defined as follows from the table:

Operation  Name 
Intersection AB and
Union AB or

When the parameters are both ether a fuzzy set or a classification then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter. When a parameter is a set, then the result is computed as if the possibility and the necessity components were equal to the set.

The variants with the first argument used as an accumulator:

procedure And_At (A : in out Classification; B : Classification);
   procedure And_At (A : in out Classification; B : Fuzzy.Set);
   procedure And_At (A : in out Classification; B : Confidence);
procedure Or_At (A : in out Classification; B : Classification);
   procedure Or_At (A : in out Classification; B : Fuzzy.Set);
   procedure Or_At (A : in out Classification; B : Confidence);

The membership test:

function Is_In (A : Classification; B : Integer) return Fuzzy_Boolean;

is defined as the value of the membership function of A in B. I.e. it tells how possible and necessary is the domain value specified by B provided that A was observed. Certain_False is returned when the parameter's value is out of 1..A.Cardinality.

[Back][TOC][Next]

5.2. String I/O with numeric indices

The child package Fuzzy.Edit.Intuitionistic provides the string I/O for fuzzy intuitionistic sets with the domain set elements specified in a numeric form.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Certain_True
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Certain_True
          );

These procedures input a fuzzy intuitionistic set (either a proper one or a classification) from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the Fuzzy.Intuitionistic.Set. The syntax is

<set>  ::=  <item> [,<set>]
<item> ::= <index> [{..|...} <index>] [:<possibility>[:<necessity>]]
<index> ::= A domain point specification
<possibility> ::= A confidence factor specification
<necessity> ::= A confidence factor specification

In [:<possibility>[:<necessity>]] the first one specifies the confidence factor of the possibility component (the upper set), the second one specifies the necessity component (the upper set). When both are omitted the value of the parameter Default determines the result. When only the possibility is specified the necessity is defaulted to the possibility combined with Default.Necessity using and. Spaces and tabs can be used as delimiters. The domain point specification is an integer number. The confidence factor can be given either in numeric form or as true or false (case insensitive). A trailing commas and colons are ignored and not matched. Examples: 

1,2,6..9
1:0,2:0.3,3..5:1:0.5
Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source      : String;
            Cardinality : Positive;
            Default     : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Set;

These functions are a shortcuts for the procedures Get. The get a set from the string Source. The parameter Cardinality defines one of the result. The input in the string can be surrounded by spaces and tabs. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

These procedures  place a fuzzy intuitionistic set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). The parameter Default determines how to omit the confidence factors for possibility and necessity. If they are equal to ones of Default, they are omitted. Further the necessity is omitted if equal to the possibility combined with Default.Necessity using and. When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;
function
Image
         (  Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;

These functions convert the parameter Value to string.

[Back][TOC][Next]

5.3. Generic string I/O

The child package Fuzzy.Generic_Edit.Intuitionistic provides string I/O with user-defined I/O routines for the domain set elements (the package Fuzzy.Edit.Intuitionistic instantiates Fuzzy.Generic_Edit.Intuitionistic). The package has no formal parameters of its own. It uses the formal procedures of its parent.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             Value   : out Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Certain_True
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             Value   : out Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Certain_True
          );

These procedures get an intuitionistic set (Fuzzy.Intuitionistic.Set or Fuzzy.Intuitionistic.Classification) from the string Source. The set has the following syntax:

<set>  ::=  <item> [,<set>]
<item> ::= <range> [:<possibility>[:<necessity>]]
<possibility> ::= A confidence factor specification
<necessity> ::= A confidence factor specification

Here the syntax of <range> is defined by the formal procedure Get of Fuzzy.Generic_Edit. Commas and colons may be surrounded by spaces and tabs. A trailing comma or colon is ignored and not matched. The parameter Default determines the confidence factors when omitted. If both are not present then the possibility is defaulted to Default.Possibility and the necessity is defaulted to Default.Necessity. When only a necessity is missing it is defaulted to the specified possibility combined with Default.Necessity using and. For example: if Default is Uncertain, the necessity is defaulted to 0; if Default is Certain_True, the necessity is defaulted to the specified possibility.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source      : String;
            Data        : User_Data;
            Cardinality : Positive;
            Default     : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Set;
function
Value
         (  Source      : String;
            Data        : User_Data;
            Cardinality : Positive;
            Default     : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Classification;

These functions get either a Fuzzy.Intuitionistic.Set or a Fuzzy.Intuitionistic.Classification from the string Source. The result has the cardinality defined by Cardinality. The input in the string can be surrounded by spaces and tabs. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

These procedures place either a Fuzzy.Intuitionistic.Set or a Fuzzy.Intuitionistic.Classification specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). The parameter Default specifies the way the confidence factors can be omitted in output. Both are omitted if the possibility equals to Default.Possibility and the necessity equals to Default.Necessity. Further the necessity can be omitted if it equals to the possibility combined with Default.Necessity using and.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Data    : User_Data;
            Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;
function
Image
         (  Data    : User_Data;
            Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;

These functions convert the parameter Value to string.

[Back][TOC][Next]

5.4. Abstract string I/O

The child package Fuzzy.Abstract_Edit.Intuitionistic provides an instantiation of Fuzzy.Generic_Edit.Intuitionistic. It defines the following class-wide routines for the type User_Data from Fuzzy.Abstract_Edit:

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data'Class;
             Value   : out Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Certain_True
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data'Class;
             Value   : out Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Certain_True
          );

function
Value
         (  Source  : String;
            Data    : User_Data'Class;
            Default : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Set;
function
Value
         (  Source  : String;
            Data    : User_Data'Class;
            Default : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Classification;

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data'Class;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data'Class;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

function
Image
         (  Data    : User_Data'Class;
            Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;
function
Image
         (  Data    : User_Data'Class;
            Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;

[Back][TOC][Next]

5.5. String I/O with named indices

The type Domain_Description from the child package Fuzzy.Abstract_Edit.Named can be used with Fuzzy.Abstract_Edit.Intuitionistic.

[Back][TOC][Next]

5.6. Basic string I/O

The child package Fuzzy.Intuitionistic.Basic_Edit provides basic subroutine for string I/O.

procedure Get_Weight
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy_Boolean;
             Default : Fuzzy_Boolean := Certain_True
          );

This procedure is used to get the weight of a domain point value in the form [:<possibility>[:<necessity>]]. If no colon present, Default is set into Value. If only the necessity component is missing then it is evaluated as the specified possibility and Default.Necessity. Thus if Default is Certain_True, then the necessity is defaulted to the specified possibility. If Default is Uncertain, then necessity is defaulted to 0.

Exceptions
Data_Error Syntax error or value is not in 0..1
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

[Back][TOC][Next]

6. Linguistic variables

A linguistic variable is some fuzzy set joining values sharing some common property, usually familiar to human beings. For example, if we consider outdoor temperatures, then warm could be a linguistic variable. A set of linguistic variables is used to represent the original domain set in terms of the variables. In the case of outdoor temperatures, this set could be (chill, cold, tepid, warm, hot):

outdoor temperatures

With this set the temperature 16ºC could be classified warm: 0.3, tepid:1, and cold: 0.15. The main purpose of linguistic variables is to reduce the original domain set, which is usually infinite (in our case it is the set of all possible temperatures), to a small conceivable set. The commonly considered operations on linguistic variables and their subsets are:

Let v={vi: R→[0,1]}i be a set of linguistic variables vi, such as warm, tepid etc.

Fuzzification is a process of conversion some, usually crisp, data from the domain set to a set of linguistic variables, as we did it with the temperature 16ºC. The membership function of the result yields the possibility of a variable under condition of the given value. In our example "warm: 0.3 " formally means:

P16ºC∈ warm = Pwarm |{16ºC} = 0.3

One could also say that 16ºC is classified as warm with the confidence 0.3. A set of linguistic variables is complete if its union gives the domain set. This, very frequently disregarded, requirement allows to avoid contradictory (in the sense of fuzzy logic) results (a statement about some x is contradictory when Px + Px is less than 1). Carefully observe, that the result of a fuzzification is in general case an intuitionistic classification (Fuzzy.Intuitionistic.Classification) as the following picture shows:

fuzzification

Here the fuzzified set T of temperatures is painted grey. It produces a classification of T: cold: 1:1, tepid: 0.9:0.4, others are 0:0. This notation means:

PT⊆ cold  =  1,     NT⊆ cold  =  1,
PT⊆ tepid  =  0.9,   NT⊆ tepid  =  0.4,
etc

Formally fuzzified T is v(T) defined as ∀xv v(T)(x) = (Px|T, Nx|T).

Accumultation maps a proper subset of linguistic variables into the original domain. The following figure illustrates the accumulation process for an intuitionistic set warm: 0.3, tepid: 1.0 and cold: 0.15. The result is painted in grey:

accumulation

Formally, if T: v→[0,1] is a fuzzy subset of v. Then accumulated Ta is a fuzzy subset of R (which can be viewed as a fuzzy number or a linguistic variable):

Ta(t)  =  Max
x
v
 min (x(t), T(x))

The interpretation of Ta(t) is as follows. For some variable xv T(x)=PT|x is the possibility that the variable x is a subset of some, maybe, imaginary set T, and x(t)=Px|{t}=Ptx is the possibility that t belongs to x. So provided that the set of linguistic variables is complete Ta(t) ≥ PtT. Thus an accumulated variable gives an estimated image of the argument in the original domain set. Should we have T, a fuzzy intuitionistic subset of v, i.e. both an upper and a lower set, we could estimate T from both above and below:

Min
x
v
 max (1-x(t), T↓(x))  ≤  T(t)  ≤  Max
x
v
 min (x(t), T↑(x))

Beware that accumulation of the lower set of some classification has no sense. Only the upper set of a classification can be accumulated. Accumulation is often used as a part of some defuzzification process. The accumulated result is converted to a crisp number using various empirical methods, such as center of gravity, center of area, etc.

Defuzzification is an operation reverse to fuzzification. The following figure shows the result of defuzzification of an intuitionistic fuzzy classification: cold: 0.4: 0, tepid: 1: 0.7, warm: 0.5: 0, others are 0: 0. The result is a crisp set painted in gray:

defuzzification

Note that the result of defuzzification is a general case crisp set. The set is not empty if correct inference rules and valid data are used. Additional restrictions imposed on the membership functions of the linguistic variables may further ensure that the result is a contiguous set. Formally the result of a defuzzification is defined as follows. Let v(T) be an intuitionistic classification of some unknown T: ∀xv v(T)(x) = (Px|T, Nx|T).. Then defuzzified v(T) is a set of numbers tR, such that for any linguistic variable x: x(t)↑≤v(T)↑ and x(t)↓≥v(T)↓.

There exist various defuzzification methods applied in practice which cannot be justified without additional assumptions about the application domain. Let v: R→[0,1] be a linguistic variable, then

vCoG =  +∞
x v(x) dx
-∞  
+∞
v(y) dy
-∞
    The center of gravity was borrowed from mathematical statistics. Its result numerically equals to the expectation value of the probability density p:
p(x) =  v(x)
+∞
v(y) dy
-∞
    Though the membership function v is a distribution of possibilities. Whether p(·) which is numerically v divided by a constant is a distribution of probabilities, and what the meaning the expectation of the latter might have depends on the application domain.
vDCoG = 
 xi v(xi)
i   
 v(xk)
k
    As the continuous center of gravity, the discrete one has a probabilistic interpretation. It numerically equals to the expectation of the distribution of probabilities Pi:
Pi =  v(xi)
 v(xk)
k
vCoA +∞
v(x) dx  =  v(y) dy
-∞ vCoA
    Note that the center of area ill-defined. For many continuous distributions of possibilities it is not defined. Infinitely small variations of the distribution may influence existence of the center of area. That means when using vCoA for outputs in a control loop of a fuzzy control system one should take into account a possibility of abrupt changes of the outputs. Especially sensible are the cases where the membership function takes small values along an interval between two spikes of equal area: like double hump of a Bactrian camel.

The following picture illustrates the empirical defuzzification methods:

Empirical defuzzification methods

[Back][TOC][Next]

6.1. Variables

6.1.1. Plain variables

The package Fuzzy.Linguistics provides an implementation of linguistic variables built over a domain of real numbers. The package is generic:

generic
   with package Fuzzy_Floats is new Fuzzy.Floats (<>);
package Fuzzy.Linguistics is ...

The formal generic parameter Fuzzy_Floats of the package is an instance of the package Fuzzy.Floats implementing fuzzy floating-point numbers. There is a pre-instantiated version of Fuzzy.Linguistics for the standard type Float: Fuzzy_Linguistics.

The package defines the type Variable representing a linguistic variable:

type Variable is private;

The implementation supports variables with the membership functions linear on a finite number of intervals. In the points of joining the membership function may have different left, right limits and two different values. The first value is the value of the membership function itself. It tells how possible is that the point belongs to the linguistic variable. The second value tells how necessary it is. Normally both are equal. This allows to represent commonly used shapes of membership function such as "shoulder", "trapezoid",  "triangle", "rectangle" and "singleton".

type Pair is record
   Value : Number;
   Level : Confidence;
end record;

This type is used to represent points from which a membership function of a variable is composed.

Composing a variable:

The following operations are used to compose a Variable:

procedure Append
          (  Var   : in out Variable;
             Value : Number;
             Level : Confidence
          );

This function is used to form the membership function of a linguistic variable Var. It adds a new point to the function. Points have to be added in ascending order. It is allowed to provide several points with same argument (Value). The parameter Level defines the confidence level of the added point. A linguistic variable have to have at least one point defined. The following table shows some examples of using Append:

Membership function Code example
shoulder declare
   Shoulder : Variable;
begin
   Append (Shoulder,  0.0, Confidence'Last);
   Append (Shoulder, 10.0, Confidence'First);
   ...
rectangle declare
   Rectangle : Variable;
begin
   Append (Rectangle, -10.0, Confidence'First);
   Append (Rectangle, -10.0, Confidence'Last);
   Append (Rectangle,  10.0, Confidence'Last);
   Append (Rectangle,  10.0, Confidence'First);
   ...
trapezoid declare
   Trapezoid : Variable;
begin
   Append (Trapezoid, -10.0, Confidence'First);
   Append (Trapezoid,   0.0, Confidence'Last);
   Append (Trapezoid,  10.0, Confidence'Last);
   Append (Trapezoid,  15.0, Confidence'First);
   ...
singleton declare
   Singleton : Variable;
begin
   Append (Singleton, 10.0, Confidence'First);
   Append (Singleton, 10.0, Confidence'Last);
   Append (Singleton, 10.0, Confidence'First);
   ...
pulse declare
   Pulse : Variable;
begin
   Append (Pulse, 0.0, 0.75);
   Append (Pulse, 0.0, Confidence'Last);
   Append (Pulse, 0.0, 0.25);
   Append (Pulse, 0.0, 0.5);
   ...

Data_Error is propagated when the specified value is out of order.

procedure Erase (Var : Variable);

This procedure makes its argument an empty set.

An alternative variant to compose a variable is to use

function "&" (Left : Pair;     Right : Pair) return Variable;
function "&" (Left : Variable; Right : Pair) return Variable;

The left parameter is either a Pair or a Variable. The result is the left parameter with the point added from Right. Data_Error is propagated when the value specified by Right value is out of order. For example, Pulse from the table above could be obtained as:

(0.0, 0.75) & (0.0, Confidence'Last) & (0.0, 0.25) & (0.0, 0.5)

Set-theoretic operations:

function "not" (A : Variable) return Variable;
function "and" (A, B : Variable) return Variable;
   function "and" (A : Variable;   B : Confidence) return Variable;
   function "and" (A : Confidence; B : Variable  ) return Variable;
function "or"  (A, B : Variable) return Variable;
   function "or"  (A : Variable;   B : Confidence) return Variable;
   function "or"  (A : Confidence; B : Variable  ) return Variable;
function "xor" (A, B : Variable) return Variable;
   function "xor" (A : Variable;   B : Confidence) return Variable;
   function "xor" (A : Confidence; B : Variable  ) return Variable;

When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter.

Equality and equivalence tests:

The equality and inequality operations are:

function "=" (A, B : Variable) return Fuzzy_Boolean;
   function
"=" (A : Variable; B : Number      ) return Fuzzy_Boolean;
   function
"=" (A : Variable; B : Interval    ) return Fuzzy_Boolean;
   function
"=" (A : Variable; B : Fuzzy_Number) return Fuzzy_Boolean;
   function
"=" (A : Number;       B : Variable) return Fuzzy_Boolean;
   function "=" (A : Interval;     B : Variable) return Fuzzy_Boolean;
   function
"=" (A : Fuzzy_Number; B : Variable) return Fuzzy_Boolean;
function
"/=" (A, B : Variable) return Fuzzy_Boolean;
   function
"/=" (A : Variable; B : Number      ) return Fuzzy_Boolean;
   function
"/=" (A : Variable; B : Interval    ) return Fuzzy_Boolean;
   function
"/=" (A : Variable; B : Fuzzy_Number) return Fuzzy_Boolean;
   function
"/=" (A : Number;       B : Variable) return Fuzzy_Boolean;
   function
"/=" (A : Interval;     B : Variable) return Fuzzy_Boolean;
   function
"/=" (A : Fuzzy_Number; B : Variable) return Fuzzy_Boolean;

The result of equality is defined as AB & BA. The result of inequality is defined as not (A = B). Numbers, intervals, fuzzy numbers and variables are supported as arguments. At least one argument should be a variable.

function Equal (A, B : Variable; Eps : Number'Base := 0.0) return Boolean;
   function
Equal
            (  A   : Pair;
               B   : Variable;
               Eps : Number'Base := 0.0
            )  return Boolean;
   function Equal
            (  A   : Variable;
                : Pair;
               Eps : Number'Base := 0.0
            )  return Boolean;
   function Equal (A, B : Pair; Eps : Number'Base := 0.0) return Boolean;

These functions return true if A and B have equivalent membership functions. It means that the membership functions have same number of distinct joining points, the ordinates of the corresponding points differ no more than by the value of the parameters Eps, abscissas of the points are exactly same. Any of parameters can be either a Variable of Pair.

Scalar arithmetic:

function "+" (Left : Variable; Right : Number) return Variable;
function
"-" (Left : Variable; Right : Number) return Variable;
function
"*" (Left : Variable; Right : Number) return Variable;
function
"/" (Left : Variable; Right : Number) return Variable;

A variable can be multiplied and divided by a number. Also a number can be added to or subtracted from a variable.

Informational functions:

function Get_Points_Number (Var : Variable) return Natural;

This function returns the number of distinct points in the membership function of Var. For the singleton in an example above it would be 1. For the trapezoid it would be 4.

function Is_Empty (Var : Variable) return Boolean;

This function returns true if Var is an empty set, i.e. if its membership function is everywhere false.

function Is_Interval (Var : Variable) return Boolean;

This function returns true if Var is an interval, i.e. if its membership function is true on a finite contiguous range of values and false outside the range. Note that a membership function of variable takes its left and right limits in any point. Thus formally no variable can be an interval. This difference is disregarded. So more precisely Is_Interval returns true if there exist a, b such that Var↑(t)=1 if t∈[a, b] , otherwise Var↑(t)=0 and Var↓(t)=1 if t∈]a, b[ , otherwise Var↓(t)=0.

function Is_Singleton (Var : Variable) return Boolean;

This function returns true if the membership function of Var is true in one point and false elsewhere. More precisely, there is t0 such that Var↑(t0)=1, for any tt0 Var↑(t)=0.

Membership and subset tests:

function Is_In (A, B : Variable) return Fuzzy_Boolean;
   function
Is_In (A : Number;      B : Variable) return Fuzzy_Boolean;
   function Is_In (A : Interval;    B : Variable) return Fuzzy_Boolean;
   function Is_In (A : Fuzzy_Float; B : Variable) return Fuzzy_Boolean;
   function
Is_In (A : Variable; B : Number     ) return Fuzzy_Boolean;
   function Is_In (A : Variable; B : Interval   ) return Fuzzy_Boolean;
   function Is_In (A : Variable; B : Fuzzy_Float) return Fuzzy_Boolean;

These functions implement membership / subset tests or else fuzzification of A using B. The result is a fuzzy logical value indicating whether A is a member / subset to B. It is defined as fuzzy inclusion ⊆. I.e. as Is_In (A, B) = (PB|A, NB|A). The parameters can be numbers, intervals, fuzzy numbers, variables. At least one of them should be a variable. Carefully observe, that for a singleton in the table above and the value 10,

Is_In (10.0, Singleton)

would return Uncertain, because the membership function takes [0, 1] range in 10.

The possibility theory:

function Possibility (A : Variable) return Confidence;
function Possibility (A, B : Variable) return Confidence;
   function
Possibility (A : Number;      B : Variable) return Confidence;
   function
Possibility (A : Interval;    B : Variable) return Confidence;
   function
Possibility (A : Fuzzy_Float; B : Variable) return Confidence;
   function Possibility (A : Variable; B : Number     ) return Confidence;
   function
Possibility (A : Variable; B : Interval   ) return Confidence;
   function
Possibility (A : Variable; B : Fuzzy_Float) return Confidence;

These functions return PA and PA|B correspondingly. The parameters can be numbers, intervals, fuzzy numbers, variables. At least one of them should be a variable.

function Necessity (A : Variable) return Confidence;
function Necessity (A, B : Variable) return Confidence;
   function
Necessity (A : Number;      B : Variable) return Confidence;
   function
Necessity (A : Interval;    B : Variable) return Confidence;
   function
Necessity (A : Fuzzy_Float; B : Variable) return Confidence;
   function Necessity (A : Variable; B : Number     ) return Confidence;
   function
Necessity (A : Variable; B : Interval   ) return Confidence;
   function
Necessity (A : Variable; B : Fuzzy_Float) return Confidence;

These functions return NA and NA|B. Observe that for an empty set NA is defined as true. The parameters can be numbers, intervals, fuzzy numbers, variables. At least one of them should be a variable.

Conversions:

function To_Variable (Value : Number) return Variable;
function To_Variable (Value : Interval) return Variable;
function To_Variable (Value : Fuzzy_Float) return Variable;

These functions can be used to convert a number, interval or fuzzy number to a variable.

function To_Number (Value : Variable) return Number;
function To_Interval (Value : Variable) return Interval;

These functions perform backward conversions to number and interval. When the conversion is impossible because the parameter is a more general set then Constraint_Error is propagated.

The package also defines the constant variable Empty which membership function is everywhere 0.

6.1.2. Dimensioned variables

The package Fuzzy.Linguistics.Measures provides an implementation of linguistic variables built over a domain of dimensioned real numbers. The package is generic:

generic
   with package
Float_Measures is
      new
Standard.Measures (Fuzzy_Floats.Number);
   with package
Interval_Measures is
      new
Intervals.Measures
          (  Float_Measures,
             Fuzzy_Floats.Float_Intervals
          );
   with package
Fuzzy_Measures is
      new
Fuzzy.Measures
          (  Fuzzy_Floats      => Fuzzy_Floats,
             Float_Measures    => Float_Measures,
             Interval_Measures => Interval_Measures
          );
package
Fuzzy.Linguistics.Measures is ...

The formal generic parameters of the package are:

There is a pre-instantiated version of Fuzzy.Linguistics.Measures for the standard type Float: Fuzzy_Linguistic_Measures.

The package Fuzzy.Linguistics.Measures defines the type Variable_Measure representing a dimensioned linguistic variable:

type Variable_Measure (SI : Unit := Units.Base.Unitless) is record
   Gain   : Variable;
   Offset : Number'Base;
end record;

The discriminant SI and the field Offset determine the dimension of the value as they do in the type Measure. The field Gain represents the numeric value of the variable in these units.

type Pair_Measure is record
   Value : Measure;
   Level : Confidence;
end record;

This type is used to represent points from which a membership function of a variable is composed.

Composing a variable:

The following operations are used to compose a Variable_Measure:

procedure Append
          (  Var   : in out Variable_Measure;
             Value : Measure;
             Level : Confidence
          );

This function is used to form the membership function of a linguistic variable Var. It adds a new point to the function. Points have to be added in ascending order. It is allowed to provide several points with same argument (Value). The parameter Level defines the confidence level of the added point. A linguistic variable have to have at least one point defined. Var and Value should have compatible dimension units, though maybe differently shifted. Otherwise Unit_Error is propagated. Data_Error is propagated when the specified value is out of order.

function Empty (Scale : Measure) return Variable_Measure;

This function returns an empty variable with the membership function that is everywhere 0. The dimension of the result is determined by the parameter Scale.

procedure Erase (Var : Variable_Measure);

This procedure makes its argument an empty set.

function "&" (Left : Pair_Measure; Right : Pair_Measure)
   return Variable_Measure;
function "&" (Left : Variable; Right : Pair_Measure)
   return Variable_Measure;

The left parameter is either a Pair_Measure or a Variable_Measure. The result is the left parameter with the point added from Right. Data_Error is propagated when the value specified by Right value is out of order. When Left and Right are of Pair_Measure then they have to have exactly same dimension units. Otherwise Unit_Error is propagated. When Left is of Variable_Measure then the dimension of Right has to be compatible though might be differently shifted.

Set-theoretic operations:

function "not" (A : Variable_Measure) return Variable_Measure;
function "and" (A, B : Variable_Measure) return Variable_Measure;
   function "and" (A : Variable_Measure; B : Confidence)
      return Variable_Measure;
   function "and" (A : Confidence; B : Variable_Measure_Measure)
      return Variable_Measure;
function "or" (A, B : Variable_Measure) return Variable_Measure;
   function "or" (A : Variable_Measure; B : Confidence)
      return Variable_Measure;
   function "or" (A : Confidence; B : Variable_Measure)
      return Variable_Measure;
function "xor" (A, B : Variable_Measure) return Variable_Measure;
   function "xor" (A : Variable_Measure; B : Confidence)
      return Variable_Measure;
   function "xor" (A : Confidence; B : Variable_Measure)
      return Variable_Measure;

When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter. When both parameters are of Variable_Measure then their dimension units have to be compatible. Otherwise Unit_Error is propagated.

Equality and equivalence tests:

The equality and inequality operations are:

function "=" (A, B : Variable_Measure) return Fuzzy_Boolean;
   function
"="  (A : Variable_Measure; B : Measure         ) return Fuzzy_Boolean;
   function
"="  (A : Variable_Measure; B : Interval_Measure) return Fuzzy_Boolean;
   function
"="  (A : Variable_Measure; B : Fuzzy_Measure   ) return Fuzzy_Boolean;
   function
"="  (A : Measure;          B : Variable_Measure) return Fuzzy_Boolean;
   function "="  (A : Interval_Measure; B : Variable_Measure) return Fuzzy_Boolean;
   function
"="  (A : Fuzzy_Measure;    B : Variable_Measure) return Fuzzy_Boolean;
function
"/=" (A, B : Variable_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Variable_Measure; B : Measure         ) return Fuzzy_Boolean;
   function
"/=" (A : Variable_Measure; B : Interval_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Variable_Measure; B : Fuzzy_Measure   ) return Fuzzy_Boolean;
   function
"/=" (A : Measure;          B : Variable_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Interval_Measure; B : Variable_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Fuzzy_Measure;    B : Variable_Measure) return Fuzzy_Boolean;

The result of equality is defined as AB & BA. The result of inequality is defined as not (A = B). Dimensioned numbers, intervals, fuzzy numbers and variables are supported as arguments. At least one argument should be a Variable_Measure. It is allowed to compare entities of different dimension units.

function Equal (A, B : Variable_Measure; Eps : Number'Base := 0.0) return Boolean;
   function
Equal
            (  A   : Pair_Measure;
               B   : Variable_Measure;
               Eps : Number'Base := 0.0
            )  return Boolean;
   function Equal
            (  A   : Variable_Measure;
                : Pair_Measure;
               Eps : Number'Base := 0.0
            )  return Boolean;
   function Equal (A, B : Pair_Measure; Eps : Number'Base := 0.0) return Boolean;

These functions return true if A and B have equivalent membership functions. It means that the membership functions have same number of distinct joining points, the ordinates of the corresponding points differ no more than by the value of the parameters Eps, abscissas of the points are exactly same. Any of parameters can be either a Variable_Measure of Pair_Measure. Values of different units are considered unequal.

Scalar arithmetic:

function "+" (Left : Variable_Measure; Right : Measure) return Variable_Measure;
function
"-" (Left : Variable_Measure; Right : Measure) return Variable_Measure;

A dimensioned value can be added to a Variable_Measure. Both arguments must have same dimension, otherwise Unit_Error is propagated.

function "*" (Left : Variable_Measure; Right : Number ) return Variable_Measure;
function
"*" (Left : Variable_Measure; Right : Measure) return Variable_Measure;
function
"*" (Left : Variable;         Right : Measure) return Variable_Measure;
function
"/" (Left : Variable_Measure; Right : Number ) return Variable_Measure;
function
"/" (Left : Variable_Measure; Right : Measure) return Variable_Measure;
function
"/" (Left : Variable;         Right : Measure) return Variable_Measure;

These functions multiply and divide a dimensioned variable by a scalar. When Right is dimensioned then Constraint_Error is propagated on unit power overflow. Unit_Error is propagated when Left and Right have incompatible shifts (see the description of the type Measure for further information.) Also a plain variable can be multiplied to or divided by a dimensioned number. The result is a dimensioned linguistic variable.

Informational functions:

function Get_Points_Number (Var : Variable_Measure) return Natural;

This function returns the number of distinct points in the membership function of Var.

function Get_Unit (Value : Variable_Measure) return Unit;

This function returns the SI measurement unit of the argument.

function Is_Empty (Var : Variable_Measure) return Boolean;

This function returns true if Var is an empty set, i.e. if its membership function is everywhere false.

function Is_Interval (Var : Variable_Measure) return Boolean;

This function returns true if Var is an interval, i.e. if its membership function is true on a finite contiguous range of values and false outside the range.

function Is_Singleton (Var : Variable_Measure) return Boolean;

This function returns true if the membership function of Var is true in one point and false elsewhere.

Membership and subset tests:

function Is_In (A, B : Variable_Measure) return Fuzzy_Boolean;
   function
Is_In (A : Measure;          B : Variable_Measure) return Fuzzy_Boolean;
   function Is_In (A : Interval_Measure; B : Variable_Measure) return Fuzzy_Boolean;
   function Is_In (A : Fuzzy_Measure;    B : Variable_Measure) return Fuzzy_Boolean;
   function
Is_In (A : Variable_Measure; B : Measure         ) return Fuzzy_Boolean;
   function Is_In (A : Variable_Measure; B : Interval_Measure) return Fuzzy_Boolean;
   function Is_In (A : Variable_Measure; B : Fuzzy_Measure   ) return Fuzzy_Boolean;

These functions implement membership / subset tests or else fuzzification of A using B. The result is a fuzzy logical value indicating whether A is a member / subset to B. The parameters can be dimensioned numbers, intervals, fuzzy numbers, variables. At least one of them should be a Variable_Measure. The parameters may have any units.

The possibility theory:

function Possibility (A : Variable_Measure) return Confidence;
function Possibility (A, B : Variable_Measure) return Confidence;
   function
Possibility (A : Measure;          B : Variable_Measure) return Confidence;
   function
Possibility (A : Interval_Measure; B : Variable_Measure) return Confidence;
   function
Possibility (A : Fuzzy_Measure;    B : Variable_Measure) return Confidence;
   function Possibility (A : Variable_Measure; B : Measure         ) return Confidence;
   function
Possibility (A : Variable_Measure; B : Interval_Measure) return Confidence;
   function
Possibility (A : Variable_Measure; B : Fuzzy_Measure   ) return Confidence;

function
Necessity (A : Variable) return Confidence;
function Necessity (A, B : Variable) return Confidence;
   function Necessity (A : Measure;          B : Variable_Measure) return Confidence;
   function
Necessity (A : Interval_Measure; B : Variable_Measure) return Confidence;
   function
Necessity (A : Fuzzy_Measure;    B : Variable_Measure) return Confidence;
   function
Necessity (A : Variable_Measure; B : Measure         ) return Confidence;
   function
Necessity (A : Variable_Measure; B : Interval_Measure) return Confidence;
   function
Necessity (A : Variable_Measure; B : Fuzzy_Measure   ) return Confidence;

Parameters may have different units in which case the possibility is 0 and the necessity is defined as not Possibility (B). Note that numbers and intervals are normal sets thus for them the result necessity will always be 0. For a variable it is 0 only if the variable is normal.

Conversions:

function Convert (Value : Variable_Measure; Scale : Measure)
   return Variable_Measure;

This function is used to convert Value to the measurement units specified by the parameter Scale. When offsets of Value and Scale are same this is null operation. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

function Get_Value (Value : Variable_Measure) return Variable;

This function returns SI equivalent of its argument. The result is a plain linguistic variable.

function Get_Value_As (Value : Variable_Measure; Scale : Measure)
   return Variable;

This function returns Scale equivalent of Value. The result is a plain linguistic variable. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

This function converts Value to its shifted equivalent. The parameter Shift specifies the required shift of the result.

function Normalize (Value : Variable_Measure) return Variable_Measure;

This function returns an unshifted equivalent of Value.

function Shift (Value : Variable_Measure; Shift : Number'Base)
   return Variable_Measure;

This function converts Value to its shifted equivalent. The parameter Shift specifies the required shift of the result.

function To_Variable_Measure (Value : Number          ) return Variable_Measure;
function To_Variable_Measure (Value : Interval        ) return Variable_Measure;
function To_Variable_Measure (Value : Fuzzy_Float     ) return Variable_Measure;
function
To_Variable_Measure (Value : Variable        ) return Variable_Measure;
function
To_Variable_Measure (Value : Measure         ) return Variable_Measure;
function To_Variable_Measure (Value : Interval_Measure) return Variable_Measure;
function To_Variable_Measure (Value : Fuzzy_Measure   ) return Variable_Measure;

These functions can be used to convert plain and dimensioned numbers, intervals and also fuzzy numbers and linguistic variables to the corresponding dimensioned linguistic variable.

function To_Measure (Value : Variable_Measure) return Measure;
function To_Interval_Measure (Value : Variable_Measure) return Interval_Measure;

These functions perform backward conversions to number and interval. When the conversion is impossible because Value represents a more general set then Constraint_Error is propagated.

6.1.3. String I/O

The generic child package Fuzzy.Linguistics.Edit provides string I/O for linguistic variables:

generic
   with package Float_Edit is
      new Strings_Edit.Float_Edit (Fuzzy_Floats.Number);
package Fuzzy.Linguistics.Edit is ...

The formal generic parameter of the package is an instance of the package Strings_Edit.Float_Edit implementing floating-point string I/O for the numbers used by the parent package.

There is a pre-instantiated version of Fuzzy.Linguistics.Edit for the standard type Float: Fuzzy.Edit.Linguistics.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Variable;
             Base    : NumberBase := 10
          );

This procedure gets a linguistic variable from the string Source. The process starts from Source (Pointer). Pointer is advanced to the string position following the variable.

The syntax of a variable is:

<variable>  ::=  [->] <item> [ {,|->} <variable>] [->]
<item> ::= <value>[{..|...}<value>] [:<level>]

Here <number> has the syntax of a floating-point number as the formal parameter Float_Edit requires. The parameter Base determines its base. <level> is a confidence factor. When missing it is assumed to be Confidence'Last. A variable is specified as a list of items. Items can be joined by either commas or arrows (->). Each item determines a value of the membership function in one domain point or in a range of points. The value is specified by <level>. Numbers of items in the list are specified in ascending order. When items are joined by arrows, the membership function is linear in between. Otherwise, it is 0 in between. Arrows can be given in front of the first item and/or after the last item to specify an extrapolation of the membership function to the left and/or right. Numbers specified in singular points may repeat to specify multiple values of the function. Commas, arrows, colons and ellipsis may be surrounded by spaces and tabs. When trailing they are not matched. Examples:

->0->10:0   The shoulder shape from the table above
-10:0->0..10->15:0   The trapezoid from the table
-10:0,-10,10,10:0   The rectangle from the table
-10..10   Same rectangle
->0:0.75, 0:1, 0:0.25, 0.5-> The pulse variable from the table
Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error or order error
End_Error Nothing matched
Layout_Error Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String;
            Base   : NumberBase := 10
         )  return Variable;

This function is a simplified version of the procedure Get. It converts the string Source. The variable in Source may be surrounded by spaces and tabulations. The whole string shall be matched. Otherwise Data_Error is propagated.

Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error
End_Error Nothing matched

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Variable;
             Base        : NumberBase := 10;
             RelSmall    : Positive   := -MaxSmall;
             AbsSmall    : Positive   := MaxSmall;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places the variable specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The parameters Base, RelSmall, AbsSmall have meaning described in Strings_Edit.Float_Edit. They are used for output of the domain set values. The output has the syntax described in the procedure Get. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then the fill character.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value    : Variable;
            Base     : NumberBase := 10;
            RelSmall : Positive   := -MaxSmall;
            AbsSmall : Positive   := MaxSmall;
         )  return String;

This function converts a linguistic variable (the parameter Value) to string.

6.1.4. Empirical defuzzification methods

Dimensionless variables. The package Fuzzy.Linguistics has the following generic child functions implementing empirical defuzzification methods:

generic
   function
Fuzzy.Linguistics.Center_Of_Area
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the center of area method. The result does not depend on any finite number of singular values (which measure is zero). It is undefined if the support set of the variable is unbounded. It is also undefined if the variable is an empty set, i.e. when the membership function is zero everywhere, except than in a finite number of points. In which case Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Center_Of_Gravity
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the center of gravity method. The result does not depend on any finite number of singular values (which measure is zero). It is undefined if the support set of the variable is unbounded. It is also undefined if the variable is an empty set, i.e. when the membership function is zero everywhere, except than in a finite number of points. In which case Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Discrete_Center_Of_Gravity
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the discrete center of gravity method. The support set of the variable should comprise a finite non-empty set. That is its membership function shall be non-zero in a non-empty finite number of points. The result is otherwise undefined and Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Leftmost_Max
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the leftmost maximum method. The result is undefined if there is no local maximums.  In which case Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Rightmost_Max
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the rightmost maximum method. The result is undefined if there is no local maximums.  In which case Constraint_Error is propagated.

There are pre-instantiated versions of these generic functions for the standard type Float. They are:

Dimensioned variables. The package Fuzzy.Linguistics.Measures provides a generic child function Empirical_Defuzzification for empirical defuzzification of dimensioned linguistic variables:

generic
   with function
Method (A : Variable) return Number is <> 
function
Fuzzy.Linguistics.Measures.Empirical_Defuzzification
         (  A : Variable_Measure
         )  return Measure;

The generic parameter of this function is the corresponding dimensionless defuzzification method, such as:

The result has the dimension and the offset of the parameter A. When the result is undefined Constraint_Error is propagated.

There are pre-instantiated versions of these generic functions for the standard type Float:

[Back][TOC][Next]

6.2. Sets of variables

6.2.1. Plain sets

The child package Fuzzy.Linguistics.Sets provides an implementation of sets of linguistic variables, like {chill, cold, tepid, warm, hot} is in the case of outdoor temperatures. The package is generic because its parent is generic:

generic
package Fuzzy.Linguistics.Sets is ...

There is a pre-instantiated version of Fuzzy.Linguistics.Sets for the standard type Float: Fuzzy_Linguistic_Sets. The package Fuzzy.Linguistics.Sets defines the type Linguistic_Set representing a set of linguistic variables:

type Linguistic_Set is private;

Each variable in a set has an unique name and index. For instance in the set of outdoor temperatures {chill, cold, tepid, warm, hot} the third variable has the name tepid.

The package also defines an enumeration type

type Defuzzification_Result_Class is
     (  Empty,
        Singleton,
        Segment,
        Subset
     );

of possible outcomes of a defuzzification process. That is conversion of a Fuzzy.Intuitionistic.Set to a crisp set of linguistic variables to a set of values from the original domain set. In our example with outdoor temperatures it would be a crisp set of temperatures. The possible outcomes are:

The following type is used to store a result of defuzzification. It is a variant record depending on the actual class of outcome:

type Defuzzification_Result
     (  Class : Defuzzification_Result_Class
     )  is
record
   case (Class) is
      when Empty     => null;
      when Singleton => Singleton : Number;
      when Segment   => Segment   : Interval;
      when Subset    => Subset    : Variable;
   end case;
end record;

The following operations are defined on Linguistic_Set:

function Accumulate
         (  Set          : Linguistic_Set;
            Distribution : Fuzzy.Set
         )  return Variable;

This function returns an accumulated result of a fuzzy subset Set. The parameter Distribution defines the subset of Set. Distribution'Length should be equal to the number of the variables in Set. Otherwise Constraint_Error is propagated.

procedure Add
          (  Set   : in out Linguistic_Set;
             Name  : String;
             Value : Variable
          );

This procedure is used to add a new variable to linguistic set. The parameter Set is the linguistic set. The parameter Name is the name of the variable. The package Name_Tables determines valid names. Constraint_Error is propagated if Name is invalid. Name_Error is propagated if Set contains a variable with the specified name. The parameter Value is the variable to be added.

function Classify
         (  Set   : Linguistic_Set;
            Value : Number
         )  return Classification;
function Classify
         (  Set   : Linguistic_Set;
            Value : Interval
         )  return Classification;
function Classify
         (  Set   : Linguistic_Set;
            Value : Fuzzy_Float
         )  return Classification;
function
Classify
         (  Set   : Linguistic_Set;
            Value : Variable
         )  return Classification;

These functions fuzzify a value. The parameter Value is either a number or an interval or a fuzzy number or a variable. The result is a classification of the value on the set of linguistic variables Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value is in the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty.

function Defuzzify
         (  Set   : Linguistic_Set;
            Value : Classification
         )  return Defuzzification_Result;

The result of the function is defuzzified Value, i.e. a set of numbers which being fuzzified (see Classify) might produce Value. Constraint_Error is propagated when the cardinality of Value differs from one of Set.

procedure Erase (Set : Linguistic_Set);

This procedure removes all variables from Set.

function Equal
         (  Left, Right : Lingustic_Set;
            Eps         : Number'Base := 0.0
        
return Boolean;

This function returns true is Left and Right are equal. Two sets of linguistic variable are equal if:

function Get
         (  Set   : Linguistic_Set;
            Index : Positive
         )  return Variable;

This function returns a variable by its index. The first variable in a set has the index 1. Constraint_Error is propagated if there is no variable with the index specified.

function Get (Set : Linguistic_Set; Name : String)
   return Variable;

This function returns a variable by its name. The names of variables are case-insensitive. End_Error is propagated if there is no variable with the name Name.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Index   : out Positive
          );

This procedure parses the string Source. If a name of a linguistic variable from Set is successfully matched starting from Source (Pointer), then Pointer is advanced to the position following the matched name and Index is set to the variable index. End_Error is propagated if no variable matches the string. Layout_Error is propagated if Pointer is not in the range Source'First..Source'Last + 1.

function Get_Cardinality (Set : Linguistic_Set) return Natural;

This function returns the number of variables in Set.

function Get_Domain (Set : Linguistic_Set)
   return Domain_Description_Ptr;

This function is used get the domain description of the linguistic set. The result is a constant pointer to a Domain_Description object.

function Get_Name (Set : Linguistic_Set; Index : Positive)
   return String;

This function is used to obtain the name of a variable by its index. Though names are case-insensitive, the original case is preserved. Constraint_Error is propagated if there is no variable with the index specified.

function To_Set
         (  Set   : Linguistic_Set;
            Value : Number
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Linguistic_Set;
            Value : Interval
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Linguistic_Set;
            Value : Fuzzy_Float
         )  return Fuzzy.Intuitionistic.Set;
function
To_Set
         (  Set   : Linguistic_Set;
            Value : Variable
         )  return Fuzzy.Intuitionistic.Set;

These functions convert a value into a subset of the linguistic variables. The parameter Value is either a number or an interval or a fuzzy number or a variable. The result is an estimation of the value on the Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value contains the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty.

The package also defines:

type Array_Of_Variables is array (Positive range <>) of Variable;

and instantiates Generic_Unbounded_Array to provide unbounded arrays of variables:

package Unbounded_Arrays is
   new
Generic_Unbounded_Array ...

6.2.2. Dimensioned sets

The child package Fuzzy.Linguistics.Measures.Sets provides an implementation of sets of dimensioned linguistic variables, like {chill, cold, tepid, warm, hot} is in the case of outdoor temperatures with the dimension °C attached to the values. The package is generic:

generic
   with package
Linguistic_Sets is new Fuzzy.Linguistics.Sets;
package
Fuzzy.Linguistics.Measures.Sets is ...

The formal generic parameter Linguistic_Sets is an instance of the package Fuzzy.Linguistics.Sets that provides the type Linguistic_Set (of plain sets of linguistic variables.) There is a pre-instantiated version of Fuzzy.Linguistics.Measures.Sets for the standard type Float: Fuzzy_Linguistic_Set_Measures.

The package Fuzzy.Linguistics.Measures.Sets defines the type Set_Measure representing a set of dimensioned linguistic variables:

type Set_Measure (SI : Unit := Units.Base.Unitless) is record
   Gain   : Linguistic_Set;
   Offset : Number'Base := 0.0;
end record;

The discriminant SI and the field Offset determine the dimension of all variables in the set. The field Gain represents the set of the plain (dimensionless) variables specified in the units determined by SI and Offset.

Analogously to the package Fuzzy.Linguistics.Sets the type Defuzzification_Result is defined to describe a result of defuzzification. It is a variant record depending on the actual class of outcome (the type Defuzzification_Result_Class defined in Fuzzy.Linguistics.Sets):

type Defuzzification_Result
     (  Class : Defuzzification_Result_Class
     )  is
record
   case (Class) is
      when Empty     => null;
      when Singleton => Singleton : Measure;
      when Segment   => Segment   : Interval_Measure;
      when Subset    => Subset    : Variable_Measure;
   end case;
end record;

The following operations are defined on Set_Measure:

function Accumulate
         (  Set          : Set_Measure;
            Distribution : Fuzzy.Set
         )  return Variable_Measure;

This function returns an accumulated result of a fuzzy subset Set. The parameter Distribution defines the subset of Set. Distribution'Length should be equal to the number of the variables in Set. Otherwise Constraint_Error is propagated.

procedure Add
          (  Set   : in out Set_Measure;
             Name  : String;
             Value : Variable_Measure
          );

This procedure is used to add a new variable to linguistic set. The parameter Set is the linguistic set. The parameter Name is the name of the variable. The package Name_Tables determines valid names. Constraint_Error is propagated if Name is invalid. Name_Error is propagated if Set contains a variable with the specified name. The parameter Value is the variable to be added. The dimension of Value should be compatible with the dimension of Set. Otherwise Unit_Error is propagated. Value and Set may have differently shifted units, though. 

function Classify
         (  Set   : Set_Measure;
            Value : Measure
         )  return Classification;
function Classify
         (  Set   : Set_Measure;
            Value : Interval_Measure
         )  return Classification;
function Classify
         (  Set   : Set_Measure;
            Value : Fuzzy_Measure
         )  return Classification;
function
Classify
         (  Set   : Set_Measure;
            Value : Variable_Measure
         )  return Classification;

These functions fuzzify a value. The parameter Value is can be a dimensioned number, interval, fuzzy number, variable. The result is a classification of the value on the set of linguistic variables Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value is in the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty. When Set and Value have different units the membership function of the upper set is always constant 0, i.e. the upper set is empty. The lower set is also empty if all variables in the set are normal.

function Defuzzify
         (  Set   : Set_Measure;
            Value : Classification
         )  return Defuzzification_Result;

The result of the function is defuzzified Value, i.e. a set of numbers which being fuzzified (see Classify) might produce Value. The result has the same dimension as the original set. Constraint_Error is propagated when the cardinality of Value differs from one of Set.

procedure Erase (Set : Set_Measure);

This procedure removes all variables from Set.

function Equal
         (  Left, Right : Set_Measure;
            Eps         : Number'Base := 0.0
        
return Boolean;

This function returns true is Left and Right are equal. Two sets of dimensioned linguistic variable are equal if:

function Get
         (  Set   : Set_Measure;
            Index : Positive
         )  return Variable_Measure;

This function returns a variable by its index. The first variable in a set has the index 1. Constraint_Error is propagated if there is no variable with the index specified.

function Get (Set : Set_Measure; Name : String)
   return Variable_Measure;

This function returns a variable by its name. The names of variables are case-insensitive. End_Error is propagated if there is no variable with the name Name.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Set_Measure;
             Index   : out Positive
          );

This procedure parses the string Source. If a name of a linguistic variable from Set is successfully matched starting from Source (Pointer), then Pointer is advanced to the position following the matched name and Index is set to the variable index. End_Error is propagated if no variable matches the string. Layout_Error is propagated if Pointer is not in the range Source'First..Source'Last + 1.

function Get_Cardinality (Set : Set_Measure) return Natural;

This function returns the number of variables in Set.

function Get_Domain (Set : Set_Measure)
   return Domain_Description_Ptr;

This function is used get the domain description of the linguistic set. The result is a constant pointer to a Domain_Description object.

function Get_Name (Set : Set_Measure; Index : Positive)
   return String;

This function is used to obtain the name of a variable by its index. Though names are case-insensitive, the original case is preserved. Constraint_Error is propagated if there is no variable with the index specified.

function To_Set
         (  Set   : Set_Measure;
            Value : Measure
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Set_Measure;
            Value : Interval_Measure
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Set_Measure;
            Value : Fuzzy_Measure
         )  return Fuzzy.Intuitionistic.Set;
function
To_Set
         (  Set   : Set_Measure;
            Value : Variable_Measure
         )  return Fuzzy.Intuitionistic.Set;

These functions convert a value into a subset of the dimensioned linguistic variables. The parameter Value is a dimensioned number, interval, fuzzy number, variable. The result is an estimation of the value on the Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value contains the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty. When Set and Value have different units the membership function of the upper set is always constant 0, i.e. the upper set is empty. The lower set is also empty if Value is a normal set, which might be untrue when it is a linguistic variable.

6.2.3. String I/O

The generic child package Fuzzy.Linguistics.Sets.Edit provides string I/O for sets of linguistic variables:

generic
   with package Float_Edit is
      new Strings_Edit.Float_Edit (Fuzzy_Floats.Number);
   with package Linguistic_Edit is
      new
Fuzzy.Linguistics.Edit (Float_Edit);
package Fuzzy.Linguistics.Sets.Edit is ...

The formal generic parameters of the package is an instance of the package Strings_Edit.Float_Edit implementing floating-point string I/O for the numbers used by the parent package and an instance of Fuzzy.Linguistics.Edit based on it. There is a pre-instantiated version of Fuzzy.Linguistics.Sets.Edit for the standard type Float named Fuzzy.Edit.Linguistic_Sets.

Input routines for sets:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Base
    : NumberBase := 10
          );

This procedure gets a set of linguistic variables from the string Source. The process starts from Source (Pointer). Pointer is advanced to the string position following the description of a set. The syntax of a set is:

<set>  ::=  <item>[,<set>]
<item> ::= <name>[(<variable>)]

Here <name> is defined as specified by the package Name_Tables. Invalid names treated as syntax errors. <variable> has the same syntax as described in Fuzzy.Linguistics.Edit for the procedure Get. The parameter Base determines the base of the joining points. Commas and brackets can be surrounded by spaces and tabs. The set of outdoor temperatures could be specified as:

chill (->-10->-4:0),
cold  (->11->17:0),
tepid (3:0->8..21->28:0),
warm  (15:0->21->29->35:0),
hot   (25:0->28->)

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error Pointer is not in the range Source'First..Source'Last+1 
Name_Error A duplicated name

function Value
         
(  Source : String;
            Base   : NumberBase := 10
        
)  return Linguistic_Set;

This function is used to convert string Source to a set of linguistic variables. The description of a set in Source may be surrounded by spaces and tabulations. The whole string shall be matched. Otherwise Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Name_Error A duplicated name

Output routines for sets:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Linguistic_Set;
             Base        : NumberBase := 10;
             RelSmall    : Positive   := -MaxSmall;
             AbsSmall    : Positive   := MaxSmall;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places a description of a linguistic set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The output has the syntax compatible with the input procedure. The parameters Base, RelSmall, AbsSmall have meaning described in Strings_Edit.Float_Edit. They are used for output of the domain set values. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then the fill character. Layout_Error is propagated if Pointer is not in the range Destination'Range or there is no room for the output.

function Image
         (  Value    : Linguistic_Set;
            Base     : NumberBase := 10;
            RelSmall : Positive   := -MaxSmall;
            AbsSmall : Positive   := MaxSmall
         )  return String;

This function converts a linguistic set (the parameter Value) to string.

Input routines for classifications and subsets:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Value   : Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Uncertain;
             Base    : NumberBase    := 10
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Value   : Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Uncertain;
             Base    : NumberBase    := 10
          );

These procedure get either a proper subset of Set (a set of linguistic variables) or a classification on Set from the string Source. The process starts from Source (Pointer). Pointer is advanced to the string position following the input. Input can be specified:

tepid..warm:1:0.2, hot

16..18

The mentioned variants cannot be mixed, so input has to be specified in either variant. The parameter Default specifies the defaults for the confidence levels in case of an input in terms of the variables. The parameter Base specified the base of the numeric values in case of an input in terms of the numeric domain.

Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error or order error
End_Error Nothing matched
Layout_Error Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source  : String;
            Set     : Linguistic_Set;
            Default : Fuzzy_Boolean := Uncertain;
            Base    : NumberBase    := 10
         )  return Fuzzy.Intuitionistic.Set;
function
Value
         (  Source  : String;
            Set     : Linguistic_Set;
            Default : Fuzzy_Boolean := Uncertain;
            Base    : NumberBase    := 10
         )  return Fuzzy.Intuitionistic.Classification;

These functions convert the string Source. A value in Source may be surrounded by spaces and tabulations. The whole string shall be matched. Otherwise Data_Error is propagated.

Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error
End_Error Nothing matched

Output routines for classifications and subsets:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Set         : Linguistic_Set;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Uncertain;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Set         : Linguistic_Set;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Uncertain;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

These procedures place either a proper subset of or a classification on Set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The output has the syntax compatible with in the input routines. Note that Value is always output in terms of the names from Set. The parameter Default determines how to omit confidence factors for the possibilities and necessities. For an output in terms of the original numeric domain, one can use Fuzzy.Linguistics.Edit.Put on a result of Accumulate. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then
the fill character.

Exceptions
Constraint_Error Different cardinalities of Set and Value
Layout_Error The value of Pointer is not in the range Destination'Range or there is no room for the output

function Image
         (  Set     : Linguistic_Set;
            Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Uncertain
         )  return String;
function
Image
         (  Set     : Linguistic_Set;
            Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Uncertain
         )  return String;

These functions convert the parameter Value to string.

Exceptions
Constraint_Error Different cardinalities of Set and Value

[Back][TOC][Next]

7. Packages and other compilation units

[Back][TOC][Next]

7.1. Basic source compilation units

Package / Subroutive Provides
Confidence_Factors The type Confidence and operations on it
       Edit I/O operations for Confidence
Fuzzy The type Set and operations on it
  Abstract_Edit I/O operations for fuzzy sets over an abstract domain
       Named The type Domain_Description and operations on it (named domain sets)
Intuitionistic I/O operations for fuzzy Intuitionistic over an abstract domain
Basic_Edit Basic I/O subroutines for set I/O
Edit I/O operations for fuzzy sets with numeric indices
  Floats An instantiation of Fuzzy.Floats with Float
Integers An instantiation of  Fuzzy.Integers with Integer
Intuitionistic I/O operations for fuzzy Intuitionistic with numeric indices
Linguistic_Sets An instantiation of Fuzzy.Linguistics.Sets.Edit based on Float
Linguistics An instantiation of Fuzzy.Linguistics.Edit based on Float
Floats Generic fuzzy floating-point numbers, the type Fuzzy_Float
  Edit Generic I/O operations for Fuzzy_Float
Generic_Edit Generic I/O operations for fuzzy sets
  Intuitionistic Generic I/O operations for fuzzy intuitionistic sets
Integers Generic fuzzy integers numbers, the type Fuzzy_Integer
  Edit Generic I/O operations for Fuzzy_Integer
Linguistics Generic linguistic variables
      Center_of_Area Generic function implementing center of area defuzzification method
Center_of_Gravity Generic function implementing center of gravity defuzzification method
Discrete_Center_of_Gravity Generic function implementing discrete_center of gravity defuzzification method
Edit Generic I/O operations for linguistic variables
Leftmost_Max Generic function implementing leftmost maximum defuzzification method
Measures Generic dimensioned linguistic variables
       Empirical_Defuzzification Generic function which instances provide defuzzification methods for dimensioned variables
Sets Generic sets of dimensioned linguistic variables, the type Set_Measure
Rightmost_Max Generic function implementing rightmost maximum defuzzification method
Sets Generic sets of linguistic variables, the type Linguistic_Set
  Edit Generic I/O operations for sets of linguistic variables and their intuitionistic sets
Logic Fuzzy logic, the type Fuzzy_Boolean
Measures Generic dimensioned fuzzy numbers, the type Fuzzy_Measure
Numbers Generic fuzzy numbers, the type Fuzzy_Number
  Edit Generic I/O operations for fuzzy numbers
Intuitionistic The type Fuzzy.Intuitionistic.Set (an intuitionistic fuzzy set)
  Basic_Edit Basic I/O subroutines for Intuitionistic I/O

[Back][TOC][Next]

7.2. Instances of generic compilation units

Package / Subroutive Provides
Fuzzy_Floats An instantiation of Fuzzy.Floats with Float
Fuzzy_Integers An instantiation of  Fuzzy.Integers with Integer
Fuzzy_Linguistic_Center_Of_Area An instance of Fuzzy.Linguistics.Center_of_Area for Float
Fuzzy_Linguistic_Center_Of_Gravity An instance of Fuzzy.Linguistics.Center_of_Gravity for Float
Fuzzy_Linguistic_Discrete_Center_Of_Gravity An instance of Fuzzy.Linguistics.Discrete_Center_of_Gravity for Float
Fuzzy_Linguistic_Leftmost_Max An instance of Fuzzy.Linguistics.Leftmost_Max for Float
Fuzzy_Linguistic_Measures An instantiation of Fuzzy.Linguistics.Measures with Float
Fuzzy_Linguistic_Measure_Center_Of_Area An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Center_Of_Area
Fuzzy_Linguistic_Measure_Center_Of_Gravity An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Center_Of_Gravity
Fuzzy_Linguistic_Measure_Discrete_Center_Of_Gravity An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Discrete_Center_Of_Gravity
Fuzzy_Linguistic_Measure_Leftmost_Max An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Leftmost_Max
Fuzzy_Linguistic_Measure_Rightmost_Max An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Rightmost_Max
Fuzzy_Linguistic_Rightmost_Max An instance of Fuzzy.Linguistics.Rightmost_Max for Float
Fuzzy_Linguisitc_Set_Measures An instantiation of Fuzzy.Linguistics.Measures.Sets with Float
Fuzzy_Linguistic_Sets An instantiation of Fuzzy.Linguistics.Sets with Float
Fuzzy_Linguistics An instantiation of Fuzzy.Linguistics with Float
Fuzzy_Measures An instantiation of Fuzzy.Measures with Float
Name_Tables Names and tables of the domain values and linguistic variables

[Back][TOC][Next]

7.3. Related  packages

The following packages are described in the separate documents:


[Back][TOC][Next]

8. Changes log

Changes to the version 4.0:

Changes to the version 3.9:

Changes to the version 3.8:

Changes to the version 3.7:

Changes to the version 3.6:

Changes to the version 3.5:

Changes to the version 3.4:

Changes to the version 3.3:

Changes to the version 3.2:

Changes to the version 3.1:

Changes to the version 3.0:

Changes to the version 2.0:

The following changes were made since the version 1.0:


[Back][TOC]

9. Table of Contents

1. Truth values
    1.1. String I/O of truth values
2. Fuzzy sets
    2.1. Tests
    2.2. Operations producing a new set
    2.3. Possibility theory
    2.4. Distance to point
    2.5. String I/O with numeric indices
    2.6. Generic string I/O
    2.7. Abstract string I/O
    2.8. String I/O with named indices
    2.9. Basic string I/O
3. Fuzzy logic
4. Fuzzy numbers
    4.1. Plain fuzzy numbers
        4.1.1. Interval mapping
        4.1.2. Arithmetic operations
        4.1.3. Possibility theory
        4.1.4. Membership and inclusion relations
        4.1.5. Equality and equivalence
        4.1.6. Relational operations
        4.1.7. Conversions
    4.2. Dimensioned fuzzy numbers
        4.2.1. Arithmetic operations
        4.2.2. Possibility theory
        4.2.3. Inclusion and other relational operations
        4.2.4. Conversions
    4.3. Floating-point I/O
        4.3.1. Integer I/O
        4.3.2. Floating-point I/O
5. Intuitionistic fuzzy sets
    5.1. Type and operations
    5.2. String I/O with numeric indices
    5.3. Generic string I/O
    5.4. Abstract string I/O
    5.5. String I/O with named indices
    5.6. Basic string I/O
6. Linguistic variables
    6.1. Variables
        6.1.1. Plain variables
        6.1.2. Dimensioned variables
        6.1.3. String I/O
        6.1.4. Empirical defuzzification methods
    6.2. Sets of variables
        6.2.1. Plain sets
        6.2.2. Dimensioned sets
        6.2.3. String I/O
7. Packages and other compilation units
    7.1. Basic source compilation units
    7.2. Instances of generic compilation units
    7.3. Related packages
8. Changes log
9. Table of contents