interplane.Get Omega
Read in your language

omega-principia

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

omega-principia / proofs / CoveringArrayHexadecimalTowerW25.lean

130 lines · 5544 bytes Raw Blame History
1-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2-- General Zero-Mathlib Lean 4.36.0 Structural Theorems:
3-- Complete Hexadecimal (v = 16 = 2^4) 4-Bitplane, 2-Nibble (v = 4), and 2-Octal (v = 8) Projection Tower Theorem.
4-- Author: M. Drake Stapleton (ORCID: 0009-0002-6890-7111)
5-- 0 sorry, 0 native_decide, zero custom axioms.
6
7namespace CoveringArrayHexadecimalTowerW25
8
9def IsCA3 (N k v : Nat) (A : Fin N → Fin k → Nat) : Prop :=
10 (∀ r c, A r c < v) ∧
11 (∀ c0 c1 c2 : Fin k, c0 ≠ c1 → c0 ≠ c2 → c1 ≠ c2 →
12 ∀ a0 a1 a2 : Nat, a0 < v → a1 < v → a2 < v →
13 ∃ r : Fin N, A r c0 = a0 ∧ A r c1 = a1 ∧ A r c2 = a2)
14
15/-- Universal strength-3 surjective alphabet projection. -/
16theorem ca3_surjective_projection {N k v1 v2 : Nat} {A : Fin N → Fin k → Nat}
17 (f : Nat → Nat)
18 (hf_range : ∀ x, x < v1 → f x < v2)
19 (hf_surj : ∀ y, y < v2 → ∃ x, x < v1 ∧ f x = y)
20 (hA : IsCA3 N k v1 A) :
21 IsCA3 N k v2 (fun r c => f (A r c)) := by
22 refine ⟨?_, ?_⟩
23 · intro r c
24 exact hf_range (A r c) (hA.1 r c)
25 · intro c0 c1 c2 h01 h02 h12 b0 b1 b2 hb0 hb1 hb2
26 rcases hf_surj b0 hb0 with ⟨a0, ha0, rfl⟩
27 rcases hf_surj b1 hb1 with ⟨a1, ha1, rfl⟩
28 rcases hf_surj b2 hb2 with ⟨a2, ha2, rfl⟩
29 rcases hA.2 c0 c1 c2 h01 h02 h12 a0 a1 a2 ha0 ha1 ha2 with ⟨r, hr0, hr1, hr2⟩
30 exact ⟨r, congrArg f hr0, congrArg f hr1, congrArg f hr2⟩
31
32/-- Hexadecimal (`v = 16 = 2^4`) 4-Bitplane Projections (`bit 0, 1, 2, 3`). -/
33theorem ca3_hex_bit0 {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
34 IsCA3 N k 2 (fun r c => A r c % 2) := by
35 apply ca3_surjective_projection (v1 := 16) (fun x => x % 2)
36 · intro x _; exact Nat.mod_lt x (by decide)
37 · intro y hy; exact ⟨y, by omega, by omega⟩
38 · exact hA
39
40theorem ca3_hex_bit1 {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
41 IsCA3 N k 2 (fun r c => (A r c / 2) % 2) := by
42 apply ca3_surjective_projection (v1 := 16) (fun x => (x / 2) % 2)
43 · intro x _; exact Nat.mod_lt _ (by decide)
44 · intro y hy; exact ⟨2 * y, by omega, by omega⟩
45 · exact hA
46
47theorem ca3_hex_bit2 {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
48 IsCA3 N k 2 (fun r c => (A r c / 4) % 2) := by
49 apply ca3_surjective_projection (v1 := 16) (fun x => (x / 4) % 2)
50 · intro x _; exact Nat.mod_lt _ (by decide)
51 · intro y hy; exact ⟨4 * y, by omega, by omega⟩
52 · exact hA
53
54theorem ca3_hex_bit3 {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
55 IsCA3 N k 2 (fun r c => (A r c / 8) % 2) := by
56 apply ca3_surjective_projection (v1 := 16) (fun x => (x / 8) % 2)
57 · intro x _; exact Nat.mod_lt _ (by decide)
58 · intro y hy; exact ⟨8 * y, by omega, by omega⟩
59 · exact hA
60
61/-- Hexadecimal (`v = 16`) Low & High Quaternary (`v = 4`) 2-Bit Nibble Projections. -/
62theorem ca3_hex_low_quat {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
63 IsCA3 N k 4 (fun r c => A r c % 4) := by
64 apply ca3_surjective_projection (v1 := 16) (fun x => x % 4)
65 · intro x _; exact Nat.mod_lt _ (by decide)
66 · intro y hy; exact ⟨y, by omega, by omega⟩
67 · exact hA
68
69theorem ca3_hex_high_quat {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
70 IsCA3 N k 4 (fun r c => A r c / 4) := by
71 apply ca3_surjective_projection (v1 := 16) (fun x => x / 4)
72 · intro x hx; omega
73 · intro y hy; exact ⟨4 * y, by omega, by omega⟩
74 · exact hA
75
76/-- Hexadecimal (`v = 16`) Low & High Octal (`v = 8`) 3-Bit Projections. -/
77theorem ca3_hex_low_octal {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
78 IsCA3 N k 8 (fun r c => A r c % 8) := by
79 apply ca3_surjective_projection (v1 := 16) (fun x => x % 8)
80 · intro x _; exact Nat.mod_lt _ (by decide)
81 · intro y hy; exact ⟨y, by omega, by omega⟩
82 · exact hA
83
84theorem ca3_hex_high_octal {N k : Nat} {A : Fin N → Fin k → Nat} (hA : IsCA3 N k 16 A) :
85 IsCA3 N k 8 (fun r c => A r c / 2) := by
86 apply ca3_surjective_projection (v1 := 16) (fun x => x / 2)
87 · intro x hx; omega
88 · intro y hy; exact ⟨2 * y, by omega, by omega⟩
89 · exact hA
90
91-- Broken-model negative controls (>= 4 literal neg_ctrl_*)
92
93theorem neg_ctrl_empty_not_ca3_v16 :
94 ¬ IsCA3 0 3 16 (fun r _ => Fin.elim0 r) := by
95 intro h
96 rcases h.2 ⟨0, by decide⟩ ⟨1, by decide⟩ ⟨2, by decide⟩ (by decide) (by decide) (by decide)
97 0 0 0 (by decide) (by decide) (by decide) with ⟨r, _, _, _⟩
98 exact Fin.elim0 r
99
100theorem neg_ctrl_bad_hex_symbol :
101 ¬ IsCA3 1 3 16 (fun _ _ => 16) := by
102 intro h
103 have hlt := h.1 ⟨0, by decide⟩ ⟨0, by decide⟩
104 exact Nat.lt_irrefl 16 hlt
105
106theorem neg_ctrl_const_zero_not_ca3_v16 :
107 ¬ IsCA3 6374 3 16 (fun _ _ => 0) := by
108 intro h
109 rcases h.2 ⟨0, by decide⟩ ⟨1, by decide⟩ ⟨2, by decide⟩ (by decide) (by decide) (by decide)
110 1 0 0 (by decide) (by decide) (by decide) with ⟨r, hr0, _, _⟩
111 exact Nat.noConfusion hr0
112
113theorem neg_ctrl_hex_shift_overflow : ¬ (16 / 4 < 4) := by
114 decide
115
116#print axioms ca3_surjective_projection
117#print axioms ca3_hex_bit0
118#print axioms ca3_hex_bit1
119#print axioms ca3_hex_bit2
120#print axioms ca3_hex_bit3
121#print axioms ca3_hex_low_quat
122#print axioms ca3_hex_high_quat
123#print axioms ca3_hex_low_octal
124#print axioms ca3_hex_high_octal
125#print axioms neg_ctrl_empty_not_ca3_v16
126#print axioms neg_ctrl_bad_hex_symbol
127#print axioms neg_ctrl_const_zero_not_ca3_v16
128#print axioms neg_ctrl_hex_shift_overflow
129
130end CoveringArrayHexadecimalTowerW25