diff options
author | Son HO | 2024-04-23 16:49:31 +0200 |
---|---|---|
committer | GitHub | 2024-04-23 16:49:31 +0200 |
commit | 1be37966ceea2510b911b119a96246b4657a62fd (patch) | |
tree | 85ed42e1be3a26741c26843ea06ada806170663a /backends/lean/Base | |
parent | f3007820a21d11721507f5054b30bf5ae99a7b95 (diff) | |
parent | e49b92903cbd3dc7c981789cb4121dc89569bed3 (diff) |
Merge pull request #156 from RaitoBezarius/orders
feat(backends/lean): scalars form a linear order
Diffstat (limited to 'backends/lean/Base')
-rw-r--r-- | backends/lean/Base/Primitives/Scalar.lean | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/backends/lean/Base/Primitives/Scalar.lean b/backends/lean/Base/Primitives/Scalar.lean index be930754..014decb1 100644 --- a/backends/lean/Base/Primitives/Scalar.lean +++ b/backends/lean/Base/Primitives/Scalar.lean @@ -1404,6 +1404,21 @@ instance (ty: ScalarTy) : Preorder (Scalar ty) where trans (a: Int) ≤ (b: Int) ∧ ¬ (b: Int) ≤ (a: Int); exact lt_iff_le_not_le repeat rewrite [← Scalar.le_equiv]; rfl +instance (ty: ScalarTy) : PartialOrder (Scalar ty) where + le_antisymm := fun a b Hab Hba => Scalar.eq_imp _ _ ((@le_antisymm Int _ _ _ ((Scalar.le_equiv a b).1 Hab) ((Scalar.le_equiv b a).1 Hba))) + +instance ScalarDecidableLE (ty: ScalarTy) : DecidableRel (· ≤ · : Scalar ty -> Scalar ty -> Prop) := by + simp [instLEScalar] + -- Lift this to the decidability of the Int version. + infer_instance + +instance (ty: ScalarTy) : LinearOrder (Scalar ty) where + le_total := fun a b => by + rcases (Int.le_total a b) with H | H + left; exact (Scalar.le_equiv _ _).2 H + right; exact (Scalar.le_equiv _ _).2 H + decidableLE := ScalarDecidableLE ty + -- Leading zeros def core.num.Usize.leading_zeros (x : Usize) : U32 := sorry def core.num.U8.leading_zeros (x : U8) : U32 := sorry |