Difference between revisions of "Function"
imported>Admin m (1 revision imported) |
|||
(50 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
Functions are | Functions are a mathematical representation of [[directed relation]]s between the [[domain]] and [[codomain]]. It can be represented as a [[key-value pairs]], or in the [[lambda calculus]]<ref>{{:Book/Structure and Interpretation of Computer Programs}}</ref> form. | ||
=Tag Line= | |||
[[Data]] with [[continuation]] together makes [[function]]. | |||
Function can be used as a generic building block to represent information in general. It can be thought of as a primitive kind of data structure. This argument can be substantiated by thinking of [[Lambda calculus]] as a generalized way of encoding functions in an explicit structured [[data]] format. | |||
==A Critical Observation== | |||
In most cases, people think of MediaWiki as a generic note taking or a dictionary of relevant pieces of static information. However, knowing the capabilities of modern browsers, HTML 5, JavaScript, and the server side PHP + Lua (Scribuntu) extension of MediaWiki, not to mention Semantic MediaWiki and its MySQL/MariaDB data storage/retrieval capabilities, the overall functions of MediaWiki must not be just seen as a passive data browsing tool, but a full blown programming and data creating environment. In programmer's term, MediaWiki can be configured to be a full blown Integrated Development Environment, for any subject matter. This is what [[PKC]] strives to become, it tries to raise users' awareness of data elements as functions, so that all data are also functions in a [[hyperlinked]] context. In other words, hyplerink is a kind of data-oriented function, that allows users to incrementally construct small and large functions at many locations and across many time scales. On the Internet, everyone is constructing some piece of a bigger function that they may never be directly conscientiously aware, but never-the-less, all users, all computers are incrementally constructing functions of many kinds through accumulating data elements, all in the [[hyperlinked]] fashion as articulated by [[Ted Nelson]]. | |||
===Scale-Free, Time-like Structures, and Ordered Namespace of Functions=== | |||
Function as a data structure is not only [[Universal abstraction|universal]], but it can also be designed to be [[Scale-free]], meanningly that the formal properties of a specific '''Function''', don't have to be bounded to a specific [[spacetime physical scale]]. However, in the space of all functions, the containment relationship in terms of what functions are classified into what sub-class(es) of functions can be studied in terms of [[Category Theory]], and more specifically, in the field of [[Lattice Theory]] or just think of them in terms of [[Partially ordered set]]s. Thinking of named functions in terms of [[lattice]] or [[Partially ordered set]], a.k.a. [[Poset]]s, is an important mental model for both software engineering, and in everyday life. Thinking of functions as elements in [[Poset]]s will give them a consistent abstraction in an [[ordered]] or [[time-like]] structure, so that it will build a generically applicable mental model for [[causal relation]]s and in terms of an [[ordered namespace]]. | |||
===Function as Causal Relation=== | |||
Function can be represented as a [[key-value pair]] of [[inputs]] and [[outputs]], which defines a way to represent [[causal relation]]s. | |||
{{:PKC/Design Principle}} | |||
==Implementation== | |||
Computationally, functions can almost always be thought of as a dictionary, or a [[lookup table]]/[[hashtable]] that relates a value of an input, to a value as the output of a function. This simplification is useful in the sense that all functions can be conceptualized as dictionaries/lookup tables, so that all functions can be treated as one type, which is a way to ensure structural purity, mathematically called a [[Monad]]. According the Beckman's talk on [[Don't fear the Monad]]<ref>{{:Video/Don't fear the Monad}}</ref>, this monadic approach will help construct complexity out of simplicity. | |||
===Function as verb=== | |||
It would be rather easy to imagine why functions can be thought of as verbs. They can act on inputs and transform them into outputs. In MediaWiki, once [[Scribunto]] is installed, this can be realized rather easily. Otherwise, the [[JavaScript]] functional programming that comes with most modern browsers, can also demonstrate the nature of the effects of functions being verbs. | |||
===Function as noun=== | |||
Function can also considered as nouns. Many function are associated with certain unique name in a defined functional namespace, functions can also be encoded in a formalized structure, that are called anonymous functions. In this case, each function's unique structural content, defines its identity. In this case, function can be thought of as names. In a computing system that treats computation as a pure structure, all functions must have their unique structures or unique names, so that their behavior can be consistently defined and asserted within the defined computing system. It is interesting to think of numbers as a kind of namespace, then, integer numbers, floating point numbers, are two kinds of namespaces. To study the nature of these namespaces in terms of their structures, such as [[IEEE 754]]<ref>{{:Video/IEEE 754}}</ref>, the functional nature becomes rather obvious. | |||
===Function as Dictionary=== | |||
When thinking of function as a computational device, which needs to serve both the roles of verb and noun, it could be best thought of as a dictionary of [[key-value pair]]. Each instance of a function can be thought of as a [[dictionary]] or [[associative array]] containing many [[key-value pair]]s. In most cases, this tuple structure best capture the duality of function that must serve as noun and verb. To extend on this generalizable foundation, a function can be thought of as a special case of [[morphism]], which has two other types, called [[functor]] and [[natural transformation]]. | |||
====Functions as dictionaries in finite sets==== | |||
Without loss of generality, using dictionary as an implementation mechanism for function can cover most cases when dealing with data sets with finite sizes. Theoretically speaking, functions represented as dictionaries are sets encoded by [[key-value pair]]s with concrete values, such as a, b, c, or 1, 2, 3. It allows one to leverage concepts consistent with set-theory to perform computation by manipulating dictionary content using set-theoretic operations, such as insert, remove, union, intersection. | |||
====Functional Composition and Software Engineering==== | |||
Once we treat functions as some generalized dictionaries, we now have a concrete software instrument to automate tasks in data/system manipulation. The most effective way to organize these software instruments is the essential challenge in [[software engineering]], which is also the essence of [[systems engineering]]. By practicing function manipulation in a context of [[software engineering]]/[[systems engineering]], will give people a wide range of real-life examples that will better cement the learning results while learning abstract ideas presented in [[Category Theory]], which is also known as the [[abstract algebra]] of [[function]]s. | |||
====Function as Relation==== | |||
A function can also be thought of as a relation. A [[relation]] that specifies either directed or directionless relation between elements. See [[Relation]] for more details. | |||
====A piece of sample code==== | |||
[[PKC]] is based on [[MediaWiki]], which in term installs [[MW:Scribunto|Scribunto]] to enable [[Lua]] programming. [[Lua]] defines functions as below: | |||
<syntaxhighlight lang=LUA> | |||
f = function (op, a, b) | |||
if op == 'add' then | |||
return a + b | |||
else if op == 'sub' then | |||
return a - b | |||
end | |||
error("invalid operation") | |||
end | |||
</syntaxhighlight> | |||
==Function represented in a Logic Model== | |||
{{Template:LogicModel | |||
|name=Function | |||
}} | |||
<noinclude> | |||
=References= | |||
<references/> | |||
==Related Pages== | |||
*[[Logically related::Data]] | |||
*[[Logically related::Morphism]] | |||
*[[Logically related::Functor]] | |||
*[[Logically related::Natural transformation]] | |||
[[Category:Morphism]] | |||
[[Category:Data]] | |||
[[Category:Universal Component]] | |||
</noinclude> |
Latest revision as of 16:34, 23 February 2022
Functions are a mathematical representation of directed relations between the domain and codomain. It can be represented as a key-value pairs, or in the lambda calculus[1] form.
Tag Line
Data with continuation together makes function.
Function can be used as a generic building block to represent information in general. It can be thought of as a primitive kind of data structure. This argument can be substantiated by thinking of Lambda calculus as a generalized way of encoding functions in an explicit structured data format.
A Critical Observation
In most cases, people think of MediaWiki as a generic note taking or a dictionary of relevant pieces of static information. However, knowing the capabilities of modern browsers, HTML 5, JavaScript, and the server side PHP + Lua (Scribuntu) extension of MediaWiki, not to mention Semantic MediaWiki and its MySQL/MariaDB data storage/retrieval capabilities, the overall functions of MediaWiki must not be just seen as a passive data browsing tool, but a full blown programming and data creating environment. In programmer's term, MediaWiki can be configured to be a full blown Integrated Development Environment, for any subject matter. This is what PKC strives to become, it tries to raise users' awareness of data elements as functions, so that all data are also functions in a hyperlinked context. In other words, hyplerink is a kind of data-oriented function, that allows users to incrementally construct small and large functions at many locations and across many time scales. On the Internet, everyone is constructing some piece of a bigger function that they may never be directly conscientiously aware, but never-the-less, all users, all computers are incrementally constructing functions of many kinds through accumulating data elements, all in the hyperlinked fashion as articulated by Ted Nelson.
Scale-Free, Time-like Structures, and Ordered Namespace of Functions
Function as a data structure is not only universal, but it can also be designed to be Scale-free, meanningly that the formal properties of a specific Function, don't have to be bounded to a specific spacetime physical scale. However, in the space of all functions, the containment relationship in terms of what functions are classified into what sub-class(es) of functions can be studied in terms of Category Theory, and more specifically, in the field of Lattice Theory or just think of them in terms of Partially ordered sets. Thinking of named functions in terms of lattice or Partially ordered set, a.k.a. Posets, is an important mental model for both software engineering, and in everyday life. Thinking of functions as elements in Posets will give them a consistent abstraction in an ordered or time-like structure, so that it will build a generically applicable mental model for causal relations and in terms of an ordered namespace.
Function as Causal Relation
Function can be represented as a key-value pair of inputs and outputs, which defines a way to represent causal relations.
Design Principle
PKC models data assets in terms of functions, which is a kind of scale-free data representation. These functional data representation are in turn categorized into Page, File, and Service. Each category of function is treated as the primitive form of data, and can be recursively referenced to perform both computation and carry computational results. All pages in PKC are conceptualized as hyperlinked data points in a functional style. All data points or pages have their unique names. These names can be thought of as function names, and each function may have many key-value-pairs as its arguments.
Data Architecture
In PKC, data is consistently represented using one universal construct, directed relation. This also means that we can always use the same data type, directed relation to interpret and manipulate data.
Architecture = Invariant Properties
It is important to note that the word Architecture implies elements of a system that doesn't change. Therefore, this section will talk about the data elements of PKC that don't change over space and time.
Logic Model (Data Architecture) Template:LogicModel 02 23, 2022 | ||||||
---|---|---|---|---|---|---|
| ||||||
| ||||||
|
References
- ↑ Abelson, Harold; Sussman, Gerald; Sussman, Julie (1985). Structure and Interpretation of Computer Programs (2nd ed.). local page: MIT Press. ISBN 0-262-51087-1.
Related Pages
Represent Knowledge in Functions
Thinking about functions at all times in this primitive, yet generic construct, allows users to think of all functions as hyperlinks that relate objects from one to the other, revealing the topological structures, or the systematic structures of anything. Most importantly, users of PKC can think of writing down notes in various pages are effectively construction functions or conducting computational work in parallel and in an explicit functionally designed data storage. The storage packages are managed in terms of files. The availability and reliability of providing these pages and files are called services. This completes the three categories of scale-free data representation. The design principle that differentiate PKC from other hyperlink/hypermedia systems is that PKC considers data content within the system as an integral part of the system. Since every instance of PKC is tightly bound with its own content, all PKC must allow maximum freedom to all instances of PKCs. To accomplish this design principle, it needs to give full ownership and power to conduct changes to the owners of individual instances. In the most egalitarian scenario, we must reduce the barrier to entry, so PKCs should be convenient and cheap to be replicated or allowing for the creation of new instances that are independent from other instances of PKC, so that the functionality of PKCs can be easily shared across many application domains.
Implementation
Computationally, functions can almost always be thought of as a dictionary, or a lookup table/hashtable that relates a value of an input, to a value as the output of a function. This simplification is useful in the sense that all functions can be conceptualized as dictionaries/lookup tables, so that all functions can be treated as one type, which is a way to ensure structural purity, mathematically called a Monad. According the Beckman's talk on Don't fear the Monad[1], this monadic approach will help construct complexity out of simplicity.
Function as verb
It would be rather easy to imagine why functions can be thought of as verbs. They can act on inputs and transform them into outputs. In MediaWiki, once Scribunto is installed, this can be realized rather easily. Otherwise, the JavaScript functional programming that comes with most modern browsers, can also demonstrate the nature of the effects of functions being verbs.
Function as noun
Function can also considered as nouns. Many function are associated with certain unique name in a defined functional namespace, functions can also be encoded in a formalized structure, that are called anonymous functions. In this case, each function's unique structural content, defines its identity. In this case, function can be thought of as names. In a computing system that treats computation as a pure structure, all functions must have their unique structures or unique names, so that their behavior can be consistently defined and asserted within the defined computing system. It is interesting to think of numbers as a kind of namespace, then, integer numbers, floating point numbers, are two kinds of namespaces. To study the nature of these namespaces in terms of their structures, such as IEEE 754[2], the functional nature becomes rather obvious.
Function as Dictionary
When thinking of function as a computational device, which needs to serve both the roles of verb and noun, it could be best thought of as a dictionary of key-value pair. Each instance of a function can be thought of as a dictionary or associative array containing many key-value pairs. In most cases, this tuple structure best capture the duality of function that must serve as noun and verb. To extend on this generalizable foundation, a function can be thought of as a special case of morphism, which has two other types, called functor and natural transformation.
Functions as dictionaries in finite sets
Without loss of generality, using dictionary as an implementation mechanism for function can cover most cases when dealing with data sets with finite sizes. Theoretically speaking, functions represented as dictionaries are sets encoded by key-value pairs with concrete values, such as a, b, c, or 1, 2, 3. It allows one to leverage concepts consistent with set-theory to perform computation by manipulating dictionary content using set-theoretic operations, such as insert, remove, union, intersection.
Functional Composition and Software Engineering
Once we treat functions as some generalized dictionaries, we now have a concrete software instrument to automate tasks in data/system manipulation. The most effective way to organize these software instruments is the essential challenge in software engineering, which is also the essence of systems engineering. By practicing function manipulation in a context of software engineering/systems engineering, will give people a wide range of real-life examples that will better cement the learning results while learning abstract ideas presented in Category Theory, which is also known as the abstract algebra of functions.
Function as Relation
A function can also be thought of as a relation. A relation that specifies either directed or directionless relation between elements. See Relation for more details.
A piece of sample code
PKC is based on MediaWiki, which in term installs Scribunto to enable Lua programming. Lua defines functions as below:
f = function (op, a, b)
if op == 'add' then
return a + b
else if op == 'sub' then
return a - b
end
error("invalid operation")
end
Function represented in a Logic Model
Logic Model (Function) Template:LogicModel 02 23, 2022 | ||||||
---|---|---|---|---|---|---|
| ||||||
| ||||||
|
References
- ↑ Beckman, Brian (Nov 21, 2012). Brian Beckman: Don't fear the Monad. local page: jasonofthel33t.
- ↑ Video/IEEE 754
Related Pages