interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / src / omega_discovery.h

88 lines · 3441 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#ifndef OMEGA_DISCOVERY_H
18#define OMEGA_DISCOVERY_H
19
20#include "omega_program.h"
21#include "omega_library.h"
22#include "omega_synthesis.h"
23#include <stdbool.h>
24#include <stddef.h>
25
26#define OMEGA_CORPUS_MAX_PROGRAMS 16
27#define OMEGA_DISCOVERY_MAX_CANDIDATES 16
28#define OMEGA_DISCOVERY_MAX_OCCURRENCES 16
29
30typedef struct {
31 OmegaProgram programs[OMEGA_CORPUS_MAX_PROGRAMS];
32 size_t count;
33} OmegaCorpus;
34
35typedef struct {
36 OmegaProgram abstraction;
37 size_t occurrence_count;
38 size_t occurrences[OMEGA_DISCOVERY_MAX_OCCURRENCES];
39 uint32_t slice_offset_insns;
40 uint32_t slice_len_insns;
41 int32_t compression_score; /* Net instructions saved across corpus */
42 bool is_nontrivial;
43 bool is_verified;
44 VerifyReport verify_report;
45} OmegaAbstractionCandidate;
46
47typedef struct {
48 OmegaAbstractionCandidate candidates[OMEGA_DISCOVERY_MAX_CANDIDATES];
49 size_t candidate_count;
50 int best_candidate_index;
51} OmegaDiscoveryResult;
52
53/* Initialize empty corpus */
54void omega_corpus_init(OmegaCorpus *corpus);
55
56/* Free resources in corpus */
57void omega_corpus_destroy(OmegaCorpus *corpus);
58
59/* Add a verified program to the corpus */
60int omega_corpus_add(OmegaCorpus *corpus, const OmegaProgram *prog);
61
62/* Compute total instruction cost of corpus */
63uint32_t omega_corpus_total_cost(const OmegaCorpus *corpus);
64
65/* Populate corpus with canonical benchmark programs demonstrating recurring sub-expression (2x + 1) */
66int omega_corpus_populate_benchmark(OmegaCorpus *corpus);
67
68/* Mine corpus for repeating common sub-expression slices and evaluate compression */
69int omega_discover_abstractions(const OmegaCorpus *corpus, OmegaDiscoveryResult *result);
70
71/* Refactor a program by substituting an abstraction for a common sub-expression */
72int omega_refactor_program(const OmegaProgram *orig, const OmegaProgram *abstraction,
73 uint32_t match_offset_insns, uint32_t match_len_insns,
74 OmegaProgram *out_refactored);
75
76/* Verify semantic preservation: compare original and refactored programs on test inputs */
77bool omega_verify_semantic_preservation(const OmegaProgram *orig, const OmegaProgram *refactored,
78 const uint64_t *test_inputs, size_t input_count);
79
80/* Admitting a discovered abstraction into a library goes through omega_vc_bridge_admit_abstraction
81 * (src/omega_vc_bridge.h): the Verified Crumb Store admit path with a receipt (VC1 stage 6). */
82
83/* Demonstrate search acceleration on held-out task */
84int omega_demonstrate_search_acceleration(const OmegaProgram *discovered_abstraction,
85 size_t *out_candidates_without,
86 size_t *out_candidates_with);
87
88#endif /* OMEGA_DISCOVERY_H */