The first output is the second input and the second output is the first input. If the inputs differ, each output differs from the input in the same position.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15import datasets.verina.verina_basic_93.task
namespace Submission
theorem solution : type_of% @SwapBitvectors_spec_satisfied := by
intro X Y h
have hy : (X.xor Y).xor Y = X := by
apply UInt8.toBitVec_inj.mp
change (X.toBitVec ^^^ Y.toBitVec) ^^^ Y.toBitVec = X.toBitVec
simp [BitVec.xor_assoc]
have hx : (X.xor Y).xor X = Y := by
apply UInt8.toBitVec_inj.mp
change (X.toBitVec ^^^ Y.toBitVec) ^^^ X.toBitVec = Y.toBitVec
rw [BitVec.xor_comm X.toBitVec Y.toBitVec]
simp [BitVec.xor_assoc]
simp [SwapBitvectors, SwapBitvectors_postcond, hy, hx, ne_comm]
end Submission
Check it yourself
Project
verina
Commit
66b3ce5014edafb20cb26b87c681e7f31847249f
Lean
leanprover/lean4:v4.18.0
With Git and Elan installed, put the download in a fresh working directory and run this there. Use a disposable environment. Lean prints the axioms at the end. The checker allows propext, Classical.choice, and Quot.sound.
Download the receipt verifier and public key. Run python3 verify-proof.py certificate.json b8e8aeab-b6b5-4c3c-ba6e-03ab835a137b.lean proof-key.pem with OpenSSL 3.