Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The system consists of the following modules, implemented symmetrically in `ddss
- **Output** (`ddss/output.py`, `ddss/output.ts`): Real-time display of facts and ideas from the database
- **Load** (`ddss/load.py`, `ddss/load.ts`): Batch import of facts from standard input
- **Dump** (`ddss/dump.py`, `ddss/dump.ts`): Export all facts and ideas to output
- **DS** (`ddss/ds.py`, `ddss/ds.ts`): Forward-chaining deductive search engine
- **Search** (`ddss/search.py`, `ddss/search.ts`): Forward-chaining deductive search engine
- **Egg** (`ddss/egg.py`, `ddss/egg.ts`): E-graph based equality reasoning engine

## Installation
Expand Down Expand Up @@ -89,14 +89,14 @@ ddss --addr postgresql://user:password@host:port/database

### Selecting Components

By default, DDSS runs with all interactive components (`input`, `output`, `ds`, `egg`). You can select specific components using the `-c` or `--component` option:
By default, DDSS runs with all interactive components (`input`, `output`, `search`, `egg`). You can select specific components using the `-c` or `--component` option:

```bash
# Run only input and output (no inference engines)
ddss --component input output

# Run with only the forward-chaining engine
ddss --component input output ds
ddss --component input output search

# Run with only the E-graph engine
ddss --component input output egg
Expand All @@ -105,7 +105,7 @@ ddss --component input output egg
Available components:
- `input`: Interactive input interface
- `output`: Real-time display of facts and ideas
- `ds`: Forward-chaining deductive search engine
- `search`: Forward-chaining deductive search engine
- `egg`: E-graph based equality reasoning engine
- `load`: Batch import facts from standard input
- `dump`: Export all facts and ideas to output
Expand Down
6 changes: 3 additions & 3 deletions ddss/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from typing import Annotated, Optional
import tyro
from .orm import initialize_database
from .ds import main as ds
from .search import main as search
from .egg import main as egg
from .input import main as input
from .output import main as output
from .load import main as load
from .dump import main as dump

component_map = {
"ds": ds,
"search": search,
"egg": egg,
"input": input,
"output": output,
Expand Down Expand Up @@ -63,7 +63,7 @@ def main(
aliases=["-c"],
help="Components to run.",
),
] = ["input", "output", "ds", "egg"],
] = ["input", "output", "search", "egg"],
) -> None:
"""DDSS - Distributed Deductive System Sorts: Run DDSS with an interactive deductive environment."""
if addr is None:
Expand Down
6 changes: 3 additions & 3 deletions ddss/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as os from "node:os";
import * as path from "node:path";
import { Command } from "commander";
import type { Sequelize } from "sequelize";
import { main as ds } from "./ds.ts";
import { main as search } from "./search.ts";
import { main as dump } from "./dump.ts";
import { main as egg } from "./egg.ts";
import { main as input } from "./input.ts";
Expand All @@ -14,7 +14,7 @@ import { initializeDatabase } from "./orm.ts";
type ComponentMain = (addr: string, sequelize: Sequelize) => Promise<void>;

const componentMap: Record<string, ComponentMain> = {
ds,
search,
egg,
Comment on lines 14 to 18

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

componentMap is typed as (addr: string, sequelize: Sequelize) => Promise<void>, but several component main functions (including the newly mapped search) are declared as main(sequelize: Sequelize). Since run() calls component(addr, sequelize), the first argument passed will be the address string, not a Sequelize instance. Consider standardizing component signatures to (addr, sequelize) (even if addr is unused) or adjusting run()/ComponentMain so the call order matches the actual function signatures.

Copilot uses AI. Check for mistakes.
input,
output,
Expand Down Expand Up @@ -49,7 +49,7 @@ export function cli() {
.name("ddss")
.description("DDSS - Distributed Deductive System Sorts: Run DDSS with an interactive deductive environment.")
.option("-a, --addr <url>", "Database address URL. If not provided, uses a temporary SQLite database.")
.option("-c, --component <names...>", "Components to run.", ["input", "output", "ds", "egg"])
.option("-c, --component <names...>", "Components to run.", ["input", "output", "search", "egg"])
.action(async (options) => {
let addr = options.addr;
let tmpDir: string | undefined;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/en/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ The system consists of the following modules, implemented symmetrically in `ddss
- **Output** (`ddss/output.py`, `ddss/output.ts`): Real-time display of facts and ideas from the database
- **Load** (`ddss/load.py`, `ddss/load.ts`): Batch import of facts from standard input
- **Dump** (`ddss/dump.py`, `ddss/dump.ts`): Export all facts and ideas to output
- **DS** (`ddss/ds.py`, `ddss/ds.ts`): Forward-chaining deductive search engine
- **Search** (`ddss/search.py`, `ddss/search.ts`): Forward-chaining deductive search engine
- **Egg** (`ddss/egg.py`, `ddss/egg.ts`): E-graph based equality reasoning engine
6 changes: 3 additions & 3 deletions docs/en/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ ddss --addr postgresql://user:password@host:port/database

## Selecting Components

By default, DDSS runs with all interactive components (`input`, `output`, `ds`, `egg`). You can select specific components using the `-c` or `--component` option:
By default, DDSS runs with all interactive components (`input`, `output`, `search`, `egg`). You can select specific components using the `-c` or `--component` option:

```bash
# Run only input and output (no inference engines)
ddss --component input output

# Run with only the forward-chaining engine
ddss --component input output ds
ddss --component input output search

# Run with only the E-graph engine
ddss --component input output egg
Expand All @@ -46,7 +46,7 @@ ddss --component input output egg
Available components:
- `input`: Interactive input interface
- `output`: Real-time display of facts and ideas
- `ds`: Forward-chaining deductive search engine
- `search`: Forward-chaining deductive search engine
- `egg`: E-graph based equality reasoning engine
- `load`: Batch import facts from standard input
- `dump`: Export all facts and ideas to output
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
- **Output** (`ddss/output.py`, `ddss/output.ts`):实时显示数据库中的事实和想法。
- **Load** (`ddss/load.py`, `ddss/load.ts`):从标准输入批量导入事实。
- **Dump** (`ddss/dump.py`, `ddss/dump.ts`):将所有事实和想法导出到输出。
- **DS** (`ddss/ds.py`, `ddss/ds.ts`):前向链接演绎搜索引擎。
- **Search** (`ddss/search.py`, `ddss/search.ts`):前向链接演绎搜索引擎。
- **Egg** (`ddss/egg.py`, `ddss/egg.ts`):基于 E-graph 的等式推理引擎。
6 changes: 3 additions & 3 deletions docs/zh/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ ddss --addr postgresql://user:password@host:port/database

## 选择组件

默认情况下,DDSS 运行所有交互式组件(`input`, `output`, `ds`, `egg`)。您可以使用 `-c` 或 `--component` 选项选择特定组件:
默认情况下,DDSS 运行所有交互式组件(`input`, `output`, `search`, `egg`)。您可以使用 `-c` 或 `--component` 选项选择特定组件:

```bash
# 仅运行输入和输出(无推理引擎)
ddss --component input output

# 仅运行前向链接引擎
ddss --component input output ds
ddss --component input output search

# 仅运行 E-graph 引擎
ddss --component input output egg
Expand All @@ -46,7 +46,7 @@ ddss --component input output egg
可用组件:
- `input`: 交互式输入接口
- `output`: 实时显示事实和想法
- `ds`: 前向链接演绎搜索引擎
- `search`: 前向链接演绎搜索引擎
- `egg`: 基于 E-graph 的等式推理引擎
- `load`: 批量导入事实
- `dump`: 导出所有事实和想法
Expand Down
16 changes: 8 additions & 8 deletions tests/test_ds.py → tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest_asyncio
from sqlalchemy import select
from ddss.orm import initialize_database, Facts, Ideas
from ddss.ds import main
from ddss.search import main


@pytest_asyncio.fixture
Expand All @@ -20,7 +20,7 @@ async def temp_db():


@pytest.mark.asyncio
async def test_ds_simple_modus_ponens(temp_db):
async def test_search_simple_modus_ponens(temp_db):
"""Test simple modus ponens: 'a => b' with '=> a' produces '=> b'."""
addr, engine, session = temp_db

Expand Down Expand Up @@ -48,7 +48,7 @@ async def test_ds_simple_modus_ponens(temp_db):


@pytest.mark.asyncio
async def test_ds_multi_premise_with_idea(temp_db):
async def test_search_multi_premise_with_idea(temp_db):
"""Test multi-premise rule: 'a, b => c' with '=> a' produces 'b => c' and idea '=> b'."""
addr, engine, session = temp_db

Expand Down Expand Up @@ -83,7 +83,7 @@ async def test_ds_multi_premise_with_idea(temp_db):


@pytest.mark.asyncio
async def test_ds_no_inference_without_matching_facts(temp_db):
async def test_search_no_inference_without_matching_facts(temp_db):
"""Test that no inference occurs when facts don't match."""
addr, engine, session = temp_db

Expand Down Expand Up @@ -114,7 +114,7 @@ async def test_ds_no_inference_without_matching_facts(temp_db):


@pytest.mark.asyncio
async def test_ds_multiple_inferences(temp_db):
async def test_search_multiple_inferences(temp_db):
"""Test multiple inference steps in sequence."""
addr, engine, session = temp_db

Expand Down Expand Up @@ -144,8 +144,8 @@ async def test_ds_multiple_inferences(temp_db):


@pytest.mark.asyncio
async def test_ds_cancellation(temp_db):
"""Test that the ds main function can be cancelled without hanging."""
async def test_search_cancellation(temp_db):
"""Test that the search main function can be cancelled without hanging."""
addr, engine, session = temp_db

# Run the main function and cancel it
Expand All @@ -161,7 +161,7 @@ async def test_ds_cancellation(temp_db):


@pytest.mark.asyncio
async def test_ds_duplicate_facts_not_added(temp_db):
async def test_search_duplicate_facts_not_added(temp_db):
"""Test that duplicate facts are not added to the database."""
addr, engine, session = temp_db

Expand Down
14 changes: 7 additions & 7 deletions tests/test_ds.ts → tests/test_search.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { jest, describe, it, expect, beforeEach, afterEach } from "@jest/globals";
import { main } from "../ddss/ds.ts";
import { main } from "../ddss/search.ts";
import { Fact, Idea } from "../ddss/orm.ts";
import { createTempDb } from "./utils.ts";

describe("ds", () => {
describe("search", () => {
let sequelize: any;
let cleanup: any;
let addr: string;
Expand Down Expand Up @@ -52,7 +52,7 @@ describe("ds", () => {
}
};

it("test_ds_simple_modus_ponens", async () => {
it("test_search_simple_modus_ponens", async () => {
// Add initial facts: a => b and => a
await Fact.bulkCreate([{ data: "a\n----\nb\n" }, { data: "----\na\n" }]);

Expand All @@ -63,7 +63,7 @@ describe("ds", () => {
expect(factsData).toContain("----\nb\n");
});

it("test_ds_multi_premise_with_idea", async () => {
it("test_search_multi_premise_with_idea", async () => {
// Add initial facts: a, b => c and => a
await Fact.bulkCreate([{ data: "a\nb\n----\nc\n" }, { data: "----\na\n" }]);

Expand All @@ -78,7 +78,7 @@ describe("ds", () => {
expect(ideasData).toContain("----\nb\n");
});

it("test_ds_no_inference_without_matching_facts", async () => {
it("test_search_no_inference_without_matching_facts", async () => {
// Add facts that don't match: a => b and => c
await Fact.bulkCreate([{ data: "a\n----\nb\n" }, { data: "----\nc\n" }]);

Expand All @@ -92,7 +92,7 @@ describe("ds", () => {
expect(factsData).toContain("----\nc\n");
});

it("test_ds_multiple_inferences", async () => {
it("test_search_multiple_inferences", async () => {
// Add facts for chained inference: a => b, b => c, => a
await Fact.bulkCreate([{ data: "a\n----\nb\n" }, { data: "b\n----\nc\n" }, { data: "----\na\n" }]);

Expand All @@ -105,7 +105,7 @@ describe("ds", () => {
expect(factsData).toContain("----\nc\n");
});

it("test_ds_duplicate_facts_not_added", async () => {
it("test_search_duplicate_facts_not_added", async () => {
// Add facts that will produce a duplicate: a => b twice with => a
// "a\n----\nc\n" and "b\n----\nc\n" (Wait, python test says a=>b twice?
// No, Python test says:
Expand Down
Loading