diff options
author | Son HO | 2024-05-14 10:52:07 +0200 |
---|---|---|
committer | GitHub | 2024-05-14 10:52:07 +0200 |
commit | f21cc739c3cc19b20ffd50b464dedb4f23d4512c (patch) | |
tree | c24c553eafb29e2c4ab763aca16b450770654341 | |
parent | 5c758f8b9b70288f3ef428c53122c75677255520 (diff) | |
parent | 001f3553287a51c1704ea3033a44e548440ec108 (diff) |
Merge pull request #177 from RaitoBezarius/oops-soundness-i-am-sowwy
backends/lean: repair definitions of `core.mem.replace`
-rw-r--r-- | backends/lean/Base/Primitives/Base.lean | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/backends/lean/Base/Primitives/Base.lean b/backends/lean/Base/Primitives/Base.lean index d682e926..c9237e65 100644 --- a/backends/lean/Base/Primitives/Base.lean +++ b/backends/lean/Base/Primitives/Base.lean @@ -134,7 +134,10 @@ def Result.attach {α: Type} (o : Result α): Result { x : α // o = ok x } := -- MISC -- ---------- -@[simp] def core.mem.replace (a : Type) (x : a) (_ : a) : a × a := (x, x) +-- This acts like a swap effectively in a functional pure world. +-- We return the old value of `dst`, i.e. `dst` itself. +-- The new value of `dst` is `src`. +@[simp] def core.mem.replace (a : Type) (dst : a) (src : a) : a × a := (dst, src) /- [core::option::Option::take] -/ @[simp] def Option.take (T: Type) (self: Option T): Option T × Option T := (self, .none) /- [core::mem::swap] -/ |