Prove minimality is unique and add it to the headlines
- Define `ConflictRange.toSet`, the set of keys lying in a range - Add the headline `MinimalUnique`: any two minimal sound ranges for the same read and result denote the same set of keys - Transport `FormalConflictRange.Minimal.toSet_eq` across the bridge; the statement is unconditional, since `Minimal` already carries soundness - State `Statement.minimalUnique` in the challenge and add it to the comparator's `theorem_names` `lake build` is warning-free and `lake comparator` accepts both headlines.
This commit is contained in:
1 parent
bd5b3c885c
commit
efd1b323e7
4 files changed
+47
-6
No files matched your search
+7
-2
@@ -4,8 +4,8 @@ import Statement
|
||||
# Challenge: minimality of the conflict-range closed form
|
||||
|
||||
This file is the trusted statement side of the comparator check. It states the
|
||||
headline theorem with a placeholder proof; `lake comparator` compares this
|
||||
statement against the proof in `Solution.lean`.
|
||||
headline theorems with placeholder proofs; `lake comparator` compares these
|
||||
statements against the proofs in `Solution.lean`.
|
||||
-/
|
||||
|
||||
namespace Statement
|
||||
@@ -15,4 +15,9 @@ namespace Statement
|
||||
theorem closedFormMinimal : ClosedFormMinimal := by
|
||||
sorry
|
||||
|
||||
/-- **Minimality is unique.** Any two minimal sound conflict ranges for the same
|
||||
read and result denote the same set of keys. -/
|
||||
theorem minimalUnique : MinimalUnique := by
|
||||
sorry
|
||||
|
||||
end Statement
|
||||
+18
-1
@@ -39,6 +39,9 @@ theorem keys_eq (cr : ConflictRange) (db : DB) :
|
||||
unfold RangeRead.inRange
|
||||
rfl
|
||||
|
||||
theorem toSet_eq (cr : ConflictRange) :
|
||||
(toRefCR cr).toSet = cr.toSet := rfl
|
||||
|
||||
theorem agreeOn_iff (cr : ConflictRange) (db₁ db₂ : DB) :
|
||||
FormalConflictRange.AgreeOn (toRefCR cr) (toRefDB db₁) (toRefDB db₂) ↔
|
||||
AgreeOn cr db₁ db₂ := by
|
||||
@@ -107,7 +110,7 @@ theorem closedForm_eq (r : RangeRead) (res : Result) :
|
||||
· unfold FormalConflictRange.conflictRangeClosedFormClosed closedForm
|
||||
simp [hne]
|
||||
|
||||
/-! ## The headline -/
|
||||
/-! ## The headlines -/
|
||||
|
||||
/-- **The closed form is minimal.** This is the reference theorem
|
||||
`minimal_conflictRangeClosedFormClosed`, transported across the definitional
|
||||
@@ -120,4 +123,18 @@ theorem closedFormMinimal : ClosedFormMinimal := by
|
||||
rw [closedForm_eq r res] at hmin
|
||||
exact (minimal_iff r res (closedForm r res)).mp hmin
|
||||
|
||||
/-- **Minimality is unique.** This is the reference theorem
|
||||
`FormalConflictRange.Minimal.toSet_eq`, transported across the definitional
|
||||
bridge. It is unconditional: the reference proof uses only that the
|
||||
intersection of two sound ranges is sound, so no readability hypothesis is
|
||||
needed. -/
|
||||
theorem minimalUnique : MinimalUnique := by
|
||||
intro r res cr cr' h h'
|
||||
have h₁ : FormalConflictRange.Minimal (toRefRead r) (toRefRes res) (toRefCR cr) :=
|
||||
(minimal_iff r res cr).mpr h
|
||||
have h₂ : FormalConflictRange.Minimal (toRefRead r) (toRefRes res) (toRefCR cr') :=
|
||||
(minimal_iff r res cr').mpr h'
|
||||
have hset := FormalConflictRange.Minimal.toSet_eq h₁ h₂
|
||||
rwa [toSet_eq cr, toSet_eq cr'] at hset
|
||||
|
||||
end Statement
|
||||
+21
-2
@@ -6,6 +6,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
||||
|
||||
> **The closed form is minimal.** For every readable read/result pair `(r, res)`,
|
||||
> `closedForm r res` is a minimal sound conflict range.
|
||||
>
|
||||
> **Minimality is unique.** Any two minimal sound ranges for the same read and
|
||||
> result denote the same set of keys.
|
||||
|
||||
It is a *statement* file, meant for review, not a proof. It contains:
|
||||
|
||||
@@ -13,7 +16,7 @@ It is a *statement* file, meant for review, not a proof. It contains:
|
||||
ranges, soundness, and minimality
|
||||
* the closed form itself, in `## The closed form`, because the theorem is *about
|
||||
that function*
|
||||
* the headline as the proposition `ClosedFormMinimal`
|
||||
* the headlines as the propositions `ClosedFormMinimal` and `MinimalUnique`
|
||||
|
||||
There is no `theorem`, no `axiom`, no `sorry`, and the only import is Mathlib.
|
||||
|
||||
@@ -156,6 +159,9 @@ def ConflictRange.mem (cr : ConflictRange) (k : Key) : Prop :=
|
||||
|
||||
instance : Membership Key ConflictRange := ⟨ConflictRange.mem⟩
|
||||
|
||||
/-- The set of keys lying in a conflict range. -/
|
||||
def ConflictRange.toSet (cr : ConflictRange) : Set Key := {k | k ∈ cr}
|
||||
|
||||
/-- The keys of a database lying in a conflict range, ascending. -/
|
||||
def ConflictRange.keys (cr : ConflictRange) (db : DB) : List Key :=
|
||||
RangeRead.inRange db.keys cr.begin cr.end_
|
||||
@@ -1112,7 +1118,7 @@ def closedForm (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
else if clampedNonpos r res then closedFormClamped r res
|
||||
else closedFormCrossed r res
|
||||
|
||||
/-! ## The headline -/
|
||||
/-! ## The headlines -/
|
||||
|
||||
/-- **The closed form is minimal.**
|
||||
|
||||
@@ -1121,4 +1127,17 @@ range: it is sound, and no proper subrange of it is sound. -/
|
||||
def ClosedFormMinimal : Prop :=
|
||||
∀ r res, Readable r res → Minimal r res (closedForm r res)
|
||||
|
||||
/-- **Minimality is unique.**
|
||||
|
||||
Any two minimal sound conflict ranges for the same read and result denote the same
|
||||
set of keys. This is a statement about `Minimal` alone, so it needs no readability
|
||||
hypothesis: minimality already carries soundness. Together with `ClosedFormMinimal`
|
||||
it says that `closedForm r res` is the minimal sound range up to its set of keys.
|
||||
|
||||
The converse direction does not hold: unique *key sets* do not pin the endpoints,
|
||||
so an empty range is only determined up to `toSet` equality. That is why this
|
||||
statement is about `ConflictRange.toSet` rather than about equality of ranges. -/
|
||||
def MinimalUnique : Prop :=
|
||||
∀ r res cr cr', Minimal r res cr → Minimal r res cr' → cr.toSet = cr'.toSet
|
||||
|
||||
end Statement
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"challenge_module": "Challenge",
|
||||
"solution_module": "Solution",
|
||||
"theorem_names": ["Statement.closedFormMinimal"],
|
||||
"theorem_names": ["Statement.closedFormMinimal", "Statement.minimalUnique"],
|
||||
"permitted_axioms": ["propext", "Quot.sound", "Classical.choice"]
|
||||
}
|
||||
Reference in new issue
Block a user