diff options
| author | Son HO | 2023-12-05 17:46:17 +0100 | 
|---|---|---|
| committer | GitHub | 2023-12-05 17:46:17 +0100 | 
| commit | 9eb117dc9e94d1b04d24c87d278d014f456b2d89 (patch) | |
| tree | 2663915767c3558203990ed14f8d5604b7fd21d1 /backends/lean/Base/Primitives | |
| parent | 4795e5f823bc89504855d8eb946b111d9314f4d5 (diff) | |
| parent | 726db4911add81a853aafcec3936b457aaeff5b4 (diff) | |
Merge pull request #38 from AeneasVerif/son_fixes2
Simplify and add some lemmas
Diffstat (limited to 'backends/lean/Base/Primitives')
| -rw-r--r-- | backends/lean/Base/Primitives/Scalar.lean | 3 | ||||
| -rw-r--r-- | backends/lean/Base/Primitives/Vec.lean | 4 | 
2 files changed, 7 insertions, 0 deletions
diff --git a/backends/lean/Base/Primitives/Scalar.lean b/backends/lean/Base/Primitives/Scalar.lean index cdd6d6f9..f74fecd4 100644 --- a/backends/lean/Base/Primitives/Scalar.lean +++ b/backends/lean/Base/Primitives/Scalar.lean @@ -427,6 +427,9 @@ def Scalar.cast {src_ty : ScalarTy} (tgt_ty : ScalarTy) (x : Scalar src_ty) : Re  @[reducible] def U64   := Scalar .U64  @[reducible] def U128  := Scalar .U128 +instance (ty : ScalarTy) : Inhabited (Scalar ty) := by +  constructor; cases ty <;> apply (Scalar.ofInt 0) +  -- TODO: reducible?  @[reducible] def core_isize_min : Isize := Scalar.ofInt Isize.min (by simp [Scalar.min, Scalar.max]; apply (Scalar.min_le_max .Isize))  @[reducible] def core_isize_max : Isize := Scalar.ofInt Isize.max (by simp [Scalar.min, Scalar.max]; apply (Scalar.min_le_max .Isize)) diff --git a/backends/lean/Base/Primitives/Vec.lean b/backends/lean/Base/Primitives/Vec.lean index e600a151..2c3fce91 100644 --- a/backends/lean/Base/Primitives/Vec.lean +++ b/backends/lean/Base/Primitives/Vec.lean @@ -37,6 +37,10 @@ example {a: Type u} (v : Vec a) : v.length ≤ Scalar.max ScalarTy.Usize := by  def Vec.new (α : Type u): Vec α := ⟨ [], by apply Scalar.cMax_suffices .Usize; simp ⟩ +instance (α : Type u) : Inhabited (Vec α) := by +  constructor +  apply Vec.new +  -- TODO: very annoying that the α is an explicit parameter  def Vec.len (α : Type u) (v : Vec α) : Usize :=    Usize.ofIntCore v.val.len (by scalar_tac) (by scalar_tac)  | 
