atsds 0.0.2-alpha1 → 0.0.2-alpha3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tsds.d.mts CHANGED
@@ -245,6 +245,27 @@ export declare class term_t extends _common_t<dst.Term> {
245
245
  * ```
246
246
  */
247
247
  ground(other: term_t, scope?: string): term_t | null;
248
+ /**
249
+ * Rename all variables in this term by adding prefix and suffix.
250
+ *
251
+ * @param prefix_and_suffix - A term representing a list with two inner lists.
252
+ * Each inner list contains 0 or 1 item representing the prefix and suffix.
253
+ * Example: "((pre_) (_suf))" adds "pre_" as prefix and "_suf" as suffix.
254
+ * @returns The renamed term, or null if renaming fails.
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * const a = new term_t("`x");
259
+ * const b = new term_t("((pre_) (_suf))");
260
+ * console.log(a.rename(b).toString()); // "`pre_x_suf"
261
+ *
262
+ * // With empty prefix (only suffix)
263
+ * const c = new term_t("`x");
264
+ * const d = new term_t("(() (_suf))");
265
+ * console.log(c.rename(d).toString()); // "`x_suf"
266
+ * ```
267
+ */
268
+ rename(prefix_and_suffix: term_t): term_t | null;
248
269
  }
249
270
  /**
250
271
  * Wrapper class for logical rules in the deductive system.
@@ -322,6 +343,27 @@ export declare class rule_t extends _common_t<dst.Rule> {
322
343
  * ```
323
344
  */
324
345
  match(other: rule_t): rule_t | null;
346
+ /**
347
+ * Rename all variables in this rule by adding prefix and suffix.
348
+ *
349
+ * @param prefix_and_suffix - A rule with only a conclusion that is a list with two inner lists.
350
+ * Each inner list contains 0 or 1 item representing the prefix and suffix.
351
+ * Example: "((pre_) (_suf))" adds "pre_" as prefix and "_suf" as suffix.
352
+ * @returns The renamed rule, or null if renaming fails.
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * const a = new rule_t("`x");
357
+ * const b = new rule_t("((pre_) (_suf))");
358
+ * console.log(a.rename(b).toString()); // "----\n`pre_x_suf\n"
359
+ *
360
+ * // With empty prefix (only suffix)
361
+ * const c = new rule_t("`x");
362
+ * const d = new rule_t("(() (_suf))");
363
+ * console.log(c.rename(d).toString()); // "----\n`x_suf\n"
364
+ * ```
365
+ */
366
+ rename(prefix_and_suffix: rule_t): rule_t | null;
325
367
  }
