File size: 2,285 Bytes
a2ee19a | 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 | import OAI.Probability.SATComputability.RelaxedCandidates
import OAI.Probability.SATComputability.VariableDeletion
namespace OAI
namespace FixedClauseThreshold.Computability
open Finset
open scoped Classical
def encodeDeletion {n : ℕ} (D : Finset (Fin n)) (s : Fin n → Bool) : DeletionCandidate n :=
fun v => if v ∈ D then none else some (s v)
def deletedVariables {n : ℕ} (x : DeletionCandidate n) : Finset (Fin n) :=
univ.filter (fun v => x v = none)
theorem literalFalse_encode {n : ℕ} (D : Finset (Fin n)) (s : Fin n → Bool)
(v : Fin n) (b : Bool) :
¬literalFalse (encodeDeletion D s) (v, b) ↔ v ∈ D ∨ s v = b := by
by_cases hv : v ∈ D
· simp [literalFalse, encodeDeletion, hv]
· cases hb : s v <;> cases b <;> simp [literalFalse, encodeDeletion, hv, hb]
theorem deletedVariables_encode {n : ℕ} (D : Finset (Fin n)) (s : Fin n → Bool) :
deletedVariables (encodeDeletion D s) = D := by
ext v
by_cases hv : v ∈ D <;> simp [deletedVariables, encodeDeletion, hv]
theorem deletionSatisfiable_iff_candidate {n m r : ℕ}
(indices : Fin m → Fin 3 → Fin n) (signs : Fin m → Fin 3 → Bool) :
deletionSatisfiable r indices signs ↔
∃ x : DeletionCandidate n, (deletedVariables x).card ≤ r ∧
∀ j, ∃ l, ¬literalFalse x (indices j l, signs j l) := by
constructor
· rintro ⟨D, hD, s, hs⟩
refine ⟨encodeDeletion D s, ?_, ?_⟩
· simpa only [deletedVariables_encode] using hD
· intro j
rcases hs j with ⟨l, hl⟩ | ⟨l, hl⟩
· exact ⟨l, (literalFalse_encode D s _ _).mpr (Or.inl hl)⟩
· exact ⟨l, (literalFalse_encode D s _ _).mpr (Or.inr hl)⟩
· rintro ⟨x, hx, hs⟩
let D := deletedVariables x
let s : Fin n → Bool := fun v => (x v).getD false
refine ⟨D, hx, s, ?_⟩
intro j
obtain ⟨l, hl⟩ := hs j
cases hv : x (indices j l) with
| none =>
left
exact ⟨l, by simp [D, deletedVariables, hv]⟩
| some b =>
right
refine ⟨l, ?_⟩
have hb : b = signs j l := by
cases b <;> cases hsign : signs j l <;>
simp_all [literalFalse]
simpa only [s, hv, Option.getD_some] using hb
end FixedClauseThreshold.Computability
end OAI
|