|
UKS
Universal Knowledge Store
|
A link: a Thought that connects three others, its source (From), its type (LinkType) and its target (To), as in [Fido→is-a→dog]. Because a link is a Thought, it can itself be the source or target of another link (a nested statement). More...
Public Member Functions | |
| Link (UKS store) | |
| Creates an unconnected, unstored link in the store. | |
| Link (Thought? from, Thought? linkType, Thought? to) | |
| Creates an unstored link [from → linkType → to], e.g. a query pattern. | |
| Link (Link l) | |
| Creates an unstored copy of a link; nested links are copied too. | |
| override string | ToString () |
| The link as text: [From→LinkType→To], preceded by its label if it has a name. | |
| Public Member Functions inherited from UKS.Thought | |
| Thought (UKS store) | |
| Creates an unlabeled Thought in the store. It becomes a stored Thought when it is given a label; usually UKS.GetOrAddThought or UKS.AddThought is simpler. | |
| Thought (Thought r) | |
| Creates a copy of a Thought's label, weights and value, without its links. | |
| Link? | AddLink (ThoughtRef linkType, ThoughtRef to) |
| Adds the link [this → linkType → to] unless it already exists. An unknown label creates the Thought (under LinkType for the link type, else under Unknown). The target may be empty. | |
| Link? | HasLink (ThoughtRef linkType, ThoughtRef to=default) |
| This Thought's own link of the given type to the given target (to any target if it is empty), or null if there is none or a label is unknown. Inherited links are not included; see UKS.GetAttributes. | |
| Link? | HasLink (ThoughtRef from, ThoughtRef linkType, ThoughtRef to) |
| The first of this Thought's links matching the given source, type and target, where an empty one matches anything; null if there is none, all three are empty, or a label is unknown. | |
| void | RemoveLink (ThoughtRef linkType, ThoughtRef to) |
| Removes the link [this → linkType → to], if present. An empty target means a link with no target; an unknown label removes nothing. | |
| void | RemoveLink (Link r) |
| Removes a stored link. r may be an unstored copy: the link with the same source, type and target is removed. | |
| Link? | AddParent (ThoughtRef parent) |
| Makes this Thought a child of the parent (an is-a link) unless it already is. An unknown label creates the parent under Unknown. | |
| void | RemoveParent (ThoughtRef parent) |
| Removes the is-a link to the parent, if present; an unknown label removes nothing. | |
| bool | HasAncestor (ThoughtRef ancestor) |
| True if ancestor is this Thought or one of its ancestors. An unknown label is never an ancestor. | |
| Thought? | AddProperty (ThoughtRef property) |
| Adds a hasProperty link to the property unless this Thought already has it, directly or by inheritance. An unknown label creates the property under Unknown. | |
| bool | HasProperty (ThoughtRef property) |
| True if this Thought or one of its ancestors has a hasProperty link to the property. | |
| void | Fire () |
| Fires the Thought: records the cycle, extends a finite time to live, and raises UKS.ThoughtFired. | |
| bool | FiredWithin (long cycles) |
| True if this Thought fired within the last cycles cycles. | |
| void | Delete () |
| Removes this Thought from its store with all its links. Its children move to its parents (a wildcard child is deleted instead), and sequences only it refers to are deleted. Deleting a link removes it from its source. | |
| override string | ToString () |
| The label, followed by _V: and the value if there is one. | |
Properties | |
| Thought? | From [get, set] |
| The source of the link. | |
| Thought? | LinkType [get, set] |
| The type of the link (is-a, has, ...). | |
| Thought? | To [get, set] |
| The target of the link; may be null. | |
| Properties inherited from UKS.Thought | |
| UKS | Store [get] |
| The store this Thought belongs to; it never changes. | |
| string | Label [get, set] |
| The Thought's name, unique in its store and case-insensitive. Setting a label already in use appends a number, and a trailing * becomes the next free number (dog* gives dog0, dog1, ...). | |
| IReadOnlyList< Link > | LinksTo [get] |
| This Thought's own links (it is their source), as a copy that is safe to keep. | |
| IReadOnlyList< Link > | LinksFrom [get] |
| The links that have this Thought as their target, as a copy that is safe to keep. | |
| IReadOnlyList< Link > | LinksAsType [get] |
| The links that have this Thought as their type, as a copy that is safe to keep. | |
| IReadOnlyList< Thought > | Parents [get] |
| The direct parents: targets of this Thought's is-a links. | |
| IReadOnlyList< Thought > | Children [get] |
| The direct children: sources of is-a links to this Thought. | |
| IEnumerable< Thought > | Ancestors [get] |
| Every ancestor (parents, their parents, ...), nearest first, each once; not this Thought. | |
| IEnumerable< Thought > | Descendants [get] |
| Every descendant (children, their children, ...), nearest first, each once; not this Thought. | |
| float | Weight [get, set] |
| Strength or confidence, 1 by default. A query multiplies the weights along an inheritance path and orders its results by weight; repeating a statement strengthens its link. | |
| float | MaxWeight [get, set] |
| An upper limit on Weight for learning code to respect; the store saves it but does not use it. | |
| bool | IsPlastic [get, set] |
| True if learning may still change this Thought's weight. The store saves the flag but does not act on it; structural Thoughts and links are not plastic. | |
| object? | Value [get, set] |
| Any object attached to the Thought. Only a string value is saved to a file. | |
| long | CreatedCycle [get] |
| The UKS.Cycle at which this Thought was created. | |
| long | TimeToLive [get, set] |
| Cycles left before this Thought (or link) is deleted, counted down by UKS.AdvanceCycle. Forever (the default) means it never expires; firing extends a finite time. | |
Additional Inherited Members | |
| Public Attributes inherited from UKS.Thought | |
| long | LastFiredCycle |
| The UKS.Cycle at which this Thought last fired; 0 if it never has. | |
| Static Public Attributes inherited from UKS.Thought | |
| const long | Forever = -1 |
| A TimeToLive of -1: the Thought never expires. | |
A link: a Thought that connects three others, its source (From), its type (LinkType) and its target (To), as in [Fido→is-a→dog]. Because a link is a Thought, it can itself be the source or target of another link (a nested statement).
A link built with a constructor is not stored: use it as a pattern (UKS.FindLinks, UKS.ApplyTestOrSetAction). Store a link with UKS.AddStatement or Thought.AddLink.
Creates an unstored link [from → linkType → to], e.g. a query pattern.
| ArgumentException | All three are null. |