This PR sets up the new integrated test/bench suite. It then migrates all benchmarks and some related tests to the new suite. There's also some documentation and some linting. For now, a lot of the old tests are left alone so this PR doesn't become even larger than it already is. Eventually, all tests should be migrated to the new suite though so there isn't a confusing mix of two systems.
38 lines
1.3 KiB
Text
38 lines
1.3 KiB
Text
def List.pwFilter {α} (R : α → α → Prop) [DecidableRel R] (l : List α) : List α :=
|
||
l.foldr (fun x IH => if ∀ y ∈ IH, R x y then x :: IH else IH) []
|
||
|
||
def List.dedup {α} [DecidableEq α] : List α → List α :=
|
||
List.pwFilter (· ≠ ·)
|
||
|
||
def Multiset.{u} : Type u → Type u :=
|
||
fun α => Quotient (List.isSetoid α)
|
||
|
||
def Multiset.ofList {α} : List α → Multiset α :=
|
||
Quot.mk _
|
||
|
||
def Multiset.map {α β} (f : α → β) (s : Multiset α) : Multiset β :=
|
||
Quot.liftOn s (fun l : List α => Multiset.ofList (l.map f)) fun _l₁ _l₂ p => Quot.sound (p.map f)
|
||
|
||
def Multiset.dedup {α} [DecidableEq α] (s : Multiset α) : Multiset α :=
|
||
Quot.liftOn s (fun l => Multiset.ofList l.dedup) fun l₁ l₂ p => Quot.sound (by sorry)
|
||
|
||
def Multiset.card {α} : Multiset α → Nat := Quot.lift List.length fun _l₁ _l₂ => List.Perm.length_eq
|
||
|
||
def test (_ : Unit) : Bool :=
|
||
let m := Multiset.ofList [0, 1]
|
||
let m := Multiset.map (fun i => i) m
|
||
let m := m.dedup
|
||
m.card < 2
|
||
|
||
/--
|
||
error: Tactic `native_decide` evaluated that the proposition
|
||
(let p := fun i => i;
|
||
(Multiset.map (fun i => i) (Multiset.ofList [0, 1])).dedup).card <
|
||
2
|
||
is false
|
||
-/
|
||
#guard_msgs in
|
||
theorem claim :
|
||
( let p : Nat → Nat := fun i => i;
|
||
(Multiset.map (fun i => i) (Multiset.ofList [0,1])).dedup).card < 2 := by
|
||
native_decide
|