cfahlgren1/math / lean /OAI /Algorithms /SubexponentialSAT /ExecCNFSemanticHelpers.lean
cfahlgren1's picture
download
raw
2.6 kB
import OAI.Algorithms.SubexponentialSAT.LeanCompat
import OAI.Algorithms.SubexponentialSAT.ExecCNF
import OAI.Algorithms.SubexponentialSAT.Encoding
namespace OAI.Algorithms
/-! Exact list identities used when composing executable CNF filters. -/
namespace SubexponentialSAT.Encoding
universe u
/-- Filtering discards complete frames; this bound needs no property of the
payload encoder. -/
theorem length_encodeList_filter_le {α : Type u} (enc : α → List Bool)
(keep : α → Bool) (values : List α) :
(encodeList enc (values.filter keep)).length ≤ (encodeList enc values).length := by
induction values with
| nil => simp
| cons a values ih =>
cases h : keep a with
| false =>
simp [ h, length_encodeList_cons] ; omega
| true =>
simp [ h, length_encodeList_cons] ; omega
end SubexponentialSAT.Encoding
namespace SubexponentialSAT.ExecCNF
universe u
variable {α : Type u} [DecidableEq α]
theorem any_strictSubset_dedupClauses (F : Formula α) (C : Clause α) :
(dedupClauses F).any (fun D => strictSubset D C) =
F.any (fun D => strictSubset D C) := by
apply Bool.eq_iff_iff.mpr
simp only [any_strictSubset_true, formulaSet_dedupClauses]
/-- An implementation may first remove duplicate clauses, then use that same
list as the scan master, without changing the exact ordered output of absorb. -/
theorem absorb_eq_filter_dedup (F : Formula α) :
absorb F = (dedupClauses F).filter
(fun C => !((dedupClauses F).any (fun D => strictSubset D C))) := by
simp only [absorb, any_strictSubset_dedupClauses]
/-- Clause deduplication retains a subsequence of the original payloads. -/
theorem length_encodeList_dedupClauses_le (enc : Clause α → List Bool) (F : Formula α) :
(Encoding.encodeList enc (dedupClauses F)).length ≤
(Encoding.encodeList enc F).length := by
induction F with
| nil => rfl
| cons C F ih =>
by_cases h : F.any (fun D => equivalent C D) = true
· simp [dedupClauses, h, Encoding.length_encodeList_cons] ; omega
· simp [dedupClauses, h, Encoding.length_encodeList_cons] ; omega
/-- Absorption cannot increase the serialized formula length, even when the
payload encoder uses unequal-length clause encodings. -/
theorem length_encodeList_absorb_le (enc : Clause α → List Bool) (F : Formula α) :
(Encoding.encodeList enc (absorb F)).length ≤
(Encoding.encodeList enc F).length := by
unfold absorb
exact (Encoding.length_encodeList_filter_le enc _ _).trans
(length_encodeList_dedupClauses_le enc F)
end SubexponentialSAT.ExecCNF
end OAI.Algorithms

Xet Storage Details

Size:
2.6 kB
·
Xet hash:
3003ef76b4db5d35868b3047c543a63384cc55407e45e25fe9f79bac6e1e670e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.