/- Released under Apache 2.0 license as described in the file LICENSE. -/ import FormalConflictRange.ComputableHull import FormalConflictRange.ComputableSearch /-! # A simple computable conflict-range algorithm This file assembles the computable pieces into one algorithm: * `activeComputableFast` decides cell activity by finite count feasibility, using the lazy hitting-set search of `ComputableSearch.lean`; * `cellRepsC`/`activeRepsOfC` enumerate the endpoint cells with executable `Finset` operations; * `hullOfActiveRepsC` extracts the least active key and greatest active upper boundary with `Finset.min`/`Finset.max`. The result, `simpleConflictRange`, is a total `ConflictRange`-valued `def` (not a classical existence statement) and is proved minimal on every readable pair. Both activity and hull extraction are executable; the eager `choices` oracle is kept only as a proof-facing reference. -/ namespace FormalConflictRange /-- The simple computable conflict-range algorithm: enumerate the endpoint cells, decide activity with the lazy oracle `activeComputableFast`, and take the hull. -/ def simpleConflictRange (r : RangeRead) (res : Result) : ConflictRange := computableCellwise r res (activeComputableFast r res) /-- The simple algorithm agrees with the cellwise oracle algorithm. -/ theorem simpleConflictRange_eq_cellwise (r : RangeRead) (res : Result) : simpleConflictRange r res = conflictRangeCellwise r res (activeComputableFast r res) := computableCellwise_eq_cellwise r res (activeComputableFast r res) /-- On a readable pair, the simple algorithm agrees with the cellwise algorithm driven by the eager `choices` oracle. -/ theorem simpleConflictRange_eq_eager_cellwise {r : RangeRead} {res : Result} (hread : Readable r res) : simpleConflictRange r res = conflictRangeCellwise r res (activeComputable r res) := by rw [simpleConflictRange_eq_cellwise] have hfun : activeComputableFast r res = activeComputable r res := funext (activeComputableFast_eq hread) rw [hfun] /-- The simple algorithm computes the general hull on every readable pair. -/ theorem simpleConflictRange_eq_general {r : RangeRead} {res : Result} (hread : Readable r res) : simpleConflictRange r res = conflictRangeGeneral r res := by rw [simpleConflictRange_eq_cellwise] exact conflictRangeCellwise_eq_general (activeComputableFast_spec hread) /-- The simple algorithm is minimal on every readable pair. -/ theorem simpleConflictRange_minimal {r : RangeRead} {res : Result} (hread : Readable r res) : Minimal r res (simpleConflictRange r res) := by rw [simpleConflictRange_eq_general hread] exact conflictRangeGeneral_minimal hread /-- The simple algorithm computes exactly the necessary-key set. -/ theorem simpleConflictRange_toSet_eq_necessarySet {r : RangeRead} {res : Result} (hread : Readable r res) : (simpleConflictRange r res).toSet = necessarySet r res := by rw [simpleConflictRange_eq_general hread] exact necessarySet_eq_flipHull (characterizesDNF_characterizingDNF hread) end FormalConflictRange