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 / CoveringArrayDecimalStrength3W18.lean

122 lines · 5148 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-- Composite-Alphabet Strength-3 Covering Array Factorization & Decimal (v = 10 = 2 * 5) Splitting.
4-- Author: M. Drake Stapleton (ORCID: 0009-0002-6890-7111)
5-- 0 sorry, 0 native_decide, zero custom axioms.
6
7namespace CoveringArrayDecimalStrength3W18
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/-- Composite-alphabet lower-factor projection for strength 3: `CA(N; 3, k, a * b) -> CA(N; 3, k, a)`. -/
33theorem ca3_mod_projection {N k a b : Nat} {A : Fin N → Fin k → Nat}
34 (ha : 0 < a) (hb : 0 < b)
35 (hA : IsCA3 N k (a * b) A) :
36 IsCA3 N k a (fun r c => A r c % a) := by
37 apply ca3_surjective_projection (fun x => x % a)
38 · intro x _
39 exact Nat.mod_lt x ha
40 · intro y hy
41 refine ⟨y, ?_, Nat.mod_eq_of_lt hy⟩
42 have h1 : a ≤ a * b := Nat.le_mul_of_pos_right a hb
43 exact Nat.lt_of_lt_of_le hy h1
44 · exact hA
45
46/-- Composite-alphabet upper-factor projection for strength 3: `CA(N; 3, k, a * b) -> CA(N; 3, k, b)`. -/
47theorem ca3_div_projection {N k a b : Nat} {A : Fin N → Fin k → Nat}
48 (ha : 0 < a) (_hb : 0 < b)
49 (hA : IsCA3 N k (a * b) A) :
50 IsCA3 N k b (fun r c => A r c / a) := by
51 apply ca3_surjective_projection (fun x => x / a)
52 · intro x hx
53 exact (Nat.div_lt_iff_lt_mul ha).2 (by rw [Nat.mul_comm]; exact hx)
54 · intro y hy
55 refine ⟨a * y, ?_, ?_⟩
56 · exact Nat.mul_lt_mul_of_pos_left hy ha
57 · rw [Nat.mul_comm]
58 exact Nat.mul_div_cancel y ha
59 · exact hA
60
61/-- Decimal (`v = 10 = 2 * 5`) Strength-3 Binary Projection (`x % 2`). -/
62theorem ca3_decimal_binary_projection {N k : Nat} {A : Fin N → Fin k → Nat}
63 (hA : IsCA3 N k 10 A) :
64 IsCA3 N k 2 (fun r c => A r c % 2) :=
65 ca3_mod_projection (a := 2) (b := 5) (by decide) (by decide) hA
66
67/-- Decimal (`v = 10 = 2 * 5`) Strength-3 Quinary Projection (`x / 2`). -/
68theorem ca3_decimal_quinary_projection {N k : Nat} {A : Fin N → Fin k → Nat}
69 (hA : IsCA3 N k 10 A) :
70 IsCA3 N k 5 (fun r c => A r c / 2) :=
71 ca3_div_projection (a := 2) (b := 5) (by decide) (by decide) hA
72
73/-- Decimal (`v = 10 = 5 * 2`) Alternate Quinary Remainder Projection (`x % 5`). -/
74theorem ca3_decimal_mod5_projection {N k : Nat} {A : Fin N → Fin k → Nat}
75 (hA : IsCA3 N k 10 A) :
76 IsCA3 N k 5 (fun r c => A r c % 5) :=
77 ca3_mod_projection (a := 5) (b := 2) (by decide) (by decide) hA
78
79/-- Decimal (`v = 10 = 5 * 2`) Alternate Binary Quotient Projection (`x / 5`). -/
80theorem ca3_decimal_div5_projection {N k : Nat} {A : Fin N → Fin k → Nat}
81 (hA : IsCA3 N k 10 A) :
82 IsCA3 N k 2 (fun r c => A r c / 5) :=
83 ca3_div_projection (a := 5) (b := 2) (by decide) (by decide) hA
84
85-- Broken-model negative controls (>= 4 literal neg_ctrl_*)
86
87theorem neg_ctrl_empty_not_ca3_v10 :
88 ¬ IsCA3 0 3 10 (fun r _ => Fin.elim0 r) := by
89 intro h
90 rcases h.2 ⟨0, by decide⟩ ⟨1, by decide⟩ ⟨2, by decide⟩ (by decide) (by decide) (by decide)
91 0 0 0 (by decide) (by decide) (by decide) with ⟨r, _, _, _⟩
92 exact Fin.elim0 r
93
94theorem neg_ctrl_bad_decimal_symbol_t3 :
95 ¬ IsCA3 1 3 10 (fun _ _ => 10) := by
96 intro h
97 have hlt := h.1 ⟨0, by decide⟩ ⟨0, by decide⟩
98 exact Nat.lt_irrefl 10 hlt
99
100theorem neg_ctrl_const_zero_not_ca3_v10 :
101 ¬ IsCA3 1868 3 10 (fun _ _ => 0) := by
102 intro h
103 rcases h.2 ⟨0, by decide⟩ ⟨1, by decide⟩ ⟨2, by decide⟩ (by decide) (by decide) (by decide)
104 1 0 0 (by decide) (by decide) (by decide) with ⟨r, hr0, _, _⟩
105 exact Nat.noConfusion hr0
106
107theorem neg_ctrl_decimal_div5_overflow : ¬ (10 / 5 < 2) := by
108 decide
109
110#print axioms ca3_surjective_projection
111#print axioms ca3_mod_projection
112#print axioms ca3_div_projection
113#print axioms ca3_decimal_binary_projection
114#print axioms ca3_decimal_quinary_projection
115#print axioms ca3_decimal_mod5_projection
116#print axioms ca3_decimal_div5_projection
117#print axioms neg_ctrl_empty_not_ca3_v10
118#print axioms neg_ctrl_bad_decimal_symbol_t3
119#print axioms neg_ctrl_const_zero_not_ca3_v10
120#print axioms neg_ctrl_decimal_div5_overflow
121
122end CoveringArrayDecimalStrength3W18