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.
50 lines
1 KiB
Text
50 lines
1 KiB
Text
inductive Sign where
|
|
| zero | neg | pos
|
|
deriving DecidableEq
|
|
|
|
instance : OfNat Sign (nat_lit 0) where
|
|
ofNat := .zero
|
|
|
|
instance : OfNat Sign (nat_lit 1) where
|
|
ofNat := .pos
|
|
|
|
instance : Neg Sign where
|
|
neg | .zero => .zero
|
|
| .pos => .neg
|
|
| .neg => .pos
|
|
|
|
namespace Sign
|
|
|
|
@[simp] theorem zero_eq : zero = 0 := rfl
|
|
@[simp] theorem neg_eq : neg = -1 := rfl
|
|
@[simp] theorem pos_eq : pos = 1 := rfl
|
|
|
|
def mul : Sign → Sign → Sign
|
|
| neg, neg => pos
|
|
| neg, pos => neg
|
|
| neg, zero => zero
|
|
| zero, _ => zero
|
|
| pos, s => s
|
|
|
|
instance : Mul Sign where
|
|
mul a b := Sign.mul a b
|
|
|
|
def le : Sign → Sign → Bool
|
|
| neg, _ => true
|
|
| zero, zero => true
|
|
| _, pos => true
|
|
| _, _ => false
|
|
|
|
instance : LE Sign where
|
|
le a b := Sign.le a b
|
|
|
|
instance : DecidableRel (· ≤ · : Sign → Sign → Prop) :=
|
|
fun a b => inferInstanceAs (Decidable (le a b = true))
|
|
|
|
theorem neg_bot {s : Sign} : s ≤ -1 → s = -1 := by
|
|
cases s <;> decide
|
|
|
|
theorem pos_top {s : Sign} : 1 ≤ s → s = 1 := by
|
|
cases s <;> decide
|
|
|
|
end Sign
|