Download data/lean/OAI/Combinatorics/EditApproximation/Coarse/CoarseAccessControlSpace.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.11 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Coarse/CoarseAccessControlSpace.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditApproximation/Coarse/CoarseAccessControlSpace.lean
-
curl -L -o CoarseAccessControlSpace.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Coarse/CoarseAccessControlSpace.lean
6.11 kB
| import OAI.Combinatorics.EditApproximation.Numerics.ScalarControlSpace | |
| import OAI.Combinatorics.EditApproximation.Coarse.CoarseReadAccess | |
| import OAI.Combinatorics.EditApproximation.Coarse.CoarseReadLeafWork | |
| namespace OAI | |
| namespace EditApproximation | |
| def saturatingSubtractInvocations (a b : β) : β := | |
| bitCompareInvocations a.bits b.bits + 1 + | |
| if (binaryNaturalCompareWithWork a b).1 = .lt then 0 | |
| else bitSubtractInvocations a.bits b.bits false | |
| theorem saturatingSubtractInvocations_le_work (a b : β) : | |
| saturatingSubtractInvocations a b β€ (saturatingSubtractWithWork a b).2 := by | |
| have hc := bitCompareInvocations_le_work a.bits b.bits | |
| have hs := bitSubtractInvocations_le_work a.bits b.bits false | |
| unfold saturatingSubtractInvocations saturatingSubtractWithWork | |
| dsimp only | |
| split_ifs <;> simp only [binaryNaturalSubtractWithWork, binaryNaturalCompareWithWork] at * <;> omega | |
| def coarseDescriptorInvocations (B d n start : β) : β := | |
| bitPowerInvocations B.bits d + saturatingSubtractInvocations n start + | |
| bitCompareInvocations (saturatingSubtractWithWork n start).1 (bitPowerWithWork B.bits d).1 + 3 | |
| theorem coarseDescriptorInvocations_le_work (B d n start : β) : | |
| coarseDescriptorInvocations B d n start β€ (coarseDescriptorWithWork B d n start).2 := by | |
| have hp := bitPowerInvocations_le_work B.bits d | |
| have hs := saturatingSubtractInvocations_le_work n start | |
| have hc := bitCompareInvocations_le_work (saturatingSubtractWithWork n start).1 | |
| (bitPowerWithWork B.bits d).1 | |
| unfold coarseDescriptorInvocations coarseDescriptorWithWork | |
| simp only [wordMinWithWork, wordLEWithWork] | |
| omega | |
| def coarseChildOffsetInvocations (offset capacity index : β) : β := | |
| bitMulInvocations index.bits capacity.bits + | |
| bitAddInvocations offset.bits (bitWordValue (binaryNaturalMulWithWork index capacity).1).bits false + 1 | |
| theorem coarseChildOffsetInvocations_le_work (offset capacity index : β) : | |
| coarseChildOffsetInvocations offset capacity index β€ (coarseChildOffsetWithWork offset capacity index).2 := by | |
| have hm := bitMulInvocations_le_work index.bits capacity.bits | |
| have ha := bitAddInvocations_le_work offset.bits | |
| (bitWordValue (binaryNaturalMulWithWork index capacity).1).bits false | |
| unfold coarseChildOffsetInvocations coarseChildOffsetWithWork | |
| simp only [binaryNaturalMulWithWork, binaryNaturalAddWithWork] at ha β’ | |
| omega | |
| def coarsePaddedReadInvocations (n offset : β) : β := bitCompareInvocations offset.bits n.bits + 1 | |
| theorem coarsePaddedReadInvocations_le_work {Ξ± : Type*} (n : β) (source : List Ξ±) (offset : β) : | |
| coarsePaddedReadInvocations n offset β€ (coarsePaddedReadWithWork n source offset).2 := by | |
| have hc := bitCompareInvocations_le_work offset.bits n.bits | |
| unfold coarsePaddedReadInvocations coarsePaddedReadWithWork binaryNaturalCompareWithWork | |
| dsimp only | |
| omega | |
| def coarseFramedReadInvocations (k n i : β) : β := | |
| bitCompareInvocations i.bits k.bits + 1 + | |
| if (binaryNaturalCompareWithWork i k).1 = .lt then 0 else | |
| bitAddInvocations k.bits n.bits false + | |
| bitCompareInvocations i.bits (bitWordValue (binaryNaturalAddWithWork k n).1).bits + | |
| if (binaryNaturalCompareWithWork i (bitWordValue (binaryNaturalAddWithWork k n).1)).1 = .lt | |
| then saturatingSubtractInvocations i k else 0 | |
| theorem coarseFramedReadInvocations_le_work {Ξ± : Type*} (k n : β) (word : List Ξ±) (i : β) : | |
| coarseFramedReadInvocations k n i β€ (coarseFramedReadWithWork k n word i).2 := by | |
| have hl := bitCompareInvocations_le_work i.bits k.bits | |
| have ha := bitAddInvocations_le_work k.bits n.bits false | |
| have hu := bitCompareInvocations_le_work i.bits (bitWordValue (binaryNaturalAddWithWork k n).1).bits | |
| have hs := saturatingSubtractInvocations_le_work i k | |
| unfold coarseFramedReadInvocations coarseFramedReadWithWork | |
| dsimp only | |
| split_ifs <;> simp only [binaryNaturalAddWithWork, binaryNaturalCompareWithWork] at * <;> omega | |
| def coarseLetterMatchInvocations : Option (Option β) β Option β β β | |
| | some (some a), some b => bitCompareInvocations a.bits b.bits + 1 | |
| | _, _ => 1 | |
| theorem coarseLetterMatchInvocations_le_work (actual : Option (Option β)) (wanted : Option β) : | |
| coarseLetterMatchInvocations actual wanted β€ (coarseLetterMatchWithWork actual wanted).2 := by | |
| cases actual with | |
| | none => cases wanted <;> exact Nat.le_refl 1 | |
| | some actual => | |
| cases actual with | |
| | none => cases wanted <;> exact Nat.le_refl 1 | |
| | some a => | |
| cases wanted with | |
| | none => exact Nat.le_refl 1 | |
| | some b => | |
| have h := bitCompareInvocations_le_work a.bits b.bits | |
| exact Nat.add_le_add_right h 1 | |
| namespace BinaryFraction | |
| def coarseReadShiftInvocations (k n : β) (target : List β) (letter : Option (Option β)) | |
| (start : β) (shift : Fin (2 * k + 1)) : β := | |
| match letter with | |
| | none => 1 | |
| | some wanted => | |
| let position := binaryNaturalAddWithWork start shift.val | |
| bitAddInvocations start.bits shift.val.bits false + | |
| coarseFramedReadInvocations k n (bitWordValue position.1) + | |
| coarseLetterMatchInvocations (coarseFramedReadWithWork k n target (bitWordValue position.1)).1 wanted + 1 | |
| theorem coarseReadShiftInvocations_le_work (k n : β) (target : List β) | |
| (letter : Option (Option β)) (start : β) (shift : Fin (2 * k + 1)) : | |
| coarseReadShiftInvocations k n target letter start shift β€ (coarseReadShiftWithWork k n target letter start shift).2 := by | |
| cases letter with | |
| | none => exact Nat.le_refl 1 | |
| | some letter => | |
| have ha := bitAddInvocations_le_work start.bits shift.val.bits false | |
| have hf := coarseFramedReadInvocations_le_work k n target | |
| (bitWordValue (binaryNaturalAddWithWork start shift.val).1) | |
| have hm := coarseLetterMatchInvocations_le_work | |
| (coarseFramedReadWithWork k n target (bitWordValue (binaryNaturalAddWithWork start shift.val).1)).1 letter | |
| unfold coarseReadShiftInvocations coarseReadShiftWithWork | |
| simp only [binaryNaturalAddWithWork] at hf hm β’ | |
| omega | |
| end BinaryFraction | |
| end EditApproximation | |
| end OAI | |