Orbital library

orbital.moon.logic
Class FuzzyLogic

java.lang.Object
  extended by orbital.moon.logic.FuzzyLogic
All Implemented Interfaces:
Logic, ExpressionBuilder, ExpressionSyntax

public class FuzzyLogic
extends java.lang.Object
implements Logic

Implementation of quantitative fuzzy logics.

Fuzzy logic is a numeric approach in which truth-values represent a degree of truth specified as a real number in the range [0,1]. (Unlike probabilities in the range [0,1] which specify a degree of belief.)

⋏:[0,1]2→[0,1] is a fuzzy AND operator, or triangular norm, iff
(n) a ⋏ 1 = a "neutral"
(c) a ⋏ b = b ⋏ a "commutative"
(mon) a1≤a2 and b1≤b2 implies a1 ⋏ b1 ≤ a2 ⋏ b2 "monotonic"
(a) a ⋏ (b ⋏ c) = (a ⋏ b) ⋏ c "associative"
(idem) a ⋏ a = a "idempotent" (optional)
(C) ⋏ is continuous "continuous" (optional)
() a ⋏ 0 = 0 (⇐ (n),(c),(mon))
() 0 ⋏ 0 = 0
1 ⋏ 0 = 0
0 ⋏ 1 = 0
1 ⋏ 1 = 1
"∧ boundary conditions" (⇐ (n),(c),(mon))
The only function that fulfills all axioms including the optional ones is a⋏b = max(a,b) [Klir, Folger 1988].

⋎:[0,1]2→[0,1] is a fuzzy OR operator or co-t-norm, iff
(n) a ⋎ 0 = a "neutral"
(c) a ⋎ b = b ⋎ a "commutative"
(mon) a1≤a2 and b1≤b2 implies a1 ⋎ b1 ≤ a2 ⋎ b2 "monotonic"
(a) a ⋎ (b ⋎ c) = (a ⋎ b) ⋎ c "associative"
(idem) a ⋎ a = a "idempotent" (optional)
(C) ⋎ is continuous "continuous" (optional)
() a ⋏ 1 = 1 (⇐ (n),(c),(mon))
() 0 ⋎ 0 = 0
1 ⋎ 0 = 1
0 ⋎ 1 = 1
1 ⋎ 1 = 1
"∨ boundary conditions" (⇐ (n),(c),(mon))
The only function that fulfills all axioms including the optional ones is a⋎b = min(a,b) [Klir, Folger 1988].
~ is a fuzzy NOT operator, iff
(1) ~1 = 0
~0 =1
"¬ boundary conditions"
(mon) a<b implies ~a ≥ ~b "monotonic"
(inv) ~ ~ a = a "involutive" (optional)
(C) ~ is continuous "continuous" (optional)

Derived operators are the fuzzy implication and bisubjunction.

a→b := sup{c ¦ a⋏c≤b}
a↔b := (a→b)⋏(b→a)

Gödel and drastic operator sets bound all operator sets. For any operators (⋏,⋎) it is

max{a,b}≤a⋎b≤u*(a,b) ≤ i*(a,b)≤a⋏b≤min{a,b}

Let X be a universal set.
fuzzy set
A = {(x,μA(x)) ¦ x∈X} is defined with a membership function μA:X→[0,1]. A finite fuzzy set A of domain {a1,…,an} is sometimes denoted formally as
"A=μA(a1)/a1 + μA(a2)/a2 + ... + μA(an)/an"
where + and / are purely syntactic symbols and do not denote arithmetic operations. Then fuzzy sets and fuzzy logic are related by
μA∪B = μA ⋎ μB
μA∩B = μA ⋏ μB
μA = ~ μA
cardinality
|A| = ∑x∈X μA(x)
entropy
E(A) = |A∩A| / |A∪A|

Also note that for fuzzy sets, idem potence and distributive on the one hand, and tertium non datur on the other hand, are mutually exclusive properties for all operators.

Author:
André Platzer
See Also:
"Klir, G. and Folger, T. (1988), Fuzzy Sets, Uncertainty and Information, Prentice-Hall, Englewood Cliffs.", "Gottwald, Siegfried. A Treatise On Many-Valued Logics, volume 9 of Studies in Logic and Computation. Research Studies Press, Baldock, Hertfordshire, England, 2001.", "Hájek, Petr. Metamathematics of Fuzzy Logic, volume 4 of Trends in Logic - Studia Logica Library. Kluwer Academic Publishers, 1998."

