Gaia Lang Public Surface API
Status: Generated from current Python docstrings and type hints.
Top-level gaia.engine.lang imports exposed to package authors. More focused
pages below split the DSL, runtime models, formula AST, compiler, and reference
helpers.
gaia.engine.lang
Gaia Lang — Python DSL for knowledge authoring.
BoolExpr
dataclass
BoolExpr(op: ComparisonOp, left: Any, right: Any)
Boolean proposition over Distribution objects.
Created by Distribution comparison operators (k > 1e-3,
y == baseline + slope * x). claim(content, expr) accepts a BoolExpr as the
second argument and lowers it to claim metadata so the compiler can
compute the resulting prior via the underlying distribution's CDF (for
inequality predicates). Equality / equation predicates are preserved in
metadata with author/default priors; constraint lowering is future work.
The :meth:__bool__ override raises so accidental Python control-flow use
(if k > 1e-3: ...) surfaces immediately rather than silently always
evaluating to True (the dataclass would otherwise be truthy).
DerivedDistribution
dataclass
DerivedDistribution(op: ArithmeticOp, left: Any, right: Any)
Arithmetic combination of distributions / scalars (e.g. baseline + slope * x).
Used as the right-hand side of an :class:Equation proposition. Carries no
runtime sampling logic — it is a syntactic placeholder retained in
equation metadata for audit and future constraint lowering.
Constants (Python int / float / Quantity) and other
DerivedDistributions may appear on either operand position.
ArithOp
dataclass
ArithOp(op: str, left: Any, right: Any)
An arithmetic operation between two Terms.
ClaimAtom
dataclass
ClaimAtom(claim: Claim)
A reference to another Claim's truth — the bridge from formula land to claim graph.
Constant
dataclass
Constant(value: Any, primitive: PrimitiveType)
A primitive literal value, validated against its declared PrimitiveType.
Equals
dataclass
Equals(left: Any, right: Any)
Term equality formula.
Formula
Bases: Protocol
Marker protocol — a truth-valued AST node.
FunctionApp
dataclass
FunctionApp(symbol: FunctionSymbol, args: tuple[Any, ...])
Application of a FunctionSymbol to a tuple of Term arguments.
FunctionSymbol
dataclass
FunctionSymbol(name: str, arg_domains: tuple[PrimitiveType | Domain, ...], result_domain: PrimitiveType | Domain)
Declaration of a user function symbol like E: Particle → Real.
Greater
dataclass
Greater(left: Any, right: Any)
Greater-than relation over Term operands.
GreaterEqual
dataclass
GreaterEqual(left: Any, right: Any)
Greater-than-or-equal relation over Term operands.
Iff
dataclass
Iff(left: Any, right: Any)
Logical equivalence between two Formula operands.
Implies
dataclass
Implies(antecedent: Any, consequent: Any)
Logical implication from antecedent Formula to consequent Formula.
Land
dataclass
Land(operands: tuple[Any, ...])
Logical conjunction over two or more Formula operands.
Less
dataclass
Less(left: Any, right: Any)
Less-than relation over Term operands.
LessEqual
dataclass
LessEqual(left: Any, right: Any)
Less-than-or-equal relation over Term operands.
Lnot
dataclass
Lnot(operand: Any)
Logical negation of a Formula operand.
Lor
dataclass
Lor(operands: tuple[Any, ...])
Logical disjunction over two or more Formula operands.
NotEquals
dataclass
NotEquals(left: Any, right: Any)
Term inequality formula.
PredicateSymbol
dataclass
PredicateSymbol(name: str, arg_domains: tuple[PrimitiveType | Domain, ...])
Declaration of a user predicate symbol like Stable: Particle → Bool.
Term
Bases: Protocol
Marker protocol. A Term is a value-bearing expression node.
UserPredicate
dataclass
UserPredicate(symbol: PredicateSymbol, args: tuple[Any, ...])
Application of a user-declared PredicateSymbol to typed Term arguments.
PrimitiveType
PrimitiveType(name: str, accept: Callable[[object], bool])
A built-in typed sort. Construction is sealed once the module finishes loading.
Create a primitive type token before the module is sealed.
Source code in gaia/engine/lang/formula/primitives.py
20 21 22 23 24 25 26 27 | |
accepts
accepts(value: object) -> bool
Return whether value belongs to this primitive type.
Source code in gaia/engine/lang/formula/primitives.py
29 30 31 | |
Associate
dataclass
Associate(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), helper: Claim | None = None, a: Claim | None = None, b: Claim | None = None, p_a_given_b: float = 0.5, p_b_given_a: float = 0.5, pattern: str | None = None)
CandidateRelation
dataclass
CandidateRelation(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), claims: tuple[Claim, ...] = (), pattern: str | None = None, status: str = 'hypothesis')
Bases: Scaffold
Marks a hypothesized relation that has not been formalized yet.
a
property
a: Claim | None
Compatibility view for older binary callers.
b
property
b: Claim | None
Compatibility view for older binary callers.
proposed
property
proposed: str | None
Compatibility view for older proposed-pattern callers.
Claim
dataclass
Claim(content: str | None = None, *, prior: float | None = None, from_actions: list[Any] | None = None, formula: Any = None, kind: ClaimKind = ClaimKind.GENERAL, **kwargs: Any)
Bases: Knowledge
Proposition with prior. Participates in BP.
Create a probabilistic claim node.
Source code in gaia/engine/lang/runtime/knowledge.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
ClaimKind
Bases: Enum
Shape discriminator for the structured-content of a Claim (spec §4.2).
GENERAL — default; formula optional, no structural commitments PARAMETER — asserts a Variable takes a specific value (Equals(var, const)) QUANTIFIED — top-level quantifier (Forall/Exists) in formula
NOT a "role" (hypothesis/prediction/observation-as-evidence) — those live on action graph nodes. Observation is an Observe action, not a Claim kind. NOT helper-claim metadata.
Compose
dataclass
Compose(name: str = '', version: str = '', inputs: tuple[Knowledge | str, ...] = (), actions: tuple[Action | str, ...] = (), conclusion: Claim | None = None)
Bases: Action
Action-level composition of child actions into a reviewable DAG.
structure_hash
structure_hash(input_refs: list[str], action_refs: list[str], conclusion_ref: str, warrant_refs: list[str], background_refs: list[str] | None = None) -> str
Hash the canonical compose payload used for the IR compose ID.
Source code in gaia/engine/lang/runtime/action.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
Compute
dataclass
Compute(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), conclusion: Claim | None = None, given: tuple[Claim, ...] = (), fn: Callable[..., Any] | None = None, code_hash: str | None = None)
Contradict
dataclass
Contradict(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), a: Claim | None = None, b: Claim | None = None, helper: Claim | None = None)
Decompose
dataclass
Decompose(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), whole: Claim | None = None, parts: tuple[Claim, ...] = (), formula: Any = None)
DependsOn
dataclass
DependsOn(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), conclusion: Claim | None = None, given: tuple[Claim, ...] = ())
Derive
dataclass
Derive(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), conclusion: Claim | None = None, given: tuple[Claim, ...] = ())
Distribution
dataclass
Distribution(content: str, *, impl: _BaseDistribution, format: str = 'markdown', **kwargs: Any)
Bases: Knowledge
Knowledge-wrapped continuous quantity with a probability distribution.
Use the family-specific factories (:func:Normal, :func:LogNormal,
:func:Beta, etc.) rather than constructing this directly — they wrap the
matching gaia.engine.bayes.distributions._BaseDistribution subclass into
a Distribution carrying a content string + identity.
The wrapped computational object is available as .impl and exposes
logpdf / logpmf / cdf / support / model_dump via thin
delegating properties on this class.
Create a Knowledge-wrapped distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Human-readable description of what this quantity is. |
required |
impl
|
_BaseDistribution
|
A |
required |
format
|
str
|
Content format (markdown by default). |
'markdown'
|
**kwargs
|
Any
|
Standard :class: |
{}
|
Source code in gaia/engine/lang/runtime/distribution.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
impl
property
impl: _BaseDistribution
Return the wrapped computational distribution object.
kind
property
kind: str
Distribution family identifier ("normal", "beta", ...).
params
property
params: dict[str, Any]
Return the distribution parameter dictionary.
logpdf
logpdf(x: float) -> float
Evaluate the log probability density at x (continuous).
Source code in gaia/engine/lang/runtime/distribution.py
239 240 241 | |
logpmf
logpmf(k: int) -> float
Evaluate the log probability mass at k (discrete).
Source code in gaia/engine/lang/runtime/distribution.py
243 244 245 | |
support
support() -> tuple[float, float]
Return the inclusive support bounds of the distribution.
Source code in gaia/engine/lang/runtime/distribution.py
247 248 249 | |
cdf
cdf(x: float) -> float
Cumulative distribution function P(X <= x).
Used at compile time to compute the prior of a predicate claim
(P(k > c) = 1 - dist.cdf(c)). Lazy import of scipy keeps this
out of the cold import path.
Source code in gaia/engine/lang/runtime/distribution.py
251 252 253 254 255 256 257 258 259 260 261 262 | |
model_dump
model_dump() -> dict[str, Any]
Return the JSON-serialisable distribution literal payload.
Source code in gaia/engine/lang/runtime/distribution.py
264 265 266 | |
Domain
dataclass
Domain(content: str, *, members: list[Any], format: str = 'markdown', **kwargs: Any)
Bases: Knowledge
A user-declared, finite, enumerable typed sort.
Subclasses Knowledge so it carries identity, provenance, and metadata. Lang-only: does NOT enter the package's IR-bound knowledge map.
Create a finite enumerable authoring domain.
Source code in gaia/engine/lang/runtime/domain.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
Equal
dataclass
Equal(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), a: Claim | None = None, b: Claim | None = None, helper: Claim | None = None)
Exclusive
dataclass
Exclusive(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), a: Claim | None = None, b: Claim | None = None, helper: Claim | None = None)
Infer
dataclass
Infer(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), helper: Claim | None = None, hypothesis: Claim | None = None, evidence: Claim | None = None, given: tuple[Claim, ...] = (), p_e_given_h: float | Claim = 0.5, p_e_given_not_h: float | Claim | None = 0.5, p_e_given_not_h_defaulted: bool = False)
Knowledge
dataclass
Knowledge(content: str, format: str = 'markdown', type: str = 'knowledge', title: str | None = None, background: list[Knowledge] = list(), parameters: list[dict[str, Any]] = list(), provenance: list[dict[str, str]] = list(), metadata: dict[str, Any] = dict(), label: str | None = None, strategy: Any | None = None)
Base knowledge node. Plain text plus metadata.
MaterializationLink
dataclass
MaterializationLink(scaffold: Scaffold, by: tuple[GaiaGraph, ...], label: str | None = None, rationale: str = '', metadata: dict[str, Any] = dict())
Bookkeeping link from scaffold to the formal graph records that handle it.
Note
dataclass
Note(content: str, *, format: str = 'markdown', **kwargs: Any)
Bases: Knowledge
Non-probabilistic contextual material. Does not enter BP.
Create a non-probabilistic note.
Source code in gaia/engine/lang/runtime/knowledge.py
66 67 68 69 70 | |
Observe
dataclass
Observe(label: str | None = None, rationale: str = '', background: list[Knowledge] = list(), metadata: dict[str, Any] = dict(), warrants: list[Claim] = list(), conclusion: Claim | None = None, given: tuple[Claim, ...] = ())
Question
dataclass
Question(content: str, **kwargs: Any)
Bases: Knowledge
Open inquiry. Does not enter BP.
Create a non-probabilistic question.
Source code in gaia/engine/lang/runtime/knowledge.py
353 354 355 356 357 358 359 | |
RoleOccurrence
dataclass
RoleOccurrence(claim: Claim, role: str, action: Action, action_type: str, action_label: str | None = None, path: tuple[str, ...] = (), source: str = 'explicit_field')
A claim role at a specific occurrence in an authored action.
Variable
dataclass
Variable(*, symbol: str, domain: PrimitiveType | Domain, value: Any | None = None, unit: str | None = None, content: str | None = None, format: str = 'markdown', **kwargs: Any)
Bases: Knowledge
A typed term referenceable by formulas, models, and actions.
Subclasses Knowledge for identity, provenance, metadata. Carries a symbol used in formulas, a domain (PrimitiveType or user-declared Domain), and an optional bound value. Binding semantics (CONSTANT / FREE / BOUND_BY_CLAIM) are inferred by Milestone B's compiler; this class stores only authored data.
Lang-only: does NOT enter the package's IR-bound knowledge map (spec §2.4).
Create a typed authoring variable.
Source code in gaia/engine/lang/runtime/variable.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
artifact
artifact(*, kind: str, source: str | None = None, locator: str | None = None, path: str | None = None, caption: str | None = None, description: str | None = None, media_type: str | None = None, content: str | None = None, title: str | None = None) -> Note
Create a note carrying structured artifact metadata.
Source code in gaia/engine/lang/dsl/artifacts.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
associate
associate(a: Any, b: Any, *, p_a_given_b: float, p_b_given_a: float, pattern: str | None = None, background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None) -> Claim
Declare a symmetric probabilistic association. Returns an association helper Claim.
a and b may be any Boolean-valued expression (Claim,
ClaimAtom, Formula node, or BoolExpr); non-Claim inputs are
lifted to helper Claims at the verb boundary per RFC #703.
Source code in gaia/engine/lang/dsl/associate_verb.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
candidate_relation
candidate_relation(*, claims: list[Any] | tuple[Any, ...], pattern: str | None = None, background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None, metadata: dict[str, Any] | None = None) -> CandidateRelation
Record a hypothesized relation without triggering formal semantics.
Every entry of claims may be any Boolean-valued expression
(Claim, ClaimAtom, Formula node, or BoolExpr);
non-Claim inputs are lifted to helper Claims at the verb boundary
per RFC #703.
Source code in gaia/engine/lang/dsl/scaffold.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
claim
claim(content: str, proposition: BoolExpr | None = None, *, title: str | None = None, format: str = 'markdown', background: list[Knowledge] | None = None, parameters: list[dict[str, Any]] | None = None, provenance: list[dict[str, str]] | None = None, prior: float | None = None, formula: Any = None, kind: ClaimKind = ClaimKind.GENERAL, tolerance: float | None = None, **metadata: Any) -> Claim
Declare a scientific assertion.
Three authoring shapes:
- Prose claim —
claim("Heliocentric model is correct.", prior=0.8). The proposition is conveyed in natural language. The optionalpriorkeyword is a low-priority shortcut routed throughregister_prior()withsource_id="claim_inline". - Predicate claim —
claim("Reaction is fast", k > 1e-2). The second positional argument is a :class:BoolExprproduced by comparing a :class:Distributionagainst a constant. The compiler registers a CDF-derived prior record for inequality predicates. See :class:gaia.engine.lang.Distributionfor how to declare the underlying continuous quantity. - Formula claim —
claim(content, formula=Forall(...))for the predicate-logic surface (unchanged from v0.5).
The tolerance keyword applies only when proposition is an equation
(lhs == rhs). PR1 stores equation metadata and a neutral default prior;
equation constraint lowering is deferred.
Source code in gaia/engine/lang/dsl/knowledge.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
compose
compose(*, name: str, version: str, background: list[Knowledge] | None = None, warrants: list[Claim] | None = None, rationale: str = '', label: str | None = None) -> Callable[[Callable[..., Claim]], Callable[..., Claim]]
Decorate a function as a Gaia action composition template.
Source code in gaia/engine/lang/runtime/composition.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
compute
compute(conclusion_type: type[Claim] | Callable[..., Any], *, fn: Callable[..., Any] | None = None, given: Claim | tuple[Claim, ...] | list[Claim] | None = (), background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None) -> Claim | Callable[..., Claim]
Deterministic computation.
Used either as compute(ResultClaim, fn=..., given=...) or as @compute.
Source code in gaia/engine/lang/dsl/support.py
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | |
contradict
contradict(a: Any, b: Any, *, background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None) -> Claim
Declare two Claims contradictory. Returns a contradiction helper Claim.
a and b may be any Boolean-valued expression (Claim,
ClaimAtom, Formula node, or BoolExpr); non-Claim inputs are
lifted to helper Claims at the verb boundary per RFC #703.
Source code in gaia/engine/lang/dsl/relate.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
depends_on
depends_on(conclusion: Any, *, given: Any, background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None, metadata: dict[str, Any] | None = None) -> DependsOn
Record unformalized load-bearing dependencies for a Claim.
conclusion and every entry of given may be any Boolean-valued
expression (Claim, ClaimAtom, Formula node, or BoolExpr);
non-Claim inputs are lifted to helper Claims at the verb boundary
per RFC #703.
Source code in gaia/engine/lang/dsl/scaffold.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
derive
derive(conclusion: Any, *, given: Any = (), background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None) -> Claim
Logical derivation. Returns the conclusion Claim.
conclusion may be a Claim, a str (which creates a fresh
Claim from the content), or any Boolean-valued expression
(ClaimAtom / Formula / BoolExpr) that lifts to a helper Claim
at the verb boundary per RFC #703.
Every entry of given is similarly lifted: a Boolean-valued
expression becomes a helper Claim; non-Claim non-Boolean-valued values
raise an educational :class:TypeError.
Source code in gaia/engine/lang/dsl/support.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
equal
equal(a: Any, b: Any, *, background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None) -> Claim
Declare two Claims equivalent. Returns an equivalence helper Claim.
a and b may be any Boolean-valued expression (Claim,
ClaimAtom, Formula node, or BoolExpr); non-Claim inputs are
lifted to helper Claims at the verb boundary per RFC #703.
Source code in gaia/engine/lang/dsl/relate.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
equals
equals(left: Any, right: Any) -> Equals
Create an equality formula.
Source code in gaia/engine/lang/dsl/formula.py
53 54 55 | |
exclusive
exclusive(a: Any, b: Any, *, background: list[Knowledge] | None = None, rationale: str = '', label: str | None = None) -> Claim
Declare two Claims as a closed binary partition. Returns an XOR helper Claim.
a and b may be any Boolean-valued expression (Claim,
ClaimAtom, Formula node, or BoolExpr); non-Claim inputs are
lifted to helper Claims at the verb boundary per RFC #703.
Source code in gaia/engine/lang/dsl/relate.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
exists
exists(variable: Variable, body: Any) -> Exists
Create an existential quantifier over a free variable.
Source code in gaia/engine/lang/dsl/formula.py
23 24 25 | |
export
export(*items: str | Knowledge) -> list[str]
Return root __all__ names for a package's public Knowledge surface.
The helper is intentionally small: it returns a plain list[str] and
stores no hidden export state. Passing strings is equivalent to writing the
names directly. Passing a Knowledge object resolves the object's public
name from the caller's module or local scope, which keeps __all__ close
to normal Python public-API conventions while avoiding string typos.
Source code in gaia/engine/lang/dsl/knowledge.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
figure
figure(*, source: str | None = None, locator: str | None = None, path: str | None = None, caption: str | None = None, description: str | None = None, media_type: str | None = None, content: str | None = None, title: str | None = None) -> Note
Create a figure artifact note.
Source code in gaia/engine/lang/dsl/artifacts.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
forall
forall(variable: Variable, body: Any) -> Forall
Create a universal quantifier over a free variable.
Source code in gaia/engine/lang/dsl/formula.py
18 19 20 | |
iff
iff(left: Any, right: Any) -> Iff
Create an equivalence formula.
Source code in gaia/engine/lang/dsl/formula.py
48 49 50 | |
implies
implies(antecedent: Any, consequent: Any) -> Implies
Create an implication formula.
Source code in gaia/engine/lang/dsl/formula.py
43 44 45 | |
infer
infer(evidence: Claim | str | None = None, *args: Any, hypothesis: Claim | None = None, given: Claim | tuple[Claim, ...] | list[Claim] | None = (), background: list[Knowledge] | None = None, p_e_given_h: float | Claim | None = None, p_e_given_not_h: float | Claim | None = _DEFAULT_P_E_GIVEN_NOT_H_ARG, rationale: str = '', label: str | None = None, **legacy_kwargs: Any) -> Claim | Strategy
Bayesian inference. Returns the evidence Claim.
The canonical v6 shape is infer(evidence, hypothesis=..., ...). The old
v5 infer([premises], conclusion, ...) form is preserved as a deprecated
compatibility path.
Source code in gaia/engine/lang/dsl/infer_verb.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
land
land(*operands: Any) -> Land
Create a logical conjunction formula.
Source code in gaia/engine/lang/dsl/formula.py
28 29 30 | |
lnot
lnot(operand: Any) -> Lnot
Create a logical negation formula.
Source code in gaia/engine/lang/dsl/formula.py
38 39 40 | |
lor
lor(*operands: Any) -> Lor
Create a logical disjunction formula.
Source code in gaia/engine/lang/dsl/formula.py
33 34 35 | |
materialize
materialize(scaffold: Scaffold, *, by: GaiaGraph | Claim | str | list[GaiaGraph | Claim | str] | tuple[GaiaGraph | Claim | str, ...], rationale: str = '', label: str | None = None, metadata: dict[str, Any] | None = None) -> MaterializationLink
Record a checked link from scaffold to formal graph records.
Source code in gaia/engine/lang/dsl/scaffold.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
note
note(content: str, *, title: str | None = None, format: str = 'markdown', **metadata: Any) -> Note
Declare non-probabilistic contextual material.
Source code in gaia/engine/lang/dsl/knowledge.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
observe
observe(conclusion: Any, *, value: Any = _OBSERVE_VALUE_SENTINEL, error: Any = None, given: Claim | tuple[Claim, ...] | list[Claim] | None = (), background: list[Knowledge] | None = None, source_refs: list[str] | None = None, rationale: str = '', label: str | None = None) -> Claim
Empirical observation.
Three authoring shapes:
- Discrete claim observation —
observe(my_claim). A Boolean-valued expression such asa & bis lifted to an explicit helper Claim first. A no-premise observation pins the conclusion to1 - CROMWELL_EPS. Usegiven=to record a conditional observation that does not pin the conclusion. - Continuous quantity observation —
observe(distribution, value=v, error=σ). Records a measurement event for a :class:Distribution-typed quantity. Returns a freshly minted :class:Claimrepresenting the observation event (pinned to1 - CROMWELL_EPSsince the measurement was made), with metadata linking back to the underlying distribution. The compiler reads this linkage for audit and future posterior-CDF lowering. The current predicate-prior lowering still uses the Distribution's prior CDF and emits a warning when an observation targets the same Distribution.
value is the measured numeric value; error is either None
for a noise-free observation, a scalar interpreted as the Gaussian
additive standard deviation, or a :class:Distribution for a
custom noise model.
- Variable observation (v0.6 unified-bayes path) —
observe(variable, value=v, error=σ). Records a measurement event for a primitive :class:Variable(the kind that appears as the observable of a Bayes predictive model). Writes the unifiedmetadata["observation"]schema consumed by :func:gaia.engine.bayes.compare. Scalarerroris sugared into an anonymousNormal(mu=0, sigma=error)so noise is always eitherNoneor a :class:DistributionKnowledge node.
Source code in gaia/engine/lang/dsl/support.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
parameter
parameter(variable: Variable, value: Any, *, content: str | None = None, describe: str | None = None, title: str | None = None, format: str = 'markdown', background: list[Knowledge] | None = None, provenance: list[dict[str, str]] | None = None, prior: float | None = None, label: str | None = None, metadata: dict[str, Any] | None = None) -> Claim
Declare that a primitive Variable takes a concrete value.
Source code in gaia/engine/lang/dsl/sugar.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
question
question(content: str, *, title: str | None = None, format: str = 'markdown', **metadata: Any) -> Question
Declare a research question. No probability, no BP participation.
Source code in gaia/engine/lang/dsl/knowledge.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
is_formula
is_formula(obj: object) -> bool
Return whether an object is explicitly tagged as a Formula node.
Source code in gaia/engine/lang/formula/predicate.py
25 26 27 | |
is_term
is_term(obj: object) -> bool
Strict check — only objects explicitly tagged as terms qualify.
Source code in gaia/engine/lang/formula/term.py
28 29 30 | |
roles_for_claim
roles_for_claim(claim: Claim, graph: ActionGraph, *, include_background: bool = True, include_warrants: bool = True) -> tuple[RoleOccurrence, ...]
Return all authored action roles for claim.
Source code in gaia/engine/lang/runtime/roles.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
roles_for_package
roles_for_package(graph: ActionGraph, *, include_background: bool = True, include_warrants: bool = True) -> dict[Claim, tuple[RoleOccurrence, ...]]
Index authored action roles by claim identity.
Source code in gaia/engine/lang/runtime/roles.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
Beta
Beta(content: str, *, alpha: Any, beta: Any, **kwargs: Any) -> Distribution
Create a Beta-distributed continuous quantity with a name.
Beta shape parameters alpha and beta are dimensionless.
Source code in gaia/engine/lang/runtime/distribution.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
BetaBinomial
BetaBinomial(content: str, *, n: Any, alpha: Any, beta: Any, **kwargs: Any) -> Distribution
Create a Beta-Binomial-distributed discrete quantity with a name.
Predictive distribution of Binomial(n, p) integrated over
p ~ Beta(alpha, beta). All three parameters are dimensionless.
The closed-form uniform marginal BetaBinomial(n, 1, 1) is the
canonical diffuse reference: P(k) = 1 / (n + 1) for k ∈ [0, n].
Source code in gaia/engine/lang/runtime/distribution.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | |
Binomial
Binomial(content: str, *, n: Any, p: Any, **kwargs: Any) -> Distribution
Create a Binomial-distributed discrete quantity with a name.
n and p are dimensionless.
Source code in gaia/engine/lang/runtime/distribution.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | |
Cauchy
Cauchy(content: str, *, mu: Any, gamma: Any, **kwargs: Any) -> Distribution
Create a Cauchy-distributed continuous quantity with a name.
mu and gamma share the location/scale unit of the underlying
random variable.
Source code in gaia/engine/lang/runtime/distribution.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
ChiSquared
ChiSquared(content: str, *, df: Any, **kwargs: Any) -> Distribution
Create a Chi-squared distributed continuous quantity with a name.
df is dimensionless.
Source code in gaia/engine/lang/runtime/distribution.py
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | |
Exponential
Exponential(content: str, *, rate: Any, **kwargs: Any) -> Distribution
Create an Exponential-distributed continuous quantity with a name.
rate may be a bare scalar or a :class:gaia.unit.Quantity (typically
1 / time). The corresponding random variable's unit is the inverse of
rate's unit; for predicate / observe consistency we record that
inverse unit as the distribution's canonical metadata["unit"].
Source code in gaia/engine/lang/runtime/distribution.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
Gamma
Gamma(content: str, *, alpha: Any, rate: Any, **kwargs: Any) -> Distribution
Create a Gamma-distributed continuous quantity with a name.
alpha is dimensionless; rate may carry the inverse unit of the
underlying random variable (typically 1 / x).
Source code in gaia/engine/lang/runtime/distribution.py
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | |
LogNormal
LogNormal(content: str, *, mu: Any, sigma: Any, **kwargs: Any) -> Distribution
Create a LogNormal-distributed continuous quantity with a name.
The LogNormal parameters live in log-space; mu and sigma must be
dimensionless scalars. Encode the unit of the underlying random variable
in the content string (e.g. LogNormal("k / s^-1", mu=log(1e-3), sigma=2)).
Source code in gaia/engine/lang/runtime/distribution.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
Normal
Normal(content: str, *, mu: Any, sigma: Any, **kwargs: Any) -> Distribution
Create a Normal-distributed continuous quantity with a name.
mu and sigma may both be bare scalars or both be
:class:gaia.unit.Quantity values sharing a unit; mixing them raises.
Source code in gaia/engine/lang/runtime/distribution.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
Poisson
Poisson(content: str, *, rate: Any, **kwargs: Any) -> Distribution
Create a Poisson-distributed discrete quantity with a name.
rate is the dimensionless expected count for the interval encoded by
the quantity name. Pass a bare scalar; unit-typed rates are rejected.
Source code in gaia/engine/lang/runtime/distribution.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | |
StudentT
StudentT(content: str, *, df: Any, mu: Any, sigma: Any, **kwargs: Any) -> Distribution
Create a Student-t distributed continuous quantity with a name.
df is dimensionless; mu and sigma share the location/scale
unit of the underlying random variable.
Source code in gaia/engine/lang/runtime/distribution.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |