mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-07-31 01:25:21 +00:00
Systematic native_decide → dec_trivial/rfl migration across all Lean modules to comply with AGENTS.md rule 5 (no native_decide unless only option): - CoreFormalism: BraidEigensolid, BraidField, ChentsovFinite, HachimojiBase, HachimojiBridging, HachimojiCodec, HachimojiLUT, HachimojiManifoldAxiom, Q16_16Numerics - BindingSite: BindingSiteCodec, BindingSiteEntropy, BindingSiteHachimoji - SilverSight: ProductSchema, ProductWireFormat, PolyFactorIdentity, Schema, WireFormat - PVGS_DQ_Bridge: all three files (native_decide->dec_trivial) - UniversalEncoding/ChiralitySpace Additional changes: - gemma4_mcp.py: upgraded to two-tier routing (local Gemma4 + FreeLLMAPI proxy) - ChentsovFinite: added traceability map and Chentsov (1972) citation - HachimojiBase: renamed Σ→Sig, Π→Pi to avoid non-ASCII issues - Import path fixes for Mathlib 4.30.0-rc2 compatibility - Doc updates: PURE_FORMULAS, SOS_CERTIFICATE, fundamental math derivations - Build log: 2026-06-26 session findings - BRKGLASS_NR_BRACKET_PROPOSAL: updated to REAL-DATA VALIDATED status - New docs: FOUNDATIONAL_GUIDANCE, PURE_EQUATION_MAP, CHENTSOV_FINITE_MATH, BREAKGLASS_FUSION_REVIEW_SPEC, COLD_REVIEWER_FORMULA - New python: phi pipeline (equation_dna_encoder, ast_parse, charclass, consistency, embed, output), nr_bracket_validation with receipt Build: lake build SilverSightRRC — passes on all committed modules. Excluded: HachimojiN8Bridge, HachimojiCharClass (missing CoreFormalism.HachimojiManifoldAxiom olean — WIP)
68 lines
3.1 KiB
Text
68 lines
3.1 KiB
Text
/-
|
||
SilverSight.Semantics.ProductWireFormat
|
||
|
||
Certified row-major wire formats for product types (α × β), using Core
|
||
WireFormat and ProductSchema.
|
||
-/
|
||
import SilverSight.Semantics.WireFormat
|
||
import SilverSight.ProductSchema
|
||
|
||
namespace SilverSight.Semantics
|
||
|
||
-- ═══════════════════════════════════════════════════════════════════════════
|
||
-- §1 Row-major wire format for (UInt8 × Bool)
|
||
-- ═══════════════════════════════════════════════════════════════════════════
|
||
|
||
def uint8BoolRowMajor : WireFormat (UInt8 × Bool) rowMajor where
|
||
encode := fun (a, b) => ByteArray.mk #[a, if b then 1 else 0]
|
||
decode := fun bs =>
|
||
match bs.data.toList with
|
||
| [a, b] => some (a, b != 0)
|
||
| _ => none
|
||
encode_size := by intro (a, b); rfl
|
||
roundTrip := by
|
||
intro (a, b)
|
||
simp
|
||
cases b <;> decide
|
||
|
||
#eval uint8BoolRowMajor.encode (42, true)
|
||
#eval uint8BoolRowMajor.decode (uint8BoolRowMajor.encode (42, true))
|
||
|
||
-- ═══════════════════════════════════════════════════════════════════════════
|
||
-- §2 Row-major wire format for (UInt8 × UInt8)
|
||
-- ═══════════════════════════════════════════════════════════════════════════
|
||
|
||
def uint8PairRowMajor : WireFormat (UInt8 × UInt8) rowMajor where
|
||
encode := fun (a, b) => ByteArray.mk #[a, b]
|
||
decode := fun bs =>
|
||
match bs.data.toList with
|
||
| [a, b] => some (a, b)
|
||
| _ => none
|
||
encode_size := by intro (a, b); rfl
|
||
roundTrip := by
|
||
intro (a, b)
|
||
simp
|
||
|
||
#eval uint8PairRowMajor.encode (42, 7)
|
||
#eval uint8PairRowMajor.decode (uint8PairRowMajor.encode (42, 7))
|
||
|
||
-- ═══════════════════════════════════════════════════════════════════════════
|
||
-- §3 Row-major wire format for (Bool × Bool)
|
||
-- ═══════════════════════════════════════════════════════════════════════════
|
||
|
||
def boolPairRowMajor : WireFormat (Bool × Bool) rowMajor where
|
||
encode := fun (a, b) => ByteArray.mk #[if a then 1 else 0, if b then 1 else 0]
|
||
decode := fun bs =>
|
||
match bs.data.toList with
|
||
| [a, b] => some (a != 0, b != 0)
|
||
| _ => none
|
||
encode_size := by intro (a, b); rfl
|
||
roundTrip := by
|
||
intro (a, b)
|
||
simp
|
||
cases a <;> cases b <;> decide
|
||
|
||
#eval boolPairRowMajor.encode (true, false)
|
||
#eval boolPairRowMajor.decode (boolPairRowMajor.encode (true, false))
|
||
|
||
end SilverSight.Semantics
|