Nested Class Summary
static class FuzzyLogic.OperatorSet
          Specifies the type of fuzzy logic to use.
 
Field Summary
static FuzzyLogic.OperatorSet BOUNDED
          Bounded or Ɨukasiewicz operators in fuzzy logic.
static FuzzyLogic.OperatorSet DRASTIC
          Drastic operators in fuzzy logic.
static FuzzyLogic.OperatorSet GOEDEL
          Gödel and Zadeh operators in fuzzy logic (default).
static FuzzyLogic.OperatorSet PRODUCT
          Product operators in fuzzy logic.
static java.lang.String usage
           
 
Constructor Summary
FuzzyLogic()
           
FuzzyLogic(FuzzyLogic.OperatorSet fuzzyLogicOperators)
          Create a new fuzzy logic implementation with a specific operator set.
 
Method Summary
 Expression.Composite compose(Expression compositor, Expression[] arguments)
          Create a compound expression representation with a composition operation.
 Formula.Composite composeDelayed(Formula f, Expression[] arguments, Notation notation)
          Delayed composition of a symbol with some arguments.
 Formula.Composite composeFixed(Symbol fsymbol, Functor f, Expression[] arguments)
          Instant composition of functors with a fixed core interperation Usually for predicates etc.
 Interpretation coreInterpretation()
          Get the core interpretation which is fixed for this logic.
 Signature coreSignature()
          Get the core signature which is supported by the language of this expression syntax.
 Expression[] createAllExpressions(java.lang.String expressions)
          Create a sequence of (compound) expressions by parsing a list of expressions.
 Expression createAtomic(Symbol symbol)
          Create an atomic expression representation of a non-compound sign.
 Expression createExpression(java.lang.String expression)
          Create a term representation by parsing a (compound) expression.

In fact, parsing expressions is only possible with a concrete syntax. So implementations of this method are encouraged to define and parse a standard notation which can often be close to the default notation of the abstract syntax.

.
 Formula createFixedSymbol(Symbol symbol, java.lang.Object referent, boolean core)
          Construct (a formula view of) an atomic symbol with a fixed interpretation.
 Formula createSymbol(Symbol symbol)
          Construct (a formula view of) an atomic symbol.
static FuzzyLogic.OperatorSet HAMACHER(double gamma)
          Hamacher operators in fuzzy logic.
 boolean infer(java.lang.String expression, java.lang.String exprDerived)
          facade for convenience.
 Inference inference()
          Get the inference relation |~K according to the implementation calculus K.
static void main(java.lang.String[] arg)
          tool-main
protected static boolean proveAll(java.io.Reader rd, orbital.moon.logic.ModernLogic logic, boolean all_true)
          Prove all conjectures read from a reader.
 boolean satisfy(Interpretation I, Formula F)
          Defines the semantic satisfaction relation ⊧.
 Signature scanSignature(java.lang.String expression)
          Scan for the signature Σ of all syntactic symbols in an expression.
 java.lang.String toString()
           
protected  void validateAtomic(Symbol symbol)
          This method validates that a symbol obeys the syntactical conventions imposed by this logic (if any).
static FuzzyLogic.OperatorSet YAGER(double p)
          Yager operators in fuzzy logic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface orbital.logic.imp.Logic
compose, createAtomic, createExpression
 
Methods inherited from interface orbital.logic.sign.ExpressionSyntax
scanSignature
 

Field Detail

usage

public static final java.lang.String usage
See Also:
Constant Field Values

GOEDEL

public static FuzzyLogic.OperatorSet GOEDEL
Gödel and Zadeh operators in fuzzy logic (default).
a ⋏ b = min{a,b}
a ⋎ b = max{a,b}
a → b = b if a>b, resp. =1 if a≤b
Gödel operators are the "outer" bound of fuzzy logic operators, i.e. min is the greatest fuzzy AND operator, and max the smallest fuzzy OR operator.

principle of minimum specificity
⇒ in the absence of further knowledge, choose Gödel operators.


PRODUCT

