FnOio / fno-specification

Repository for https://w3id.org/function/spec
6 stars 1 forks source link

Cardinality of functions #7

Open bblfish opened 2 years ago

bblfish commented 2 years ago

In §4.1 I read

No cardinalities are defined in the Function Ontology, as there are no hard limits on cardinality to be defined. A function can implement multiple algorithms, solve multiple problems, and have multiple executions. All executions can have multiple input parameters and output values. Vice versa, input parameters and output values can be linked to multiple executions, and an execution (i.e., a set of input values and output values) can be linked to multiple functions.

I think all these are non-controversial, except that a function can have multiple results. So I think this decision needs to be argued for carefully.

Here is the counterargument that would need to be answered: In mathematics (such as category theory) a function is a relation that covers the whole of a domain and has exactly one value for each element of the domain, each of those values being located in the range. We find this in owl, where an owl:FunctionalProperty is a relation for any object on which it is defined, has exactly one value.

In Category Theory we have the following two categories which are related by 3)

  1. For functions we have the category of Sets and functions between them
  2. For relations we have the category of Sets and relations between them (see @epatters excellent paper Knowledge Representation in Bicategories of Relations)
  3. The Kleisli category of the Powerset monad on the category of Sets is the Bicategory of Relations see Example 5.1.17 page 142 in @paoloperrone's 2019 Notes on Category Theory. I.E. functions from A to the powerset of B form relations and can be composed.

So there are some interesting questions:

bblfish commented 2 years ago

Assuming one found a way of adding a pure definition of a function to the Function Ontology. How would one model Java? The key article to read there is Bart Jacobs's classic 2003 Coalgebras and monads in the semantics of Java - and his earlier articles on OO and colagebras from the 1990s.

The semantis of a statement

public B foo(A x)

is written mathematically as

S × A → Hang + Normal + Abrupt

ie a function that takes a pair of a state and an argument A and returns either a result that specifies the Hanging of the VM or a Normal return value (e.g. B ) or an Abrupt termination given by an exception. Both the exception and the Normal termination return a new state of the VM expressed as

S × A → 1 + (S × B) + (S × E)

a function takes a state and an argument and returns either a singleton (unit) or a new state and the result or a new state and the Exception. Bart Jacobs then shows how one can transform that into a monad view and also into a coalgebraic view. The coalgebraic view is the OO perspective: objects with methods that transform its state.