326
368
  /**
327
369
  * Search engine for the deductive system.
package/dist/tsds.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import e from"./ds.mjs";const t=await e();let r=1024;function s(e=0){const t=r;return 0!==e&&(r=e),t}class n{type;value;capacity;constructor(e,r,i=0){if(this.type=e,r instanceof n){if(this.value=r.value,this.capacity=r.capacity,0!==i)throw new Error("Cannot set capacity when copying from another instance.")}else if(r instanceof this.type)this.value=r,this.capacity=i;else if("string"==typeof r){if(this.capacity=0!==i?i:s(),this.value=this.type.from_string(r,this.capacity),null===this.value)throw new Error("Initialization from a string failed.")}else{if(!(r instanceof t.Buffer))throw new Error("Unsupported type for initialization.");if(this.value=this.type.from_binary(r),this.capacity=this.size(),0!==i)throw new Error("Cannot set capacity when initializing from bytes.")}}toString(){const e=this.type.to_string(this.value,s());if(""===e)throw new Error("Conversion to string failed.");return e}data(){return this.type.to_binary(this.value)}size(){return this.value.data_size()}copy(){return new(0,this.constructor)(this.value.clone(),this.size())}key(){return this.toString()}}class i extends n{constructor(e,r=0){super(t.String,e,r)}}class a extends n{constructor(e,r=0){super(t.Variable,e,r)}name(){return new i(this.value.name())}}class u extends n{constructor(e,r=0){super(t.Item,e,r)}name(){return new i(this.value.name())}}class c extends n{constructor(e,r=0){super(t.List,e,r)}length(){return this.value.length()}getitem(e){return new o(this.value.getitem(e))}}class o extends n{constructor(e,r=0){super(t.Term,e,r)}term(){const e=this.value.get_type();if(e===t.TermType.Variable)return new a(this.value.variable());if(e===t.TermType.Item)return new u(this.value.item());if(e===t.TermType.List)return new c(this.value.list());throw new Error("Unexpected term type.")}ground(e,r=""){const n=s(),i=t.Term.ground(this.value,e.value,r,n);return null===i?null:new o(i,n)}}class l extends n{constructor(e,r=0){super(t.Rule,e,r)}length(){return this.value.length()}getitem(e){return new o(this.value.getitem(e))}conclusion(){return new o(this.value.conclusion())}ground(e,r=""){const n=s(),i=t.Rule.ground(this.value,e.value,r,n);return null===i?null:new l(i,n)}match(e){const r=s(),n=t.Rule.match(this.value,e.value,r);return null===n?null:new l(n,r)}}class h{_search;constructor(e=1e3,r=1e4){this._search=new t.Search(e,r)}set_limit_size(e){this._search.set_limit_size(e)}set_buffer_size(e){this._search.set_buffer_size(e)}reset(){this._search.reset()}add(e){return this._search.add(e)}execute(e){return this._search.execute(t=>e(new l(t).copy()))}}export{s as buffer_size,u as item_t,c as list_t,l as rule_t,h as search_t,i as string_t,o as term_t,a as variable_t};
1
+ import e from"./ds.mjs";const t=await e();let r=1024;function n(e=0){const t=r;return 0!==e&&(r=e),t}class s{type;value;capacity;constructor(e,r,i=0){if(this.type=e,r instanceof s){if(this.value=r.value,this.capacity=r.capacity,0!==i)throw new Error("Cannot set capacity when copying from another instance.")}else if(r instanceof this.type)this.value=r,this.capacity=i;else if("string"==typeof r){if(this.capacity=0!==i?i:n(),this.value=this.type.from_string(r,this.capacity),null===this.value)throw new Error("Initialization from a string failed.")}else{if(!(r instanceof t.Buffer))throw new Error("Unsupported type for initialization.");if(this.value=this.type.from_binary(r),this.capacity=this.size(),0!==i)throw new Error("Cannot set capacity when initializing from bytes.")}}toString(){const e=this.type.to_string(this.value,n());if(""===e)throw new Error("Conversion to string failed.");return e}data(){return this.type.to_binary(this.value)}size(){return this.value.data_size()}copy(){return new(0,this.constructor)(this.value.clone(),this.size())}key(){return this.toString()}}class i extends s{constructor(e,r=0){super(t.String,e,r)}}class a extends s{constructor(e,r=0){super(t.Variable,e,r)}name(){return new i(this.value.name())}}class u extends s{constructor(e,r=0){super(t.Item,e,r)}name(){return new i(this.value.name())}}class l extends s{constructor(e,r=0){super(t.List,e,r)}length(){return this.value.length()}getitem(e){return new c(this.value.getitem(e))}}class c extends s{constructor(e,r=0){super(t.Term,e,r)}term(){const e=this.value.get_type();if(e===t.TermType.Variable)return new a(this.value.variable());if(e===t.TermType.Item)return new u(this.value.item());if(e===t.TermType.List)return new l(this.value.list());throw new Error("Unexpected term type.")}ground(e,r=""){const s=n(),i=t.Term.ground(this.value,e.value,r,s);return null===i?null:new c(i,s)}rename(e){const r=n(),s=t.Term.rename(this.value,e.value,r);return null===s?null:new c(s,r)}}class o extends s{constructor(e,r=0){super(t.Rule,e,r)}length(){return this.value.length()}getitem(e){return new c(this.value.getitem(e))}conclusion(){return new c(this.value.conclusion())}ground(e,r=""){const s=n(),i=t.Rule.ground(this.value,e.value,r,s);return null===i?null:new o(i,s)}match(e){const r=n(),s=t.Rule.match(this.value,e.value,r);return null===s?null:new o(s,r)}rename(e){const r=n(),s=t.Rule.rename(this.value,e.value,r);return null===s?null:new o(s,r)}}class h{_search;constructor(e=1e3,r=1e4){this._search=new t.Search(e,r)}set_limit_size(e){this._search.set_limit_size(e)}set_buffer_size(e){this._search.set_buffer_size(e)}reset(){this._search.reset()}add(e){return this._search.add(e)}execute(e){return this._search.execute(t=>e(new o(t).copy()))}}export{n as buffer_size,u as item_t,l as list_t,o as rule_t,h as search_t,i as string_t,c as term_t,a as variable_t};
2
2
  //# sourceMappingURL=tsds.mjs.map
package/dist/tsds.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tsds.mjs","sources":["../atsds/tsds.mts"],"sourcesContent":["/**\n * TypeScript wrapper for a deductive system implemented in WebAssembly.\n * Provides classes and functions for working with logical terms, rules, and inference.\n */\n\nimport create_ds from \"./ds.mjs\";\nimport type * as dst from \"./ds.d.mts\";\n\nconst ds: dst.EmbindModule = await create_ds();\n\nlet _buffer_size: number = 1024;\n\n/**\n * Gets the current buffer size, or sets a new buffer size and returns the previous value.\n * The buffer size is used for internal operations like conversions and transformations.\n *\n * @param size - The new buffer size to set. If 0 (default), the current size is returned without modification.\n * @returns The previous buffer size value.\n *\n * @example\n * ```typescript\n * const currentSize = buffer_size(); // Get current size\n * const oldSize = buffer_size(2048); // Set new size, returns old size\n * ```\n */\nexport function buffer_size(size: number = 0): number {\n const old_size = _buffer_size;\n if (size !== 0) {\n _buffer_size = size;\n }\n return old_size;\n}\n\n/**\n * Common interface for all deductive system types.\n * @internal\n */\ninterface Common {\n clone(): Common;\n data_size(): number;\n}\n\n/**\n * Static methods interface for deductive system types.\n * @internal\n */\ninterface StaticCommon<T extends Common> {\n from_binary(buffer: dst.Buffer): T;\n to_binary(value: T): dst.Buffer;\n from_string(text: string, size: number): T;\n to_string(value: T, size: number): string;\n}\n\n/**\n * Valid initialization arguments for deductive system types.\n * @internal\n */\ntype InitialArgument<T extends Common> = _common_t<T> | T | string | dst.Buffer | null;\n\n/**\n * Base class for all deductive system wrapper types.\n * Handles initialization, serialization, and common operations.\n * @internal\n */\nclass _common_t<T extends Common> {\n type: StaticCommon<T>;\n value: T;\n capacity: number;\n\n /**\n * Creates a new instance.\n *\n * @param type - The static type interface for this common type.\n * @param value - Initial value (can be another instance, base value, string, or buffer).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails or invalid arguments are provided.\n */\n constructor(type: StaticCommon<T>, value: InitialArgument<T>, size: number = 0) {\n this.type = type;\n if (value instanceof _common_t) {\n this.value = value.value;\n this.capacity = value.capacity;\n if (size !== 0) {\n throw new Error(\"Cannot set capacity when copying from another instance.\");\n }\n } else if (value instanceof (this.type as unknown as new () => T)) {\n this.value = value;\n this.capacity = size;\n } else if (typeof value === \"string\") {\n this.capacity = size !== 0 ? size : buffer_size();\n this.value = this.type.from_string(value, this.capacity);\n if (this.value === null) {\n throw new Error(\"Initialization from a string failed.\");\n }\n } else if (value instanceof ds.Buffer) {\n this.value = this.type.from_binary(value);\n this.capacity = this.size();\n if (size !== 0) {\n throw new Error(\"Cannot set capacity when initializing from bytes.\");\n }\n } else {\n throw new Error(\"Unsupported type for initialization.\");\n }\n }\n\n /**\n * Convert the value to a string representation.\n *\n * @returns The string representation.\n * @throws {Error} If conversion fails.\n */\n toString(): string {\n const result = this.type.to_string(this.value, buffer_size());\n if (result === \"\") {\n throw new Error(\"Conversion to string failed.\");\n }\n return result;\n }\n\n /**\n * Get the binary representation of the value.\n *\n * @returns The binary data as a Buffer.\n */\n data(): dst.Buffer {\n return this.type.to_binary(this.value);\n }\n\n /**\n * Get the size of the data in bytes.\n *\n * @returns The data size.\n */\n size(): number {\n return this.value.data_size();\n }\n\n /**\n * Create a deep copy of this instance.\n *\n * @returns A new instance with cloned value.\n */\n copy(): this {\n const this_constructor = this.constructor as new (value: T, size: number) => this;\n return new this_constructor(this.value.clone() as T, this.size());\n }\n\n /**\n * Get a key representation for this value.\n * The key equality is consistent with object equality.\n *\n * @returns The string key.\n */\n key(): string {\n return this.toString();\n }\n}\n\n/**\n * Wrapper class for deductive system strings.\n * Supports initialization from strings, buffers, or other instances.\n *\n * @example\n * ```typescript\n * const str1 = new string_t(\"hello\");\n * const str2 = new string_t(str1.data()); // From binary\n * console.log(str1.toString()); // \"hello\"\n * ```\n */\nexport class string_t extends _common_t<dst.String> {\n /**\n * Creates a new string instance.\n *\n * @param value - Initial value (string, buffer, or another string_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.String>, size: number = 0) {\n super(ds.String, value, size);\n }\n}\n\n/**\n * Wrapper class for logical variables in the deductive system.\n * Variables are used in logical terms and can be unified.\n *\n * @example\n * ```typescript\n * const var1 = new variable_t(\"`X\");\n * console.log(var1.name().toString()); // \"X\"\n * ```\n */\nexport class variable_t extends _common_t<dst.Variable> {\n /**\n * Creates a new variable instance.\n *\n * @param value - Initial value (string, buffer, or another variable_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Variable>, size: number = 0) {\n super(ds.Variable, value, size);\n }\n\n /**\n * Get the name of this variable.\n *\n * @returns The variable name as a string_t.\n */\n name(): string_t {\n return new string_t(this.value.name());\n }\n}\n\n/**\n * Wrapper class for items in the deductive system.\n * Items represent constants or functors in logical terms.\n *\n * @example\n * ```typescript\n * const item = new item_t(\"atom\");\n * console.log(item.name().toString()); // \"atom\"\n * ```\n */\nexport class item_t extends _common_t<dst.Item> {\n /**\n * Creates a new item instance.\n *\n * @param value - Initial value (string, buffer, or another item_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Item>, size: number = 0) {\n super(ds.Item, value, size);\n }\n\n /**\n * Get the name of this item.\n *\n * @returns The item name as a string_t.\n */\n name(): string_t {\n return new string_t(this.value.name());\n }\n}\n\n/**\n * Wrapper class for lists in the deductive system.\n * Lists contain ordered sequences of terms.\n *\n * @example\n * ```typescript\n * const list = new list_t(\"(a b c)\");\n * console.log(list.length()); // 3\n * console.log(list.getitem(0).toString()); // \"a\"\n * ```\n */\nexport class list_t extends _common_t<dst.List> {\n /**\n * Creates a new list instance.\n *\n * @param value - Initial value (string, buffer, or another list_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.List>, size: number = 0) {\n super(ds.List, value, size);\n }\n\n /**\n * Get the number of elements in the list.\n *\n * @returns The list length.\n */\n length(): number {\n return this.value.length();\n }\n\n /**\n * Get an element from the list by index.\n *\n * @param index - The zero-based index of the element.\n * @returns The term at the specified index.\n */\n getitem(index: number): term_t {\n return new term_t(this.value.getitem(index));\n }\n}\n\n/**\n * Wrapper class for logical terms in the deductive system.\n * A term can be a variable, item, or list.\n *\n * @example\n * ```typescript\n * const term = new term_t(\"(f `x a)\");\n * const innerTerm = term.term(); // Get the underlying term type\n * ```\n */\nexport class term_t extends _common_t<dst.Term> {\n /**\n * Creates a new term instance.\n *\n * @param value - Initial value (string, buffer, or another term_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Term>, size: number = 0) {\n super(ds.Term, value, size);\n }\n\n /**\n * Extracts the underlying term and returns it as its concrete type (variable_t, item_t, or list_t).\n *\n * @returns The term as a variable_t, item_t, or list_t.\n * @throws {Error} If the term type is unexpected.\n */\n term(): variable_t | item_t | list_t {\n const term_type: dst.TermType = this.value.get_type();\n if (term_type === ds.TermType.Variable) {\n return new variable_t(this.value.variable());\n } else if (term_type === ds.TermType.Item) {\n return new item_t(this.value.item());\n } else if (term_type === ds.TermType.List) {\n return new list_t(this.value.list());\n } else {\n throw new Error(\"Unexpected term type.\");\n }\n }\n\n /**\n * Ground this term using a dictionary to substitute variables with values.\n *\n * @param other - A term representing a dictionary (list of pairs). Each pair contains a variable and its substitution value.\n * Example: \"((`a b))\" means substitute variable `a with value b.\n * @param scope - Optional scope string for variable scoping.\n * @returns The grounded term, or null if grounding fails.\n *\n * @example\n * ```typescript\n * const a = new term_t(\"`a\");\n * const b = new term_t(\"((`a b))\");\n * console.log(a.ground(b).toString()); // \"b\"\n *\n * // With scope\n * const c = new term_t(\"`a\");\n * const d = new term_t(\"((x y `a `b) (y x `b `c))\");\n * console.log(c.ground(d, \"x\").toString()); // \"`c\"\n * ```\n */\n ground(other: term_t, scope: string = \"\"): term_t | null {\n const capacity = buffer_size();\n const term = ds.Term.ground(this.value, other.value, scope, capacity);\n if (term === null) {\n return null;\n }\n return new term_t(term, capacity);\n }\n}\n\n/**\n * Wrapper class for logical rules in the deductive system.\n * A rule consists of zero or more premises (above the line) and a conclusion (below the line).\n *\n * @example\n * ```typescript\n * const rule = new rule_t(\"(father `X `Y)\\n----------\\n(parent `X `Y)\\n\");\n * console.log(rule.conclusion().toString()); // \"(parent `X `Y)\"\n * console.log(rule.length()); // 1 (number of premises)\n * ```\n */\nexport class rule_t extends _common_t<dst.Rule> {\n /**\n * Creates a new rule instance.\n *\n * @param value - Initial value (string, buffer, or another rule_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Rule>, size: number = 0) {\n super(ds.Rule, value, size);\n }\n\n /**\n * Get the number of premises in the rule.\n *\n * @returns The number of premises.\n */\n length(): number {\n return this.value.length();\n }\n\n /**\n * Get a premise term by index.\n *\n * @param index - The zero-based index of the premise.\n * @returns The premise term at the specified index.\n */\n getitem(index: number): term_t {\n return new term_t(this.value.getitem(index));\n }\n\n /**\n * Get the conclusion of the rule.\n *\n * @returns The conclusion term.\n */\n conclusion(): term_t {\n return new term_t(this.value.conclusion());\n }\n\n /**\n * Ground this rule using a dictionary to substitute variables with values.\n *\n * @param other - A rule representing a dictionary (list of pairs). Each pair contains a variable and its substitution value.\n * Example: new rule_t(\"((`a b))\") means substitute variable `a with value b.\n * @param scope - Optional scope string for variable scoping.\n * @returns The grounded rule, or null if grounding fails.\n *\n * @example\n * ```typescript\n * const a = new rule_t(\"`a\");\n * const b = new rule_t(\"((`a b))\");\n * console.log(a.ground(b).toString()); // \"----\\nb\\n\"\n *\n * // With scope\n * const c = new rule_t(\"`a\");\n * const d = new rule_t(\"((x y `a `b) (y x `b `c))\");\n * console.log(c.ground(d, \"x\").toString()); // \"----\\n`c\\n\"\n * ```\n */\n ground(other: rule_t, scope: string = \"\"): rule_t | null {\n const capacity = buffer_size();\n const rule = ds.Rule.ground(this.value, other.value, scope, capacity);\n if (rule === null) {\n return null;\n }\n return new rule_t(rule, capacity);\n }\n\n /**\n * Match this rule with another rule using unification.\n * This unifies the first premise of this rule with the other rule.\n * The other rule must be a fact (a rule without premises).\n *\n * @param other - The rule to match against (must be a fact without premises).\n * @returns The matched rule, or null if matching fails.\n *\n * @example\n * ```typescript\n * const mp = new rule_t(\"(`p -> `q)\\n`p\\n`q\\n\");\n * const pq = new rule_t(\"((! (! `x)) -> `x)\");\n * console.log(mp.match(pq).toString()); // \"(! (! `x))\\n----------\\n`x\\n\"\n * ```\n */\n match(other: rule_t): rule_t | null {\n const capacity = buffer_size();\n const rule = ds.Rule.match(this.value, other.value, capacity);\n if (rule === null) {\n return null;\n }\n return new rule_t(rule, capacity);\n }\n}\n\n/**\n * Search engine for the deductive system.\n * Manages a knowledge base of rules and performs logical inference.\n *\n * @example\n * ```typescript\n * const search = new search_t();\n * search.add(\"(parent john mary)\");\n * search.add(\"(father `X `Y)\\n----------\\n(parent `X `Y)\\n\");\n * search.execute((rule) => {\n * console.log(rule.toString());\n * return false; // Return false to continue, true to stop\n * });\n * ```\n */\nexport class search_t {\n _search: dst.Search;\n\n /**\n * Creates a new search engine instance.\n *\n * @param limit_size - Size of the buffer for storing the final objects (rules/facts) in the knowledge base (default: 1000).\n * @param buffer_size - Size of the buffer for internal operations like conversions and transformations (default: 10000).\n */\n constructor(limit_size: number = 1000, buffer_size: number = 10000) {\n this._search = new ds.Search(limit_size, buffer_size);\n }\n\n /**\n * Set the size of the buffer for storing final objects.\n *\n * @param limit_size - The new limit size for storing rules/facts.\n */\n set_limit_size(limit_size: number): void {\n this._search.set_limit_size(limit_size);\n }\n\n /**\n * Set the buffer size for internal operations.\n *\n * @param buffer_size - The new buffer size.\n */\n set_buffer_size(buffer_size: number): void {\n this._search.set_buffer_size(buffer_size);\n }\n\n /**\n * Reset the search engine, clearing all rules and facts.\n */\n reset(): void {\n this._search.reset();\n }\n\n /**\n * Add a rule or fact to the knowledge base.\n *\n * @param text - The rule or fact as a string.\n * @returns True if successfully added, false otherwise.\n */\n add(text: string): boolean {\n return this._search.add(text);\n }\n\n /**\n * Execute the search engine with a callback for each inferred rule.\n *\n * @param callback - Function called for each candidate rule. Return false to continue, true to stop.\n * @returns The number of rules processed.\n */\n execute(callback: (candidate: rule_t) => boolean): number {\n return this._search.execute((candidate: dst.Rule): boolean => {\n return callback(new rule_t(candidate).copy());\n });\n }\n}\n"],"names":["ds","create_ds","_buffer_size","buffer_size","size","old_size","_common_t","type","value","capacity","constructor","this","Error","from_string","Buffer","from_binary","toString","result","to_string","data","to_binary","data_size","copy","this_constructor","clone","key","string_t","super","String","variable_t","Variable","name","item_t","Item","list_t","List","length","getitem","index","term_t","Term","term","term_type","get_type","TermType","variable","item","list","ground","other","scope","rule_t","Rule","conclusion","rule","match","search_t","_search","limit_size","Search","set_limit_size","set_buffer_size","reset","add","text","execute","callback","candidate"],"mappings":"wBAQA,MAAMA,QAA6BC,IAEnC,IAAIC,EAAuB,KAerB,SAAUC,EAAYC,EAAe,GACvC,MAAMC,EAAWH,EAIjB,OAHa,IAATE,IACAF,EAAeE,GAEZC,CACX,CAiCA,MAAMC,EACFC,KACAC,MACAC,SAUA,WAAAC,CAAYH,EAAuBC,EAA2BJ,EAAe,GAEzE,GADAO,KAAKJ,KAAOA,EACRC,aAAiBF,GAGjB,GAFAK,KAAKH,MAAQA,EAAMA,MACnBG,KAAKF,SAAWD,EAAMC,SACT,IAATL,EACA,MAAM,IAAIQ,MAAM,gEAEjB,GAAIJ,aAAkBG,KAAKJ,KAC9BI,KAAKH,MAAQA,EACbG,KAAKF,SAAWL,OACb,GAAqB,iBAAVI,GAGd,GAFAG,KAAKF,SAAoB,IAATL,EAAaA,EAAOD,IACpCQ,KAAKH,MAAQG,KAAKJ,KAAKM,YAAYL,EAAOG,KAAKF,UAC5B,OAAfE,KAAKH,MACL,MAAM,IAAII,MAAM,4CAEjB,MAAIJ,aAAiBR,EAAGc,QAO3B,MAAM,IAAIF,MAAM,wCAJhB,GAFAD,KAAKH,MAAQG,KAAKJ,KAAKQ,YAAYP,GACnCG,KAAKF,SAAWE,KAAKP,OACR,IAATA,EACA,MAAM,IAAIQ,MAAM,oDAIxB,CACJ,CAQA,QAAAI,GACI,MAAMC,EAASN,KAAKJ,KAAKW,UAAUP,KAAKH,MAAOL,KAC/C,GAAe,KAAXc,EACA,MAAM,IAAIL,MAAM,gCAEpB,OAAOK,CACX,CAOA,IAAAE,GACI,OAAOR,KAAKJ,KAAKa,UAAUT,KAAKH,MACpC,CAOA,IAAAJ,GACI,OAAOO,KAAKH,MAAMa,WACtB,CAOA,IAAAC,GAEI,OAAO,IAAIC,EADcZ,KAAKD,aACFC,KAAKH,MAAMgB,QAAcb,KAAKP,OAC9D,CAQA,GAAAqB,GACI,OAAOd,KAA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1
+ {"version":3,"file":"tsds.mjs","sources":["../atsds/tsds.mts"],"sourcesContent":["/**\n * TypeScript wrapper for a deductive system implemented in WebAssembly.\n * Provides classes and functions for working with logical terms, rules, and inference.\n */\n\nimport create_ds from \"./ds.mjs\";\nimport type * as dst from \"./ds.d.mts\";\n\nconst ds: dst.EmbindModule = await create_ds();\n\nlet _buffer_size: number = 1024;\n\n/**\n * Gets the current buffer size, or sets a new buffer size and returns the previous value.\n * The buffer size is used for internal operations like conversions and transformations.\n *\n * @param size - The new buffer size to set. If 0 (default), the current size is returned without modification.\n * @returns The previous buffer size value.\n *\n * @example\n * ```typescript\n * const currentSize = buffer_size(); // Get current size\n * const oldSize = buffer_size(2048); // Set new size, returns old size\n * ```\n */\nexport function buffer_size(size: number = 0): number {\n const old_size = _buffer_size;\n if (size !== 0) {\n _buffer_size = size;\n }\n return old_size;\n}\n\n/**\n * Common interface for all deductive system types.\n * @internal\n */\ninterface Common {\n clone(): Common;\n data_size(): number;\n}\n\n/**\n * Static methods interface for deductive system types.\n * @internal\n */\ninterface StaticCommon<T extends Common> {\n from_binary(buffer: dst.Buffer): T;\n to_binary(value: T): dst.Buffer;\n from_string(text: string, size: number): T;\n to_string(value: T, size: number): string;\n}\n\n/**\n * Valid initialization arguments for deductive system types.\n * @internal\n */\ntype InitialArgument<T extends Common> = _common_t<T> | T | string | dst.Buffer | null;\n\n/**\n * Base class for all deductive system wrapper types.\n * Handles initialization, serialization, and common operations.\n * @internal\n */\nclass _common_t<T extends Common> {\n type: StaticCommon<T>;\n value: T;\n capacity: number;\n\n /**\n * Creates a new instance.\n *\n * @param type - The static type interface for this common type.\n * @param value - Initial value (can be another instance, base value, string, or buffer).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails or invalid arguments are provided.\n */\n constructor(type: StaticCommon<T>, value: InitialArgument<T>, size: number = 0) {\n this.type = type;\n if (value instanceof _common_t) {\n this.value = value.value;\n this.capacity = value.capacity;\n if (size !== 0) {\n throw new Error(\"Cannot set capacity when copying from another instance.\");\n }\n } else if (value instanceof (this.type as unknown as new () => T)) {\n this.value = value;\n this.capacity = size;\n } else if (typeof value === \"string\") {\n this.capacity = size !== 0 ? size : buffer_size();\n this.value = this.type.from_string(value, this.capacity);\n if (this.value === null) {\n throw new Error(\"Initialization from a string failed.\");\n }\n } else if (value instanceof ds.Buffer) {\n this.value = this.type.from_binary(value);\n this.capacity = this.size();\n if (size !== 0) {\n throw new Error(\"Cannot set capacity when initializing from bytes.\");\n }\n } else {\n throw new Error(\"Unsupported type for initialization.\");\n }\n }\n\n /**\n * Convert the value to a string representation.\n *\n * @returns The string representation.\n * @throws {Error} If conversion fails.\n */\n toString(): string {\n const result = this.type.to_string(this.value, buffer_size());\n if (result === \"\") {\n throw new Error(\"Conversion to string failed.\");\n }\n return result;\n }\n\n /**\n * Get the binary representation of the value.\n *\n * @returns The binary data as a Buffer.\n */\n data(): dst.Buffer {\n return this.type.to_binary(this.value);\n }\n\n /**\n * Get the size of the data in bytes.\n *\n * @returns The data size.\n */\n size(): number {\n return this.value.data_size();\n }\n\n /**\n * Create a deep copy of this instance.\n *\n * @returns A new instance with cloned value.\n */\n copy(): this {\n const this_constructor = this.constructor as new (value: T, size: number) => this;\n return new this_constructor(this.value.clone() as T, this.size());\n }\n\n /**\n * Get a key representation for this value.\n * The key equality is consistent with object equality.\n *\n * @returns The string key.\n */\n key(): string {\n return this.toString();\n }\n}\n\n/**\n * Wrapper class for deductive system strings.\n * Supports initialization from strings, buffers, or other instances.\n *\n * @example\n * ```typescript\n * const str1 = new string_t(\"hello\");\n * const str2 = new string_t(str1.data()); // From binary\n * console.log(str1.toString()); // \"hello\"\n * ```\n */\nexport class string_t extends _common_t<dst.String> {\n /**\n * Creates a new string instance.\n *\n * @param value - Initial value (string, buffer, or another string_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.String>, size: number = 0) {\n super(ds.String, value, size);\n }\n}\n\n/**\n * Wrapper class for logical variables in the deductive system.\n * Variables are used in logical terms and can be unified.\n *\n * @example\n * ```typescript\n * const var1 = new variable_t(\"`X\");\n * console.log(var1.name().toString()); // \"X\"\n * ```\n */\nexport class variable_t extends _common_t<dst.Variable> {\n /**\n * Creates a new variable instance.\n *\n * @param value - Initial value (string, buffer, or another variable_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Variable>, size: number = 0) {\n super(ds.Variable, value, size);\n }\n\n /**\n * Get the name of this variable.\n *\n * @returns The variable name as a string_t.\n */\n name(): string_t {\n return new string_t(this.value.name());\n }\n}\n\n/**\n * Wrapper class for items in the deductive system.\n * Items represent constants or functors in logical terms.\n *\n * @example\n * ```typescript\n * const item = new item_t(\"atom\");\n * console.log(item.name().toString()); // \"atom\"\n * ```\n */\nexport class item_t extends _common_t<dst.Item> {\n /**\n * Creates a new item instance.\n *\n * @param value - Initial value (string, buffer, or another item_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Item>, size: number = 0) {\n super(ds.Item, value, size);\n }\n\n /**\n * Get the name of this item.\n *\n * @returns The item name as a string_t.\n */\n name(): string_t {\n return new string_t(this.value.name());\n }\n}\n\n/**\n * Wrapper class for lists in the deductive system.\n * Lists contain ordered sequences of terms.\n *\n * @example\n * ```typescript\n * const list = new list_t(\"(a b c)\");\n * console.log(list.length()); // 3\n * console.log(list.getitem(0).toString()); // \"a\"\n * ```\n */\nexport class list_t extends _common_t<dst.List> {\n /**\n * Creates a new list instance.\n *\n * @param value - Initial value (string, buffer, or another list_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.List>, size: number = 0) {\n super(ds.List, value, size);\n }\n\n /**\n * Get the number of elements in the list.\n *\n * @returns The list length.\n */\n length(): number {\n return this.value.length();\n }\n\n /**\n * Get an element from the list by index.\n *\n * @param index - The zero-based index of the element.\n * @returns The term at the specified index.\n */\n getitem(index: number): term_t {\n return new term_t(this.value.getitem(index));\n }\n}\n\n/**\n * Wrapper class for logical terms in the deductive system.\n * A term can be a variable, item, or list.\n *\n * @example\n * ```typescript\n * const term = new term_t(\"(f `x a)\");\n * const innerTerm = term.term(); // Get the underlying term type\n * ```\n */\nexport class term_t extends _common_t<dst.Term> {\n /**\n * Creates a new term instance.\n *\n * @param value - Initial value (string, buffer, or another term_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Term>, size: number = 0) {\n super(ds.Term, value, size);\n }\n\n /**\n * Extracts the underlying term and returns it as its concrete type (variable_t, item_t, or list_t).\n *\n * @returns The term as a variable_t, item_t, or list_t.\n * @throws {Error} If the term type is unexpected.\n */\n term(): variable_t | item_t | list_t {\n const term_type: dst.TermType = this.value.get_type();\n if (term_type === ds.TermType.Variable) {\n return new variable_t(this.value.variable());\n } else if (term_type === ds.TermType.Item) {\n return new item_t(this.value.item());\n } else if (term_type === ds.TermType.List) {\n return new list_t(this.value.list());\n } else {\n throw new Error(\"Unexpected term type.\");\n }\n }\n\n /**\n * Ground this term using a dictionary to substitute variables with values.\n *\n * @param other - A term representing a dictionary (list of pairs). Each pair contains a variable and its substitution value.\n * Example: \"((`a b))\" means substitute variable `a with value b.\n * @param scope - Optional scope string for variable scoping.\n * @returns The grounded term, or null if grounding fails.\n *\n * @example\n * ```typescript\n * const a = new term_t(\"`a\");\n * const b = new term_t(\"((`a b))\");\n * console.log(a.ground(b).toString()); // \"b\"\n *\n * // With scope\n * const c = new term_t(\"`a\");\n * const d = new term_t(\"((x y `a `b) (y x `b `c))\");\n * console.log(c.ground(d, \"x\").toString()); // \"`c\"\n * ```\n */\n ground(other: term_t, scope: string = \"\"): term_t | null {\n const capacity = buffer_size();\n const term = ds.Term.ground(this.value, other.value, scope, capacity);\n if (term === null) {\n return null;\n }\n return new term_t(term, capacity);\n }\n\n /**\n * Rename all variables in this term by adding prefix and suffix.\n *\n * @param prefix_and_suffix - A term representing a list with two inner lists.\n * Each inner list contains 0 or 1 item representing the prefix and suffix.\n * Example: \"((pre_) (_suf))\" adds \"pre_\" as prefix and \"_suf\" as suffix.\n * @returns The renamed term, or null if renaming fails.\n *\n * @example\n * ```typescript\n * const a = new term_t(\"`x\");\n * const b = new term_t(\"((pre_) (_suf))\");\n * console.log(a.rename(b).toString()); // \"`pre_x_suf\"\n *\n * // With empty prefix (only suffix)\n * const c = new term_t(\"`x\");\n * const d = new term_t(\"(() (_suf))\");\n * console.log(c.rename(d).toString()); // \"`x_suf\"\n * ```\n */\n rename(prefix_and_suffix: term_t): term_t | null {\n const capacity = buffer_size();\n const term = ds.Term.rename(this.value, prefix_and_suffix.value, capacity);\n if (term === null) {\n return null;\n }\n return new term_t(term, capacity);\n }\n}\n\n/**\n * Wrapper class for logical rules in the deductive system.\n * A rule consists of zero or more premises (above the line) and a conclusion (below the line).\n *\n * @example\n * ```typescript\n * const rule = new rule_t(\"(father `X `Y)\\n----------\\n(parent `X `Y)\\n\");\n * console.log(rule.conclusion().toString()); // \"(parent `X `Y)\"\n * console.log(rule.length()); // 1 (number of premises)\n * ```\n */\nexport class rule_t extends _common_t<dst.Rule> {\n /**\n * Creates a new rule instance.\n *\n * @param value - Initial value (string, buffer, or another rule_t).\n * @param size - Optional buffer capacity for the internal storage.\n * @throws {Error} If initialization fails.\n */\n constructor(value: InitialArgument<dst.Rule>, size: number = 0) {\n super(ds.Rule, value, size);\n }\n\n /**\n * Get the number of premises in the rule.\n *\n * @returns The number of premises.\n */\n length(): number {\n return this.value.length();\n }\n\n /**\n * Get a premise term by index.\n *\n * @param index - The zero-based index of the premise.\n * @returns The premise term at the specified index.\n */\n getitem(index: number): term_t {\n return new term_t(this.value.getitem(index));\n }\n\n /**\n * Get the conclusion of the rule.\n *\n * @returns The conclusion term.\n */\n conclusion(): term_t {\n return new term_t(this.value.conclusion());\n }\n\n /**\n * Ground this rule using a dictionary to substitute variables with values.\n *\n * @param other - A rule representing a dictionary (list of pairs). Each pair contains a variable and its substitution value.\n * Example: new rule_t(\"((`a b))\") means substitute variable `a with value b.\n * @param scope - Optional scope string for variable scoping.\n * @returns The grounded rule, or null if grounding fails.\n *\n * @example\n * ```typescript\n * const a = new rule_t(\"`a\");\n * const b = new rule_t(\"((`a b))\");\n * console.log(a.ground(b).toString()); // \"----\\nb\\n\"\n *\n * // With scope\n * const c = new rule_t(\"`a\");\n * const d = new rule_t(\"((x y `a `b) (y x `b `c))\");\n * console.log(c.ground(d, \"x\").toString()); // \"----\\n`c\\n\"\n * ```\n */\n ground(other: rule_t, scope: string = \"\"): rule_t | null {\n const capacity = buffer_size();\n const rule = ds.Rule.ground(this.value, other.value, scope, capacity);\n if (rule === null) {\n return null;\n }\n return new rule_t(rule, capacity);\n }\n\n /**\n * Match this rule with another rule using unification.\n * This unifies the first premise of this rule with the other rule.\n * The other rule must be a fact (a rule without premises).\n *\n * @param other - The rule to match against (must be a fact without premises).\n * @returns The matched rule, or null if matching fails.\n *\n * @example\n * ```typescript\n * const mp = new rule_t(\"(`p -> `q)\\n`p\\n`q\\n\");\n * const pq = new rule_t(\"((! (! `x)) -> `x)\");\n * console.log(mp.match(pq).toString()); // \"(! (! `x))\\n----------\\n`x\\n\"\n * ```\n */\n match(other: rule_t): rule_t | null {\n const capacity = buffer_size();\n const rule = ds.Rule.match(this.value, other.value, capacity);\n if (rule === null) {\n return null;\n }\n return new rule_t(rule, capacity);\n }\n\n /**\n * Rename all variables in this rule by adding prefix and suffix.\n *\n * @param prefix_and_suffix - A rule with only a conclusion that is a list with two inner lists.\n * Each inner list contains 0 or 1 item representing the prefix and suffix.\n * Example: \"((pre_) (_suf))\" adds \"pre_\" as prefix and \"_suf\" as suffix.\n * @returns The renamed rule, or null if renaming fails.\n *\n * @example\n * ```typescript\n * const a = new rule_t(\"`x\");\n * const b = new rule_t(\"((pre_) (_suf))\");\n * console.log(a.rename(b).toString()); // \"----\\n`pre_x_suf\\n\"\n *\n * // With empty prefix (only suffix)\n * const c = new rule_t(\"`x\");\n * const d = new rule_t(\"(() (_suf))\");\n * console.log(c.rename(d).toString()); // \"----\\n`x_suf\\n\"\n * ```\n */\n rename(prefix_and_suffix: rule_t): rule_t | null {\n const capacity = buffer_size();\n const rule = ds.Rule.rename(this.value, prefix_and_suffix.value, capacity);\n if (rule === null) {\n return null;\n }\n return new rule_t(rule, capacity);\n }\n}\n\n/**\n * Search engine for the deductive system.\n * Manages a knowledge base of rules and performs logical inference.\n *\n * @example\n * ```typescript\n * const search = new search_t();\n * search.add(\"(parent john mary)\");\n * search.add(\"(father `X `Y)\\n----------\\n(parent `X `Y)\\n\");\n * search.execute((rule) => {\n * console.log(rule.toString());\n * return false; // Return false to continue, true to stop\n * });\n * ```\n */\nexport class search_t {\n _search: dst.Search;\n\n /**\n * Creates a new search engine instance.\n *\n * @param limit_size - Size of the buffer for storing the final objects (rules/facts) in the knowledge base (default: 1000).\n * @param buffer_size - Size of the buffer for internal operations like conversions and transformations (default: 10000).\n */\n constructor(limit_size: number = 1000, buffer_size: number = 10000) {\n this._search = new ds.Search(limit_size, buffer_size);\n }\n\n /**\n * Set the size of the buffer for storing final objects.\n *\n * @param limit_size - The new limit size for storing rules/facts.\n */\n set_limit_size(limit_size: number): void {\n this._search.set_limit_size(limit_size);\n }\n\n /**\n * Set the buffer size for internal operations.\n *\n * @param buffer_size - The new buffer size.\n */\n set_buffer_size(buffer_size: number): void {\n this._search.set_buffer_size(buffer_size);\n }\n\n /**\n * Reset the search engine, clearing all rules and facts.\n */\n reset(): void {\n this._search.reset();\n }\n\n /**\n * Add a rule or fact to the knowledge base.\n *\n * @param text - The rule or fact as a string.\n * @returns True if successfully added, false otherwise.\n */\n add(text: string): boolean {\n return this._search.add(text);\n }\n\n /**\n * Execute the search engine with a callback for each inferred rule.\n *\n * @param callback - Function called for each candidate rule. Return false to continue, true to stop.\n * @returns The number of rules processed.\n */\n execute(callback: (candidate: rule_t) => boolean): number {\n return this._search.execute((candidate: dst.Rule): boolean => {\n return callback(new rule_t(candidate).copy());\n });\n }\n}\n"],"names":["ds","create_ds","_buffer_size","buffer_size","size","old_size","_common_t","type","value","capacity","constructor","this","Error","from_string","Buffer","from_binary","toString","result","to_string","data","to_binary","data_size","copy","this_constructor","clone","key","string_t","super","String","variable_t","Variable","name","item_t","Item","list_t","List","length","getitem","index","term_t","Term","term","term_type","get_type","TermType","variable","item","list","ground","other","scope","rename","prefix_and_suffix","rule_t","Rule","conclusion","rule","match","search_t","_search","limit_size","Search","set_limit_size","set_buffer_size","reset","add","text","execute","callback","candidate"],"mappings":"wBAQA,MAAMA,QAA6BC,IAEnC,IAAIC,EAAuB,KAerB,SAAUC,EAAYC,EAAe,GACvC,MAAMC,EAAWH,EAIjB,OAHa,IAATE,IACAF,EAAeE,GAEZC,CACX,CAiCA,MAAMC,EACFC,KACAC,MACAC,SAUA,WAAAC,CAAYH,EAAuBC,EAA2BJ,EAAe,GAEzE,GADAO,KAAKJ,KAAOA,EACRC,aAAiBF,GAGjB,GAFAK,KAAKH,MAAQA,EAAMA,MACnBG,KAAKF,SAAWD,EAAMC,SACT,IAATL,EACA,MAAM,IAAIQ,MAAM,gEAEjB,GAAIJ,aAAkBG,KAAKJ,KAC9BI,KAAKH,MAAQA,EACbG,KAAKF,SAAWL,OACb,GAAqB,iBAAVI,GAGd,GAFAG,KAAKF,SAAoB,IAATL,EAAaA,EAAOD,IACpCQ,KAAKH,MAAQG,KAAKJ,KAAKM,YAAYL,EAAOG,KAAKF,UAC5B,OAAfE,KAAKH,MACL,MAAM,IAAII,MAAM,4CAEjB,MAAIJ,aAAiBR,EAAGc,QAO3B,MAAM,IAAIF,MAAM,wCAJhB,GAFAD,KAAKH,MAAQG,KAAKJ,KAAKQ,YAAYP,GACnCG,KAAKF,SAAWE,KAAKP,OACR,IAATA,EACA,MAAM,IAAIQ,MAAM,oDAIxB,CACJ,CAQA,QAAAI,GACI,MAAMC,EAASN,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