Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/research/atemporal/at0/model/at0_output.c # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / research / atemporal / at0 / model / at0_output.c` 92 lines ยท 4214 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* OMEGA-AT0-ENGINE v1: the engine's versioned output. Its values block is the 18 * AT0_RESULT_V1 section 1 values block without the oracle's reference lines, 19 * so a runner can splice it into a result. This is a private format of the 20 * model directory, not a contract and not an identity. */ 21 #include "at0_model.h" 22 #include 23 #include 24 25 int at0_f64_format(double x, char *buf, size_t cap) 26 { 27 if (!isfinite(x)) return snprintf(buf, cap, "nonfinite"); 28 if (x == 0.0) x = 0.0; /* fold -0.0 to +0.0 */ 29 uint64_t bits; 30 memcpy(&bits, &x, sizeof bits); 31 return snprintf(buf, cap, "f64:%016llx", (unsigned long long)bits); 32 } 33 34 typedef struct { char *buf; size_t cap; size_t len; int overflow; } out_t; 35 static void put(out_t *o, const char *s) 36 { 37 size_t n = strlen(s); 38 if (o->len + n >= o->cap) { o->overflow = 1; return; } 39 memcpy(o->buf + o->len, s, n); o->len += n; o->buf[o->len] = 0; 40 } 41 static void put_value(out_t *o, double v, at0_scaled b) 42 { 43 char t[64]; 44 at0_f64_format(v, t, sizeof t); put(o, t); put(o, " "); 45 at0_scaled_format(b, t, sizeof t); put(o, t); 46 } 47 48 long at0_engine_emit(const at0_case *c, const at0_engine_result *r, char *buf, size_t cap) 49 { 50 if (!c || !r || !buf || cap == 0) return -1; 51 static const char *axes[3] = { "X", "Y", "Z" }; 52 static const char *signs[2] = { "PLUS", "MINUS" }; 53 out_t o = { buf, cap, 0, 0 }; 54 char t[512]; 55 buf[0] = 0; 56 put(&o, "OMEGA-AT0-ENGINE v1\ndomain omega.at0.engine.v1\ncontract AT0_RESULT_V2\n"); 57 snprintf(t, sizeof t, "case_name %s\ncase_id %s\nacceptance_id %s\ncase_file_sha256 %s\n", 58 c->name, c->case_id, c->acceptance_id, c->case_file_sha256); put(&o, t); 59 put(&o, "begin numerics\narithmetic BINARY64\n"); 60 put(&o, r->bound_kind == AT0_BOUND_ESTIMATED ? "bound_kind ESTIMATED\n" : "bound_kind NONE\n"); 61 put(&o, "threads 1\nend numerics\nbegin values\n"); 62 snprintf(t, sizeof t, "physical_state_kernel_dim %d\n", r->kernel_dim); put(&o, t); 63 put(&o, "constraint_residual "); 64 if (r->psi_nonzero) put_value(&o, r->constraint_residual, r->constraint_residual_bound); else put(&o, "undefined 0@0"); 65 put(&o, "\n"); 66 put(&o, "povm_residual "); put_value(&o, r->povm_residual, r->povm_residual_bound); put(&o, "\n"); 67 for (int k = 0; k < r->label_count; k++) { 68 const at0_label_values *lv = &r->label[k]; 69 const char *status = lv->status == AT0_LABEL_DEFINED ? "DEFINED" 70 : lv->status == AT0_LABEL_UNDEFINED ? "UNDEFINED" : "INDETERMINATE"; 71 snprintf(t, sizeof t, "label %d %s %s\n", k, c->labels[k], status); put(&o, t); 72 } 73 for (int k = 0; k < r->label_count; k++) { 74 const at0_label_values *lv = &r->label[k]; 75 snprintf(t, sizeof t, "clock_probability %d ", k); put(&o, t); 76 if (r->psi_nonzero) put_value(&o, lv->clock_probability, lv->clock_probability_bound); else put(&o, "undefined 0@0"); 77 put(&o, "\n"); 78 } 79 for (int k = 0; k < r->label_count; k++) { 80 const at0_label_values *lv = &r->label[k]; 81 for (int ax = 0; ax < 3; ax++) { 82 for (int sg = 0; sg < 2; sg++) { 83 snprintf(t, sizeof t, "pauli %d %s %s ", k, axes[ax], signs[sg]); put(&o, t); 84 if (lv->status == AT0_LABEL_DEFINED) put_value(&o, lv->pauli[ax][sg], lv->pauli_bound[ax][sg]); 85 else put(&o, "undefined 0@0"); 86 put(&o, "\n"); 87 } 88 } 89 } 90 put(&o, "end values\nend\n"); 91 return o.overflow ? -1 : (long)o.len; 92 }