Skip to main content

Gaia Lang — Python DSL for knowledge authoring, compilation, and inference

Project description

Gaia Lang

CI codecov License: MIT

A Python DSL for authoring machine-readable scientific knowledge. Gaia Lang lets researchers declare propositions, logical constraints, and reasoning strategies as Python objects, then compiles them into a canonical intermediate representation (Gaia IR) for inference via belief propagation.

Quick Example

from gaia.lang import claim, setting, contradiction, deduction

# Declare knowledge
aristotle = setting("Aristotle's doctrine: heavier objects fall faster.")
heavy_faster = claim("Observations show heavier stones fall faster in air.")
composite_slower = claim("A tied composite should fall slower (light part drags heavy).")
composite_faster = claim("A tied composite should fall faster (greater total mass).")

# Logical constraint
paradox = contradiction(composite_slower, composite_faster,
    reason="Same premise yields opposite predictions")

# Reasoning
vacuum_law = claim("In vacuum all bodies fall at the same rate.",
    given=[paradox, heavy_faster])

Install

pip install gaia-lang

For development:

git clone https://github.com/SiliconEinstein/Gaia.git
cd Gaia && uv sync

CLI Workflow

gaia compile   →   gaia check   →   gaia infer   →   gaia register
  (DSL → IR)      (validate)      (BP preview)      (registry PR)
Command Purpose
gaia compile [path] Compile Python DSL to Gaia IR (.gaia/ir.json)
gaia check [path] Validate package structure and IR consistency
gaia infer [path] Run belief propagation with a review sidecar
gaia register [path] Submit package to the Gaia Official Registry

Create a Knowledge Package

1. Initialize

uv init --lib galileo-falling-bodies-gaia
cd galileo-falling-bodies-gaia
uv add gaia-lang
mv src/galileo_falling_bodies_gaia src/galileo_falling_bodies

2. Configure pyproject.toml

[project]
name = "galileo-falling-bodies-gaia"
version = "1.0.0"

[tool.gaia]
type = "knowledge-package"
uuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  • Package name must end with -gaia
  • type must be "knowledge-package"
  • uuid is required for registry submission

3. Write DSL declarations in src/galileo_falling_bodies/__init__.py

from gaia.lang import claim, setting, contradiction

aristotle = setting("Aristotle: heavier objects fall faster.")
heavy_faster = claim("Heavy stones fall faster in air.")
composite_slower = claim("Tied composite should be slower.")
composite_faster = claim("Tied composite should be faster.")

paradox = contradiction(composite_slower, composite_faster,
    reason="Same premise yields opposite conclusions")

vacuum_law = claim("In vacuum all bodies fall at the same rate.",
    given=[paradox, heavy_faster])

__all__ = ["aristotle", "heavy_faster", "composite_slower",
           "composite_faster", "paradox", "vacuum_law"]

4. Compile and validate

gaia compile .
gaia check .

5. Publish

git tag v1.0.0 && git push origin main --tags
gaia register . --registry-dir ../gaia-registry --create-pr

DSL Surface

Knowledge

Function Description
claim(content, *, given, background, parameters, provenance) Scientific assertion — the only type carrying probability
setting(content) Background context — no probability, no BP participation
question(content) Open research inquiry

Operators (deterministic constraints)

Function Semantics
contradiction(a, b) A and B cannot both be true
equivalence(a, b) A and B share the same truth value
complement(a, b) A and B have opposite truth values
disjunction(*claims) At least one must be true

Strategies (reasoning declarations)

Function Description
noisy_and(premises, conclusion) All premises jointly support conclusion
infer(premises, conclusion) General conditional probability table
deduction(premises, conclusion) Deductive reasoning (conjunction → implication)
abduction(observation, hypothesis) Inference to best explanation
analogy(source, target, bridge) Analogical transfer
extrapolation(source, target, continuity) Continuity-based prediction
elimination(exhaustiveness, excluded, survivor) Process of elimination
case_analysis(exhaustiveness, cases, conclusion) Case-by-case reasoning
mathematical_induction(base, step, conclusion) Inductive proof
composite(premises, conclusion, sub_strategies) Hierarchical composition

Architecture

gaia/
├── lang/       DSL runtime, declarations, and compiler
├── ir/         Gaia IR schema, validation, formalization
├── bp/         Belief propagation engine (4 backends)
├── cli/        CLI commands (compile, check, infer, register)
└── review/     Review sidecar model

Documentation

Testing

pytest
ruff check .
ruff format --check .

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gaia_lang-0.1.0.tar.gz (69.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gaia_lang-0.1.0-py3-none-any.whl (77.7 kB view details)

Uploaded Python 3

File details

Details for the file gaia_lang-0.1.0.tar.gz.

File metadata

  • Download URL: gaia_lang-0.1.0.tar.gz
  • Upload date:
  • Size: 69.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gaia_lang-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c190dc4beeae88540268d9cf567e47f2418be91ac6cb7ad60fda2fa31bf402c
MD5 f228386e88ccbbe81e8d726ed0674afe
BLAKE2b-256 5abaaf7e85f2ff43e08b0bd4e993b9557a607d4d5ae475a886f47149f3f6794f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gaia_lang-0.1.0.tar.gz:

Publisher: publish.yml on SiliconEinstein/Gaia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gaia_lang-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gaia_lang-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 77.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gaia_lang-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c48af60369133ce9aa73d1deb1cda68408e1e6ccc610c6080b22f38e0eb8de5
MD5 1a9f822bf7937d319792ac50b3735369
BLAKE2b-256 8123c0847e79e649158395b00a9585b8021948f563e79f52f0781c920f30d2ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for gaia_lang-0.1.0-py3-none-any.whl:

Publisher: publish.yml on SiliconEinstein/Gaia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page