File size: 4,906 Bytes
9dbc64e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | import OAI.Computability.DepthThree.Model
namespace OAI
universe uDepth1 uDepth2 uDepth3
namespace DepthThreeLowerBound
abbrev Clause (V : Type uDepth1) := Finset (Literal V)
abbrev CNF (V : Type uDepth2) := List (Clause V)
variable {V : Type uDepth3}
namespace Literal
def compl (l : Literal V) : Literal V := (l.1, !l.2)
@[simp] theorem eval_eq_true (l : Literal V) (x : Cube V) :
l.eval x = true ↔ x l.1 = l.2 := by simp [eval]
@[simp] theorem compl_compl (l : Literal V) : l.compl.compl = l := by
cases l with
| mk v b => cases b <;> rfl
@[simp] theorem eval_compl (l : Literal V) (x : Cube V) :
l.compl.eval x = !(l.eval x) := by
rcases l with ⟨v, b⟩
cases b <;> cases h : x v <;> simp [compl, eval, h]
end Literal
namespace Clause
noncomputable def eval (C : Clause V) (x : Cube V) : Bool := by
classical
exact decide (∃ l ∈ C, l.eval x = true)
noncomputable def scope (C : Clause V) : Finset V := by
classical
exact C.image Prod.fst
noncomputable def width (C : Clause V) : ℕ := C.scope.card
def Normalized (C : Clause V) : Prop :=
∀ v, (v, false) ∈ C → (v, true) ∈ C → False
@[simp] theorem eval_eq_true (C : Clause V) (x : Cube V) :
C.eval x = true ↔ ∃ l ∈ C, x l.1 = l.2 := by
classical
simp [eval]
@[simp] theorem eval_empty (x : Cube V) : (∅ : Clause V).eval x = false := by
simp [eval]
@[simp] theorem scope_empty : (∅ : Clause V).scope = ∅ := by
classical
simp [scope]
@[simp] theorem width_empty : (∅ : Clause V).width = 0 := by
simp [width]
@[simp] theorem eval_singleton (l : Literal V) (x : Cube V) :
({l} : Clause V).eval x = l.eval x := by
classical
simp [eval, Literal.eval]
theorem eval_mono {C D : Clause V} (h : C ⊆ D) {x : Cube V}
(hx : C.eval x = true) : D.eval x = true := by
rw [eval_eq_true] at hx ⊢
obtain ⟨l, hl, hx⟩ := hx
exact ⟨l, h hl, hx⟩
theorem Normalized.subset {C D : Clause V} (hD : D.Normalized) (h : C ⊆ D) :
C.Normalized := by
intro v hf ht
exact hD v (h hf) (h ht)
theorem Normalized.fst_injOn {C : Clause V} (h : C.Normalized) :
Set.InjOn Prod.fst (↑C : Set (Literal V)) := by
rintro ⟨v, b⟩ hb ⟨w, c⟩ hc hv
change v = w at hv
subst w
cases b <;> cases c
· rfl
· exact (h v hb hc).elim
· exact (h v hc hb).elim
· rfl
theorem Normalized.card_eq_width {C : Clause V} (h : C.Normalized) :
C.card = C.width := by
classical
exact (Finset.card_image_of_injOn h.fst_injOn).symm
theorem scope_mono {C D : Clause V} (h : C ⊆ D) : C.scope ⊆ D.scope := by
classical
exact Finset.image_subset_image h
theorem width_mono {C D : Clause V} (h : C ⊆ D) : C.width ≤ D.width :=
Finset.card_le_card (scope_mono h)
end Clause
namespace CNF
noncomputable def eval (H : CNF V) (x : Cube V) : Bool := by
classical
exact decide (∀ C ∈ H, C.eval x = true)
def WidthAtMost (H : CNF V) (b : ℕ) : Prop := ∀ C ∈ H, C.width ≤ b
def Normalized (H : CNF V) : Prop := ∀ C ∈ H, C.Normalized
@[simp] theorem eval_eq_true (H : CNF V) (x : Cube V) :
H.eval x = true ↔ ∀ C ∈ H, C.eval x = true := by
classical
simp [eval]
@[simp] theorem eval_nil (x : Cube V) : CNF.eval ([] : CNF V) x = true := by
simp [eval]
@[simp] theorem eval_cons (C : Clause V) (H : CNF V) (x : Cube V) :
CNF.eval (C :: H) x = (C.eval x && H.eval x) := by
classical
apply Bool.eq_iff_iff.mpr
rw [eval_eq_true, Bool.and_eq_true, eval_eq_true]
constructor
· intro h
exact ⟨h C (by simp), fun D hD => h D (by simp [hD])⟩
· rintro ⟨hc, hH⟩ D hD
rcases List.mem_cons.mp hD with hD | hD
· simpa only [hD] using hc
· exact hH D hD
@[simp] theorem eval_append (H J : CNF V) (x : Cube V) :
(H ++ J).eval x = (H.eval x && J.eval x) := by
induction H with
| nil => simp
| cons C H ih => simp [ih, Bool.and_assoc]
theorem eval_antitone {H J : CNF V} (h : H ⊆ J) {x : Cube V}
(hx : J.eval x = true) : H.eval x = true := by
rw [eval_eq_true] at hx ⊢
exact fun C hC => hx C (h hC)
theorem WidthAtMost.mono {H : CNF V} {b c : ℕ} (h : H.WidthAtMost b)
(hbc : b ≤ c) : H.WidthAtMost c := fun C hC => (h C hC).trans hbc
end CNF
def indicator (b : Bool) : ℝ := if b then 1 else 0
def sign (b : Bool) : ℝ := if b then 1 else -1
@[simp] theorem indicator_false : indicator false = 0 := rfl
@[simp] theorem indicator_true : indicator true = 1 := rfl
@[simp] theorem sign_false : sign false = -1 := rfl
@[simp] theorem sign_true : sign true = 1 := rfl
@[simp] theorem indicator_and (b c : Bool) :
indicator (b && c) = indicator b * indicator c := by
cases b <;> cases c <;> simp [indicator]
theorem indicator_nonneg (b : Bool) : 0 ≤ indicator b := by
cases b <;> simp [indicator]
theorem indicator_le_one (b : Bool) : indicator b ≤ 1 := by
cases b <;> simp [indicator]
end DepthThreeLowerBound
end OAI
|