Download lean/OAI/Computability/QuantumFactoring/BitNumbers.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 869 Bytes
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/QuantumFactoring/BitNumbers.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Computability/QuantumFactoring/BitNumbers.lean
-
curl -L -o BitNumbers.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/QuantumFactoring/BitNumbers.lean
869 Bytes
| import Mathlib | |
| import OAI.Computability.QuantumFactoring.BitEncoding | |
| namespace OAI | |
| section | |
| open scoped BigOperators | |
| namespace ExactQuantumFactoring | |
| open scoped BigOperators | |
| lemma bitsValue_toNat {b : ℕ} (x : Fin b → Bool) : | |
| (bitsValue x).toNat = ∑ i : Fin b, 2^i.val*(x i).toNat := by | |
| induction b with | |
| | zero => simp [bitsValue] | |
| | succ b ih => | |
| rw [bitsValue, BitVec.toNat_cons', Nat.shiftLeft_eq, ih, Fin.sum_univ_castSucc] | |
| simp only [Fin.val_last, Fin.val_castSucc] | |
| ring | |
| lemma bitsValue_ofFn {b : ℕ} (v : Fin (2^b)) : | |
| (bitsValue (fun i : Fin b => v.val.testBit i.val)).toNat = v.val := by | |
| have he : (fun i : Fin b => v.val.testBit i.val) = | |
| (fun i : Fin b => (BitVec.ofNat b v.val).getLsbD i.val) := by simp | |
| rw [he, bitsValue_bits, BitVec.toNat_ofNat, Nat.mod_eq_of_lt v.isLt] | |
| end ExactQuantumFactoring | |
| end | |
| end OAI | |