public static FuzzyLogic.OperatorSet PRODUCT
Product operators in fuzzy logic.
a ⋏ b = a⋅b
a ⋎ b = a+b - a⋅b
a → b = min{b/a,1}, resp. =1 for a=0


BOUNDED

public static FuzzyLogic.OperatorSet BOUNDED
Bounded or Ɨukasiewicz operators in fuzzy logic. Which come from the implication ⇒ in the Ɨukasiewicz-logic, by a⇒b ≡ ¬(a⋏¬b), as well as a⋎b ≡ ¬a⇒b.
a ⋏ b = max{0,a+b-1}
a ⋎ b = min{1,a+b}
a → b = a ⇒ b = min{1,b-a+1}


DRASTIC

public static FuzzyLogic.OperatorSet DRASTIC
Drastic operators in fuzzy logic.
a ⋏ b = i*(a,b) := min{a,b} if max{a,b}=1, else 0
a ⋎ b = u*(a,b) := max{a,b} if min{a,b}=0, else 1
a → b = b if b<a=1, else 1
Drastic operators are the "inner" bound of fuzzy logic operators, i.e. i* is the smallest fuzzy AND operator, and u* the greatest fuzzy OR operator.

Attributes:
discontinuous
Constructor Detail

FuzzyLogic

public FuzzyLogic()

FuzzyLogic

public FuzzyLogic(FuzzyLogic.OperatorSet fuzzyLogicOperators)
Create a new fuzzy logic implementation with a specific operator set.

Parameters:
fuzzyLogicOperators - the set of fuzzy logic operators to use.
See Also:
GOEDEL, BOUNDED, PRODUCT, DRASTIC, HAMACHER(double), YAGER(double)
Method Detail

main

public static void main(java.lang.String[] arg)
                 throws java.lang.Exception
tool-main

Throws:
java.lang.Exception

toString

public java.lang.String toString()

infer

public boolean infer(java.lang.String expression,
                     java.lang.String exprDerived)
              throws ParseException
facade for convenience.

Parameters:
expression - the comma separated list of premise expressions to parse.
Returns:
whether w |~K d.
Throws:
ParseException
See Also:
Facade

satisfy

public boolean satisfy(Interpretation I,
                       Formula F)
Description copied from interface: Logic
Defines the semantic satisfaction relation ⊧.
I ⊧ F, which is usually iff I(F) = true
In other words, returns whether I is a satisfying Σ-Model of F.

For multi-valued logics, the above definition of a semantic satisfaction relation would experience a small generalization

I ⊧ F, iff I(F) ∈ D
for a fixed set D of designated truth-values.

Unlike the implementation method Formula.apply(Object), this surface method must automatically consider the core interpretation of this logic for symbol interpretations (and possible redefinitions) as well.

Specified by:
satisfy in interface Logic
Parameters:
I - the interpretation within which to evaluate F.
F - the formula to check whether it is satisfied in I.
Returns:
whether I ⊧ F, i.e. whether I satisfies F.
See Also:
Logic.coreInterpretation()

inference

public Inference inference()
Description copied from interface: Logic
Get the inference relation |~K according to the implementation calculus K.

Specified by:
inference in interface Logic
Returns:
the inference relation |~K of logical inference.

coreSignature

public Signature coreSignature()
Description copied from interface: ExpressionSyntax
Get the core signature which is supported by the language of this expression syntax.

The core "signature" contains the logical signs that inherently belong to this term algebra and are not subject to interpretation. Logical signs are logical constants like true, false, and logical operators like ¬, ∧, ∨, →, ∀, ∃. The latter are also called logical junctors.

Note that some authors do not count the core "signature" as part of the proper signature Σ but would rather call it "meta"-signature.

Specified by:
coreSignature in interface ExpressionSyntax
Returns:
the core signature that is valid for every expression following this syntax. Elements in the core signature all have a fixed interpretation.
See Also:
Logic.coreInterpretation()

coreInterpretation

public Interpretation coreInterpretation()
Description copied from interface: Logic
Get the core interpretation which is fixed for this logic.

This will usually contain the interpretation functors of logical operators like ¬, ∧, ∨, →, ⇔, ∀ and ∃.

Specified by:
coreInterpretation in interface Logic
Returns:
the core interpretation that is valid for every expression, for fixed interpretation semantics. Elements in the core signature all have a fixed interpretation.
See Also:
ExpressionSyntax.coreSignature()

