@hzhangxyz/ddss 0.0.9 → 0.0.11
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/README.md +144 -0
- package/dist/index.js +618 -0
- package/package.json +22 -21
- package/dist/main.js +0 -58
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Distributed Deductive System Sorts (DDSS)
|
|
2
|
+
|
|
3
|
+
DDSS is a distributed deductive system with a scalable architecture. It currently supports distributed engines including forward-chaining, E-graph, and more.
|
|
4
|
+
|
|
5
|
+
## Design Philosophy
|
|
6
|
+
|
|
7
|
+
DDSS adopts a modular architecture that decomposes the deductive system into independent but collaborative sub-systems:
|
|
8
|
+
|
|
9
|
+
1. **Separation of Concerns**: Each module focuses on a specific reasoning task
|
|
10
|
+
2. **Concurrent Execution**: All modules collaborate asynchronously through a shared database, fully utilizing system resources
|
|
11
|
+
3. **Persistent Storage**: Uses a database to store facts and ideas, ensuring data consistency
|
|
12
|
+
|
|
13
|
+
The system uses a database as the central hub, with two tables (`facts` and `ideas`) for interaction between sub-systems:
|
|
14
|
+
|
|
15
|
+
- **Eager engines** (e.g., forward-chaining): Read facts and eagerly produce new facts. They also add ideas to broadcast "I want this XXX" - indicating what new facts they need to produce more results.
|
|
16
|
+
|
|
17
|
+
- **Lazy engines** (e.g., E-graph): Could produce too many facts if eager, so they quietly accept facts without producing many. They only produce facts when they see ideas from other engines that they can (partially) fulfill.
|
|
18
|
+
|
|
19
|
+
## Modules
|
|
20
|
+
|
|
21
|
+
- **Input** (`ddss/input.py`): Interactive input interface with BNF syntax parsing
|
|
22
|
+
- **Output** (`ddss/output.py`): Real-time display of facts and ideas from the database
|
|
23
|
+
- **Load** (`ddss/load.py`): Batch import of facts from standard input
|
|
24
|
+
- **Dump** (`ddss/dump.py`): Export all facts and ideas to output
|
|
25
|
+
- **DS** (`ddss/ds.py`): Forward-chaining deductive search engine
|
|
26
|
+
- **Egg** (`ddss/egg.py`): E-graph based equality reasoning engine
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
### Using uvx (Recommended)
|
|
31
|
+
|
|
32
|
+
The simplest way is to run with `uvx`:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uvx ddss
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This automatically installs all dependencies and starts the DDSS system.
|
|
39
|
+
|
|
40
|
+
### Using pip
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install ddss
|
|
44
|
+
ddss
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### Basic Usage
|
|
50
|
+
|
|
51
|
+
Run DDSS with a temporary SQLite database:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
ddss
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Specifying a Database
|
|
58
|
+
|
|
59
|
+
DDSS supports multiple database backends using the `-a` or `--addr` option:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# SQLite (persistent)
|
|
63
|
+
ddss --addr sqlite:///path/to/database.db
|
|
64
|
+
|
|
65
|
+
# MySQL
|
|
66
|
+
ddss --addr mysql://user:password@host:port/database
|
|
67
|
+
|
|
68
|
+
# MariaDB
|
|
69
|
+
ddss --addr mariadb://user:password@host:port/database
|
|
70
|
+
|
|
71
|
+
# PostgreSQL
|
|
72
|
+
ddss --addr postgresql://user:password@host:port/database
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Selecting Components
|
|
76
|
+
|
|
77
|
+
By default, DDSS runs with all interactive components (`input`, `output`, `ds`, `egg`). You can select specific components using the `-c` or `--component` option:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Run only input and output (no inference engines)
|
|
81
|
+
ddss --component input output
|
|
82
|
+
|
|
83
|
+
# Run with only the forward-chaining engine
|
|
84
|
+
ddss --component input output ds
|
|
85
|
+
|
|
86
|
+
# Run with only the E-graph engine
|
|
87
|
+
ddss --component input output egg
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Available components:
|
|
91
|
+
- `input`: Interactive input interface
|
|
92
|
+
- `output`: Real-time display of facts and ideas
|
|
93
|
+
- `ds`: Forward-chaining deductive search engine
|
|
94
|
+
- `egg`: E-graph based equality reasoning engine
|
|
95
|
+
- `load`: Batch import facts from standard input
|
|
96
|
+
- `dump`: Export all facts and ideas to output
|
|
97
|
+
|
|
98
|
+
### Interactive Usage
|
|
99
|
+
|
|
100
|
+
After starting, input facts and rules at the `input:` prompt. The syntax follows the format `premise => conclusion`:
|
|
101
|
+
|
|
102
|
+
**Example 1: Simple Inference**
|
|
103
|
+
|
|
104
|
+
Input a fact stating `a` is true:
|
|
105
|
+
```
|
|
106
|
+
input: => a
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Input a rule stating if `a` then `b`:
|
|
110
|
+
```
|
|
111
|
+
input: a => b
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The system automatically derives and displays `=> b`:
|
|
115
|
+
```
|
|
116
|
+
fact: => b
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Example 2: Equality Reasoning**
|
|
120
|
+
|
|
121
|
+
Input an equality relation `a == b`:
|
|
122
|
+
```
|
|
123
|
+
input: => a == b
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Input an idea for `b == a` by creating a rule that requires it:
|
|
127
|
+
```
|
|
128
|
+
input: b == a => target
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The system will derive both the idea and facts:
|
|
132
|
+
```
|
|
133
|
+
idea: => b == a
|
|
134
|
+
fact: => b == a
|
|
135
|
+
fact: => target
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
This project is licensed under the GNU Affero General Public License v3.0 or later. See [LICENSE.md](LICENSE.md) for details.
|
|
141
|
+
|
|
142
|
+
## Links
|
|
143
|
+
|
|
144
|
+
- GitHub: https://github.com/USTC-KnowledgeComputingLab/ddss
|