MEMELANG

v03 · 18 Feb 2025 · Bri Holt · info@memelang.net

Introduction

Memelang is a notation for logically encoding knowledge. Memelang traverses a knowledge graph using only three novel operators: ] indicates a node, [ indicates an edge, and - "inverses" an edge. Memelang also uses standard math operators such as =, !=, <=, >=, >, and <. The basic syntax states that some node A has some relation (edge) R to some other node B:

A[R]B=W

For example, "Alice's uncle is Bob," where A=Alice and R=uncle, B=Bob, and W=t (true). Memelang encodes this relation thusly:

Alice[uncle]Bob = t

The W value may indicate true, false, or a quantity. Whenever the value is a quantity, the B must be a unit of that quantity. For example, "Alice's height is 1.6 meters" is encoded:

Alice[height]meter=1.6

Relations may be chained. For example, we know that an uncle is a parent's brother:

Alice[parent[brother]Bob = t

Inverse Relations

Logically, for any true relation, there exists an inverse relation as well. The inverse relation is indicated by a minus sign:

A[R]B = B[-R]A

For the example above, Bob's "inverse uncle" is Alice. In English, inverse uncle could be "niece" or "nephew."

Alice[uncle]Bob = Bob[-uncle]Alice

Inverse relation chains are inverted and reversed:

Alice[parent[brother]Bob = Bob[-brother[-parent]Alice

Queries

An incomplete statement is interpreted as a search query where the missing field is a wildcard:

// A is wildcard
// returns everyone who has Bob as an uncle
[uncle]Bob

// B is wildcard
// returns everyone who is Alice's uncle
Alice[uncle]

// R is wildcard
// returns all relations between Alice and Bob
Alice[]Bob

// Both Bs are chained wildcards
// returns all grandchildren of Cindy
Cindy[child]child]

Note that an empty =W is interpreted as the semi-wildcard !=f which returns any value except false.

To search for A values matching two statements, the space character is used as an AND operator. This query searches for people whose uncle is Bob and whose mother is Cindy:

[uncle]Bob [mother]Cindy

To search for A values that match at least one of multiple statements, the special =tn (where n is a whole number) value serves as an OR operator. All statements with the same n value are grouped into an OR clause. The query below searches for people whose uncle is Bob and whose mother is Dana or Cindy:

[uncle]Bob [mother]Dana=t1 [mother]Cindy=t1

Logic

Memelang encodes a logical "if/then" statement with a wildcard node operator in the middle of the statement. If relation to the left of the wildcard node are satisfied for a given node, then the relation to the right is true. For example, "if a person is at least 1 meter tall, then they may ride the rollercoaster" is encoded:

1.0 <= meter[-height][rideRollercoaster]allow = t
Alice[height]meter = 1.6
// therefore
Alice[rideRollercoaster]allow = t

Logic may suggest a relation. For example, any kind of product should have a price in USD greater than or equal to one cent:

product[-kind][price]usd >= 0.01

Logic may also encode a relation chain. For example, an uncle is a parent's brother:

[-uncle][parent]brother]

Memelang in PostgreSQL

In the memesql3 implementation, statements are stored in a PostgreSQL database. The scheme, simplified here, stores both true statements and logic statements in the same table:

CREATE TABLE meme (
 V DECIMAL   /* floating point number like 1.1 */
 VE VARCHAR, /* equality operator like < > = */
 A VARCHAR,  /* A node */
 C VARCHAR,  /* Condition Edge */
 D VARCHAR,  /* Declaration Edge */
 B VARCHAR,  /* B node */
 WE VARCHAR, /* equality operator like <= != */
 W DECIMAL   /* floating point number like -2.7 */
);

Each row is interpreted to produce a meme in the form:

V = A[C][D]B = W

To store an unconditional statement, the special C=is is used. This relation is reflexive such that:

A[is[D]B = A[-is[D]B = A[D]B

So the simple statement Alice[uncle]Bob is be expanded to have the row values V=1 (true) VE="=" A=Alice C=is D=uncle B=Bob WE="=" W=1 (true), which produces:

t = Alice[is][uncle]Bob = t

Any other C value produces a conditional statement. For example, the row values V=1 VE="=" A=product C=-kind D=price B=usd WE=">=" W=0.01 form:

t = product[-kind][price]usd >= 0.01

License

Memelang is free for public use under the Memelicense. Patents pending. Copyright 2025 HOLTWORK LLC. Contact info@memelang.net.