Skip to content

Commit cfc46ac

Browse files
authored
feat: internalization for grind order (#10562)
This PR simplifies the `grind order` module, and internalizes the order constraints. It removes the `Offset` type class because it introduced too much complexity. We now cover the same use cases with a simpler approach: - Any type that implements at least `Std.IsPreorder` - Arbitrary ordered rings. - `Nat` by the `Nat.ToInt` adapter.
1 parent 7c0868d commit cfc46ac

File tree

18 files changed

+435
-354
lines changed

18 files changed

+435
-354
lines changed

src/Init/Data/Int/OfNat.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ theorem finVal {n : Nat} {a : Fin n} {a' : Int}
8888
(h₁ : Lean.Grind.ToInt.toInt a = a') : NatCast.natCast (a.val) = a' := by
8989
rw [← h₁, Lean.Grind.ToInt.toInt, Lean.Grind.instToIntFinCoOfNatIntCast]
9090

91+
theorem eq_eq {a b : Nat} {a' b' : Int}
92+
(h₁ : NatCast.natCast a = a') (h₂ : NatCast.natCast b = b') : (a = b) = (a' = b') := by
93+
simp [← h₁, ←h₂]; constructor
94+
next => intro; subst a; rfl
95+
next => simp [Int.natCast_inj]
96+
97+
theorem lt_eq {a b : Nat} {a' b' : Int}
98+
(h₁ : NatCast.natCast a = a') (h₂ : NatCast.natCast b = b') : (a < b) = (a' < b') := by
99+
simp only [← h₁, ← h₂, Int.ofNat_lt]
100+
101+
theorem le_eq {a b : Nat} {a' b' : Int}
102+
(h₁ : NatCast.natCast a = a') (h₂ : NatCast.natCast b = b') : (a ≤ b) = (a' ≤ b') := by
103+
simp only [← h₁, ← h₂, Int.ofNat_le]
104+
91105
end Nat.ToInt
92106

93107
namespace Int.Nonneg

src/Init/Grind.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ public import Init.Grind.Attr
2424
public import Init.Data.Int.OfNat -- This may not have otherwise been imported, breaking `grind` proofs.
2525
public import Init.Grind.AC
2626
public import Init.Grind.Injective
27-
public import Init.Grind.Order

src/Init/Grind/Order.lean

Lines changed: 0 additions & 299 deletions
This file was deleted.

0 commit comments

Comments
 (0)