Memetics

Version 01

A.R:B = B'R:A = Q

Memetic notation manipulates data in a knowledge graph, combining aspects of formal logic, graph theory, type theory, and database theory. The syntax is chosen to be accessible to a broader, non-mathematical audience and for ease of typing on a QWERTY keyboard.

In memetic notation, knowledge is reduced to units called memes. Each meme states that some A has some relation R to some B. For example, "Alice's uncle is Bob," where A=Alice and R=uncle, and B=Bob. A and B are members of a set of element identifiers. Any identifier may be used in an A or B position, depending on the relation's direction. R is a member of a set of relation identifiers. Element identifiers and relation identifiers preferably do not intersect. For computers, identifiers are optimally stored as binary integers elsewhere correlated to strings. For humans, identifiers are optimally written as simplified lowercase A-Z words as they are here.

In database theory terms, A, R, and B are columns and each meme is a row in a relational table. In graph theory terms, every R forms a directed graph with nodes from the element identifiers, and edges from various As to various Bs. In set theory terms, each identifier is a set and each meme is a member of its A, R, and B sets.

This notation is being actively developed, please contact info@holtwork.com with inquiries.

Conventional Notation

The ARB relationship may be described using conventional functional notation.

R(A,B) = Q Some function R() takes A and B as inputs and outputs a Q. The R() function essentially answers the question, is A related to B by this R() function?
'R(B,A) = Q Every relation R(A,B) has an inverse relation 'R(B,A).
Q := {null, false, true, real number} Various values of Q describe the relationship.
Q = null The relation is unknown. Unknown may also be assumed to be false.
Q = false The relation is known to be false.
Q = true The relation is known to be true.
Q = real number The R property of some A equals Q quantity of B units. B is always a unit when Q is a number.
uncle(alice,bob) = true In this truth example, it is true that Bob is Alice's uncle.
height(alice,meter) = 1.6 In this quantitative example, Alice has a height of 1.6 meters. The B in quantitative relations is always a unit.
g(A,R,B) g(alice,uncle,*) = ((alice,uncle,bob,true),...) A g() function takes A, R, and/or B as input and outputs a set of matching (A,R,B) coordinates. Asterisks or empties are treated as wildcards.
ga(A,R,B) ga(*,uncle,bob)=(alice,carl,...) The functions ga() takes A, R and B as inputs and outputs an array of As from matching coordinates. The functions gr(), gb(), gq() act likewise and output R, B, and Q arrays respectively.

Simple Memetic Statements

The conventional notation above will prove cumbersome in complex statements. Memetic notation applies these functions implicitly. The syntax of memetic notation is chosen for ease of typing on a QWERTY keyboard. Note that the meaning of punctuation in memetic notation may differ from that of existing notations.

A.R:B=Q; A.R:B; A R B; A R B Q; Some A is related by some R to some B. The R is preceded by a dot, the B is preceded by a colon, and Q preceded by an equals. Q=true it is omittable. For simple statements, all punctuation is omittable.
alice.uncle:bob = true; alice.uncle:bob; alice uncle bob; In this truth example, it is true that Bob is Alice's uncle.
alice.height:meter = 1.6; alice height meter 1.6; In this quantitative example, Alice has a height of 1.6 meters. The B in quantitative relations is always a unit.
B.'R:A=Q; B'R:A=Q; B 'R A Q; bob 'uncle alice; Inverse relations are specified with an apostrophe before the R. In the character sequence dot-apostrophe is simplified to just apostrophe.

Complex Memetic Statements

Memetic notation may be extended to ask questions and form logical statements. An example complex statement looks like: [[Ax.Rx & [.Ry:By > Qy]] @cnt #=0]. Each expression in the statement has a special function. Certain expressions return sets and forward arrays. A set is a series of memes. An array is a series of values taken from one column (either A, R, B, or Q) from a set of memes. Each expression is explained below.

Set Query Operations

Known memes are stored in the dataset where they can be queried. On a computer, the dataset is stored in a database. On paper, the dataset is the listed memes.

A If specified, retrieves the set of all memes with this A. If omitted, the starting set is the set of all memes. Forwards an array of the As. Only used at the start of a statement. A set of memes all having the same A value is termed an A-set.
.R Retrieves the set of all memes with this R and an A equal to any value from the previous forwarded array. Forwards an array of the Bs. The output set may be larger than the input set.
'R Retrieves the set of all memes with this R and an B equal to any value from the previous forwarded array. Forwards an array of the As. The output set may be larger than the input set.
:B Filters the previous set to only those memes with this B. Forwards an array of Qs. Only used at the end of a statement. A set of memes all having the same B value is termed a B-set.
alice This example queries the dataset for all memes where A=alice. It essentially asks, "What is known about Alice?" Returns an array such as [alice.uncle:bob=true;...].
alice.uncle This example queries the dataset for all memes where A=alice and R=uncle. It essentially asks, "Who are Alice's uncles?" Returns a set such as [alice.uncle:bob=true; ...].
.uncle:bob This example queries the dataset for all memes where B=bob and R=uncle. It essentially asks, "Who are Bob's nieces/nephews?" Returns a set such as [alice.uncle:bob=true; ...].
bob'uncle This example is the same as .uncle:bob stated inversely. Returns a set such as [bob'uncle:alice=true; ...].
alice:bob This example queries the dataset for all memes where A=alice and B=bob. It essentially asks, "What are the direct relations between Alice and Bob?" Returns a set such as [alice.uncle:bob=true;...].

