math_spec.lowering
Lower a validated model to a :class:~math_spec.program.Program.
One lowering, on the language side: it reads the typed AST and emits
declarations with names resolved and shapes fixed, and reaches no consumer. A
construct with no lowering raises :class:~math_spec.errors.LanguageError
naming its rewrite.
lower_program(expanded)
#
Compile an expanded model into a :class:~math_spec.program.Program.
A domain: binary variable lowers with fixed 0/1 bounds.
| RAISES | DESCRIPTION |
|---|---|
LanguageError
|
A construct outside the language, named with its rewrite. |
Source code in src/math_spec/lowering.py
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 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 | |
to_program(spec)
#
spec as a :class:~math_spec.program.Program — the public door.
Takes whatever you have: a YAML path, the YAML itself, a mapping, a loaded model, or a program already. Idempotent, so a caller that does not know which it holds can call this and be sure.
Not memoised; :func:~math_spec.piecewise.expand_piecewise is.
| PARAMETER | DESCRIPTION |
|---|---|
spec
|
What to read the declarations from. |
| RETURNS | DESCRIPTION |
|---|---|
Program
|
Every declaration the file makes, with names resolved and shapes |
Program
|
fixed. |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
The file is not a valid model. |
LanguageError
|
A construct outside the language, named with its rewrite. |