HAMACHER

public static FuzzyLogic.OperatorSet HAMACHER(double gamma)
Hamacher operators in fuzzy logic.
a ⋏ b = a⋅b / (γ+(1-γ)(a+b-a⋅b))
a ⋎ b = (a+b-(2-γ)a⋅b) / (1-(1-γ)a⋅b)

Parameters:
gamma - the parameter γ.
Preconditions:
gamma≥0

YAGER

public static FuzzyLogic.OperatorSet YAGER(double p)
Yager operators in fuzzy logic.
a ⋏ b = 1 - min{1,((1-a)p+(1-b)p))1/p}
a ⋎ b = min{1,(ap+bp))1/p}
For p→∞ these operators approximate those of GOEDEL.

Preconditions:
p>0

proveAll

protected static final boolean proveAll(java.io.Reader rd,
                                        orbital.moon.logic.ModernLogic logic,
                                        boolean all_true)
                                 throws ParseException,
                                        java.io.IOException
Prove all conjectures read from a reader. The conjectures have the following forms
 <premise> (, <premise>)* |= <conclusion>    # <comment> <EOL>
 <formula> == <formula>    # <comment> <EOL>
 ...
 

Parameters:
rd - the source for the conjectures to prove.
logic - the logic to use.
all_true - If true this method will return whether all conjectures in rd could be proven. If false this method will return whether some conjectures in rd could be proven.
Returns:
a value depending upon all_true.
Throws:
ParseException
java.io.IOException
See Also:
LogicParser.readTRS(Reader,ExpressionSyntax,Function)

createAtomic

public Expression createAtomic(Symbol symbol)
Description copied from interface: Logic
Create an atomic expression representation of a non-compound sign.

Atomic symbols are either elemental atoms, strings or numbers. In contrast, a logical formula that is not compound of something (on the level of logical junctors) like "P(x,y)" is sometimes called atom.

Note
A compound expression like "P(x)" will not be atomic symbols (although a logic might consider such single predicate applications as atomic in the sense of atomicity on the level of logical junctors). However, the variable "x", and the predicate symbol "P" are atomic symbols.

Specified by:
createAtomic in interface Logic
Specified by:
createAtomic in interface ExpressionBuilder
Parameters:
symbol - the symbol whose atomic expression representation to create.
Returns:
an instance of Expression that represents the atomic symbol in this logic.
See Also:
Factory Method

compose

public Expression.Composite compose(Expression compositor,
                                    Expression[] arguments)
                             throws ParseException,
                                    TypeException
Description copied from interface: Logic
Create a compound expression representation with a composition operation. Connects expressions with a compositor to form a complex expression.

Signature.get(String,Object[]) may be useful for determining the right functor symbol for a composition in case of an atomic compositor.

Be aware that this method does a composition (in the sense of semiotics) of signs/expressions, but not usually a composition (in the sense of mathematics) of functions. Mathematically speaking, the composition that this method performs would usually be called application instead of composition. Although composition (in the sense of mathematics) and application are correlated, they have different types at first sight

:(σ→τ)×(τ'→σ') → (τ→τ'); (g,f) ↦ g∘f = (x↦g(f(x))), provided that σ'σ
_(_):(σ→τ)×σ' → τ; (f,x) ↦ f(x) provided that σ'σ
Yet together with λ-abstraction, composition can be expressed in terms of application (as the definition above shows). And in conjunction with the (selective) identification of type void→σ' with σ' application can also be expressed per composition.

Specified by:
compose in interface Logic
Specified by:
compose in interface ExpressionBuilder
Parameters:
compositor - the expression that is used for composing the arguments.
arguments - the arguments a passed to the combining operation.
Returns:
an expression that represents the combined operation with its arguments, like in
compositor(a[0],…,a[a.length-1])
Throws:
ParseException - if the composition expression is syntactically malformed. Either due to a lexical or grammatical error (also due to wrong type of arguments).
TypeException - if the arguments have the wrong type for composition, i.e. compositor.getType().on(typeOf(arg)) raises a TypeException. Note that type errors are still a kind of syntactic errors, but should be separated from pure parse exceptions in order to simplify distinction for exception handlers.
See Also:
Factory Method

createSymbol

public Formula createSymbol(Symbol symbol)
Construct (a formula view of) an atomic symbol.

Parameters:
symbol - the symbol for which to create a formula representation
See Also:
ExpressionBuilder.createAtomic(Symbol)

createFixedSymbol

public Formula createFixedSymbol(Symbol symbol,
                                 java.lang.Object referent,
                                 boolean core)
Construct (a formula view of) an atomic symbol with a fixed interpretation.

Parameters:
symbol - the symbol for which to create a formula representation
referent - the fixed interpretation of this symbol
core - whether symbol is in the core such that it does not belong to the proper signature.
See Also:
ExpressionBuilder.createAtomic(Symbol)

composeDelayed

public Formula.Composite composeDelayed(Formula f,
                                        Expression[] arguments,
                                        Notation notation)
Delayed composition of a symbol with some arguments. Usually for user-defined predicates etc. or predicates subject to interpretation.

Parameters:
f - the compositing formula.
arguments - the arguments to the composition by f.
notation - the notation for the composition (usually determined by the composing symbol).

composeFixed

public Formula.Composite composeFixed(Symbol fsymbol,
                                      Functor f,
                                      Expression[] arguments)
Instant composition of functors with a fixed core interperation Usually for predicates etc. subject to fixed core interpretation..

Parameters:
f - the compositing formula.
arguments - the arguments to the composition by f.
fsymbol - the symbol with with the fixed interpretation f.

createExpression

public Expression createExpression(java.lang.String expression)
                            throws ParseException
Create a term representation by parsing a (compound) expression.

In fact, parsing expressions is only possible with a concrete syntax. So implementations of this method are encouraged to define and parse a standard notation which can often be close to the default notation of the abstract syntax.

. Parses single formulas or sequences of formulas delimited by comma and enclosed in curly brackets. Sequences of expressions are represented by a special compound expression encapsulating the array of expressions as its component.

Specified by:
createExpression in interface Logic
Specified by:
createExpression in interface ExpressionSyntax
Parameters:
expression - the compound expression to parse. A string of "" denotes the empty expression. However note that the empty expression may not be accepted in some term algebras. Those parsers rejecting the empty expression are then inclined to throw a ParseException, instead.
Returns:
an instance of Expression that represents the given expression string in this language.
Throws:
ParseException - when the expression is syntactically malformed. Either due to a lexical or grammatical error.
See Also:
Factory Method

scanSignature

public Signature scanSignature(java.lang.String expression)
                        throws ParseException
Description copied from interface: ExpressionSyntax
Scan for the signature Σ of all syntactic symbols in an expression.

However, note that this method does not necessarily perform rich type querying. Especially for user-defined functions with an arbitrary argument-type structure, it is generally recommended to construct the relevant signature entries explicitly.

Specified by:
scanSignature in interface ExpressionSyntax
Parameters:
expression - the expression that should be scanned for symbol names.
Returns:
Signature of the syntactic symbols in expression except those of the core signature.
Throws:
ParseException - (optional) when the expression is syntactically malformed. Either due to a lexical or grammatical error. (optional behaviour for performance reasons). Will not throw ParseExceptions if createExpression would not either.
See Also:
ExpressionSyntax.coreSignature(), "Factory Method"

createAllExpressions

public Expression[] createAllExpressions(java.lang.String expressions)
                                  throws ParseException
Create a sequence of (compound) expressions by parsing a list of expressions. This method is like createExpression(String), but restricted to lists of expressions.

For example, in the context of conjectures when given

 {A&B, A&~C}
 
an implementation could parse it as two formulas A&B and A&~C.

Parameters:
expressions - the comma separated list of expressions to parse.
Throws:
java.lang.UnsupportedOperationException - if no syntax notation for sequences of formulas has been defined.
ParseException
See Also:
Convenience Method, createExpression(String)
Postconditions:
RES instanceof Formula[] covariant return-type
Note:
This method is superfluous since its sole function is to unwrap the result of createExpression(String) for sequences of expressions. So you are advised to stick to the interface method createExpression(String) to minimize implementation dependencies of your code.

validateAtomic

protected void validateAtomic(Symbol symbol)
                       throws java.lang.IllegalArgumentException
This method validates that a symbol obeys the syntactical conventions imposed by this logic (if any).

Throws:
java.lang.IllegalArgumentException - if signifier is not an identifier.

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.