Quantity Comparison Operations

Comparison operators automatically receive an array of Qs and filter the preceding set accordingly. Herein, M, N, and P denote statements such as A.R:B. While X and Y denote values such as false, true, or a number.

M #= X For the set of memes M, return the subset of memes from M where Q equals X.
M > X Return the subset of memes from M where Q is greater than X.
M < X Return the subset of memes from M where Q is less than X.
M >= X Return the subset of memes from M where Q is greater than or equal to X.
M <= X Return the subset of memes from M where Q is less than or equal to X.
M != X Return the subset of memes from M where Q does NOT equal X.
.height:m < 1.7 This example returns a subset of all memes with any A, R=height, B=m (meter), and Q<1.7. It effectively for all objects shorter than 1.7 meters.

Quantity Aggregator Operations

The aggregator operator @ performs an aggregation operation on the memes in the preceding set according to the adjacent function name. The aggregator forwards a numeric value and returns a set comprising the last matching A, the last R, the last B and a Q according to the aggregation function.

M @cnt The @cnt function counts the number of memes in the previous set.
M @cnt #= 0 This statement is the equivalent of "There exist no memes such that M," where M is some statement. In computer execution, this acts as a constraint that throws an error upon evaluating to false. In logic, this serves as a quantifier.
M @cnt #= 1 "There exists exactly one meme such that M"
M @cnt >= 1 "There exists at least one meme such that M"
M @cnt > N @cnt This example returns true if the M-set contains more memes than the N-set.
M @max Select the maximum Q value.
M @min Select the minimum Q value.
M @sum Sum all Q values in the set.
M @prod Multiply all Q values in the set.
M @avg Average all Q values in the set such that @avg = @sum / @cnt.
.balance:usd<0 @cnt #= 0 In this example, a user's balance cannot fall below zero.

Quantity Arithmetic Operations

Arithmetic operators automatically receive an array of Qs.

M += X For every meme in M, Q is increased by X.
M -= X For every meme in M, Q is decreased by X.
M *= X For every meme in M, Q is multiplied by X.
M /= X For every meme in M, Q is divided by X.
M %= X For every meme in M, Q is modulated by X.
M ^= X For every meme in M, Q is exponentiated by X.
camera'kind.price *= 0.8 In this example, all camera price quantities in all units are reduced by 20%.
camera'kind.price:usd *= 0.8 In this example, all camera price quantities using USD units are reduced by 20%.

Set-Value Operations

M = X; A.R:B = true; The value operator states that M-statement evaluates to X-value, and M-statement is a possible devaluation of X-value.
M = X & Y; A.R:B = true & true; The AND operator evaluates to true when both X-value and Y-value are true. Non-empty sets evaluate to true. Numbers greater than zero evaluate to true.
M = X | Y; A.R:B = false | true; The OR operator evaluates to true if either X-value or Y-value is true.
M = null; A.R = null; A R null; .R:B= null; A:B = null; The set nullifier syntax removes all items from the M-set.

Set Junction Operations

M & N; The set conjunction operator (AND) merges two sets into one set where every A appears in both sets. Memes with As in only one set are excluded. Here, M and N are sets of memes.
M | N; The set disjunction operator (OR) merges all memes from two sets into one set. Is optionally processed in parallel on a computing device. The (;) semicolon defaults to (|) behavior in appropriate cases.
M ~ N; The set non-conjunction operator (XOR) merges two sets into one set where every A appears in only one set, but not both.
M &! N; .Rx &! .Ry:B == .Rx!Ry:b; The set anti-conjunction operator (NAND) removes memes from the M-set having A-values that appear in N-set. Returns the smaller M-set. The sequence ampersand exclamation dot can be shorthanded to exclamation.
A.Rx | A.Ry; A.Rx,Ry; A disjunction of two relations on one A returns a set with both relations and is equivalent to SELECT Rx, Ry in SQL. This sequence is simplified to a comma for brevity.
.kind:camera ~ .kind:phone & [.price:usd < 1000 | .resolution:megapixels >= 20]; In this example, the query finds a set where each meme belongs to a camera, or a phone, but not an item that is both camera and phone, that is priced less than $1000 or has a resolution greater than or equal to 20 megapixels. For each satisfying A, the output set includes the A.kind, A.price:usd, and A.resolution memes.

Set Implication Operations

