Facts & propositions (guardrail_calculus.facts)
Propositions and the type-level chain of labelled checks shared by the builder surface and the reasoning layer.
facts
Propositions and the typed check chain.
Prop wraps a boolean expression with optional human text; Check, Nil, and Snoc form the type-level list of labelled checks accumulated by subject builders, and SubjectFacts is the sealed block a subject contributes to a puzzle.
Shared by the builder surface and the reasoning layer; imports only the kernel and the dimensions module, so it stays cycle-free.
ExprT
module-attribute
ExprT = TypeVar('ExprT')
PropT
module-attribute
PropT = TypeVar('PropT', bound=Prop)
BoolishT
module-attribute
BoolishT = TypeVar('BoolishT', bound=Boolish_Bound)
Given_Bound
module-attribute
Given_Bound = Prop[Any] | None
Prop
dataclass
Bases: Generic[ExprT]
A proposition: a boolean expression plus optional human-facing text.
Prop is what .given(...) and .check(...) store.
text is the sentence shown in explanations; when omitted it falls back to the
expression's own label. bind re-roots the proxy _ to a concrete subject during ingestion.
Attributes:
| Name | Type | Description |
|---|---|---|
expr |
ExprT
|
The underlying expression (e.g., a BoolExpr). |
text |
str | None
|
Human-facing description of the proposition. |
Source code in src/guardrail_calculus/facts.py
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 | |
expr
instance-attribute
expr
text
class-attribute
instance-attribute
text = None
display_text
property
display_text
bind
bind(subject_name)
Source code in src/guardrail_calculus/facts.py
64 65 66 67 68 69 70 71 | |
ChecksLike
Bases: Protocol
Structural protocol for the type-level check chain.
Source code in src/guardrail_calculus/facts.py
101 102 103 104 105 106 107 | |
items
items()
Source code in src/guardrail_calculus/facts.py
107 | |
Check
dataclass
A single labelled candidate proposition, e.g. check "A" over a prop.
The label is kept in the type (LabelT) so a solved puzzle can be indexed
by literal label with the result type preserved.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
LabelT
|
The literal string label identifying the check. |
prop |
PropT
|
The checked Prop proposition. |
Source code in src/guardrail_calculus/facts.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
label
instance-attribute
label
prop
instance-attribute
prop
Nil
dataclass
The empty check chain (cons-list base case).
See Snoc for the recursive case.
Source code in src/guardrail_calculus/facts.py
130 131 132 133 134 135 136 137 138 | |
items
items()
Source code in src/guardrail_calculus/facts.py
137 138 | |
Snoc
dataclass
A check chain: everything in init followed by one more last.
Builders accumulate checks by snoc-ing, so the full sequence of labels and
props is recoverable both at runtime (items) and in the static type.
Attributes:
| Name | Type | Description |
|---|---|---|
init |
InitT
|
The preceding part of the check chain. |
last |
LastT
|
The last Check added to the chain. |
Source code in src/guardrail_calculus/facts.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
init
instance-attribute
init
last
instance-attribute
last
items
items()
Source code in src/guardrail_calculus/facts.py
156 157 158 | |
SubjectFacts
dataclass
The sealed block one subject contributes to a puzzle.
Produced by subject()...block(). given is the subject's premise (if
any), checks is its type-level chain of candidate propositions, and
own is the self-reference used inside the block.
Attributes:
| Name | Type | Description |
|---|---|---|
own |
OwnT
|
The self-reference proxy for this subject. |
given |
GivenT
|
The subject's premise/given premise. |
checks |
ChecksT
|
The chain of checks to be validated. |
Source code in src/guardrail_calculus/facts.py
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 | |
own
instance-attribute
own
given
instance-attribute
given
checks
instance-attribute
checks
prop
prop(value: Prop[ExprT]) -> Prop[ExprT]
prop(value: ExprT) -> Prop[ExprT]
prop(value)
Coerce a boolean expression (or an existing Prop) into a Prop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Boolish_Bound | Prop[Any]
|
The expression or existing proposition to coerce. |
required |
Returns:
| Type | Description |
|---|---|
Prop[Any]
|
A coerced Prop container. |
Source code in src/guardrail_calculus/facts.py
86 87 88 89 90 91 92 93 94 95 96 97 98 | |