--- language: - en license: other license_name: undecided license_link: LICENSE pretty_name: Causal Graph size_categories: - 1K 2000 * (1 + 0.04 / 1) ^ (1 * 8) = 2737.14 Result: Future value = 2,737.14, Interest earned = 737.14 Assumes: fixed rate; equal compounding periods; no deposits, withdrawals or fees. ``` ## How an answer is produced 1. **Extract.** Numbers in the question are linked to named variables by nearby labels and compatible units. Links are one-to-one. Explicit `name=value` pairs always take precedence, so they are the most reliable way to state inputs. 2. **Retrieve.** Formulas, concepts and processes are scored on alias phrases, word and character n-grams, lexicon features, a two-hop graph spread and input availability. Weights live in `kb/config.json`. 3. **Choose.** A formula is used only if it scores at least 0.8 of the best match. Anything below an absolute threshold of 0.12 is not shown, and the engine abstains. 4. **Re-read.** Inputs are extracted again with the chosen formula in view. If an output is given and one input is missing, the formula is solved for that input and the answer says so. 5. **Compute.** Formulas run through a whitelisted evaluator with guards. Producers run before consumers. Values that disagree by more than 1% with stated figures are flagged. 6. **Report.** The answer lists what was read, each formula's steps and assumptions, plans for formulas that cannot run ("To use X, I still need ..."), applicable rules, and the matching concept with a pitfall. ## Knowledge base format All knowledge is JSON under `kb/`, loaded strictly: unknown keys and duplicate IDs are errors. | Folder | Item | Key fields | |---|---|---| | `kb/variables/` | Quantity | `id`, `name`, `kind`, `unit`, `base`, `aliases`, `weak`, `unit_only_ok`, `phrases` | | `kb/formulas/` | Formula | `id`, `name`, `domain`, `aliases`, `concepts`, `features`, `inputs`, `defaults`, `steps`, `outputs`, `guards`, `decisions`, `assumptions`, `examples` | | `kb/concepts/` | Concept | `id`, `name`, `domain`, `aliases`, `features`, `statements`, `pitfalls`, `actions`, `causes`, `uses`, `related`, `contrast` | | `kb/processes.json` | Process | `id`, `name`, `domain`, `aliases`, `features`, `when`, `steps`, `checks` | | `kb/rules.json` | Rule | `id`, `if_atoms`, `if_expr`, `then`, `text` | | `kb/lexicon.json` | Feature atoms | context, domain and intent cues used by retrieval | | `kb/config.json` | Settings | retrieval weights, graph decay and hops, thresholds | A formula example, from `kb/formulas/` (abridged): ```json { "id": "finance.future_value", "inputs": ["principal", "annual_rate", "years", "periods_per_year"], "steps": [["future_value", "principal * (1 + annual_rate / periods_per_year) ** (periods_per_year * years)"], ["interest_earned", "future_value - principal"]], "outputs": ["future_value", "interest_earned"], "examples": [{"inputs": {"principal": 1000, "annual_rate": 0.05, "periods_per_year": 12, "years": 10}, "expect": {"future_value": 1647.0095}}] } ``` ## Graph export `python3 -m symmix --export DIR` writes four files, computed from the knowledge base alone. A pre-built export is in `export/`. | File | Contents | |---|---| | `graph.json` | The full typed graph: 2,616 nodes and 4,831 edges, pretty-printed JSON | | `vocabulary.json` | 54,107 n-gram terms (word, character and feature) | | `vectors.json` | Sparse TF-IDF vectors for 2,477 items in word, character and feature spaces | | `manifest.json` | Counts, retrieval settings and a statement of what the files are | `graph.json` has the shape `{"format": "symmix-export/1", "nodes": [...], "edges": [...]}`. Node types: `variable` (1,285), `atom` (474), `formula` (401), `concept` (377), `rule` (56), `process` (23). A variable node and an edge: ```json {"id": "var:hourly_wage", "type": "variable", "name": "Hourly wage", "kind": "money", "unit": "currency per hour"} {"source": "chem.titration_endpoint", "target": "var:analyte_concentration", "relation": "input"} ``` Edge relations and counts: `feature` 2,001, `input` 1,084, `output` 523, `explains` 403, `asserts` 143, `related` 272, `uses` 122, `requires` 60, `feeds` 59, `contrast` 49, `cites` 47, `suggests` 35, `causes` 33. The vectors are sparse lexical weights over written terms. They are not learned embeddings, and two items are similar only when they share words, character sequences or features. The graph is hand-built and has not been checked against an independent reference. ## Adding knowledge 1. Add or edit JSON in `kb/`. Every new formula needs worked examples. 2. Run `python3 -m symmix --check`. It checks references, cycles, lexicon coverage, weight sums and formula examples. 3. Run `python3 -m unittest`. 4. Regenerate the export with `python3 -m symmix --export export`. ## Repository layout ```text symmix/ engine: model.py (pipeline), extract.py (number linking), index.py, graph.py, formulas.py and safe_eval.py (formula engine), rules.py, units.py, kb.py, check.py, export.py, cli.py kb/ the knowledge base (variables, formulas, concepts, processes, rules, lexicon, config) export/ the pre-built graph, vocabulary, vectors and manifest tests/ 206 tests in 14 modules evaluation/ question-set scripts used during development ``` ## License Apache 2.0