M == N; The mutual implication operator states that for every M=true also N=true and for every N=true also M=true. Especially used in defining statements whereby M-statements are equivalent to N-statements.
M => N; The partial implication operator states that for every M=true also N=true.
!M => N; M !> N; Example negative implication such that if M=false then N=true.
Af == [Af.Rx:Bx=Qx; Af.Ry:By=Qy; ...]; An identifier is defined as the set of all memes containing it.
[Af => Ag] == [Ag.Rx:Bx=Qx; Ag.Ry:By=Qy; ...]; Here, Ag receives all of Af's relations. The partial implication operator applies the relations from the statement on the right to the statement on the left.
[Af => Ag.R.B=!Q] == [Ag.Rx:Bx=!Qx; Ag.Ry:By=!Qy; ...]; Here, the !Q on the right applies not to all Qs in Af's relations, making Ag is the opposite of Af.
Af:Bf => Ag:Bg; Here, all relations between Af and Bf are applied between Ag and Bg.
.kind:fruit => .kind:food; Here, every A that is a fruit is also a food.

Relational Logic

The above operations can be combined to form relational logic whereby one relation is comprised of two or more other relations.

alice.parent.brother:bob = true; Relations may be chained. Here, Alice has some unnamed parent who has a brother Bob.
bob.'brother.'parent:alice = true; bob'brother'parent:alice = true; Inverted Rs chain A-A or B-B or A-B. The dot before an apostrophe is omittable.
.uncle == .parent.brother; A relation may be defined as a chain of other relations. Note the set equality in the double equals sign.
'uncle == 'brother'parent; The inverse of a chain is the relations inversed and reversed.
.sibling == 'sibling; A reciprocal relation is its own inverse. If A is the sibling of B, then B is the sibling of A.
bob.male.bob = true; A reflexive relation has A=B. Equivalent to "It is true that A is R."
.ancestor == .ancestor.ancestor; A recursive relation can be chained to itself infinitely.
.equals == .equals'equals; Unless explicitly stated, recursion implicitly excludes reflection (A=B) to avoid the paradox whereby my sibling's sibling is also my sibling, and I am my sibling's sibling, therefore I am my own sibling. Here, the mathematical relation equals is denoted as reciprocal, reflexive, and recursive.
'ancestor == 'ancestor'ancestor; A recursive relation's inversion must also be recursive.
.brother == .sibling.male; In a relation chain comprising at least one non-reflexive relation and at least one reflexive relation, the reflexive relations are termed reducers because their purpose is to reduce the set from the non-reflexive relations. Here, male is a reducer as it reduces the set of siblings to only males.
'brother == 'male'sibling == .male.sibling; Reciprocal relation inversion is arbitrary.
.parent == .sibling.parent; In a relation's definition that comprises the relation itself and a non-reflexive relation, the non-reflexive relation is termed the reacher as it reaches for additional relations. Here, my sibling's parent is also my parent.
.is == 'ex; A.is:B = A.B @cnt > 0; alice.human.alice => alice.is:human; The existential relation is returns true/false if A has any B relation. Note that B is transposed to the R position on the right. This example reads, "Alice is a human" and inversely, "A human example is Alice."
human kind species; species'kind'is:alice; 'is & .kind:species => .isSpecies; In this example, the second row asks the question, "What kind of species is Alice?" and the third row creates a categorical relation that is a subset of the existential relation.
.speed:mps == [.distance:meter / .time:sec]; A relation may be defined as an arithmetic operation between other relations. Here, for A where A.distance:meter is a number and A.time:sec is a number, create a new meme A.speed:mps equal to the quotient of the numbers of other two memes.

Matrix Relation Operations

The matrix operator takes a set of disjunctive A-sets and performs the described relations on each permutation. The resulting new temporary memes are given A identifiers distinguishing them as temporary; for example, permanent identifiers are positive and temporary identifiers are negative. If the program instructs the device to permanently store the temporary memes, then the temporary identifiers are swapped for permanent identifiers. The $ is not strictly necessary as a dot would suffice, however the distinction is a reminder that this expression creates a new A-set. Here, an example of a process calculating the hypotenuse between A=Alice and B=Bob as distance.

alice.xcoord:num=1; alice.ycoord:num=2; bob.xcoord:num=7; bob.ycoord:num=12; $hypotenuse.first:A = true; $hypotenuse.second:B = true; $hypotenuse.length:num = [[A.xco - B.xco]^2 + [A.yco - B.yco]^2]]^0.5; alice$hypotenuse:bob => distance;

Invalid Statements

Invalid statements are listed in red with their valid counterparts below.

.Rx == .Ry & .Rz; .Rx == .Ry == .Rz; Identities do not contain junctions.
.Rx => .Ry & .Rz; .Rx => .Ry; .Rx => .Rz; Junctions are used in only the conditional clause of an implication, never the consequential clause.
alice.distance:bob = X; alice.location:meter = Y; bob.location:meter = Z; distance.length:meter = Y - Z; Whenever Q is a number, B is a unit. Relative measures involving two identifiers require a third identifier for the measurement. This example measures the one-dimensional distance in meters between alice and bob.

License

Memetics is free for reciprocal public use under the Memetics Public License. Patents pending.