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/src/checker2/c2_blast.h # 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 / src / checker2 / c2_blast.h` 60 lines ยท 2978 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 /* c2_blast: checker2's bit-blaster for bounded integer programs (omega#446). 18 * 19 * Property NO-TRAP for function F of a unit checker2 has accepted: 20 * for every argument value, a run of F that passes its `requires` clauses (trap code 9 is the 21 * caller's fault, OSC-2) ends without any trap: no overflow, shift, cast, loop-bound or 22 * `ensures` (code 10) trap, and no explicit TRAP instruction is reached. 23 * The CNF is satisfiable exactly when some argument value reaches such a trap, so an LRAT proof 24 * of unsatisfiability, accepted by c2_lrat_check, proves the property. 25 * 26 * Semantics bit-blasted (docs/osc/OSC-1-DESIGN.md section 5): unsigned results reduce modulo 2^w; 27 * signed ADD/SUB/MUL/NEG/SHL trap OVERFLOW when the result is not representable; a shift amount 28 * outside 0..w-1 traps SHIFT; CAST traps CAST when the value is not representable in the target; 29 * CMP is signed for signed operands; bool is one bit. 30 * 31 * Supported subset (anything else is refused, never approximated): scalar parameters and 32 * registers only; CONST MOV BIN(ADD SUB MUL AND OR XOR SHL, SHR on unsigned) UN CMP CAST BR CBR 33 * RET TRAP. Refused: CALL, memory, handles, slices, DIV, REM, SHR on signed operands. Every path is 34 * executed symbolically (paths whose branch condition is a constant do not fork, so loops with a 35 * constant counter unroll exactly); more than C2_BLAST_MAX_PATHS paths or C2_BLAST_MAX_STEPS 36 * steps is refused as too large. */ 37 #ifndef C2_BLAST_H 38 #define C2_BLAST_H 39 40 #include "c2_ir.h" 41 #include "c2_lrat.h" 42 43 #define C2_BLAST_MAX_PATHS 4096 44 #define C2_BLAST_MAX_STEPS 4000000L 45 #define C2_PROPERTY_NOTRAP "no-trap-except-requires" 46 47 typedef struct { 48 const char *rule; /* "BLAST-OK" or the refusal reason */ 49 char detail[160]; 50 int inputs; /* argument bits (CNF variables 2..inputs+1) */ 51 int paths, trap_sites; /* explored paths; path points where a trap can fire */ 52 } C2BlastInfo; 53 54 /* 0: cnf built (caller frees with c2_cnf_free); -1: refused (info->rule). The unit must already be 55 * accepted by c2_check_unit; c2_blast_notrap runs it again and refuses otherwise. */ 56 int c2_blast_notrap(const C2Unit *u, int fi, C2Cnf *cnf, C2BlastInfo *info); 57 /* index of the function called name, or -1 */ 58 int c2_func_index(const C2Unit *u, const char *name); 59 60 #endif /* C2_BLAST_H */