diff options
author | Son Ho | 2024-04-25 08:21:43 +0200 |
---|---|---|
committer | Son Ho | 2024-04-25 08:21:43 +0200 |
commit | 51214e534e26d473b9260befc967cfd287bb9eb3 (patch) | |
tree | eb09a3852be8f20f14943b9fe52223f3b02ca330 /backends/lean/Base | |
parent | 5f2a388d1ff039cde0d78daaba58c191b404405e (diff) | |
parent | 1be37966ceea2510b911b119a96246b4657a62fd (diff) |
Merge branch 'main' into option-take
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 |