Rank-one LAR preprocessing and random selectors
DefinitionInfoLossLAR_FirstBridgeBundle_07affine-transportinfo-loss-larquantum-reductions
Rank-one preprocessing converts an LAR test into a zero-fiber LWE test. This interface specifies random selectors, circuit bundles, zero-secret experiments, the computable direction used by the rank-one construction, and bounded uniform choices. It gives the data needed to represent the original distinguisher as one subroutine call.
Definition code
import Definitions.Def_InfoLossLAR_FirstBridgeBundle_05
import Definitions.Def_InfoLossLAR_FirstBridgeBundle_06_Optimized
open _root_.InfoLossLARNativeSupplements.h7fd26e43562bbe30.AFT.BinaryArithmetic.RationalBits renaming exists_code → AFT.BinaryArithmetic.RationalBits.exists_code
open _root_.InfoLossLARNativeSupplements.h7fd26e43562bbe30.AFT.BinaryArithmetic.RationalBits renaming exists_code → _p2mNativeSupplement0
open _root_.InfoLossLARNativeSupplements.hbc5d2d237f3bc4c8.AFT.BinaryArithmetic renaming bits_value → AFT.BinaryArithmetic.bits_value
open _root_.InfoLossLARNativeSupplements.hbc5d2d237f3bc4c8.AFT.BinaryArithmetic renaming bits_value → _p2mNativeSupplement1
open _root_.InfoLossLARNativeSupplements.h5a8ca90c605f85fc.AFT.CanonicalMoments renaming independent_embedding_expectation_general → AFT.CanonicalMoments.independent_embedding_expectation_general
open _root_.InfoLossLARNativeSupplements.h5a8ca90c605f85fc.AFT.CanonicalMoments renaming independent_embedding_expectation_general → _p2mNativeSupplement2
open _root_.InfoLossLARNativeSupplements.hf808c8dbbd952db7.AFT.CanonicalMoments renaming independent_equiv_expectation_general → AFT.CanonicalMoments.independent_equiv_expectation_general
open _root_.InfoLossLARNativeSupplements.hf808c8dbbd952db7.AFT.CanonicalMoments renaming independent_equiv_expectation_general → _p2mNativeSupplement3
open _root_.InfoLossLARNativeSupplements.h854528c9e123c6f3.AFT.RationalNumerics.HeightBound renaming div → AFT.RationalNumerics.HeightBound.div
open _root_.InfoLossLARNativeSupplements.h854528c9e123c6f3.AFT.RationalNumerics.HeightBound renaming div → _p2mNativeSupplement4
open _root_.InfoLossLARNativeSupplements.ha562531658b7642e.AFT.RationalNumerics.HeightBound renaming inv → AFT.RationalNumerics.HeightBound.inv
open _root_.InfoLossLARNativeSupplements.ha562531658b7642e.AFT.RationalNumerics.HeightBound renaming inv → _p2mNativeSupplement5
open _root_.InfoLossLARNativeSupplements.h4f5add37bf40c2da.AFT.RationalNumerics.HeightBound renaming mono → AFT.RationalNumerics.HeightBound.mono
open _root_.InfoLossLARNativeSupplements.h4f5add37bf40c2da.AFT.RationalNumerics.HeightBound renaming mono → _p2mNativeSupplement6
open _root_.InfoLossLARNativeSupplements.hec331a1b1191da2d.AFT.RationalNumerics.HeightBound renaming mul → AFT.RationalNumerics.HeightBound.mul
open _root_.InfoLossLARNativeSupplements.hec331a1b1191da2d.AFT.RationalNumerics.HeightBound renaming mul → _p2mNativeSupplement7
open _root_.InfoLossLARNativeSupplements.hca9f3ecea512145f.AFT.RationalNumerics.HeightBound renaming of_int → AFT.RationalNumerics.HeightBound.of_int
open _root_.InfoLossLARNativeSupplements.hca9f3ecea512145f.AFT.RationalNumerics.HeightBound renaming of_int → _p2mNativeSupplement8
open _root_.InfoLossLARNativeSupplements.h5b3dd70c728d6348.AFT.RationalNumerics.HeightBound renaming of_nat → AFT.RationalNumerics.HeightBound.of_nat
open _root_.InfoLossLARNativeSupplements.h5b3dd70c728d6348.AFT.RationalNumerics.HeightBound renaming of_nat → _p2mNativeSupplement9
open _root_.InfoLossLARNativeSupplements.h8fac5110874b5cd9.AFT.RationalNumerics.HeightBound renaming one → AFT.RationalNumerics.HeightBound.one
open _root_.InfoLossLARNativeSupplements.h8fac5110874b5cd9.AFT.RationalNumerics.HeightBound renaming one → _p2mNativeSupplement10
open _root_.InfoLossLARNativeSupplements.h90032182500c2e77.AFT.RationalNumerics.HeightBound renaming pow → AFT.RationalNumerics.HeightBound.pow
open _root_.InfoLossLARNativeSupplements.h90032182500c2e77.AFT.RationalNumerics.HeightBound renaming pow → _p2mNativeSupplement11
open _root_.InfoLossLARNativeSupplements.h6381918e2bfc67e4.AFT.RationalNumerics renaming arctanSum_error → AFT.RationalNumerics.arctanSum_error
open _root_.InfoLossLARNativeSupplements.h6381918e2bfc67e4.AFT.RationalNumerics renaming arctanSum_error → _p2mNativeSupplement12
open _root_.InfoLossLARNativeSupplements.h3497cf28d345cc71.AFT.RationalNumerics renaming arctan_term_bound → AFT.RationalNumerics.arctan_term_bound
open _root_.InfoLossLARNativeSupplements.h3497cf28d345cc71.AFT.RationalNumerics renaming arctan_term_bound → _p2mNativeSupplement13
open _root_.InfoLossLARNativeSupplements.had468f01f375d910.AFT.RationalNumerics renaming boundedRootList_nodup → AFT.RationalNumerics.boundedRootList_nodup
open _root_.InfoLossLARNativeSupplements.had468f01f375d910.AFT.RationalNumerics renaming boundedRootList_nodup → _p2mNativeSupplement14
open _root_.InfoLossLARNativeSupplements.h41ae6c8d47a51d34.AFT.RationalNumerics renaming commonDenominator_le → AFT.RationalNumerics.commonDenominator_le
open _root_.InfoLossLARNativeSupplements.h41ae6c8d47a51d34.AFT.RationalNumerics renaming commonDenominator_le → _p2mNativeSupplement15
open _root_.InfoLossLARNativeSupplements.h5f0d1be1226eed7f.AFT.RationalNumerics renaming commonDenominator_pos → AFT.RationalNumerics.commonDenominator_pos
open _root_.InfoLossLARNativeSupplements.h5f0d1be1226eed7f.AFT.RationalNumerics renaming commonDenominator_pos → _p2mNativeSupplement16
open _root_.InfoLossLARNativeSupplements.h1076ff82614707e5.AFT.RationalNumerics renaming commonNumerator_abs_le → AFT.RationalNumerics.commonNumerator_abs_le
open _root_.InfoLossLARNativeSupplements.h1076ff82614707e5.AFT.RationalNumerics renaming commonNumerator_abs_le → _p2mNativeSupplement17
open _root_.InfoLossLARNativeSupplements.h3827d5d7d51242c6.AFT.RationalNumerics renaming commonNumerator_cast → AFT.RationalNumerics.commonNumerator_cast
open _root_.InfoLossLARNativeSupplements.h3827d5d7d51242c6.AFT.RationalNumerics renaming commonNumerator_cast → _p2mNativeSupplement18
open _root_.InfoLossLARNativeSupplements.h4b0b2c49d14fd209.AFT.RationalNumerics renaming commonNumerator_div → AFT.RationalNumerics.commonNumerator_div
open _root_.InfoLossLARNativeSupplements.h4b0b2c49d14fd209.AFT.RationalNumerics renaming commonNumerator_div → _p2mNativeSupplement19
open _root_.InfoLossLARNativeSupplements.h2882c93186ab7cf8.AFT.RationalNumerics renaming denominator_dvd_common → AFT.RationalNumerics.denominator_dvd_common
open _root_.InfoLossLARNativeSupplements.h2882c93186ab7cf8.AFT.RationalNumerics renaming denominator_dvd_common → _p2mNativeSupplement20
open _root_.InfoLossLARNativeSupplements.h05d99dd2bef78a64.AFT.RationalNumerics renaming integerLinearIteration_abs_le → AFT.RationalNumerics.integerLinearIteration_abs_le
open _root_.InfoLossLARNativeSupplements.h05d99dd2bef78a64.AFT.RationalNumerics renaming integerLinearIteration_abs_le → _p2mNativeSupplement21
open _root_.InfoLossLARNativeSupplements.hc6ad092b2f522781.AFT.RationalNumerics renaming integerLinearIteration_exact → AFT.RationalNumerics.integerLinearIteration_exact
open _root_.InfoLossLARNativeSupplements.hc6ad092b2f522781.AFT.RationalNumerics renaming integerLinearIteration_exact → _p2mNativeSupplement22
open _root_.InfoLossLARNativeSupplements.hdcd54a4fdf95f258.AFT.RationalNumerics renaming integerLinearIteration_height → AFT.RationalNumerics.integerLinearIteration_height
open _root_.InfoLossLARNativeSupplements.hdcd54a4fdf95f258.AFT.RationalNumerics renaming integerLinearIteration_height → _p2mNativeSupplement23
open _root_.InfoLossLARNativeSupplements.he7db6c4ee6224eee.AFT.RationalNumerics renaming linearIteration_height → AFT.RationalNumerics.linearIteration_height
open _root_.InfoLossLARNativeSupplements.he7db6c4ee6224eee.AFT.RationalNumerics renaming linearIteration_height → _p2mNativeSupplement24
open _root_.InfoLossLARNativeSupplements.h18af7218e3ae5082.AFT.RationalNumerics renaming mem_boundedRootList → AFT.RationalNumerics.mem_boundedRootList
open _root_.InfoLossLARNativeSupplements.h18af7218e3ae5082.AFT.RationalNumerics renaming mem_boundedRootList → _p2mNativeSupplement25
open _root_.InfoLossLARNativeSupplements.h878260dd8e6c9a6e.AFT.RationalNumerics renaming piApprox_error → AFT.RationalNumerics.piApprox_error
open _root_.InfoLossLARNativeSupplements.h878260dd8e6c9a6e.AFT.RationalNumerics renaming piApprox_error → _p2mNativeSupplement26
open _root_.InfoLossLARNativeSupplements.h91d71a61f0497f7b.AFT.RationalNumerics renaming piApprox_le_five → AFT.RationalNumerics.piApprox_le_five
open _root_.InfoLossLARNativeSupplements.h91d71a61f0497f7b.AFT.RationalNumerics renaming piApprox_le_five → _p2mNativeSupplement27
open _root_.InfoLossLARNativeSupplements.hb0db73987b7b1eff.AFT.V7Calibration renaming actualPublicBodyChoice_nonempty → AFT.V7Calibration.actualPublicBodyChoice_nonempty
open _root_.InfoLossLARNativeSupplements.hb0db73987b7b1eff.AFT.V7Calibration renaming actualPublicBodyChoice_nonempty → _p2mNativeSupplement28
open _root_.InfoLossLARNativeSupplements.hb6587a05bd2df660.AFT.V7Calibration renaming actualPublicPrimaryChoice_nonempty → AFT.V7Calibration.actualPublicPrimaryChoice_nonempty
open _root_.InfoLossLARNativeSupplements.hb6587a05bd2df660.AFT.V7Calibration renaming actualPublicPrimaryChoice_nonempty → _p2mNativeSupplement29
open _root_.InfoLossLARNativeSupplements.he83cfe7a7db39d44.CurrentAFT.BinaryFiniteProduct renaming current_value → CurrentAFT.BinaryFiniteProduct.current_value
open _root_.InfoLossLARNativeSupplements.he83cfe7a7db39d44.CurrentAFT.BinaryFiniteProduct renaming current_value → _p2mNativeSupplement30
open _root_.InfoLossLARNativeSupplements.hf109288ce2bff41a.CurrentAFT.BinaryFullResponseCounts renaming current_sizes → CurrentAFT.BinaryFullResponseCounts.current_sizes
open _root_.InfoLossLARNativeSupplements.hf109288ce2bff41a.CurrentAFT.BinaryFullResponseCounts renaming current_sizes → _p2mNativeSupplement31
open _root_.InfoLossLARNativeSupplements.hab90893a8a9293a2.CurrentAFT.BinaryListSum renaming current_value → CurrentAFT.BinaryListSum.current_value
open _root_.InfoLossLARNativeSupplements.hab90893a8a9293a2.CurrentAFT.BinaryListSum renaming current_value → _p2mNativeSupplement32
open _root_.InfoLossLARNativeSupplements.hb7b15c9a79e648be.CurrentAFT.BinaryRootMetadataSerializer renaming actualChoice_ordinary → CurrentAFT.BinaryRootMetadataSerializer.actualChoice_ordinary
open _root_.InfoLossLARNativeSupplements.hb7b15c9a79e648be.CurrentAFT.BinaryRootMetadataSerializer renaming actualChoice_ordinary → _p2mNativeSupplement33
open _root_.InfoLossLARNativeSupplements.h9bd8eaff2c880c78.CurrentAFT.BinaryRootMetadataSerializer renaming actualChoice_primary → CurrentAFT.BinaryRootMetadataSerializer.actualChoice_primary
open _root_.InfoLossLARNativeSupplements.h9bd8eaff2c880c78.CurrentAFT.BinaryRootMetadataSerializer renaming actualChoice_primary → _p2mNativeSupplement34
open _root_.InfoLossLARNativeSupplements.ha802267fba3ae37a.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_input → CurrentAFT.BinaryRootMetadataSerializer.candidate_input
open _root_.InfoLossLARNativeSupplements.ha802267fba3ae37a.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_input → _p2mNativeSupplement35
open _root_.InfoLossLARNativeSupplements.h1ccc0b12a2e9b2e7.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_kept → CurrentAFT.BinaryRootMetadataSerializer.candidate_kept
open _root_.InfoLossLARNativeSupplements.h1ccc0b12a2e9b2e7.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_kept → _p2mNativeSupplement36
open _root_.InfoLossLARNativeSupplements.hf63ab620f3c57a9b.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_ordinary → CurrentAFT.BinaryRootMetadataSerializer.candidate_ordinary
open _root_.InfoLossLARNativeSupplements.hf63ab620f3c57a9b.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_ordinary → _p2mNativeSupplement37
open _root_.InfoLossLARNativeSupplements.h8b1af35cb5128d1e.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_primary → CurrentAFT.BinaryRootMetadataSerializer.candidate_primary
open _root_.InfoLossLARNativeSupplements.h8b1af35cb5128d1e.CurrentAFT.BinaryRootMetadataSerializer renaming candidate_primary → _p2mNativeSupplement38
open _root_.InfoLossLARNativeSupplements.hc002c1f58373bc9e.CurrentAFT.BinaryRootMetadataSerializer renaming classify_numbering → CurrentAFT.BinaryRootMetadataSerializer.classify_numbering
open _root_.InfoLossLARNativeSupplements.hc002c1f58373bc9e.CurrentAFT.BinaryRootMetadataSerializer renaming classify_numbering → _p2mNativeSupplement39
open _root_.InfoLossLARNativeSupplements.h0654708b8f7abd41.CurrentAFT.BinaryRootMetadataSerializer renaming current_castMetadata → CurrentAFT.BinaryRootMetadataSerializer.current_castMetadata
open _root_.InfoLossLARNativeSupplements.h0654708b8f7abd41.CurrentAFT.BinaryRootMetadataSerializer renaming current_castMetadata → _p2mNativeSupplement40
open _root_.InfoLossLARNativeSupplements.h62365cd168bf9746.CurrentAFT.BinaryRootMetadataSerializer renaming current_cast_tags → CurrentAFT.BinaryRootMetadataSerializer.current_cast_tags
open _root_.InfoLossLARNativeSupplements.h62365cd168bf9746.CurrentAFT.BinaryRootMetadataSerializer renaming current_cast_tags → _p2mNativeSupplement41
open _root_.InfoLossLARNativeSupplements.hd04a074a03468451.CurrentAFT.BinaryRootMetadataSerializer renaming current_congr_counts → CurrentAFT.BinaryRootMetadataSerializer.current_congr_counts
open _root_.InfoLossLARNativeSupplements.hd04a074a03468451.CurrentAFT.BinaryRootMetadataSerializer renaming current_congr_counts → _p2mNativeSupplement42
open _root_.InfoLossLARNativeSupplements.h92779a9b15e1ad74.CurrentAFT.BinaryRootMetadataSerializer renaming current_kept_le → CurrentAFT.BinaryRootMetadataSerializer.current_kept_le
open _root_.InfoLossLARNativeSupplements.h92779a9b15e1ad74.CurrentAFT.BinaryRootMetadataSerializer renaming current_kept_le → _p2mNativeSupplement43
open _root_.InfoLossLARNativeSupplements.h5d3e6518d488d268.CurrentAFT.BinaryRootMetadataSerializer renaming current_metadata_actual → CurrentAFT.BinaryRootMetadataSerializer.current_metadata_actual
open _root_.InfoLossLARNativeSupplements.h5d3e6518d488d268.CurrentAFT.BinaryRootMetadataSerializer renaming current_metadata_actual → _p2mNativeSupplement44
open _root_.InfoLossLARNativeSupplements.h6da04ab1cb4f0ae9.CurrentAFT.BinaryRootMetadataSerializer renaming current_native_counts → CurrentAFT.BinaryRootMetadataSerializer.current_native_counts
open _root_.InfoLossLARNativeSupplements.h6da04ab1cb4f0ae9.CurrentAFT.BinaryRootMetadataSerializer renaming current_native_counts → _p2mNativeSupplement45
open _root_.InfoLossLARNativeSupplements.h0034013fd46e34b6.CurrentAFT.BinaryRootMetadataSerializer renaming current_rational_actual → CurrentAFT.BinaryRootMetadataSerializer.current_rational_actual
open _root_.InfoLossLARNativeSupplements.h0034013fd46e34b6.CurrentAFT.BinaryRootMetadataSerializer renaming current_rational_actual → _p2mNativeSupplement46
open _root_.InfoLossLARNativeSupplements.he41810aeef644de7.CurrentAFT.BinaryRootMetadataSerializer renaming current_rational_native → CurrentAFT.BinaryRootMetadataSerializer.current_rational_native
open _root_.InfoLossLARNativeSupplements.he41810aeef644de7.CurrentAFT.BinaryRootMetadataSerializer renaming current_rational_native → _p2mNativeSupplement47
open _root_.InfoLossLARNativeSupplements.hdf21f91932116c35.CurrentAFT.BinaryRootMetadataSerializer renaming current_role → CurrentAFT.BinaryRootMetadataSerializer.current_role
open _root_.InfoLossLARNativeSupplements.hdf21f91932116c35.CurrentAFT.BinaryRootMetadataSerializer renaming current_role → _p2mNativeSupplement48
open _root_.InfoLossLARNativeSupplements.h2f02b0da80d0da15.CurrentAFT.BinaryRootMetadataSerializer renaming current_role_actual → CurrentAFT.BinaryRootMetadataSerializer.current_role_actual
open _root_.InfoLossLARNativeSupplements.h2f02b0da80d0da15.CurrentAFT.BinaryRootMetadataSerializer renaming current_role_actual → _p2mNativeSupplement49
open _root_.InfoLossLARNativeSupplements.hf05bd272bb1b56e1.CurrentAFT.BinaryRootMetadataSerializer renaming current_tagSlot → CurrentAFT.BinaryRootMetadataSerializer.current_tagSlot
open _root_.InfoLossLARNativeSupplements.hf05bd272bb1b56e1.CurrentAFT.BinaryRootMetadataSerializer renaming current_tagSlot → _p2mNativeSupplement50
open _root_.InfoLossLARNativeSupplements.h99dea6e0b2cb92cd.CurrentAFT.BinaryRootMetadataSerializer renaming current_tagSlot_actual → CurrentAFT.BinaryRootMetadataSerializer.current_tagSlot_actual
open _root_.InfoLossLARNativeSupplements.h99dea6e0b2cb92cd.CurrentAFT.BinaryRootMetadataSerializer renaming current_tagSlot_actual → _p2mNativeSupplement51
open _root_.InfoLossLARNativeSupplements.h5aa51497de94248a.CurrentAFT.BinaryRootMetadataSerializer renaming find_value → CurrentAFT.BinaryRootMetadataSerializer.find_value
open _root_.InfoLossLARNativeSupplements.h5aa51497de94248a.CurrentAFT.BinaryRootMetadataSerializer renaming find_value → _p2mNativeSupplement52
open _root_.InfoLossLARNativeSupplements.he1ba053a04ebe416.CurrentAFT.BinaryRootMetadataSerializer renaming inputOrdering_symm_kept → CurrentAFT.BinaryRootMetadataSerializer.inputOrdering_symm_kept
open _root_.InfoLossLARNativeSupplements.he1ba053a04ebe416.CurrentAFT.BinaryRootMetadataSerializer renaming inputOrdering_symm_kept → _p2mNativeSupplement53
open _root_.InfoLossLARNativeSupplements.hb19b481a4ab916e9.CurrentAFT.BinaryRootMetadataSerializer renaming inputOrdering_symm_ordinary → CurrentAFT.BinaryRootMetadataSerializer.inputOrdering_symm_ordinary
open _root_.InfoLossLARNativeSupplements.hb19b481a4ab916e9.CurrentAFT.BinaryRootMetadataSerializer renaming inputOrdering_symm_ordinary → _p2mNativeSupplement54
open _root_.InfoLossLARNativeSupplements.h925bf1f311c5581d.CurrentAFT.BinaryRootMetadataSerializer renaming inputOrdering_symm_primary → CurrentAFT.BinaryRootMetadataSerializer.inputOrdering_symm_primary
open _root_.InfoLossLARNativeSupplements.h925bf1f311c5581d.CurrentAFT.BinaryRootMetadataSerializer renaming inputOrdering_symm_primary → _p2mNativeSupplement55
open _root_.InfoLossLARNativeSupplements.h28bdeb915df6f31b.CurrentAFT.BinaryRootMetadataSerializer renaming keptOrdering_number → CurrentAFT.BinaryRootMetadataSerializer.keptOrdering_number
open _root_.InfoLossLARNativeSupplements.h28bdeb915df6f31b.CurrentAFT.BinaryRootMetadataSerializer renaming keptOrdering_number → _p2mNativeSupplement56
open _root_.InfoLossLARNativeSupplements.hd98ece77ce245c62.CurrentAFT.BinaryRootMetadataSerializer renaming kept_length_le → CurrentAFT.BinaryRootMetadataSerializer.kept_length_le
open _root_.InfoLossLARNativeSupplements.hd98ece77ce245c62.CurrentAFT.BinaryRootMetadataSerializer renaming kept_length_le → _p2mNativeSupplement57
open _root_.InfoLossLARNativeSupplements.h0c3b1f75a36dc0a1.CurrentAFT.BinaryRootMetadataSerializer renaming matchesBlock_input → CurrentAFT.BinaryRootMetadataSerializer.matchesBlock_input
open _root_.InfoLossLARNativeSupplements.h0c3b1f75a36dc0a1.CurrentAFT.BinaryRootMetadataSerializer renaming matchesBlock_input → _p2mNativeSupplement58
open _root_.InfoLossLARNativeSupplements.h3614eab28d16c434.CurrentAFT.BinaryRootMetadataSerializer renaming matchesBlock_value → CurrentAFT.BinaryRootMetadataSerializer.matchesBlock_value
open _root_.InfoLossLARNativeSupplements.h3614eab28d16c434.CurrentAFT.BinaryRootMetadataSerializer renaming matchesBlock_value → _p2mNativeSupplement59
open _root_.InfoLossLARNativeSupplements.h7211ad64e277ecd6.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_get → CurrentAFT.BinaryRootMetadataSerializer.nativeTag_get
open _root_.InfoLossLARNativeSupplements.h7211ad64e277ecd6.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_get → _p2mNativeSupplement60
open _root_.InfoLossLARNativeSupplements.h5bfd14958fa45ca1.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_increasing → CurrentAFT.BinaryRootMetadataSerializer.nativeTag_increasing
open _root_.InfoLossLARNativeSupplements.h5bfd14958fa45ca1.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_increasing → _p2mNativeSupplement61
open _root_.InfoLossLARNativeSupplements.h830e34787bfcc36e.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_membership → CurrentAFT.BinaryRootMetadataSerializer.nativeTag_membership
open _root_.InfoLossLARNativeSupplements.h830e34787bfcc36e.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_membership → _p2mNativeSupplement62
open _root_.InfoLossLARNativeSupplements.hdf4e90e4faeda9bb.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_tagsInput → CurrentAFT.BinaryRootMetadataSerializer.nativeTag_tagsInput
open _root_.InfoLossLARNativeSupplements.hdf4e90e4faeda9bb.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_tagsInput → _p2mNativeSupplement63
open _root_.InfoLossLARNativeSupplements.h0eb6479555712d22.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_tagsInput_vector → CurrentAFT.BinaryRootMetadataSerializer.nativeTag_tagsInput_vector
open _root_.InfoLossLARNativeSupplements.h0eb6479555712d22.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_tagsInput_vector → _p2mNativeSupplement64
open _root_.InfoLossLARNativeSupplements.he3484ce79e618bef.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_value → CurrentAFT.BinaryRootMetadataSerializer.nativeTag_value
open _root_.InfoLossLARNativeSupplements.he3484ce79e618bef.CurrentAFT.BinaryRootMetadataSerializer renaming nativeTag_value → _p2mNativeSupplement65
open _root_.InfoLossLARNativeSupplements.hb10c61056b84e123.CurrentAFT.BinaryRootMetadataSerializer renaming position_input → CurrentAFT.BinaryRootMetadataSerializer.position_input
open _root_.InfoLossLARNativeSupplements.hb10c61056b84e123.CurrentAFT.BinaryRootMetadataSerializer renaming position_input → _p2mNativeSupplement66
open _root_.InfoLossLARNativeSupplements.h717398dca61c08fb.CurrentAFT.BinaryRootMetadataSerializer renaming rational_current_cast_tags → CurrentAFT.BinaryRootMetadataSerializer.rational_current_cast_tags
open _root_.InfoLossLARNativeSupplements.h717398dca61c08fb.CurrentAFT.BinaryRootMetadataSerializer renaming rational_current_cast_tags → _p2mNativeSupplement67
open _root_.InfoLossLARNativeSupplements.h5c1679d60747a3c8.CurrentAFT.BinaryRootMetadataSerializer renaming retainedInput_at_group → CurrentAFT.BinaryRootMetadataSerializer.retainedInput_at_group
open _root_.InfoLossLARNativeSupplements.h5c1679d60747a3c8.CurrentAFT.BinaryRootMetadataSerializer renaming retainedInput_at_group → _p2mNativeSupplement68
open _root_.InfoLossLARNativeSupplements.hd10b40ce4e5fb3ce.CurrentAFT.BinaryRootMetadataSerializer renaming retainedInput_get → CurrentAFT.BinaryRootMetadataSerializer.retainedInput_get
open _root_.InfoLossLARNativeSupplements.hd10b40ce4e5fb3ce.CurrentAFT.BinaryRootMetadataSerializer renaming retainedInput_get → _p2mNativeSupplement69
open _root_.InfoLossLARNativeSupplements.h790debae9bc7d744.CurrentAFT.BinaryRootMetadataSerializer renaming role_input → CurrentAFT.BinaryRootMetadataSerializer.role_input
open _root_.InfoLossLARNativeSupplements.h790debae9bc7d744.CurrentAFT.BinaryRootMetadataSerializer renaming role_input → _p2mNativeSupplement70
open _root_.InfoLossLARNativeSupplements.h36433fb6e771176d.CurrentAFT.BinaryRootMetadataSerializer renaming role_kept → CurrentAFT.BinaryRootMetadataSerializer.role_kept
open _root_.InfoLossLARNativeSupplements.h36433fb6e771176d.CurrentAFT.BinaryRootMetadataSerializer renaming role_kept → _p2mNativeSupplement71
open _root_.InfoLossLARNativeSupplements.h1c0aacbfbcab259c.CurrentAFT.BinaryRootMetadataSerializer renaming role_ordinary → CurrentAFT.BinaryRootMetadataSerializer.role_ordinary
open _root_.InfoLossLARNativeSupplements.h1c0aacbfbcab259c.CurrentAFT.BinaryRootMetadataSerializer renaming role_ordinary → _p2mNativeSupplement72
open _root_.InfoLossLARNativeSupplements.had28d56c66c172c2.CurrentAFT.BinaryRootMetadataSerializer renaming role_primary → CurrentAFT.BinaryRootMetadataSerializer.role_primary
open _root_.InfoLossLARNativeSupplements.had28d56c66c172c2.CurrentAFT.BinaryRootMetadataSerializer renaming role_primary → _p2mNativeSupplement73
open _root_.InfoLossLARNativeSupplements.hf7b606d7b6c71037.CurrentAFT.BinaryRootMetadataSerializer renaming splitIndex_value → CurrentAFT.BinaryRootMetadataSerializer.splitIndex_value
open _root_.InfoLossLARNativeSupplements.hf7b606d7b6c71037.CurrentAFT.BinaryRootMetadataSerializer renaming splitIndex_value → _p2mNativeSupplement74
open _root_.InfoLossLARNativeSupplements.hc171b658125977dd.CurrentAFT.BinaryRootMetadataSerializer renaming tagBlocks_card → CurrentAFT.BinaryRootMetadataSerializer.tagBlocks_card
open _root_.InfoLossLARNativeSupplements.hc171b658125977dd.CurrentAFT.BinaryRootMetadataSerializer renaming tagBlocks_card → _p2mNativeSupplement75
open _root_.InfoLossLARNativeSupplements.h864990220cd05a68.CurrentAFT.BinaryRootMetadataSerializer renaming tagSlot_input → CurrentAFT.BinaryRootMetadataSerializer.tagSlot_input
open _root_.InfoLossLARNativeSupplements.h864990220cd05a68.CurrentAFT.BinaryRootMetadataSerializer renaming tagSlot_input → _p2mNativeSupplement76
open _root_.InfoLossLARNativeSupplements.he99bee3d04267632.CurrentAFT.BinaryRootMetadataSerializer renaming tagsInput_get → CurrentAFT.BinaryRootMetadataSerializer.tagsInput_get
open _root_.InfoLossLARNativeSupplements.he99bee3d04267632.CurrentAFT.BinaryRootMetadataSerializer renaming tagsInput_get → _p2mNativeSupplement77
open _root_.InfoLossLARNativeSupplements.h15d8c2848429780a.CurrentAFT.BinaryRootMetadataSerializer renaming vector_count_cast_get → CurrentAFT.BinaryRootMetadataSerializer.vector_count_cast_get
open _root_.InfoLossLARNativeSupplements.h15d8c2848429780a.CurrentAFT.BinaryRootMetadataSerializer renaming vector_count_cast_get → _p2mNativeSupplement78
open _root_.InfoLossLARNativeSupplements.h6033ffbe1c08cc96.CurrentAFT.BinaryRootMetadataSerializer renaming vector_length_cast_get → CurrentAFT.BinaryRootMetadataSerializer.vector_length_cast_get
open _root_.InfoLossLARNativeSupplements.h6033ffbe1c08cc96.CurrentAFT.BinaryRootMetadataSerializer renaming vector_length_cast_get → _p2mNativeSupplement79
open _root_.InfoLossLARNativeSupplements.he438d921f6936ff8.CurrentAFT.BinaryRootMetadataSerializer renaming vector_mem_toList → CurrentAFT.BinaryRootMetadataSerializer.vector_mem_toList
open _root_.InfoLossLARNativeSupplements.he438d921f6936ff8.CurrentAFT.BinaryRootMetadataSerializer renaming vector_mem_toList → _p2mNativeSupplement80
open _root_.InfoLossLARNativeSupplements.he37fcb2fedaaad11.CurrentAFT.BinarySparseCycleEvaluation renaming current_tuple_value → CurrentAFT.BinarySparseCycleEvaluation.current_tuple_value
open _root_.InfoLossLARNativeSupplements.he37fcb2fedaaad11.CurrentAFT.BinarySparseCycleEvaluation renaming current_tuple_value → _p2mNativeSupplement81
open _root_.InfoLossLARNativeSupplements.h42f327202f6ffc34.CurrentAFT.BinarySparseCycleEvaluation renaming rootEntry_value → CurrentAFT.BinarySparseCycleEvaluation.rootEntry_value
open _root_.InfoLossLARNativeSupplements.h42f327202f6ffc34.CurrentAFT.BinarySparseCycleEvaluation renaming rootEntry_value → _p2mNativeSupplement82
open _root_.InfoLossLARNativeSupplements.h046841627a1cee9b.CurrentAFT.BinarySparseCycleEvaluation renaming roots_value → CurrentAFT.BinarySparseCycleEvaluation.roots_value
open _root_.InfoLossLARNativeSupplements.h046841627a1cee9b.CurrentAFT.BinarySparseCycleEvaluation renaming roots_value → _p2mNativeSupplement83
open _root_.InfoLossLARNativeSupplements.hd0df78f75d4d893f.CurrentAFT.BinarySparseCycleEvaluation renaming term_value → CurrentAFT.BinarySparseCycleEvaluation.term_value
open _root_.InfoLossLARNativeSupplements.hd0df78f75d4d893f.CurrentAFT.BinarySparseCycleEvaluation renaming term_value → _p2mNativeSupplement84
open _root_.InfoLossLARNativeSupplements.hf4f5fd4dcb0d678c.CurrentAFT.BinarySparseCycleEvaluation renaming weightEntry_value → CurrentAFT.BinarySparseCycleEvaluation.weightEntry_value
open _root_.InfoLossLARNativeSupplements.hf4f5fd4dcb0d678c.CurrentAFT.BinarySparseCycleEvaluation renaming weightEntry_value → _p2mNativeSupplement85
open _root_.InfoLossLARNativeSupplements.haf9b5363dbfc3f4c.CurrentAFT.BinarySparseCycleSemantic renaming coordinates_apply → CurrentAFT.BinarySparseCycleSemantic.coordinates_apply
open _root_.InfoLossLARNativeSupplements.haf9b5363dbfc3f4c.CurrentAFT.BinarySparseCycleSemantic renaming coordinates_apply → _p2mNativeSupplement86
open _root_.InfoLossLARNativeSupplements.hb39aff037bdc4326.CurrentAFT.BinarySparseCycleSemantic renaming current_value → CurrentAFT.BinarySparseCycleSemantic.current_value
open _root_.InfoLossLARNativeSupplements.hb39aff037bdc4326.CurrentAFT.BinarySparseCycleSemantic renaming current_value → _p2mNativeSupplement87
open _root_.InfoLossLARNativeSupplements.h0cda298b0874d5b6.CurrentAFT.BinarySparseCycleSemantic renaming product_coordinates → CurrentAFT.BinarySparseCycleSemantic.product_coordinates
open _root_.InfoLossLARNativeSupplements.h0cda298b0874d5b6.CurrentAFT.BinarySparseCycleSemantic renaming product_coordinates → _p2mNativeSupplement88
open _root_.InfoLossLARNativeSupplements.h10d530ee15bdc77f.CurrentAFT.BinarySparseCycleSemantic renaming roots_coordinates → CurrentAFT.BinarySparseCycleSemantic.roots_coordinates
open _root_.InfoLossLARNativeSupplements.h10d530ee15bdc77f.CurrentAFT.BinarySparseCycleSemantic renaming roots_coordinates → _p2mNativeSupplement89
open _root_.InfoLossLARNativeSupplements.h5cfbe96a887c7fbe.CurrentAFT.BinaryTouchedCycle renaming candidates_length → CurrentAFT.BinaryTouchedCycle.candidates_length
open _root_.InfoLossLARNativeSupplements.h5cfbe96a887c7fbe.CurrentAFT.BinaryTouchedCycle renaming candidates_length → _p2mNativeSupplement90
open _root_.InfoLossLARNativeSupplements.hbcb1352f59b47e7a.CurrentAFT.BinaryTouchedCycle renaming prepare_length → CurrentAFT.BinaryTouchedCycle.prepare_length
open _root_.InfoLossLARNativeSupplements.hbcb1352f59b47e7a.CurrentAFT.BinaryTouchedCycle renaming prepare_length → _p2mNativeSupplement91
open _root_.InfoLossLARNativeSupplements.h7b66ba8c3614b749.CurrentAFT.BinaryTouchedCycle renaming unique_length → CurrentAFT.BinaryTouchedCycle.unique_length
open _root_.InfoLossLARNativeSupplements.h7b66ba8c3614b749.CurrentAFT.BinaryTouchedCycle renaming unique_length → _p2mNativeSupplement92
open _root_.InfoLossLARNativeSupplements.h8bc15ae79e4624be.CurrentAFT.BinaryTouchedCycleBuffer renaming lookup_value → CurrentAFT.BinaryTouchedCycleBuffer.lookup_value
open _root_.InfoLossLARNativeSupplements.h8bc15ae79e4624be.CurrentAFT.BinaryTouchedCycleBuffer renaming lookup_value → _p2mNativeSupplement93
open _root_.InfoLossLARNativeSupplements.hf362d6b0d865f5c6.CurrentAFT.BinaryTouchedCycleRanks renaming positions_value → CurrentAFT.BinaryTouchedCycleRanks.positions_value
open _root_.InfoLossLARNativeSupplements.hf362d6b0d865f5c6.CurrentAFT.BinaryTouchedCycleRanks renaming positions_value → _p2mNativeSupplement94
open _root_.InfoLossLARNativeSupplements.h4cdf4f6ad2d19d90.CurrentAFT.BinaryTupleSum renaming current_value → CurrentAFT.BinaryTupleSum.current_value
open _root_.InfoLossLARNativeSupplements.h4cdf4f6ad2d19d90.CurrentAFT.BinaryTupleSum renaming current_value → _p2mNativeSupplement95
open _root_.InfoLossLARNativeSupplements.ha8fcea89e723dc23.CurrentAFT.BinaryTupleSum renaming get_ofFn_fun → CurrentAFT.BinaryTupleSum.get_ofFn_fun
open _root_.InfoLossLARNativeSupplements.ha8fcea89e723dc23.CurrentAFT.BinaryTupleSum renaming get_ofFn_fun → _p2mNativeSupplement96
open _root_.InfoLossLARNativeSupplements.ha84cbfc4268e8d40.CurrentAFT.BinaryTupleSum renaming prepend_get → CurrentAFT.BinaryTupleSum.prepend_get
open _root_.InfoLossLARNativeSupplements.ha84cbfc4268e8d40.CurrentAFT.BinaryTupleSum renaming prepend_get → _p2mNativeSupplement97
open _root_.InfoLossLARNativeSupplements.hcca3d782e3229b7c.CurrentAFT.BinaryTupleSum renaming prepend_value → CurrentAFT.BinaryTupleSum.prepend_value
open _root_.InfoLossLARNativeSupplements.hcca3d782e3229b7c.CurrentAFT.BinaryTupleSum renaming prepend_value → _p2mNativeSupplement98
open _root_.InfoLossLARNativeSupplements.h78d75bb492074482.CurrentAFT.CountedBoundedRootTags.Tag renaming card → CurrentAFT.CountedBoundedRootTags.Tag.card
open _root_.InfoLossLARNativeSupplements.h78d75bb492074482.CurrentAFT.CountedBoundedRootTags.Tag renaming card → _p2mNativeSupplement99
open _root_.InfoLossLARNativeSupplements.h9568a61082f27bb9.CurrentAFT.CountedBoundedRootTags.Tag renaming nodup → CurrentAFT.CountedBoundedRootTags.Tag.nodup
open _root_.InfoLossLARNativeSupplements.h9568a61082f27bb9.CurrentAFT.CountedBoundedRootTags.Tag renaming nodup → _p2mNativeSupplement100
open _root_.InfoLossLARNativeSupplements.hf6e7f4bd634f80a9.CurrentAFT.CountedBoundedRootTags.Tag renaming read_value → CurrentAFT.CountedBoundedRootTags.Tag.read_value
open _root_.InfoLossLARNativeSupplements.hf6e7f4bd634f80a9.CurrentAFT.CountedBoundedRootTags.Tag renaming read_value → _p2mNativeSupplement101
open _root_.InfoLossLARNativeSupplements.hd05ef333dfb7baf7.CurrentAFT.CountedBoundedRootTags.Tag renaming store_value → CurrentAFT.CountedBoundedRootTags.Tag.store_value
open _root_.InfoLossLARNativeSupplements.hd05ef333dfb7baf7.CurrentAFT.CountedBoundedRootTags.Tag renaming store_value → _p2mNativeSupplement102
open _root_.InfoLossLARNativeSupplements.h8bf8720ebb55498f.CurrentAFT.CountedBoundedRootTags.Tag renaming vector_increasing → CurrentAFT.CountedBoundedRootTags.Tag.vector_increasing
open _root_.InfoLossLARNativeSupplements.h8bf8720ebb55498f.CurrentAFT.CountedBoundedRootTags.Tag renaming vector_increasing → _p2mNativeSupplement103
open _root_.InfoLossLARNativeSupplements.h5fde173c8469afa6.CurrentAFT.CountedBoundedRootTags renaming current_sets → CurrentAFT.CountedBoundedRootTags.current_sets
open _root_.InfoLossLARNativeSupplements.h5fde173c8469afa6.CurrentAFT.CountedBoundedRootTags renaming current_sets → _p2mNativeSupplement104
open _root_.InfoLossLARNativeSupplements.he8f344a3055fc54a.CurrentAFT.CountedBoundedRootTags renaming entry_sets → CurrentAFT.CountedBoundedRootTags.entry_sets
open _root_.InfoLossLARNativeSupplements.he8f344a3055fc54a.CurrentAFT.CountedBoundedRootTags renaming entry_sets → _p2mNativeSupplement105
open _root_.InfoLossLARNativeSupplements.h2c50018e32584610.CurrentAFT.CountedBoundedRootTags renaming guarded_value → CurrentAFT.CountedBoundedRootTags.guarded_value
open _root_.InfoLossLARNativeSupplements.h2c50018e32584610.CurrentAFT.CountedBoundedRootTags renaming guarded_value → _p2mNativeSupplement106
open _root_.InfoLossLARNativeSupplements.h4aa23a1b871c5bc6.CurrentAFT.CountedBoundedRootTags renaming sum_value → CurrentAFT.CountedBoundedRootTags.sum_value
open _root_.InfoLossLARNativeSupplements.h4aa23a1b871c5bc6.CurrentAFT.CountedBoundedRootTags renaming sum_value → _p2mNativeSupplement107
open _root_.InfoLossLARNativeSupplements.h5a83c4211de0d052.CurrentAFT.CountedBoundedRootTags renaming sum_value_equiv → CurrentAFT.CountedBoundedRootTags.sum_value_equiv
open _root_.InfoLossLARNativeSupplements.h5a83c4211de0d052.CurrentAFT.CountedBoundedRootTags renaming sum_value_equiv → _p2mNativeSupplement108
open _root_.InfoLossLARNativeSupplements.h857ff8dbe55756b8.CurrentAFT.CurrentCycleEntryProgram renaming bodyCount_eq → CurrentAFT.CurrentCycleEntryProgram.bodyCount_eq
open _root_.InfoLossLARNativeSupplements.h857ff8dbe55756b8.CurrentAFT.CurrentCycleEntryProgram renaming bodyCount_eq → _p2mNativeSupplement109
open _root_.InfoLossLARNativeSupplements.h4b24203afd73c049.CurrentAFT.CurrentCycleEntryProgram renaming roots_mod_iff → CurrentAFT.CurrentCycleEntryProgram.roots_mod_iff
open _root_.InfoLossLARNativeSupplements.h4b24203afd73c049.CurrentAFT.CurrentCycleEntryProgram renaming roots_mod_iff → _p2mNativeSupplement110
open _root_.InfoLossLARNativeSupplements.h187f69822989eb63.CurrentAFT.CurrentCycleEntryProgram renaming selectedEntry_cast → CurrentAFT.CurrentCycleEntryProgram.selectedEntry_cast
open _root_.InfoLossLARNativeSupplements.h187f69822989eb63.CurrentAFT.CurrentCycleEntryProgram renaming selectedEntry_cast → _p2mNativeSupplement111
open _root_.InfoLossLARNativeSupplements.h9180bab9fc132623.CurrentAFT.CurrentCycleEntryProgram renaming selected_probability_source → CurrentAFT.CurrentCycleEntryProgram.selected_probability_source
open _root_.InfoLossLARNativeSupplements.h9180bab9fc132623.CurrentAFT.CurrentCycleEntryProgram renaming selected_probability_source → _p2mNativeSupplement112
open _root_.InfoLossLARNativeSupplements.hf7c0550335227b9c.CurrentAFT.CurrentGaussianBits renaming ratio_bounds → CurrentAFT.CurrentGaussianBits.ratio_bounds
open _root_.InfoLossLARNativeSupplements.hf7c0550335227b9c.CurrentAFT.CurrentGaussianBits renaming ratio_bounds → _p2mNativeSupplement113
open _root_.InfoLossLARNativeSupplements.ha029c925a85a9044.CurrentAFT.CurrentPublicShiftProgram renaming encode_value → CurrentAFT.CurrentPublicShiftProgram.encode_value
open _root_.InfoLossLARNativeSupplements.ha029c925a85a9044.CurrentAFT.CurrentPublicShiftProgram renaming encode_value → _p2mNativeSupplement114
open _root_.InfoLossLARNativeSupplements.h4ae04e3f1cb5b359.CurrentAFT.CurrentRootSlotIndex renaming tagPosition_eq → CurrentAFT.CurrentRootSlotIndex.tagPosition_eq
open _root_.InfoLossLARNativeSupplements.h4ae04e3f1cb5b359.CurrentAFT.CurrentRootSlotIndex renaming tagPosition_eq → _p2mNativeSupplement115
open _root_.InfoLossLARNativeSupplements.h20ee486b3d1dffd8.CurrentAFT.CyclePatternProgram renaming averagedEvaluate_cast → CurrentAFT.CyclePatternProgram.averagedEvaluate_cast
open _root_.InfoLossLARNativeSupplements.h20ee486b3d1dffd8.CurrentAFT.CyclePatternProgram renaming averagedEvaluate_cast → _p2mNativeSupplement116
open _root_.InfoLossLARNativeSupplements.hb37dd6f3dcea3b7d.CurrentAFT.CyclePatternProgram renaming evaluate_local → CurrentAFT.CyclePatternProgram.evaluate_local
open _root_.InfoLossLARNativeSupplements.hb37dd6f3dcea3b7d.CurrentAFT.CyclePatternProgram renaming evaluate_local → _p2mNativeSupplement117
open _root_.InfoLossLARNativeSupplements.h689ba464633d8cff.CurrentAFT.CyclePatternProgram renaming evaluate_semantics → CurrentAFT.CyclePatternProgram.evaluate_semantics
open _root_.InfoLossLARNativeSupplements.h689ba464633d8cff.CurrentAFT.CyclePatternProgram renaming evaluate_semantics → _p2mNativeSupplement118
open _root_.InfoLossLARNativeSupplements.hd02155c30f7ca58d.CurrentAFT.CyclePatternProgram renaming gaussianEvaluate_eq_windowEvaluate → CurrentAFT.CyclePatternProgram.gaussianEvaluate_eq_windowEvaluate
open _root_.InfoLossLARNativeSupplements.hd02155c30f7ca58d.CurrentAFT.CyclePatternProgram renaming gaussianEvaluate_eq_windowEvaluate → _p2mNativeSupplement119
open _root_.InfoLossLARNativeSupplements.hc532f8ed89f571a1.CurrentAFT.CyclePatternProgram renaming gaussianEvaluate_semantics → CurrentAFT.CyclePatternProgram.gaussianEvaluate_semantics
open _root_.InfoLossLARNativeSupplements.hc532f8ed89f571a1.CurrentAFT.CyclePatternProgram renaming gaussianEvaluate_semantics → _p2mNativeSupplement120
open _root_.InfoLossLARNativeSupplements.h3e1ece29cbe1b4d4.CurrentAFT.CyclePatternProgram renaming restricted_expectation → CurrentAFT.CyclePatternProgram.restricted_expectation
open _root_.InfoLossLARNativeSupplements.h3e1ece29cbe1b4d4.CurrentAFT.CyclePatternProgram renaming restricted_expectation → _p2mNativeSupplement121
open _root_.InfoLossLARNativeSupplements.h33993643e1712ab8.CurrentAFT.CycleRootExpansion renaming current_body_two_le → CurrentAFT.CycleRootExpansion.current_body_two_le
open _root_.InfoLossLARNativeSupplements.h33993643e1712ab8.CurrentAFT.CycleRootExpansion renaming current_body_two_le → _p2mNativeSupplement122
open _root_.InfoLossLARNativeSupplements.hd99e5f9e75bbb7e1.CurrentAFT.CycleSelections renaming averagedSelectedLaw_coordinate → CurrentAFT.CycleSelections.averagedSelectedLaw_coordinate
open _root_.InfoLossLARNativeSupplements.hd99e5f9e75bbb7e1.CurrentAFT.CycleSelections renaming averagedSelectedLaw_coordinate → _p2mNativeSupplement123
open _root_.InfoLossLARNativeSupplements.h788b7dba49e3cc6b.CurrentAFT.CycleSelections renaming selectedLaw_coordinate → CurrentAFT.CycleSelections.selectedLaw_coordinate
open _root_.InfoLossLARNativeSupplements.h788b7dba49e3cc6b.CurrentAFT.CycleSelections renaming selectedLaw_coordinate → _p2mNativeSupplement124
open _root_.InfoLossLARNativeSupplements.h8eafa7c1234de921.CurrentAFT.FullResponseEnumeration renaming mem_boundedSubsets → CurrentAFT.FullResponseEnumeration.mem_boundedSubsets
open _root_.InfoLossLARNativeSupplements.h8eafa7c1234de921.CurrentAFT.FullResponseEnumeration renaming mem_boundedSubsets → _p2mNativeSupplement125
open _root_.InfoLossLARNativeSupplements.h4d94229af05aca84.CurrentAFT.Parameters renaming modulus_eq_find → CurrentAFT.Parameters.modulus_eq_find
open _root_.InfoLossLARNativeSupplements.h4d94229af05aca84.CurrentAFT.Parameters renaming modulus_eq_find → _p2mNativeSupplement126
open _root_.InfoLossLARNativeSupplements.h7c8d9f04458b8eff.CurrentAFT.ProtectedCycle renaming cycleLaw_marginal → CurrentAFT.ProtectedCycle.cycleLaw_marginal
open _root_.InfoLossLARNativeSupplements.h7c8d9f04458b8eff.CurrentAFT.ProtectedCycle renaming cycleLaw_marginal → _p2mNativeSupplement127
open _root_.InfoLossLARNativeSupplements.ha0baf4dfdfb7707f.CurrentAFT.ProtectedCycle renaming cycleLaw_marginal_of_two_le → CurrentAFT.ProtectedCycle.cycleLaw_marginal_of_two_le
open _root_.InfoLossLARNativeSupplements.ha0baf4dfdfb7707f.CurrentAFT.ProtectedCycle renaming cycleLaw_marginal_of_two_le → _p2mNativeSupplement128
open _root_.InfoLossLARNativeSupplements.h94f62847a0770621.CurrentAFT.ProtectedCycle renaming independent_pair_law → CurrentAFT.ProtectedCycle.independent_pair_law
open _root_.InfoLossLARNativeSupplements.h94f62847a0770621.CurrentAFT.ProtectedCycle renaming independent_pair_law → _p2mNativeSupplement129
open _root_.InfoLossLARNativeSupplements.h2021c53cebcb97f7.CurrentAFT.RationalScalarFamilyAverage renaming current_eq_window_sum → CurrentAFT.RationalScalarFamilyAverage.current_eq_window_sum
open _root_.InfoLossLARNativeSupplements.h2021c53cebcb97f7.CurrentAFT.RationalScalarFamilyAverage renaming current_eq_window_sum → _p2mNativeSupplement130
open _root_.InfoLossLARNativeSupplements.h6473fbae786c301e.CurrentAFT.RootSignedMassProgram renaming referenceEntry_cast → CurrentAFT.RootSignedMassProgram.referenceEntry_cast
open _root_.InfoLossLARNativeSupplements.h6473fbae786c301e.CurrentAFT.RootSignedMassProgram renaming referenceEntry_cast → _p2mNativeSupplement131
open _root_.InfoLossLARNativeSupplements.h4c23fa31c2a53a0c.CurrentAFT.RootSignedMassProgram renaming singleton_probability → CurrentAFT.RootSignedMassProgram.singleton_probability
open _root_.InfoLossLARNativeSupplements.h4c23fa31c2a53a0c.CurrentAFT.RootSignedMassProgram renaming singleton_probability → _p2mNativeSupplement132
open _root_.InfoLossLARNativeSupplements.hb738544899c1bf50.CurrentAFT.TensorPublicProjection renaming independent_decision_expectation → CurrentAFT.TensorPublicProjection.independent_decision_expectation
open _root_.InfoLossLARNativeSupplements.hb738544899c1bf50.CurrentAFT.TensorPublicProjection renaming independent_decision_expectation → _p2mNativeSupplement133
open _root_.InfoLossLARNativeSupplements.hf2382f7ddc8e222e.AFT.RationalNumerics renaming natAbs_finset_sum_le → AFT.RationalNumerics.natAbs_finset_sum_le
open _root_.InfoLossLARNativeSupplements.hf2382f7ddc8e222e.AFT.RationalNumerics renaming natAbs_finset_sum_le → _p2mNativeSupplement134
open _root_.InfoLossLARNativeSupplements.h707562ec4bd11ae8.AFT.RationalNumerics.HeightBound renaming reduced_le → AFT.RationalNumerics.HeightBound.reduced_le
open _root_.InfoLossLARNativeSupplements.h707562ec4bd11ae8.AFT.RationalNumerics.HeightBound renaming reduced_le → _p2mNativeSupplement135
open _root_.InfoLossLARNativeSupplements.hd70d55bab6f2346d.CurrentAFT.CountedBoundedRootTags renaming bounded_sum → CurrentAFT.CountedBoundedRootTags.bounded_sum
open _root_.InfoLossLARNativeSupplements.hd70d55bab6f2346d.CurrentAFT.CountedBoundedRootTags renaming bounded_sum → _p2mNativeSupplement136
open _root_.InfoLossLARNativeSupplements.hb84db39a2a2ae627.CurrentAFT.CountedBoundedRootTags renaming flatMap_attach → CurrentAFT.CountedBoundedRootTags.flatMap_attach
open _root_.InfoLossLARNativeSupplements.hb84db39a2a2ae627.CurrentAFT.CountedBoundedRootTags renaming flatMap_attach → _p2mNativeSupplement137
open _root_.InfoLossLARNativeSupplements.he91e90e23380c2d0.CurrentAFT.JointTaggedPhysicalFock renaming law_nonempty → CurrentAFT.JointTaggedPhysicalFock.law_nonempty
open _root_.InfoLossLARNativeSupplements.he91e90e23380c2d0.CurrentAFT.JointTaggedPhysicalFock renaming law_nonempty → _p2mNativeSupplement138
section
set_option autoImplicit false
set_option maxHeartbeats 3000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace InfoLossLAR.WorstCase.TM2Boolean.RPN
open QAlgorithms.Complexity
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open QMCNumericRuntime
open Integration9_9.TM2PlatformSerialization
def boundedNat (slots : List Unit) (n : ℕ) : Str := _root_.Integration9_9.TM2PlatformSerialization.lengthToken (slots.take n)
theorem boundedNat_eq (slots : List Unit) (n : ℕ) (h : n ≤ slots.length) :
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots n = encNat n := by simp [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat, _root_.Integration9_9.TM2PlatformSerialization.lengthToken_eq, List.length_take, Nat.min_eq_left h]
def instructionWord (slots : List Unit) (target : ℕ) (v : _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.Node) : Str :=
if v.1 = 0 then encNat 0 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots target
else if v.1 = 1 then encNat 1 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots target
else if v.1 = 2 then encNat 2 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots v.2.1 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots target
else if v.1 = 3 then encNat 3 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots v.2.1 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots target
else if v.1 = 4 then encNat 4 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots v.2.1 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots v.2.2 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots target
else encNat 5 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots v.2.1 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots v.2.2 ++ _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat slots target
theorem instructionWord_node {total : ℕ} (slots : List Unit) (op : _root_.InfoLossLAR.WorstCase.BooleanOp) (target : Fin total)
(h : op.Valid target.val) (ht : target.val ≤ slots.length) :
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWord slots target.val (_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.node op) = (op.toGate target).code := by
cases op with
| constant b => cases b <;> simp [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.node, _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWord, _root_.InfoLossLAR.WorstCase.BooleanOp.toGate, _root_.InfoLossLAR.WorstCase.BooleanGate.code, _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat_eq slots target.val ht]
| copy a | negate a =>
have ha : a < target.val := h a (by simp [_root_.InfoLossLAR.WorstCase.BooleanOp.sources])
simp [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.node, _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWord, _root_.InfoLossLAR.WorstCase.BooleanOp.toGate, _root_.InfoLossLAR.WorstCase.BooleanGate.code, ha,
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat_eq slots target.val ht, _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat_eq slots a (ha.le.trans ht)]
| xor a b | and a b =>
have ha : a < target.val := h a (by simp [_root_.InfoLossLAR.WorstCase.BooleanOp.sources])
have hb : b < target.val := h b (by simp [_root_.InfoLossLAR.WorstCase.BooleanOp.sources])
simp [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.node, _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWord, _root_.InfoLossLAR.WorstCase.BooleanOp.toGate, _root_.InfoLossLAR.WorstCase.BooleanGate.code, ha, hb,
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat_eq slots target.val ht, _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat_eq slots a (ha.le.trans ht),
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.boundedNat_eq slots b (hb.le.trans ht)]
def instructionWords (slots : List Unit) (start : ℕ) (nodes : List _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.Node) : List Str :=
(List.range nodes.length).map (fun i => _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWord slots (start+i) ((nodes[i]?).getD (0,0,0)))
theorem instructionWords_mapIdx (slots : List Unit) (start : ℕ) (nodes : List _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.Node) :
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWords slots start nodes = nodes.mapIdx (fun i v => _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWord slots (start+i) v) := by
apply List.ext_getElem
· simp [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWords]
· intro i hi hj
have hin : i < nodes.length := by simpa only [List.length_mapIdx] using hj
simp only [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWords, List.getElem_map, List.getElem_range, List.getElem_mapIdx,
List.getElem?_eq_getElem hin, Option.getD_some]
theorem instructionWords_gates {total : ℕ} (slots : List Unit) (start : ℕ) (ops : List _root_.InfoLossLAR.WorstCase.BooleanOp)
(h : start+ops.length ≤ total) (hv : _root_.InfoLossLAR.WorstCase.BooleanProgram.Valid start ops)
(hs : start+ops.length ≤ slots.length) :
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWords slots start (ops.map _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.node) = (_root_.InfoLossLAR.WorstCase.BooleanProgram.gates start ops h).map _root_.InfoLossLAR.WorstCase.BooleanGate.code := by
rw [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWords_mapIdx]
induction ops generalizing start with
| nil => rfl
| cons op ops ih =>
simp only [_root_.InfoLossLAR.WorstCase.BooleanProgram.Valid] at hv
simp only [List.length_cons] at h hs
simp only [List.map_cons, List.mapIdx_cons, _root_.InfoLossLAR.WorstCase.BooleanProgram.gates]
simp only [Nat.add_zero]
rw [_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWord_node slots op (⟨start, by omega⟩ : Fin total) hv.1 (by change start ≤ slots.length; omega)]
congr 1
have hh := ih (start+1) (by omega) hv.2 (by omega)
simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hh
end InfoLossLAR.WorstCase.TM2Boolean.RPN
end
section
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace InfoLossLAR.WorstCase
open QAlgorithms.Complexity
open scoped BigOperators
/-- A concrete four-assignment multiplexer on natural fresh-wire addresses. -/
def multiSelectorChunk (start left : ℕ) (choice : ℕ × ℕ) : List _root_.InfoLossLAR.WorstCase.BooleanOp :=
[.negate choice.1,.and start left,.and choice.1 choice.2,.xor (start+1) (start+2)]
def multiSelectorOps : ℕ → ℕ → List (ℕ × ℕ) → List _root_.InfoLossLAR.WorstCase.BooleanOp
| _,_,[] => []
| start,left,choice::rest =>
_root_.InfoLossLAR.WorstCase.multiSelectorChunk start left choice ++ multiSelectorOps (start+4) (start+3) rest
def multiSelectorOutput : ℕ → ℕ → List (ℕ × ℕ) → ℕ
| _,left,[] => left
| start,_,_::rest => multiSelectorOutput (start+4) (start+3) rest
def multiSelectorValue (state : ℕ → Bool) : Bool → List (ℕ × ℕ) → Bool
| initial,[] => initial
| initial,choice::rest =>
multiSelectorValue state (if state choice.1 then state choice.2 else initial) rest
theorem multiSelectorOps_length (start left : ℕ) (choices : List (ℕ × ℕ)) :
(_root_.InfoLossLAR.WorstCase.multiSelectorOps start left choices).length=4*choices.length := by
induction choices generalizing start left with
| nil => rfl
| cons choice rest ih =>
simp only [_root_.InfoLossLAR.WorstCase.multiSelectorOps,List.length_append,_root_.InfoLossLAR.WorstCase.multiSelectorChunk,List.length_cons,List.length_nil,ih]
omega
theorem multiSelectorOutput_lt (start left : ℕ) (choices : List (ℕ × ℕ)) (hl : left<start) :
_root_.InfoLossLAR.WorstCase.multiSelectorOutput start left choices<start+4*choices.length := by
induction choices generalizing start left with
| nil => simpa only [_root_.InfoLossLAR.WorstCase.multiSelectorOutput,List.length_nil,Nat.mul_zero,Nat.add_zero] using hl
| cons choice rest ih =>
have h := ih (start+4) (start+3) (by omega)
simp only [_root_.InfoLossLAR.WorstCase.multiSelectorOutput,List.length_cons]
omega
/-- A finite input register extended by zero outside its physical addresses. -/
def selectorBitsExtension {n : ℕ} (state : Bits n) (index : ℕ) : Bool :=
if h : index<n then state ⟨index,h⟩ else false
@[simp] theorem selectorBitsExtension_get {n : ℕ} (state : Bits n) (index : Fin n) :
_root_.InfoLossLAR.WorstCase.selectorBitsExtension state index.val=state index := by simp [_root_.InfoLossLAR.WorstCase.selectorBitsExtension]
end InfoLossLAR.WorstCase
end
section
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace InfoLossLAR.WorstCase
open QAlgorithms.Complexity
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open OAI.MetricKMedian.Binary.Automatic.Poly
open QMCNumericRuntime Integration9_9.TM2PlatformSerialization
open TM2Boolean.RPN
/-- The literal four node records emitted for one selection stage. -/
def multiSelectorNodeChunk (start left : ℕ) (choice : ℕ × ℕ) : List _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.Node :=
[(3,choice.1,0),(5,start,left),(5,choice.1,choice.2),(4,start+1,start+2)]
/-- A bounded index loop, with no binary-address to unary expansion. -/
def multiSelectorNodes (start left : ℕ) (choices : List (ℕ × ℕ)) : List _root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.Node :=
(List.range choices.length).flatMap (fun index =>
_root_.InfoLossLAR.WorstCase.multiSelectorNodeChunk (start+4*index) (if index=0 then left else start+4*index-1)
((choices[index]?).getD (0,0)))
/-- Real native serializer for the selector's Boolean instruction words. Source
and destination unary addresses are bounded by the supplied actual wire slots. -/
def multiSelectorGateWords (slots : List Unit) (start left : ℕ) (choices : List (ℕ × ℕ)) : List Str :=
_root_.InfoLossLAR.WorstCase.TM2Boolean.RPN.instructionWords slots start (_root_.InfoLossLAR.WorstCase.multiSelectorNodes start left choices)
/-- Closed output address used by the actual description generator. -/
def multiSelectorFinalIndex (start left : ℕ) (choices : List (ℕ × ℕ)) : ℕ :=
if choices.isEmpty then left else start+4*choices.length-1
def multiSelectorScratch (choices : List (ℕ × ℕ)) : List Unit :=
choices.flatMap (fun _ => [(),(),(),()])
theorem multiSelectorScratch_length (choices : List (ℕ × ℕ)) :
(_root_.InfoLossLAR.WorstCase.multiSelectorScratch choices).length=4*choices.length := by
induction choices with
| nil => rfl
| cons choice rest ih =>
simp only [_root_.InfoLossLAR.WorstCase.multiSelectorScratch,List.flatMap_cons,List.length_append,List.length_cons,List.length_nil] at *
omega
end InfoLossLAR.WorstCase
end
section
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option backward.isDefEq.respectTransparency false
namespace InfoLossLAR.WorstCase
open QAlgorithms.Complexity
open scoped BigOperators
/-- One physical quantum block, with its actual circuit and normalized input. -/
structure QuantumBlock where
wires : ℕ
circuit : Layered wires
input : QState wires
out : Fin wires
normalized : (∑ state,‖input state‖^2)=1
noncomputable def QuantumBlock.probability (block : _root_.InfoLossLAR.WorstCase.QuantumBlock) : ℝ :=
∑ state : Bits block.wires,if state block.out then ‖runLayered block.circuit block.input state‖^2 else 0
def bundleWidth : List _root_.InfoLossLAR.WorstCase.QuantumBlock → ℕ
| [] => 0
| block::blocks => block.wires+bundleWidth blocks
def bundleState : (blocks : List _root_.InfoLossLAR.WorstCase.QuantumBlock) → QState (_root_.InfoLossLAR.WorstCase.bundleWidth blocks)
| [] => fun _ => 1
| block::blocks => _root_.InfoLossLAR.WorstCase.tensorState block.input (bundleState blocks)
def bundleCircuit : (blocks : List _root_.InfoLossLAR.WorstCase.QuantumBlock) → Layered (_root_.InfoLossLAR.WorstCase.bundleWidth blocks)
| [] => []
| block::blocks => _root_.InfoLossLAR.WorstCase.leftCircuit block.circuit++_root_.InfoLossLAR.WorstCase.rightCircuit (bundleCircuit blocks)
def bundleOutput : (blocks : List _root_.InfoLossLAR.WorstCase.QuantumBlock) → Fin blocks.length → Fin (_root_.InfoLossLAR.WorstCase.bundleWidth blocks)
| [],index => Fin.elim0 index
| block::blocks,index => Fin.cases
(Fin.castAdd (_root_.InfoLossLAR.WorstCase.bundleWidth blocks) block.out)
(fun tail => Fin.natAdd block.wires (bundleOutput blocks tail)) index
/-- A real platform distinguisher at one fixed input length. -/
def familyBlock (D : Family) (length : ℕ) (input : Bits length) : _root_.InfoLossLAR.WorstCase.QuantumBlock where
wires := length+(D.anc length+1)
circuit := D.circ length
input := basisInput input
out := D.out length
normalized := by simpa only [Complex.normSq_eq_norm_sq] using _root_.InfoLossLAR.WorstCase.basisInput_mass (a := D.anc length) input
/-- Prepare all candidate input lengths, with false padding beyond the actual
query. The selected block is at its exact true query length. -/
def queryBlocks (D : Family) (maximum : ℕ) (query : Str) : List _root_.InfoLossLAR.WorstCase.QuantumBlock :=
List.ofFn (fun length : Fin (maximum+1) => _root_.InfoLossLAR.WorstCase.familyBlock D length.val
(fun index => (query[index.val]?).getD false))
/-- Physical descriptions erase input amplitudes and normalization proofs. -/
def bundlePhysical (blocks : List _root_.InfoLossLAR.WorstCase.QuantumBlock) : (Σ wires : ℕ,Layered wires) :=
⟨_root_.InfoLossLAR.WorstCase.bundleWidth blocks,_root_.InfoLossLAR.WorstCase.bundleCircuit blocks⟩
def appendPhysical (first second : (Σ wires : ℕ,Layered wires)) : (Σ wires : ℕ,Layered wires) :=
⟨first.1+second.1,_root_.InfoLossLAR.WorstCase.leftCircuit first.2++_root_.InfoLossLAR.WorstCase.rightCircuit second.2⟩
end InfoLossLAR.WorstCase
end
section
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace InfoLossLAR.WorstCase
open QAlgorithms.Complexity
open OAI.MetricKMedian.Binary
open OAI.MetricKMedian.Binary.Automatic
open OAI.MetricKMedian.Binary.Automatic.Poly
open QMCNumericRuntime Integration9_9.TM2PlatformSerialization
/-- Existing unary slots, excluding the stop bit. -/
def unaryPayload (xs : Str) : Str := xs.take (inputWidth xs)
theorem _root_.InfoLossLAR.WorstCase.emitter_width_append (number : ℕ) (suffix : Str) : inputWidth (encNat number++suffix)=number := by
simpa only [encNat,List.append_assoc,List.singleton_append] using inputWidth_prefix number suffix
theorem unaryPayload_length (xs : Str) : (_root_.InfoLossLAR.WorstCase.unaryPayload xs).length=inputWidth xs := by
have h : inputWidth xs ≤ xs.length := List.findIdx_le_length
simp only [_root_.InfoLossLAR.WorstCase.unaryPayload,List.length_take,Nat.min_eq_left h]
@[simp] theorem unaryPayload_encNat (number : ℕ) (suffix : Str) :
_root_.InfoLossLAR.WorstCase.unaryPayload (encNat number++suffix)=unary number := by
unfold _root_.InfoLossLAR.WorstCase.unaryPayload
rw [_root_.InfoLossLAR.WorstCase.emitter_width_append]
simp [encNat,unary,List.take_append]
@[simp] theorem unaryPayload_number (number : ℕ) : _root_.InfoLossLAR.WorstCase.unaryPayload (encNat number)=unary number := by
simpa only [List.append_nil] using _root_.InfoLossLAR.WorstCase.unaryPayload_encNat number []
/-- Canonical unary offset addition uses only existing prior slots. -/
def shiftWireWord (prior wire : Str) : Str := _root_.Integration9_9.TM2PlatformSerialization.lengthToken (prior++_root_.InfoLossLAR.WorstCase.unaryPayload wire)
@[simp] theorem shiftWireWord_encNat (prior : Str) (number : ℕ) (suffix : Str) :
_root_.InfoLossLAR.WorstCase.shiftWireWord prior (encNat number++suffix)=encNat (prior.length+number) := by
simp only [_root_.InfoLossLAR.WorstCase.shiftWireWord,_root_.InfoLossLAR.WorstCase.unaryPayload_encNat,_root_.Integration9_9.TM2PlatformSerialization.lengthToken_eq,List.length_append,unary,List.length_replicate]
/-- Canonicalize tags and offset all actual wire fields, including malformed
words whose missing stop bits must never trigger unbounded expansion. -/
def shiftInstructionWord (prior xs : Str) : Str :=
let tag := _root_.Integration9_9.TM2PlatformSerialization.readUnary xs
let first := _root_.Integration9_9.TM2PlatformSerialization.readUnary tag.2
let tagCode := _root_.Integration9_9.TM2PlatformSerialization.lengthToken (_root_.InfoLossLAR.WorstCase.unaryPayload xs)
let firstCode := _root_.Integration9_9.TM2PlatformSerialization.lengthToken (prior++_root_.InfoLossLAR.WorstCase.unaryPayload tag.2)
if inputWidth xs=4 then
tagCode++firstCode++_root_.Integration9_9.TM2PlatformSerialization.lengthToken (prior++_root_.InfoLossLAR.WorstCase.unaryPayload first.2)
else tagCode++firstCode
@[simp] theorem leftInstruction_encInstr {n m : ℕ} (gate : Instr n) :
encInstr (_root_.InfoLossLAR.WorstCase.leftInstruction (m := m) gate)=encInstr gate := by
cases gate <;> rfl
/-- Parsed layers are offset without changing their layer order or grouping. -/
def shiftCircuitWords (prior : Str) (layers : List (List Str)) : List (List Str) :=
layers.map (fun layer => layer.map (_root_.InfoLossLAR.WorstCase.shiftInstructionWord prior))
/-- A parsed actual D description includes its physical wire slots, its
local output token and all actual layer/instruction words. -/
abbrev PhysicalFrameWords := Str × (Str × List (List Str))
def readFamilyFrame (input : Str × Str) : _root_.InfoLossLAR.WorstCase.PhysicalFrameWords :=
let ancilla := _root_.Integration9_9.TM2PlatformSerialization.readUnary input.2
let output := _root_.Integration9_9.TM2PlatformSerialization.readUnary ancilla.2
(input.1++_root_.InfoLossLAR.WorstCase.unaryPayload input.2++[true],(output.1,(_root_.InfoLossLAR.WorstCase.readCircuitLayers output.2).2))
theorem readFamilyFrame_correct (D : Family) (length : ℕ) :
_root_.InfoLossLAR.WorstCase.readFamilyFrame (unary length,encFamilyAt D length)=
(unary (length+(D.anc length+1)),
(encNat (D.out length).val,(D.circ length).map (List.map encInstr))) := by
unfold _root_.InfoLossLAR.WorstCase.readFamilyFrame encFamilyAt
simp only [List.append_assoc,_root_.Integration9_9.TM2PlatformSerialization.readUnary_append,_root_.InfoLossLAR.WorstCase.unaryPayload_encNat]
have h := _root_.InfoLossLAR.WorstCase.readCircuitLayers_append (D.circ length) []
simp only [List.append_nil] at h
rw [h]
simp [unary,List.replicate_add,List.append_assoc]
/-- Every previous physical block supplies only its existing wire slots. -/
def precedingWireSlots (input : List _root_.InfoLossLAR.WorstCase.PhysicalFrameWords × ℕ) : Str :=
(input.1.take input.2).flatMap (fun frame => frame.1)
/-- The concrete polynomial-time emitter computes each block's offset from
its supplied predecessors and emits every actual gate with that offset. -/
def bundleCircuitWordLayers (frames : List _root_.InfoLossLAR.WorstCase.PhysicalFrameWords) : List (List Str) :=
(List.range frames.length).flatMap fun index =>
let frame := (frames[index]?).getD ([],([],[]))
_root_.InfoLossLAR.WorstCase.shiftCircuitWords (_root_.InfoLossLAR.WorstCase.precedingWireSlots (frames,index)) frame.2.2
/-- Actual D output tokens get precisely the same per-block physical offset. -/
def bundleOutputWords (frames : List _root_.InfoLossLAR.WorstCase.PhysicalFrameWords) : List Str :=
(List.range frames.length).map fun index =>
let frame := (frames[index]?).getD ([],([],[]))
_root_.InfoLossLAR.WorstCase.shiftWireWord (_root_.InfoLossLAR.WorstCase.precedingWireSlots (frames,index)) frame.2.1
theorem _root_.InfoLossLAR.WorstCase.emitter_width_number (number : ℕ) : inputWidth (encNat number)=number := by
simpa only [List.append_nil] using _root_.InfoLossLAR.WorstCase.emitter_width_append number []
/-- Actual physical circuit frames are emitted directly from their true
qubit counts, output wire and instruction descriptions. -/
def blockFrameWords (block : _root_.InfoLossLAR.WorstCase.QuantumBlock) : _root_.InfoLossLAR.WorstCase.PhysicalFrameWords :=
(unary block.wires,(encNat block.out.val,block.circuit.map (List.map encInstr)))
theorem shiftWireWord_spec (prior word : Str) :
_root_.InfoLossLAR.WorstCase.shiftWireWord prior word=encNat (prior.length+inputWidth word) := by
simp only [_root_.InfoLossLAR.WorstCase.shiftWireWord,_root_.Integration9_9.TM2PlatformSerialization.lengthToken_eq,List.length_append,_root_.InfoLossLAR.WorstCase.unaryPayload_length]
theorem shiftWireWord_comp (first second word : Str) :
_root_.InfoLossLAR.WorstCase.shiftWireWord first (_root_.InfoLossLAR.WorstCase.shiftWireWord second word)=_root_.InfoLossLAR.WorstCase.shiftWireWord (first++second) word := by
rw [_root_.InfoLossLAR.WorstCase.shiftWireWord_spec second word,_root_.InfoLossLAR.WorstCase.shiftWireWord_spec,_root_.InfoLossLAR.WorstCase.emitter_width_number,_root_.InfoLossLAR.WorstCase.shiftWireWord_spec]
simp only [List.length_append,Nat.add_assoc]
theorem bundleOutputWords_cons (frame : _root_.InfoLossLAR.WorstCase.PhysicalFrameWords) (frames : List _root_.InfoLossLAR.WorstCase.PhysicalFrameWords) :
_root_.InfoLossLAR.WorstCase.bundleOutputWords (frame::frames)=
_root_.InfoLossLAR.WorstCase.shiftWireWord [] frame.2.1::(_root_.InfoLossLAR.WorstCase.bundleOutputWords frames).map (_root_.InfoLossLAR.WorstCase.shiftWireWord frame.1) := by
unfold _root_.InfoLossLAR.WorstCase.bundleOutputWords
simp only [List.length_cons,List.range_succ_eq_map,List.map_cons,List.map_map,Function.comp_def,
List.getElem?_cons_zero,Option.getD_some,_root_.InfoLossLAR.WorstCase.precedingWireSlots,List.take_zero,List.flatMap_nil]
apply congrArg (List.cons (_root_.InfoLossLAR.WorstCase.shiftWireWord [] frame.2.1))
apply List.map_congr_left
intro index _
simp only [List.getElem?_cons_succ,_root_.InfoLossLAR.WorstCase.precedingWireSlots,List.take_succ_cons,List.flatMap_cons]
exact (_root_.InfoLossLAR.WorstCase.shiftWireWord_comp frame.1 _ _).symm
/-- Every emitted output token names the actual corresponding physical wire. -/
theorem bundleOutputWords_correct (blocks : List _root_.InfoLossLAR.WorstCase.QuantumBlock) :
_root_.InfoLossLAR.WorstCase.bundleOutputWords (blocks.map _root_.InfoLossLAR.WorstCase.blockFrameWords)=
List.ofFn (fun index : Fin blocks.length => encNat (_root_.InfoLossLAR.WorstCase.bundleOutput blocks index).val) := by
induction blocks with
| nil => rfl
| cons block blocks ih =>
rw [List.map_cons,_root_.InfoLossLAR.WorstCase.bundleOutputWords_cons,ih,List.ofFn_succ]
simp only [_root_.InfoLossLAR.WorstCase.blockFrameWords,_root_.InfoLossLAR.WorstCase.shiftWireWord_spec,_root_.InfoLossLAR.WorstCase.emitter_width_number,List.length_nil,zero_add,
_root_.InfoLossLAR.WorstCase.bundleOutput,Fin.cases_zero,Fin.val_castAdd]
apply congrArg (List.cons (encNat block.out.val))
rw [List.map_ofFn]
apply congrArg List.ofFn
funext index
simp only [Function.comp_def,_root_.InfoLossLAR.WorstCase.shiftWireWord_spec,_root_.InfoLossLAR.WorstCase.emitter_width_number,unary,List.length_replicate,
_root_.InfoLossLAR.WorstCase.bundleOutput,Fin.cases_succ,Fin.val_natAdd]
def emitDOutputs (descriptions : List (Str × Str)) : List Str :=
_root_.InfoLossLAR.WorstCase.bundleOutputWords (descriptions.map _root_.InfoLossLAR.WorstCase.readFamilyFrame)
def describedQueryBlocks (D : Family) (maximum : ℕ) : List (Str × Str) :=
List.ofFn (fun length : Fin (maximum+1) => (unary length.val,encFamilyAt D length.val))
theorem describedQueryBlocks_frames (D : Family) (maximum : ℕ) (query : Str) :
(_root_.InfoLossLAR.WorstCase.describedQueryBlocks D maximum).map _root_.InfoLossLAR.WorstCase.readFamilyFrame=(_root_.InfoLossLAR.WorstCase.queryBlocks D maximum query).map _root_.InfoLossLAR.WorstCase.blockFrameWords := by
simp only [_root_.InfoLossLAR.WorstCase.describedQueryBlocks,_root_.InfoLossLAR.WorstCase.queryBlocks,List.map_ofFn,Function.comp_def,_root_.InfoLossLAR.WorstCase.readFamilyFrame_correct,
_root_.InfoLossLAR.WorstCase.blockFrameWords,_root_.InfoLossLAR.WorstCase.familyBlock]
theorem emitDOutputs_correct (D : Family) (maximum : ℕ) (query : Str) :
_root_.InfoLossLAR.WorstCase.emitDOutputs (_root_.InfoLossLAR.WorstCase.describedQueryBlocks D maximum)=
List.ofFn (fun index : Fin (_root_.InfoLossLAR.WorstCase.queryBlocks D maximum query).length =>
encNat (_root_.InfoLossLAR.WorstCase.bundleOutput (_root_.InfoLossLAR.WorstCase.queryBlocks D maximum query) index).val) := by
rw [_root_.InfoLossLAR.WorstCase.emitDOutputs,_root_.InfoLossLAR.WorstCase.describedQueryBlocks_frames D maximum query,_root_.InfoLossLAR.WorstCase.bundleOutputWords_correct]
end InfoLossLAR.WorstCase
end
section
namespace Integration9_9
end Integration9_9
namespace Integration9_9.TM2OutputLength
end Integration9_9.TM2OutputLength
namespace Integration9_9.TM2OutputLength.pushBound
end Integration9_9.TM2OutputLength.pushBound
namespace Integration9_9.TM2OutputLength.pushBound.match_1
end Integration9_9.TM2OutputLength.pushBound.match_1
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace Integration9_9.TM2StockThread
open Turing StateTransition Function TM2Simulation
local instance stackDecidable (machine : FinTM2) : DecidableEq machine.K := machine.kDecidableEq
local instance stackFinite (machine : FinTM2) : Fintype machine.K := machine.kFin
local instance labelFinite (machine : FinTM2) : Fintype machine.Λ := machine.ΛFin
local instance stateFinite (machine : FinTM2) : Fintype machine.σ := machine.σFin
inductive Buffer | input | scratch | output
deriving Fintype,DecidableEq
inductive Phase | parse | feed | contextReverse | contextForward | quoteOutput | finishReverse
deriving Fintype,DecidableEq
abbrev Stack (machine : FinTM2) := machine.K ⊕ _root_.Integration9_9.TM2StockThread.Buffer
abbrev Label (machine : FinTM2) := machine.Λ ⊕ _root_.Integration9_9.TM2StockThread.Phase
abbrev State (machine : FinTM2) := machine.σ × Option Bool
def Alphabet (machine : FinTM2) : _root_.Integration9_9.TM2StockThread.Stack machine → Type
| .inl stack => machine.Γ stack
| .inr _ => Bool
def initial (machine : FinTM2) : _root_.Integration9_9.TM2StockThread.State machine := (machine.initialState,none)
def next (machine : FinTM2) (phase : _root_.Integration9_9.TM2StockThread.Phase) : TM2.Stmt (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine) :=
.load (fun state => (state.1,none)) (.goto (fun _ => .inr phase))
def driver (machine : FinTM2) (inputAlphabet : machine.Γ machine.k₀ ≃ Bool)
(outputAlphabet : machine.Γ machine.k₁ ≃ Bool) :
_root_.Integration9_9.TM2StockThread.Phase → TM2.Stmt (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine)
| .parse =>
.pop (.inr .input) (fun state bit => (state.1,bit))
(.branch (fun state => state.2 == some true)
(.pop (.inr .input) (fun state bit => (state.1,bit))
(.push (.inr .scratch) (fun state => state.2.getD false) (_root_.Integration9_9.TM2StockThread.next machine .parse)))
(_root_.Integration9_9.TM2StockThread.next machine .feed))
| .feed =>
.pop (.inr .scratch) (fun state bit => (state.1,bit))
(.branch (fun state => state.2.isSome)
(.push (.inl machine.k₀) (fun state => inputAlphabet.symm (state.2.getD false)) (_root_.Integration9_9.TM2StockThread.next machine .feed))
(.load (fun _ => _root_.Integration9_9.TM2StockThread.initial machine) (.goto (fun _ => .inl machine.main))))
| .contextReverse =>
.pop (.inr .input) (fun state bit => (state.1,bit))
(.branch (fun state => state.2.isSome)
(.push (.inr .scratch) (fun state => state.2.getD false) (_root_.Integration9_9.TM2StockThread.next machine .contextReverse))
(_root_.Integration9_9.TM2StockThread.next machine .contextForward))
| .contextForward =>
.pop (.inr .scratch) (fun state bit => (state.1,bit))
(.branch (fun state => state.2.isSome)
(.push (.inr .output) (fun state => state.2.getD false) (_root_.Integration9_9.TM2StockThread.next machine .contextForward))
(.push (.inr .output) (fun _ => false) (_root_.Integration9_9.TM2StockThread.next machine .quoteOutput)))
| .quoteOutput =>
.pop (.inl machine.k₁) (fun state symbol => (state.1,symbol.map outputAlphabet))
(.branch (fun state => state.2.isSome)
(.push (.inr .scratch) (fun _ => true)
(.push (.inr .scratch) (fun state => state.2.getD false) (_root_.Integration9_9.TM2StockThread.next machine .quoteOutput)))
(_root_.Integration9_9.TM2StockThread.next machine .finishReverse))
| .finishReverse =>
.pop (.inr .scratch) (fun state bit => (state.1,bit))
(.branch (fun state => state.2.isSome)
(.push (.inr .output) (fun state => state.2.getD false) (_root_.Integration9_9.TM2StockThread.next machine .finishReverse))
(.load (fun _ => _root_.Integration9_9.TM2StockThread.initial machine) .halt))
def program (machine : FinTM2) (inputAlphabet : machine.Γ machine.k₀ ≃ Bool)
(outputAlphabet : machine.Γ machine.k₁ ≃ Bool) :
_root_.Integration9_9.TM2StockThread.Label machine → TM2.Stmt (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine)
| .inl label => _root_.Integration9_9.TM2Simulation.statement Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .contextReverse)) (machine.m label)
| .inr phase => _root_.Integration9_9.TM2StockThread.driver machine inputAlphabet outputAlphabet phase
/-- A real finite caller, preserving arbitrary internal alphabet types of the
callee. Only its actual Boolean input/output interfaces are used. -/
def threadedMachine (machine : FinTM2) (inputAlphabet : machine.Γ machine.k₀ ≃ Bool)
(outputAlphabet : machine.Γ machine.k₁ ≃ Bool) : FinTM2 where
K := _root_.Integration9_9.TM2StockThread.Stack machine
k₀ := .inr .input
k₁ := .inr .output
Γ := _root_.Integration9_9.TM2StockThread.Alphabet machine
Γk₀Fin := inferInstanceAs (Fintype Bool)
Λ := _root_.Integration9_9.TM2StockThread.Label machine
main := .inr .parse
σ := _root_.Integration9_9.TM2StockThread.State machine
initialState := _root_.Integration9_9.TM2StockThread.initial machine
m := _root_.Integration9_9.TM2StockThread.program machine inputAlphabet outputAlphabet
/-- The caller executes the actual arbitrary-alphabet callee in the same
number of steps, retaining every Boolean caller buffer and caller control field. -/
theorem native_run (machine : FinTM2) (inputAlphabet : machine.Γ machine.k₀ ≃ Bool)
(outputAlphabet : machine.Γ machine.k₁ ≃ Bool)
(anchor : _root_.Integration9_9.TM2StockThread.State machine) (frame : ∀ stack,List (_root_.Integration9_9.TM2StockThread.Alphabet machine stack))
(start finish : TM2.Cfg machine.Γ machine.Λ machine.σ)
(caller : TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine)) (steps : ℕ)
(h : EvalsToInTime (TM2.step machine.m) start (some finish) steps)
(hframe : _root_.Integration9_9.TM2Subroutine.FrameRel Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .contextReverse)) anchor frame start caller) :
∃ result,Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine inputAlphabet outputAlphabet)) caller (some result) steps) ∧
_root_.Integration9_9.TM2Subroutine.FrameRel Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .contextReverse)) anchor frame finish result := by
exact _root_.Integration9_9.TM2Subroutine.run Sum.inl Sum.inl_injective (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst
Sum.inl (some (.inr .contextReverse)) machine.m (_root_.Integration9_9.TM2StockThread.program machine inputAlphabet outputAlphabet)
(fun _ => rfl) anchor frame start finish caller steps h hframe
def fullStacks (machine : FinTM2) (native : ∀ k,List (machine.Γ k))
(input scratch output : List Bool) : ∀ stack,List (_root_.Integration9_9.TM2StockThread.Alphabet machine stack)
| .inl k => native k
| .inr .input => input
| .inr .scratch => scratch
| .inr .output => output
def phaseCfg (machine : FinTM2) (phase : _root_.Integration9_9.TM2StockThread.Phase) (native : ∀ k,List (machine.Γ k))
(input scratch output : List Bool) : TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine) :=
⟨some (.inr phase),_root_.Integration9_9.TM2StockThread.initial machine,_root_.Integration9_9.TM2StockThread.fullStacks machine native input scratch output⟩
def callCfg (machine : FinTM2) (native : ∀ k,List (machine.Γ k))
(input scratch output : List Bool) : TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine) :=
⟨some (.inl machine.main),_root_.Integration9_9.TM2StockThread.initial machine,_root_.Integration9_9.TM2StockThread.fullStacks machine native input scratch output⟩
def terminalCfg (machine : FinTM2) (native : ∀ k,List (machine.Γ k))
(input scratch output : List Bool) : TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine) :=
⟨none,_root_.Integration9_9.TM2StockThread.initial machine,_root_.Integration9_9.TM2StockThread.fullStacks machine native input scratch output⟩
def nativeInput (machine : FinTM2) (word : List (machine.Γ machine.k₀)) : ∀ k,List (machine.Γ k) :=
Function.update (fun _ => []) machine.k₀ word
def nativeOutput (machine : FinTM2) (word : List (machine.Γ machine.k₁)) : ∀ k,List (machine.Γ k) :=
Function.update (fun _ => []) machine.k₁ word
theorem _root_.Integration9_9.TM2StockThread.caller_cfg_ext {machine : FinTM2}
(first second : TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockThread.Label machine) (_root_.Integration9_9.TM2StockThread.State machine))
(hl : first.l=second.l) (hv : first.var=second.var)
(hs : ∀ stack,first.stk stack=second.stk stack) : first=second := by
have hh := funext hs
cases first
cases second
simp_all
theorem parse_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (bit : Bool) (input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .parse native (true::bit::input) scratch output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .parse native input (bit::scratch) output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem parse_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .parse native (false::input) scratch output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .feed native input scratch output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem feed_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(letters : List (machine.Γ machine.k₀)) (bit : Bool) (input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .feed (_root_.Integration9_9.TM2StockThread.nativeInput machine letters) input (bit::scratch) output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .feed (_root_.Integration9_9.TM2StockThread.nativeInput machine (ein.symm bit::letters)) input scratch output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
· rfl
· rfl
· intro stack
cases stack with
| inl k =>
by_cases h : k=machine.k₀
· subst k
simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeInput,_root_.Integration9_9.TM2StockThread.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeInput,h]
| inr b => cases b <;> rfl
theorem feed_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (input output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .feed native input [] output)=
some (_root_.Integration9_9.TM2StockThread.callCfg machine native input [] output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem context_reverse_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (bit : Bool) (input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse native (bit::input) scratch output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse native input (bit::scratch) output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem context_reverse_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse native [] scratch output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native [] scratch output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem context_forward_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (bit : Bool) (input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native input (bit::scratch) output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native input scratch (bit::output)) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem context_forward_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (input output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native input [] output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput native input [] (false::output)) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem quote_output_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(symbol : machine.Γ machine.k₁) (letters : List (machine.Γ machine.k₁)) (input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput (_root_.Integration9_9.TM2StockThread.nativeOutput machine (symbol::letters)) input scratch output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) input (eout symbol::true::scratch) output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
· intro stack
cases stack with
| inl k =>
by_cases h : k=machine.k₁
· subst k
simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,h]
| inr b => cases b <;> simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
theorem quote_output_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) input scratch output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) input scratch output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
· intro stack
cases stack with
| inl k => simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
| inr b => cases b <;> simp [TM2.stepAux,_root_.Integration9_9.TM2StockThread.program,_root_.Integration9_9.TM2StockThread.driver,_root_.Integration9_9.TM2StockThread.next,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockThread.initial]
theorem finish_reverse_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (bit : Bool) (input scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse native input (bit::scratch) output)=
some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse native input scratch (bit::output)) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem finish_reverse_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (input output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse native input [] output)=
some (_root_.Integration9_9.TM2StockThread.terminalCfg machine native input [] output) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem buffer_loop {α β C : Type} (step : C → Option C)
(cfg : List α → List β → C) (done : List β → C) (encode : α → List β)
(hstep : ∀ symbol word acc,step (cfg (symbol::word) acc)=some (cfg word ((encode symbol).reverse++acc)))
(hdone : ∀ acc,step (cfg [] acc)=some (done acc))
(word : List α) (acc : List β) :
((flip bind step)^[word.length+1]) (some (cfg word acc))=
some (done ((word.flatMap encode).reverse++acc)) := by
change ((fun state : Option C => state.bind step)^[word.length+1]) (some (cfg word acc))=
some (done ((word.flatMap encode).reverse++acc))
induction word generalizing acc with
| nil => simpa using hdone acc
| cons symbol word ih =>
simp only [List.length_cons]
rw [Function.iterate_succ_apply,Option.bind_some,hstep,ih]
simp only [List.flatMap_cons,List.reverse_append,List.append_assoc]
theorem flatMap_singleton_map {α β : Type} (f : α → β) (word : List α) :
word.flatMap (fun symbol => [f symbol])=word.map f := by
induction word with
| nil => rfl
| cons symbol word ih => simp only [List.flatMap_cons,List.map_cons,List.singleton_append,ih]
def parse_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (word context scratch output : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.phaseCfg machine .parse native (OAI.MetricKMedian.Binary.quote word++context) scratch output)
(some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .feed native context (word.reverse++scratch) output)) (word.length+1) := by
refine ⟨⟨word.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .parse native (OAI.MetricKMedian.Binary.quote word++context) acc output)
(fun acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .feed native context acc output) (fun bit : Bool => [bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockThread.parse_step machine ein eout native bit _ acc output)
(fun acc => _root_.Integration9_9.TM2StockThread.parse_done machine ein eout native context acc output) word scratch
simpa only [List.flatMap_singleton'] using h
def feed_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(letters : List (machine.Γ machine.k₀)) (scratch input output : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.phaseCfg machine .feed (_root_.Integration9_9.TM2StockThread.nativeInput machine letters) input scratch output)
(some (_root_.Integration9_9.TM2StockThread.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine ((scratch.map ein.symm).reverse++letters)) input [] output))
(scratch.length+1) := by
refine ⟨⟨scratch.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .feed (_root_.Integration9_9.TM2StockThread.nativeInput machine acc) input word output)
(fun acc => _root_.Integration9_9.TM2StockThread.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine acc) input [] output) (fun bit : Bool => [ein.symm bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockThread.feed_step machine ein eout acc bit input rest output)
(fun acc => _root_.Integration9_9.TM2StockThread.feed_done machine ein eout (_root_.Integration9_9.TM2StockThread.nativeInput machine acc) input output) scratch letters
simpa only [_root_.Integration9_9.TM2StockThread.flatMap_singleton_map] using h
def context_reverse_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (context scratch output : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse native context scratch output)
(some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native [] (context.reverse++scratch) output)) (context.length+1) := by
refine ⟨⟨context.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse native word acc output)
(fun acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native [] acc output) (fun bit : Bool => [bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockThread.context_reverse_step machine ein eout native bit rest acc output)
(fun acc => _root_.Integration9_9.TM2StockThread.context_reverse_done machine ein eout native acc output) context scratch
simpa only [List.flatMap_singleton'] using h
def context_forward_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (scratch input output : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native input scratch output)
(some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput native input [] (false::(scratch.reverse++output)))) (scratch.length+1) := by
refine ⟨⟨scratch.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .contextForward native input word acc)
(fun acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput native input [] (false::acc)) (fun bit : Bool => [bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockThread.context_forward_step machine ein eout native bit input rest acc)
(fun acc => _root_.Integration9_9.TM2StockThread.context_forward_done machine ein eout native input acc) scratch output
simpa only [List.flatMap_singleton'] using h
def quote_output_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(letters : List (machine.Γ machine.k₁)) (input scratch output : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) input scratch output)
(some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) input
((letters.flatMap (fun symbol => [true,eout symbol])).reverse++scratch) output)) (letters.length+1) := by
refine ⟨⟨letters.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .quoteOutput (_root_.Integration9_9.TM2StockThread.nativeOutput machine word) input acc output)
(fun acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) input acc output)
(fun symbol : machine.Γ machine.k₁ => [true,eout symbol])
(fun symbol rest acc => _root_.Integration9_9.TM2StockThread.quote_output_step machine ein eout symbol rest input acc output)
(fun acc => _root_.Integration9_9.TM2StockThread.quote_output_done machine ein eout input acc output) letters scratch
exact h
def finish_reverse_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(native : ∀ k,List (machine.Γ k)) (scratch input output : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse native input scratch output)
(some (_root_.Integration9_9.TM2StockThread.terminalCfg machine native input [] (scratch.reverse++output))) (scratch.length+1) := by
refine ⟨⟨scratch.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockThread.phaseCfg machine .finishReverse native input word acc)
(fun acc => _root_.Integration9_9.TM2StockThread.terminalCfg machine native input [] acc) (fun bit : Bool => [bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockThread.finish_reverse_step machine ein eout native bit input rest acc)
(fun acc => _root_.Integration9_9.TM2StockThread.finish_reverse_done machine ein eout native input acc) scratch output
simpa only [List.flatMap_singleton'] using h
theorem nativeInput_nil (machine : FinTM2) : _root_.Integration9_9.TM2StockThread.nativeInput machine []=(fun _ => []) := by
funext k
by_cases h : k=machine.k₀ <;> simp [_root_.Integration9_9.TM2StockThread.nativeInput,h]
theorem nativeOutput_nil (machine : FinTM2) : _root_.Integration9_9.TM2StockThread.nativeOutput machine []=(fun _ => []) := by
funext k
by_cases h : k=machine.k₁ <;> simp [_root_.Integration9_9.TM2StockThread.nativeOutput,h]
theorem _root_.Integration9_9.TM2StockThread.initial_caller_eq (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input : List Bool) :
initList (_root_.Integration9_9.TM2StockThread.threadedMachine machine ein eout) input=_root_.Integration9_9.TM2StockThread.phaseCfg machine .parse (_root_.Integration9_9.TM2StockThread.nativeInput machine []) input [] [] := by
rw [_root_.Integration9_9.TM2StockThread.nativeInput_nil]
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
· rfl
· rfl
· intro stack
cases stack with
| inl k => simp [initList,_root_.Integration9_9.TM2StockThread.threadedMachine,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
| inr b => cases b <;> simp [initList,_root_.Integration9_9.TM2StockThread.threadedMachine,_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
theorem _root_.Integration9_9.TM2StockThread.terminal_caller_eq (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(output : List Bool) :
_root_.Integration9_9.TM2StockThread.terminalCfg machine (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] [] output=haltList (_root_.Integration9_9.TM2StockThread.threadedMachine machine ein eout) output := by
rw [_root_.Integration9_9.TM2StockThread.nativeOutput_nil]
apply _root_.Integration9_9.TM2StockThread.caller_cfg_ext
· rfl
· rfl
· intro stack
cases stack with
| inl k => simp [haltList,_root_.Integration9_9.TM2StockThread.threadedMachine,_root_.Integration9_9.TM2StockThread.terminalCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
| inr b => cases b <;> simp [haltList,_root_.Integration9_9.TM2StockThread.threadedMachine,_root_.Integration9_9.TM2StockThread.terminalCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
theorem _root_.Integration9_9.TM2StockThread.native_initial_frame (machine : FinTM2) (letters : List (machine.Γ machine.k₀)) (context : List Bool) :
_root_.Integration9_9.TM2Subroutine.FrameRel Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .contextReverse)) (_root_.Integration9_9.TM2StockThread.initial machine)
(_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) context [] [])
(initList machine letters) (_root_.Integration9_9.TM2StockThread.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine letters) context [] []) := by
refine ⟨rfl,rfl,?_,?_⟩
· intro k
by_cases h : k=machine.k₀
· subst k
simp [_root_.Integration9_9.TM2StockThread.callCfg,_root_.Integration9_9.TM2StockThread.fullStacks,initList,_root_.Integration9_9.TM2StockThread.nativeInput]
· simp [_root_.Integration9_9.TM2StockThread.callCfg,_root_.Integration9_9.TM2StockThread.fullStacks,initList,_root_.Integration9_9.TM2StockThread.nativeInput,h]
· intro stack hstack
cases stack with
| inl k => exact (hstack k rfl).elim
| inr b => cases b <;> rfl
theorem _root_.Integration9_9.TM2StockThread.native_terminal_frame (machine : FinTM2) (letters : List (machine.Γ machine.k₁)) (context : List Bool) :
_root_.Integration9_9.TM2Subroutine.FrameRel Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .contextReverse)) (_root_.Integration9_9.TM2StockThread.initial machine)
(_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) context [] [])
(haltList machine letters) (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) context [] []) := by
refine ⟨rfl,rfl,?_,?_⟩
· intro k
by_cases h : k=machine.k₁
· subst k
simp [_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,haltList,_root_.Integration9_9.TM2StockThread.nativeOutput]
· simp [_root_.Integration9_9.TM2StockThread.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,haltList,_root_.Integration9_9.TM2StockThread.nativeOutput,h]
· intro stack hstack
cases stack with
| inl k => exact (hstack k rfl).elim
| inr b => cases b <;> rfl
/-- The arbitrary stock callee runs from its genuine canonical input to
output, while retaining the caller context in its original separate stack. -/
theorem native_call_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input : List (machine.Γ machine.k₀)) (output : List (machine.Γ machine.k₁)) (context : List Bool) (time : ℕ)
(h : TM2OutputsInTime machine input (some output) time) :
Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine input) context [] [])
(some (_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse (_root_.Integration9_9.TM2StockThread.nativeOutput machine output) context [] [])) time) := by
obtain ⟨result,⟨hrun⟩,hframe⟩ := _root_.Integration9_9.TM2StockThread.native_run machine ein eout (_root_.Integration9_9.TM2StockThread.initial machine)
(_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) context [] []) (initList machine input) (haltList machine output)
(_root_.Integration9_9.TM2StockThread.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine input) context [] []) time h (_root_.Integration9_9.TM2StockThread.native_initial_frame machine input context)
have he : result=_root_.Integration9_9.TM2StockThread.phaseCfg machine .contextReverse (_root_.Integration9_9.TM2StockThread.nativeOutput machine output) context [] [] :=
_root_.Integration9_9.TM2Subroutine.unique Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .contextReverse)) (_root_.Integration9_9.TM2StockThread.initial machine) (_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) context [] [])
(haltList machine output) result _ hframe (_root_.Integration9_9.TM2StockThread.native_terminal_frame machine output context)
subst result
exact ⟨hrun⟩
theorem _root_.Integration9_9.TM2StockThread.quote_flatMap (word : List Bool) : OAI.MetricKMedian.Binary.quote word=
word.flatMap (fun bit => [true,bit])++[false] := by
induction word with
| nil => rfl
| cons bit word ih => simp only [OAI.MetricKMedian.Binary.quote,List.flatMap_cons,ih,List.cons_append,List.nil_append]
theorem _root_.Integration9_9.TM2StockThread.quotedPayload_length {α : Type} (encode : α → Bool) (word : List α) :
(word.flatMap (fun symbol => [true,encode symbol])).length=2*word.length := by
induction word with
| nil => rfl
| cons symbol word ih => simp only [List.flatMap_cons,List.length_append,List.length_cons,List.length_nil,ih]; omega
/-- The actual arbitrary-alphabet caller computes the pair of the callee
output and untouched context, with a fully quantified native running-time bound. -/
theorem outputsInTime (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(word context : List Bool) (letters : List (machine.Γ machine.k₁)) (time : ℕ)
(hcallee : TM2OutputsInTime machine (word.map ein.symm) (some letters) time) :
Nonempty (TM2OutputsInTime (_root_.Integration9_9.TM2StockThread.threadedMachine machine ein eout)
(OAI.MetricKMedian.Binary.quote word++context)
(some (OAI.MetricKMedian.Binary.quote (letters.map eout)++context))
(time+2*word.length+2*context.length+3*letters.length+6)) := by
have hparse := _root_.Integration9_9.TM2StockThread.parse_run machine ein eout (_root_.Integration9_9.TM2StockThread.nativeInput machine []) word context [] []
simp only [List.append_nil] at hparse
have hfeed := _root_.Integration9_9.TM2StockThread.feed_run machine ein eout [] word.reverse context []
simp only [List.map_reverse,List.reverse_reverse,List.append_nil,List.length_reverse] at hfeed
obtain ⟨hcall⟩ := _root_.Integration9_9.TM2StockThread.native_call_run machine ein eout (word.map ein.symm) letters context time hcallee
have hreverse := _root_.Integration9_9.TM2StockThread.context_reverse_run machine ein eout (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) context [] []
simp only [List.append_nil] at hreverse
have hforward := _root_.Integration9_9.TM2StockThread.context_forward_run machine ein eout (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) context.reverse [] []
simp only [List.reverse_reverse,List.append_nil,List.length_reverse] at hforward
have hquote := _root_.Integration9_9.TM2StockThread.quote_output_run machine ein eout letters [] [] (false::context)
simp only [List.append_nil] at hquote
have hfinish := _root_.Integration9_9.TM2StockThread.finish_reverse_run machine ein eout (_root_.Integration9_9.TM2StockThread.nativeOutput machine [])
(letters.flatMap (fun symbol => [true,eout symbol])).reverse [] (false::context)
simp only [List.reverse_reverse,List.length_reverse,_root_.Integration9_9.TM2StockThread.quotedPayload_length] at hfinish
have hout : letters.flatMap (fun symbol => [true,eout symbol])++false::context=
OAI.MetricKMedian.Binary.quote (letters.map eout)++context := by
simp only [_root_.Integration9_9.TM2StockThread.quote_flatMap,List.flatMap_map,Function.comp_def,List.append_assoc,List.singleton_append]
rw [hout] at hfinish
have h1 := EvalsToInTime.trans _ _ _ _ _ _ hparse hfeed
have h2 := EvalsToInTime.trans _ _ _ _ _ _ h1 hcall
have h3 := EvalsToInTime.trans _ _ _ _ _ _ h2 hreverse
have h4 := EvalsToInTime.trans _ _ _ _ _ _ h3 hforward
have h5 := EvalsToInTime.trans _ _ _ _ _ _ h4 hquote
have h6 := EvalsToInTime.trans _ _ _ _ _ _ h5 hfinish
have hbound : h6.steps ≤ time+2*word.length+2*context.length+3*letters.length+6 := by
have h := h6.steps_le_m
omega
have hfinal : EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(_root_.Integration9_9.TM2StockThread.phaseCfg machine .parse (_root_.Integration9_9.TM2StockThread.nativeInput machine []) (OAI.MetricKMedian.Binary.quote word++context) [] [])
(some (_root_.Integration9_9.TM2StockThread.terminalCfg machine (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] []
(OAI.MetricKMedian.Binary.quote (letters.map eout)++context)))
(time+2*word.length+2*context.length+3*letters.length+6) :=
⟨h6.toEvalsTo,hbound⟩
change Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockThread.program machine ein eout))
(initList (_root_.Integration9_9.TM2StockThread.threadedMachine machine ein eout) (OAI.MetricKMedian.Binary.quote word++context))
(some (haltList (_root_.Integration9_9.TM2StockThread.threadedMachine machine ein eout) (OAI.MetricKMedian.Binary.quote (letters.map eout)++context))) _)
rw [_root_.Integration9_9.TM2StockThread.initial_caller_eq,←_root_.Integration9_9.TM2StockThread.terminal_caller_eq]
exact ⟨hfinal⟩
/-- Polynomial-time threading for the original platform stock machine
model, without any finiteness assumption on internal alphabet types. -/
theorem thread_polynomial {α β γ : Type} {ea : α → List Bool} {eb : β → List Bool}
(ec : γ → List Bool) {f : α → β} (callee : TM2ComputableInPolyTime ea eb f) :
Nonempty (TM2ComputableInPolyTime (OAI.MetricKMedian.Binary.encodePair ea ec)
(OAI.MetricKMedian.Binary.encodePair eb ec) (fun pair : α × γ => (f pair.1,pair.2))) := by
classical
let wrapper := _root_.Integration9_9.TM2StockThread.threadedMachine callee.tm callee.inputAlphabet callee.outputAlphabet
let growth := _root_.Integration9_9.TM2OutputLength.programPushBound callee.tm.m
let cost : Polynomial ℕ := (1+3*Polynomial.C growth)*callee.time+5*Polynomial.X+6
have hout (pair : α × γ) : Nonempty (TM2OutputsInTime wrapper
(OAI.MetricKMedian.Binary.encodePair ea ec pair)
(some (OAI.MetricKMedian.Binary.encodePair eb ec (f pair.1,pair.2)))
(cost.eval (OAI.MetricKMedian.Binary.encodePair ea ec pair).length)) := by
have hrun := _root_.Integration9_9.TM2StockThread.outputsInTime callee.tm callee.inputAlphabet callee.outputAlphabet
(ea pair.1) (ec pair.2) ((eb (f pair.1)).map callee.outputAlphabet.invFun)
(callee.time.eval (ea pair.1).length) (callee.outputsFun pair.1)
have hraw : Nonempty (TM2OutputsInTime wrapper
(OAI.MetricKMedian.Binary.encodePair ea ec pair)
(some (OAI.MetricKMedian.Binary.encodePair eb ec (f pair.1,pair.2)))
(callee.time.eval (ea pair.1).length+2*(ea pair.1).length+2*(ec pair.2).length+
3*(eb (f pair.1)).length+6)) := by
simpa only [OAI.MetricKMedian.Binary.encodePair,List.map_map,Function.comp_def,
Equiv.invFun_as_coe,Equiv.apply_symm_apply,List.map_id_fun,List.map_id_fun',id_eq,List.length_map] using hrun
obtain ⟨hr⟩ := hraw
let size := (OAI.MetricKMedian.Binary.encodePair ea ec pair).length
have hs : size=2*(ea pair.1).length+1+(ec pair.2).length := OAI.MetricKMedian.Binary.encodePair_length _ _ _
have ha : (ea pair.1).length ≤ size := by omega
have hm := OAI.MetricKMedian.Binary.polynomial_eval_mono callee.time ha
have hb := _root_.Integration9_9.TM2OutputLength.output_length_le callee.tm
((ea pair.1).map callee.inputAlphabet.invFun) ((eb (f pair.1)).map callee.outputAlphabet.invFun)
(callee.time.eval (ea pair.1).length) (callee.outputsFun pair.1)
simp only [List.length_map] at hb
change (eb (f pair.1)).length ≤ (ea pair.1).length+growth*callee.time.eval (ea pair.1).length at hb
have hg := Nat.mul_le_mul_left growth hm
have htime : callee.time.eval (ea pair.1).length+2*(ea pair.1).length+2*(ec pair.2).length+
3*(eb (f pair.1)).length+6 ≤ cost.eval size := by
simp only [cost,Polynomial.eval_add,Polynomial.eval_mul,Polynomial.eval_one,Polynomial.eval_ofNat,
Polynomial.eval_C,Polynomial.eval_X]
nlinarith
exact ⟨⟨hr.toEvalsTo,hr.steps_le_m.trans htime⟩⟩
refine ⟨{
tm := wrapper
inputAlphabet := Equiv.refl Bool
outputAlphabet := Equiv.refl Bool
time := cost
outputsFun := ?_ }⟩
intro pair
have h := Classical.choice (hout pair)
simpa only [Equiv.refl,List.map_id] using h
end Integration9_9.TM2StockThread
end
section
namespace Integration9_9
end Integration9_9
namespace Integration9_9.TM2Composition
end Integration9_9.TM2Composition
namespace Integration9_9.TM2Composition.Alphabet
end Integration9_9.TM2Composition.Alphabet
namespace Integration9_9.TM2Composition.Alphabet.match_1
end Integration9_9.TM2Composition.Alphabet.match_1
namespace Integration9_9.TM2Composition.canonical
end Integration9_9.TM2Composition.canonical
namespace Integration9_9.TM2Composition.leftStack
end Integration9_9.TM2Composition.leftStack
namespace Integration9_9.TM2Composition.leftSymbol
end Integration9_9.TM2Composition.leftSymbol
namespace Integration9_9.TM2Composition.machine
end Integration9_9.TM2Composition.machine
namespace Integration9_9.TM2Composition.middle
end Integration9_9.TM2Composition.middle
namespace Integration9_9.TM2Composition.program
end Integration9_9.TM2Composition.program
namespace Integration9_9.TM2Composition.rightStack
end Integration9_9.TM2Composition.rightStack
namespace Integration9_9.TM2Composition.rightSymbol
end Integration9_9.TM2Composition.rightSymbol
namespace Integration9_9.TM2OutputLength
end Integration9_9.TM2OutputLength
namespace Integration9_9.TM2OutputLength.pushBound
end Integration9_9.TM2OutputLength.pushBound
namespace Integration9_9.TM2OutputLength.pushBound.match_1
end Integration9_9.TM2OutputLength.pushBound.match_1
namespace Integration9_9.TM2Simulation
end Integration9_9.TM2Simulation
namespace Integration9_9.TM2Simulation.ControlLens
end Integration9_9.TM2Simulation.ControlLens
namespace Integration9_9.TM2Simulation.ControlLens.mk
end Integration9_9.TM2Simulation.ControlLens.mk
namespace Integration9_9.TM2Simulation.singleStack
end Integration9_9.TM2Simulation.singleStack
namespace Integration9_9.TM2Simulation.statement
end Integration9_9.TM2Simulation.statement
namespace Integration9_9.TM2Simulation.statement.match_1
end Integration9_9.TM2Simulation.statement.match_1
namespace Integration9_9.TM2Simulation.statement.match_3
end Integration9_9.TM2Simulation.statement.match_3
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace Integration9_9.TM2StockLoop
open Turing StateTransition Function TM2Simulation
open TM2StockThread (Stack Alphabet fullStacks nativeInput nativeOutput)
local instance stackDecidable (machine : FinTM2) : DecidableEq machine.K := machine.kDecidableEq
local instance stackFinite (machine : FinTM2) : Fintype machine.K := machine.kFin
local instance labelFinite (machine : FinTM2) : Fintype machine.Λ := machine.ΛFin
local instance stateFinite (machine : FinTM2) : Fintype machine.σ := machine.σFin
inductive Phase | inputReverse | feed | inspect | copy | finish
deriving Fintype,DecidableEq
abbrev Label (machine : FinTM2) := machine.Λ ⊕ _root_.Integration9_9.TM2StockLoop.Phase
abbrev State (machine : FinTM2) := machine.σ × (Bool × Option Bool)
def initial (machine : FinTM2) : _root_.Integration9_9.TM2StockLoop.State machine := (machine.initialState,(false,none))
def next (machine : FinTM2) (phase : _root_.Integration9_9.TM2StockLoop.Phase) : TM2.Stmt (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockLoop.Label machine) (_root_.Integration9_9.TM2StockLoop.State machine) :=
.load (fun state => (state.1,(state.2.1,none))) (.goto (fun _ => .inr phase))
def driver (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool) :
_root_.Integration9_9.TM2StockLoop.Phase → TM2.Stmt (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockLoop.Label machine) (_root_.Integration9_9.TM2StockLoop.State machine)
| .inputReverse =>
.pop (.inr .input) (fun state bit => (state.1,(state.2.1,bit)))
(.branch (fun state => state.2.2.isSome)
(.push (.inr .scratch) (fun state => state.2.2.getD false) (_root_.Integration9_9.TM2StockLoop.next machine .inputReverse))
(_root_.Integration9_9.TM2StockLoop.next machine .feed))
| .feed =>
.pop (.inr .scratch) (fun state bit => (state.1,(state.2.1,bit)))
(.branch (fun state => state.2.2.isSome)
(.push (.inl machine.k₀) (fun state => ein.symm (state.2.2.getD false)) (_root_.Integration9_9.TM2StockLoop.next machine .feed))
(.load (fun _ => _root_.Integration9_9.TM2StockLoop.initial machine) (.goto (fun _ => .inl machine.main))))
| .inspect =>
.pop (.inl machine.k₁) (fun state symbol => (state.1,(state.2.1,symbol.map eout)))
(.load (fun state => (state.1,(state.2.2 == some true,none))) (.goto (fun _ => .inr .copy)))
| .copy =>
.pop (.inl machine.k₁) (fun state symbol => (state.1,(state.2.1,symbol.map eout)))
(.branch (fun state => state.2.2.isSome)
(.push (.inr .scratch) (fun state => state.2.2.getD false) (_root_.Integration9_9.TM2StockLoop.next machine .copy))
(.branch (fun state => state.2.1) (_root_.Integration9_9.TM2StockLoop.next machine .feed) (_root_.Integration9_9.TM2StockLoop.next machine .finish)))
| .finish =>
.pop (.inr .scratch) (fun state bit => (state.1,(state.2.1,bit)))
(.branch (fun state => state.2.2.isSome)
(.push (.inr .output) (fun state => state.2.2.getD false) (_root_.Integration9_9.TM2StockLoop.next machine .finish))
(.load (fun _ => _root_.Integration9_9.TM2StockLoop.initial machine) .halt))
def program (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool) :
_root_.Integration9_9.TM2StockLoop.Label machine → TM2.Stmt (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockLoop.Label machine) (_root_.Integration9_9.TM2StockLoop.State machine)
| .inl label => _root_.Integration9_9.TM2Simulation.statement Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .inspect)) (machine.m label)
| .inr phase => _root_.Integration9_9.TM2StockLoop.driver machine ein eout phase
def loopMachine (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool) : FinTM2 where
K := _root_.Integration9_9.TM2StockThread.Stack machine
k₀ := .inr .input
k₁ := .inr .output
Γ := _root_.Integration9_9.TM2StockThread.Alphabet machine
Γk₀Fin := inferInstanceAs (Fintype Bool)
Λ := _root_.Integration9_9.TM2StockLoop.Label machine
main := .inr .inputReverse
σ := _root_.Integration9_9.TM2StockLoop.State machine
initialState := _root_.Integration9_9.TM2StockLoop.initial machine
m := _root_.Integration9_9.TM2StockLoop.program machine ein eout
def phaseCfg (machine : FinTM2) (phase : _root_.Integration9_9.TM2StockLoop.Phase) (mode : Bool) (native : ∀ k,List (machine.Γ k))
(input scratch output : List Bool) : TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockLoop.Label machine) (_root_.Integration9_9.TM2StockLoop.State machine) :=
⟨some (.inr phase),(machine.initialState,(mode,none)),_root_.Integration9_9.TM2StockThread.fullStacks machine native input scratch output⟩
def callCfg (machine : FinTM2) (native : ∀ k,List (machine.Γ k)) :
TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockLoop.Label machine) (_root_.Integration9_9.TM2StockLoop.State machine) :=
⟨some (.inl machine.main),_root_.Integration9_9.TM2StockLoop.initial machine,_root_.Integration9_9.TM2StockThread.fullStacks machine native [] [] []⟩
def terminalCfg (machine : FinTM2) (output : List Bool) :
TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockLoop.Label machine) (_root_.Integration9_9.TM2StockLoop.State machine) :=
⟨none,_root_.Integration9_9.TM2StockLoop.initial machine,_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) [] [] output⟩
theorem _root_.Integration9_9.TM2StockLoop.cfg_ext {machine : FinTM2} (first second : TM2.Cfg (_root_.Integration9_9.TM2StockThread.Alphabet machine) (_root_.Integration9_9.TM2StockLoop.Label machine) (_root_.Integration9_9.TM2StockLoop.State machine))
(hl : first.l=second.l) (hv : first.var=second.var)
(hs : ∀ stack,first.stk stack=second.stk stack) : first=second := by
have hh := funext hs
cases first
cases second
simp_all
theorem input_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(bit : Bool) (input scratch : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inputReverse false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) (bit::input) scratch [])=
some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inputReverse false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) input (bit::scratch) []) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem input_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(scratch : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inputReverse false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) [] scratch [])=
some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) [] scratch []) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem feed_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(mode bit : Bool) (letters : List (machine.Γ machine.k₀)) (scratch : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed mode (_root_.Integration9_9.TM2StockThread.nativeInput machine letters) [] (bit::scratch) [])=
some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed mode (_root_.Integration9_9.TM2StockThread.nativeInput machine (ein.symm bit::letters)) [] scratch []) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
· rfl
· rfl
· intro stack
cases stack with
| inl k =>
by_cases h : k=machine.k₀
· subst k
simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeInput,_root_.Integration9_9.TM2StockLoop.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeInput,h]
| inr b => cases b <;> rfl
theorem feed_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(mode : Bool) (letters : List (machine.Γ machine.k₀)) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed mode (_root_.Integration9_9.TM2StockThread.nativeInput machine letters) [] [] [])=
some (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine letters)) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem inspect_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(flag : Bool) (letters : List (machine.Γ machine.k₁)) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout)
(_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inspect false (_root_.Integration9_9.TM2StockThread.nativeOutput machine (eout.symm flag::letters)) [] [] [])=
some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .copy flag (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) [] [] []) := by
cases flag <;>
apply congrArg some <;>
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
all_goals first
| (simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial] <;> done)
| (intro stack; cases stack with
| inl k =>
by_cases h : k=machine.k₁
· subst k
simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial,h]
| inr b => cases b <;> simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial])
theorem copy_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(mode : Bool) (symbol : machine.Γ machine.k₁) (letters : List (machine.Γ machine.k₁)) (scratch : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .copy mode (_root_.Integration9_9.TM2StockThread.nativeOutput machine (symbol::letters)) [] scratch [])=
some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .copy mode (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) [] (eout symbol::scratch) []) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial]
· intro stack
cases stack with
| inl k =>
by_cases h : k=machine.k₁
· subst k
simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial]
· simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial,h]
| inr b => cases b <;> simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockThread.nativeOutput,_root_.Integration9_9.TM2StockLoop.initial]
theorem copy_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(mode : Bool) (scratch : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .copy mode (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] scratch [])=
some (if mode then _root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed true (_root_.Integration9_9.TM2StockThread.nativeInput machine []) [] scratch []
else _root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] scratch []) := by
rw [_root_.Integration9_9.TM2StockThread.nativeOutput_nil,_root_.Integration9_9.TM2StockThread.nativeInput_nil]
cases mode <;>
apply congrArg some <;>
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
all_goals first | rfl | (intro stack; cases stack with
| inl k => simp [TM2.stepAux,_root_.Integration9_9.TM2StockLoop.program,_root_.Integration9_9.TM2StockLoop.driver,_root_.Integration9_9.TM2StockLoop.next,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,_root_.Integration9_9.TM2StockLoop.initial]
| inr b => cases b <;> rfl)
theorem finish_step (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(bit : Bool) (scratch output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] (bit::scratch) output)=
some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] scratch (bit::output)) := by
apply congrArg some
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
theorem finish_done (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(output : List Bool) :
TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] [] output)=
some (_root_.Integration9_9.TM2StockLoop.terminalCfg machine output) := by
rw [_root_.Integration9_9.TM2StockThread.nativeOutput_nil]
apply congrArg some
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
all_goals first | rfl | (intro stack; cases stack with | inl k => rfl | inr b => cases b <;> rfl)
def input_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(word scratch : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inputReverse false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) word scratch [])
(some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) [] (word.reverse++scratch) [])) (word.length+1) := by
refine ⟨⟨word.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockLoop.phaseCfg machine .inputReverse false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) word acc [])
(fun acc => _root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) [] acc []) (fun bit : Bool => [bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockLoop.input_step machine ein eout bit rest acc) (_root_.Integration9_9.TM2StockLoop.input_done machine ein eout) word scratch
simpa only [List.flatMap_singleton'] using h
def feed_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(mode : Bool) (letters : List (machine.Γ machine.k₀)) (scratch : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(_root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed mode (_root_.Integration9_9.TM2StockThread.nativeInput machine letters) [] scratch [])
(some (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine ((scratch.map ein.symm).reverse++letters)))) (scratch.length+1) := by
refine ⟨⟨scratch.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed mode (_root_.Integration9_9.TM2StockThread.nativeInput machine acc) [] word [])
(fun acc => _root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine acc)) (fun bit : Bool => [ein.symm bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockLoop.feed_step machine ein eout mode bit acc rest) (_root_.Integration9_9.TM2StockLoop.feed_done machine ein eout mode) scratch letters
simpa only [_root_.Integration9_9.TM2StockThread.flatMap_singleton_map] using h
def copy_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(mode : Bool) (letters : List (machine.Γ machine.k₁)) (scratch : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(_root_.Integration9_9.TM2StockLoop.phaseCfg machine .copy mode (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) [] scratch [])
(some (if mode then _root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed true (_root_.Integration9_9.TM2StockThread.nativeInput machine []) [] ((letters.map eout).reverse++scratch) []
else _root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] ((letters.map eout).reverse++scratch) []))
(letters.length+1) := by
refine ⟨⟨letters.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockLoop.phaseCfg machine .copy mode (_root_.Integration9_9.TM2StockThread.nativeOutput machine word) [] acc [])
(fun acc => if mode then _root_.Integration9_9.TM2StockLoop.phaseCfg machine .feed true (_root_.Integration9_9.TM2StockThread.nativeInput machine []) [] acc []
else _root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] acc [])
(fun symbol : machine.Γ machine.k₁ => [eout symbol])
(fun symbol rest acc => _root_.Integration9_9.TM2StockLoop.copy_step machine ein eout mode symbol rest acc) (_root_.Integration9_9.TM2StockLoop.copy_done machine ein eout mode) letters scratch
simpa only [_root_.Integration9_9.TM2StockThread.flatMap_singleton_map] using h
def finish_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(scratch output : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(_root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] scratch output)
(some (_root_.Integration9_9.TM2StockLoop.terminalCfg machine (scratch.reverse++output))) (scratch.length+1) := by
refine ⟨⟨scratch.length+1,?_⟩,le_rfl⟩
have h := _root_.Integration9_9.TM2StockThread.buffer_loop (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(fun word acc => _root_.Integration9_9.TM2StockLoop.phaseCfg machine .finish false (_root_.Integration9_9.TM2StockThread.nativeOutput machine []) [] word acc)
(_root_.Integration9_9.TM2StockLoop.terminalCfg machine) (fun bit : Bool => [bit])
(fun bit rest acc => _root_.Integration9_9.TM2StockLoop.finish_step machine ein eout bit rest acc) (_root_.Integration9_9.TM2StockLoop.finish_done machine ein eout) scratch output
simpa only [List.flatMap_singleton'] using h
theorem _root_.Integration9_9.TM2StockLoop.initial_frame (machine : FinTM2) (letters : List (machine.Γ machine.k₀)) :
_root_.Integration9_9.TM2Subroutine.FrameRel Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .inspect)) (_root_.Integration9_9.TM2StockLoop.initial machine) (_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) [] [] [])
(initList machine letters) (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine letters)) := by
refine ⟨rfl,rfl,?_,?_⟩
· intro k
by_cases h : k=machine.k₀
· subst k
simp [_root_.Integration9_9.TM2StockLoop.callCfg,_root_.Integration9_9.TM2StockThread.fullStacks,initList,_root_.Integration9_9.TM2StockThread.nativeInput]
· simp [_root_.Integration9_9.TM2StockLoop.callCfg,_root_.Integration9_9.TM2StockThread.fullStacks,initList,_root_.Integration9_9.TM2StockThread.nativeInput,h]
· intro stack hstack
cases stack with
| inl k => exact (hstack k rfl).elim
| inr b => cases b <;> rfl
theorem _root_.Integration9_9.TM2StockLoop.terminal_frame (machine : FinTM2) (letters : List (machine.Γ machine.k₁)) :
_root_.Integration9_9.TM2Subroutine.FrameRel Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .inspect)) (_root_.Integration9_9.TM2StockLoop.initial machine) (_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) [] [] [])
(haltList machine letters) (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inspect false (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) [] [] []) := by
refine ⟨rfl,rfl,?_,?_⟩
· intro k
by_cases h : k=machine.k₁
· subst k
simp [_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,haltList,_root_.Integration9_9.TM2StockThread.nativeOutput]
· simp [_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks,haltList,_root_.Integration9_9.TM2StockThread.nativeOutput,h]
· intro stack hstack
cases stack with
| inl k => exact (hstack k rfl).elim
| inr b => cases b <;> rfl
theorem callee_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input : List (machine.Γ machine.k₀)) (output : List (machine.Γ machine.k₁)) (time : ℕ)
(h : TM2OutputsInTime machine input (some output) time) :
Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine input))
(some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inspect false (_root_.Integration9_9.TM2StockThread.nativeOutput machine output) [] [] [])) time) := by
obtain ⟨result,⟨hrun⟩,hframe⟩ := _root_.Integration9_9.TM2Subroutine.run (K := machine.K) (J := _root_.Integration9_9.TM2StockThread.Stack machine) (Λ := machine.Λ)
(L := _root_.Integration9_9.TM2StockLoop.Label machine) (σ := machine.σ) (τ := _root_.Integration9_9.TM2StockLoop.State machine) (Γ := machine.Γ) (Δ := _root_.Integration9_9.TM2StockThread.Alphabet machine)
Sum.inl Sum.inl_injective (fun _ => Equiv.refl _)
_root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl (some (.inr .inspect)) machine.m (_root_.Integration9_9.TM2StockLoop.program machine ein eout) (fun _ => rfl)
(_root_.Integration9_9.TM2StockLoop.initial machine) (_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) [] [] [])
(initList machine input) (haltList machine output) (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine input)) time h (_root_.Integration9_9.TM2StockLoop.initial_frame machine input)
have he : result=_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inspect false (_root_.Integration9_9.TM2StockThread.nativeOutput machine output) [] [] [] :=
_root_.Integration9_9.TM2Subroutine.unique (K := machine.K) (J := _root_.Integration9_9.TM2StockThread.Stack machine) (Λ := machine.Λ)
(L := _root_.Integration9_9.TM2StockLoop.Label machine) (σ := machine.σ) (τ := _root_.Integration9_9.TM2StockLoop.State machine) (Γ := machine.Γ) (Δ := _root_.Integration9_9.TM2StockThread.Alphabet machine)
Sum.inl (fun _ => Equiv.refl _) _root_.Integration9_9.TM2Simulation.ControlLens.fst Sum.inl
(some (.inr .inspect)) (_root_.Integration9_9.TM2StockLoop.initial machine) (_root_.Integration9_9.TM2StockThread.fullStacks machine (fun _ => []) [] [] [])
(haltList machine output) result _ hframe (_root_.Integration9_9.TM2StockLoop.terminal_frame machine output)
subst result
exact ⟨hrun⟩
def inspect_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(flag : Bool) (letters : List (machine.Γ machine.k₁)) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inspect false (_root_.Integration9_9.TM2StockThread.nativeOutput machine (eout.symm flag::letters)) [] [] [])
(some (_root_.Integration9_9.TM2StockLoop.phaseCfg machine .copy flag (_root_.Integration9_9.TM2StockThread.nativeOutput machine letters) [] [] [])) 1 := by
refine ⟨⟨1,?_⟩,le_rfl⟩
simpa only [Function.iterate_one,flip,Bind.bind,Option.bind_some] using
_root_.Integration9_9.TM2StockLoop.inspect_step machine ein eout flag letters
/-- One genuine stock-machine loop round that returns the final result. -/
theorem stop_round (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input : List (machine.Γ machine.k₀)) (letters : List (machine.Γ machine.k₁)) (time : ℕ)
(h : TM2OutputsInTime machine input (some (eout.symm false::letters)) time) :
Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout)) (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine input))
(some (_root_.Integration9_9.TM2StockLoop.terminalCfg machine (letters.map eout))) (time+2*letters.length+3)) := by
obtain ⟨hc⟩ := _root_.Integration9_9.TM2StockLoop.callee_run machine ein eout input (eout.symm false::letters) time h
have hi := _root_.Integration9_9.TM2StockLoop.inspect_run machine ein eout false letters
have hp := _root_.Integration9_9.TM2StockLoop.copy_run machine ein eout false letters []
simp only [Bool.false_eq_true,if_false,List.append_nil] at hp
have hf := _root_.Integration9_9.TM2StockLoop.finish_run machine ein eout (letters.map eout).reverse []
simp only [List.reverse_reverse,List.append_nil,List.length_reverse,List.length_map] at hf
have h1 := EvalsToInTime.trans _ _ _ _ _ _ hc hi
have h2 := EvalsToInTime.trans _ _ _ _ _ _ h1 hp
have h3 := EvalsToInTime.trans _ _ _ _ _ _ h2 hf
exact ⟨⟨h3.toEvalsTo,h3.steps_le_m.trans (by omega)⟩⟩
/-- One genuine stock-machine loop round that feeds the next state through
the original input interface, even when native input and output share a stack. -/
theorem next_round (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input : List (machine.Γ machine.k₀)) (letters : List (machine.Γ machine.k₁)) (time : ℕ)
(h : TM2OutputsInTime machine input (some (eout.symm true::letters)) time) :
Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout)) (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine input))
(some (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine ((letters.map eout).map ein.symm)))) (time+2*letters.length+3)) := by
obtain ⟨hc⟩ := _root_.Integration9_9.TM2StockLoop.callee_run machine ein eout input (eout.symm true::letters) time h
have hi := _root_.Integration9_9.TM2StockLoop.inspect_run machine ein eout true letters
have hp := _root_.Integration9_9.TM2StockLoop.copy_run machine ein eout true letters []
simp only [if_true,List.append_nil] at hp
have hf := _root_.Integration9_9.TM2StockLoop.feed_run machine ein eout true [] (letters.map eout).reverse
simp only [List.map_reverse,List.reverse_reverse,List.append_nil,List.length_reverse,List.length_map] at hf
have h1 := EvalsToInTime.trans _ _ _ _ _ _ hc hi
have h2 := EvalsToInTime.trans _ _ _ _ _ _ h1 hp
have h3 := EvalsToInTime.trans _ _ _ _ _ _ h2 hf
exact ⟨⟨h3.toEvalsTo,h3.steps_le_m.trans (by omega)⟩⟩
def initial_run (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input : List Bool) :
EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program machine ein eout))
(_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inputReverse false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) input [] [])
(some (_root_.Integration9_9.TM2StockLoop.callCfg machine (_root_.Integration9_9.TM2StockThread.nativeInput machine (input.map ein.symm)))) (2*input.length+2) := by
have hi := _root_.Integration9_9.TM2StockLoop.input_run machine ein eout input []
simp only [List.append_nil] at hi
have hf := _root_.Integration9_9.TM2StockLoop.feed_run machine ein eout false [] input.reverse
simp only [List.map_reverse,List.reverse_reverse,List.append_nil,List.length_reverse] at hf
have h := EvalsToInTime.trans _ _ _ _ _ _ hi hf
exact ⟨h.toEvalsTo,h.steps_le_m.trans (by omega)⟩
theorem _root_.Integration9_9.TM2StockLoop.initial_caller_eq (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(input : List Bool) : initList (_root_.Integration9_9.TM2StockLoop.loopMachine machine ein eout) input=
_root_.Integration9_9.TM2StockLoop.phaseCfg machine .inputReverse false (_root_.Integration9_9.TM2StockThread.nativeInput machine []) input [] [] := by
rw [_root_.Integration9_9.TM2StockThread.nativeInput_nil]
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
· rfl
· rfl
· intro stack
cases stack with
| inl k => simp [initList,_root_.Integration9_9.TM2StockLoop.loopMachine,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
| inr b => cases b <;> simp [initList,_root_.Integration9_9.TM2StockLoop.loopMachine,_root_.Integration9_9.TM2StockLoop.phaseCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
theorem _root_.Integration9_9.TM2StockLoop.terminal_caller_eq (machine : FinTM2) (ein : machine.Γ machine.k₀ ≃ Bool) (eout : machine.Γ machine.k₁ ≃ Bool)
(output : List Bool) : _root_.Integration9_9.TM2StockLoop.terminalCfg machine output=haltList (_root_.Integration9_9.TM2StockLoop.loopMachine machine ein eout) output := by
apply _root_.Integration9_9.TM2StockLoop.cfg_ext
· rfl
· rfl
· intro stack
cases stack with
| inl k => simp [haltList,_root_.Integration9_9.TM2StockLoop.loopMachine,_root_.Integration9_9.TM2StockLoop.terminalCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
| inr b => cases b <;> simp [haltList,_root_.Integration9_9.TM2StockLoop.loopMachine,_root_.Integration9_9.TM2StockLoop.terminalCfg,_root_.Integration9_9.TM2StockThread.fullStacks]
noncomputable def sizeBound {α β : Type} {ea : α → List Bool} {eb : β → List Bool} {f : α → β}
(callee : TM2ComputableInPolyTime ea eb f) : Polynomial ℕ :=
Polynomial.X+Polynomial.C (_root_.Integration9_9.TM2OutputLength.programPushBound callee.tm.m)*callee.time
theorem length_bound {α β : Type} {ea : α → List Bool} {eb : β → List Bool} {f : α → β}
(callee : TM2ComputableInPolyTime ea eb f) (input : α) :
(eb (f input)).length ≤ (_root_.Integration9_9.TM2StockLoop.sizeBound callee).eval (ea input).length := by
have h := _root_.Integration9_9.TM2OutputLength.output_length_le callee.tm
((ea input).map callee.inputAlphabet.invFun) ((eb (f input)).map callee.outputAlphabet.invFun)
(callee.time.eval (ea input).length) (callee.outputsFun input)
simpa only [_root_.Integration9_9.TM2StockLoop.sizeBound,List.length_map,Polynomial.eval_add,Polynomial.eval_X,Polynomial.eval_mul,Polynomial.eval_C] using h
noncomputable def passTime {α β : Type} {ea : α → List Bool} {eb : β → List Bool} {f : α → β}
(callee : TM2ComputableInPolyTime ea eb f) (size : ℕ) : ℕ :=
callee.time.eval size+2*(_root_.Integration9_9.TM2StockLoop.sizeBound callee).eval size+3
/-- The original stock loop machine realizes every proved bounded execution
of the actual stock step program. Both iteration and encoded state bounds
are charged to the resulting real TM2 running time. -/
theorem run_bounded {α β : Type} {ea : α → List Bool} {eb : β → List Bool}
{f : α → β ⊕ α} (callee : TM2ComputableInPolyTime ea (OAI.MetricKMedian.Binary.encodeLoop ea eb) f)
{size rounds : ℕ} {start : α} {result : β}
(h : OAI.MetricKMedian.Binary.BoundedRun ea f size rounds start result) :
Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program callee.tm callee.inputAlphabet callee.outputAlphabet))
(_root_.Integration9_9.TM2StockLoop.callCfg callee.tm (_root_.Integration9_9.TM2StockThread.nativeInput callee.tm ((ea start).map callee.inputAlphabet.symm)))
(some (_root_.Integration9_9.TM2StockLoop.terminalCfg callee.tm (eb result))) (rounds*_root_.Integration9_9.TM2StockLoop.passTime callee size)) := by
induction h with
| @stop a b ha hf =>
have hc : TM2OutputsInTime callee.tm ((ea a).map callee.inputAlphabet.symm)
(some (callee.outputAlphabet.symm false::(eb b).map callee.outputAlphabet.symm))
(callee.time.eval (ea a).length) := by
simpa only [hf,OAI.MetricKMedian.Binary.encodeLoop,List.map_cons,Equiv.invFun_as_coe] using callee.outputsFun a
obtain ⟨hr⟩ := _root_.Integration9_9.TM2StockLoop.stop_round callee.tm callee.inputAlphabet callee.outputAlphabet _ _ _ hc
simp only [List.map_map,Function.comp_def,Equiv.apply_symm_apply,List.map_id_fun',id_eq,List.length_map] at hr
have ht := OAI.MetricKMedian.Binary.polynomial_eval_mono callee.time ha
have hl := (_root_.Integration9_9.TM2StockLoop.length_bound callee a).trans (OAI.MetricKMedian.Binary.polynomial_eval_mono (_root_.Integration9_9.TM2StockLoop.sizeBound callee) ha)
simp only [hf,OAI.MetricKMedian.Binary.encodeLoop,List.length_cons] at hl
have hb : callee.time.eval (ea a).length+2*(eb b).length+3 ≤ 1*_root_.Integration9_9.TM2StockLoop.passTime callee size := by
simp only [one_mul,_root_.Integration9_9.TM2StockLoop.passTime]
omega
exact ⟨⟨hr.toEvalsTo,hr.steps_le_m.trans hb⟩⟩
| @step a a' b n ha hf h ih =>
have hc : TM2OutputsInTime callee.tm ((ea a).map callee.inputAlphabet.symm)
(some (callee.outputAlphabet.symm true::(ea a').map callee.outputAlphabet.symm))
(callee.time.eval (ea a).length) := by
simpa only [hf,OAI.MetricKMedian.Binary.encodeLoop,List.map_cons,Equiv.invFun_as_coe] using callee.outputsFun a
obtain ⟨hr⟩ := _root_.Integration9_9.TM2StockLoop.next_round callee.tm callee.inputAlphabet callee.outputAlphabet _ _ _ hc
simp only [List.map_map,Function.comp_def,Equiv.apply_symm_apply,List.map_id_fun',id_eq,List.length_map] at hr
obtain ⟨hi⟩ := ih
have ht := OAI.MetricKMedian.Binary.polynomial_eval_mono callee.time ha
have hl := (_root_.Integration9_9.TM2StockLoop.length_bound callee a).trans (OAI.MetricKMedian.Binary.polynomial_eval_mono (_root_.Integration9_9.TM2StockLoop.sizeBound callee) ha)
simp only [hf,OAI.MetricKMedian.Binary.encodeLoop,List.length_cons] at hl
have hb : callee.time.eval (ea a).length+2*(ea a').length+3 ≤ _root_.Integration9_9.TM2StockLoop.passTime callee size := by
simp only [_root_.Integration9_9.TM2StockLoop.passTime]
omega
have hall := EvalsToInTime.trans _ _ _ _ _ _ hr hi
have hbound : hall.steps ≤ (n+1)*_root_.Integration9_9.TM2StockLoop.passTime callee size := by
have hh := hall.steps_le_m
rw [Nat.add_mul,one_mul]
omega
exact ⟨⟨hall.toEvalsTo,hbound⟩⟩
/-- Polynomial bounded iteration in the full original platform stock TM2
model, with no internal alphabet restriction or additional step uniformity premise. -/
theorem loop_polynomial {α β : Type} {ea : α → List Bool} {eb : β → List Bool}
{f : α → β ⊕ α} (callee : TM2ComputableInPolyTime ea (OAI.MetricKMedian.Binary.encodeLoop ea eb) f)
(result : α → β) (iterations sizes : Polynomial ℕ)
(h : ∀ input,∃ rounds ≤ iterations.eval (ea input).length,
OAI.MetricKMedian.Binary.BoundedRun ea f (sizes.eval (ea input).length) rounds input (result input)) :
Nonempty (TM2ComputableInPolyTime ea eb result) := by
classical
let wrapper := _root_.Integration9_9.TM2StockLoop.loopMachine callee.tm callee.inputAlphabet callee.outputAlphabet
let cost : Polynomial ℕ := 2*Polynomial.X+2+
iterations*(callee.time.comp sizes+2*(_root_.Integration9_9.TM2StockLoop.sizeBound callee).comp sizes+3)
have hout (input : α) : Nonempty (TM2OutputsInTime wrapper (ea input) (some (eb (result input)))
(cost.eval (ea input).length)) := by
obtain ⟨rounds,hr,hbounded⟩ := h input
obtain ⟨hloop⟩ := _root_.Integration9_9.TM2StockLoop.run_bounded callee hbounded
have hi := _root_.Integration9_9.TM2StockLoop.initial_run callee.tm callee.inputAlphabet callee.outputAlphabet (ea input)
have hall := EvalsToInTime.trans _ _ _ _ _ _ hi hloop
have hm := Nat.mul_le_mul_right (_root_.Integration9_9.TM2StockLoop.passTime callee (sizes.eval (ea input).length)) hr
have he : cost.eval (ea input).length=2*(ea input).length+2+
iterations.eval (ea input).length*_root_.Integration9_9.TM2StockLoop.passTime callee (sizes.eval (ea input).length) := by
simp only [cost,Polynomial.eval_add,Polynomial.eval_mul,Polynomial.eval_X,Polynomial.eval_ofNat,
Polynomial.eval_comp,_root_.Integration9_9.TM2StockLoop.passTime]
have hb : hall.steps ≤ cost.eval (ea input).length := by
rw [he]
have hh := hall.steps_le_m
omega
change Nonempty (EvalsToInTime (TM2.step (_root_.Integration9_9.TM2StockLoop.program callee.tm callee.inputAlphabet callee.outputAlphabet))
(initList wrapper (ea input)) (some (haltList wrapper (eb (result input)))) _)
rw [_root_.Integration9_9.TM2StockLoop.initial_caller_eq,←_root_.Integration9_9.TM2StockLoop.terminal_caller_eq]
exact ⟨⟨hall.toEvalsTo,hb⟩⟩
refine ⟨{
tm := wrapper
inputAlphabet := Equiv.refl Bool
outputAlphabet := Equiv.refl Bool
time := cost
outputsFun := ?_ }⟩
intro input
have run := Classical.choice (hout input)
simpa only [Equiv.refl,List.map_id] using run
end Integration9_9.TM2StockLoop
end
section
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace Integration9_9.TM2StockLists
open Turing Function Polynomial
open OAI.MetricKMedian.Binary
/-- Change only the extensional function in an actual stock machine certificate. -/
def congrProgram {α β : Type} {ea : α → List Bool} {eb : β → List Bool}
{f : α → β} (P : TM2ComputableInPolyTime ea eb f) (g : α → β)
(h : ∀ a,f a=g a) : TM2ComputableInPolyTime ea eb g :=
{ P with outputsFun := fun a => by rw [←h a]; exact P.outputsFun a }
/-- Native preparation for a context-preserving opaque stock call. -/
noncomputable def foldPrepare {α β : Type} (ea : α → List Bool) (eb : β → List Bool) (a0 : α) :
PolyProgram (ListFold.enc ea eb)
(encodePair (encodePair eb ea) (ListFold.enc ea eb))
(fun s : List α × β => ((s.2,s.1.head?.getD a0),s)) := by
let px := PolyProgram.fst (encodeList ea) eb
let py := PolyProgram.snd (encodeList ea) eb
let hd := px.comp (PolyProgram.listHead ea a0)
exact ((py.fanout hd).fanout (PolyProgram.identity (ListFold.enc ea eb))).congr _ (fun _ => rfl)
/-- The actual native caller ignores the extra result on the empty-list branch. -/
noncomputable def foldPost {α β : Type} (ea : α → List Bool) (eb : β → List Bool) (a0 : α) :
PolyProgram (encodePair eb (ListFold.enc ea eb)) (encodeLoop (ListFold.enc ea eb) eb)
(fun s : β × (List α × β) =>
if s.2.1.isEmpty then .inl s.2.2 else .inr (s.2.1.tail,s.1)) := by
let state := PolyProgram.snd eb (ListFold.enc ea eb)
let source := state.comp (PolyProgram.fst (encodeList ea) eb)
let old := state.comp (PolyProgram.snd (encodeList ea) eb)
let fresh := PolyProgram.fst eb (ListFold.enc ea eb)
let tail := source.comp (PolyProgram.listTail ea a0)
let recur := (tail.fanout fresh).comp (PolyProgram.injectRight (ListFold.enc ea eb) eb)
let done := old.comp (PolyProgram.injectLeft (ListFold.enc ea eb) eb)
exact (PolyProgram.ite (source.comp (PolyProgram.listIsEmpty ea)) recur done).congr _ (fun _ => rfl)
/-- One actual list-fold step, retaining the original arbitrary internal alphabets
of the supplied stock operation and framing its context on separate Bool stacks. -/
theorem fold_body {α β : Type} {ea : α → List Bool} {eb : β → List Bool}
(a0 : α) {op : β × α → β} (P : TM2ComputableInPolyTime (encodePair eb ea) eb op) :
Nonempty (TM2ComputableInPolyTime (ListFold.enc ea eb) (encodeLoop (ListFold.enc ea eb) eb)
(ListFold.body a0 op)) := by
obtain ⟨threaded⟩ := _root_.Integration9_9.TM2StockThread.thread_polynomial (ListFold.enc ea eb) P
obtain ⟨first⟩ := _root_.Integration9_9.TM2Composition.comp (_root_.Integration9_9.TM2StockLists.foldPrepare ea eb a0).stock threaded
obtain ⟨whole⟩ := _root_.Integration9_9.TM2Composition.comp first (_root_.Integration9_9.TM2StockLists.foldPost ea eb a0).stock
exact ⟨_root_.Integration9_9.TM2StockLists.congrProgram whole _ (fun _ => rfl)⟩
/-- A genuine stock TM2 fold under a polynomial bound on each prefix accumulator. -/
theorem listFold {α β : Type} {ea : α → List Bool} {eb : β → List Bool}
{op : β × α → β} (P : TM2ComputableInPolyTime (encodePair eb ea) eb op)
(a0 : α) (B : Polynomial ℕ)
(hB : ∀ (as : List α) (b : β) pre suf,as=pre++suf →
(eb (pre.foldl (fun b a => op (b,a)) b)).length ≤
B.eval (encodePair (encodeList ea) eb (as,b)).length) :
Nonempty (TM2ComputableInPolyTime (encodePair (encodeList ea) eb) eb
(fun x => x.1.foldl (fun b a => op (b,a)) x.2)) := by
obtain ⟨step⟩ := _root_.Integration9_9.TM2StockLists.fold_body a0 P
exact _root_.Integration9_9.TM2StockLoop.loop_polynomial step (ListFold.result op) (X+1) (2*X+1+B) (fun s => by
refine ⟨s.1.length+1,?_,?_⟩
· have h := EncodedList.length_le ea s.1
simp only [eval_add,eval_X,eval_one,ListFold.enc,encodePair_length]
omega
· apply ListFold.run
intro pre suf he
have hh := hB s.1 s.2 pre suf he
have hx : (encodeList ea suf).length ≤ (encodeList ea s.1).length := by
rw [he,EncodedList.append,List.length_append]
omega
simp only [ListFold.enc,encodePair_length] at hh ⊢
simp only [eval_add,eval_mul,eval_ofNat,eval_X,eval_one]
omega)
/-- Mapping an arbitrary original stock TM2 subroutine over an encoded list.
The driver reuses its finite control and preserves its internal alphabet types. -/
theorem listMap {α β : Type} {ea : α → List Bool} {eb : β → List Bool}
{f : α → β} (P : TM2ComputableInPolyTime ea eb f) (a0 : α) :
Nonempty (TM2ComputableInPolyTime (encodeList ea) (encodeList eb) (List.map f)) := by
obtain ⟨threaded⟩ := _root_.Integration9_9.TM2StockThread.thread_polynomial (encodeList eb) P
obtain ⟨first⟩ := _root_.Integration9_9.TM2Composition.comp (PolyProgram.exchange (encodeList eb) ea).stock threaded
obtain ⟨step0⟩ := _root_.Integration9_9.TM2Composition.comp first (PolyProgram.listCons eb).stock
let step := _root_.Integration9_9.TM2StockLists.congrProgram step0 (fun x : List β × α => f x.2::x.1) (fun _ => rfl)
obtain ⟨fold⟩ := _root_.Integration9_9.TM2StockLists.listFold step a0 (X*(2*_root_.Integration9_9.TM2StockLoop.sizeBound P+1)+X) (by
intro as bs pre suf he
simp only [ListAlgorithms.pushMap,EncodedList.append,List.length_append,EncodedList.reverse_length]
let L := (encodePair (encodeList ea) (encodeList eb) (as,bs)).length
have hpre : (encodeList ea pre).length ≤ (encodeList ea as).length := by
rw [he,EncodedList.append,List.length_append]; omega
have hlen : pre.length ≤ L := by
have hp := EncodedList.length_le ea pre
simp only [L,encodePair_length]; omega
have hbs : (encodeList eb bs).length ≤ L := by simp only [L,encodePair_length]; omega
have hh := EncodedList.length_bound eb (pre.map f) ((_root_.Integration9_9.TM2StockLoop.sizeBound P).eval L) (by
intro b hb
obtain ⟨a,ha,rfl⟩ := List.mem_map.mp hb
apply (_root_.Integration9_9.TM2StockLoop.length_bound P a).trans
apply polynomial_eval_mono
have hmem := EncodedList.member_length ea pre a ha
simp only [L,encodePair_length]; omega)
simp only [List.length_map] at hh
simp only [eval_add,eval_mul,eval_X,eval_ofNat,eval_one]
change _ ≤ L*(2*(_root_.Integration9_9.TM2StockLoop.sizeBound P).eval L+1)+L
nlinarith)
let start := (PolyProgram.identity (encodeList ea)).fanout
(PolyProgram.constant (encodeList ea) (encodeList eb) [])
obtain ⟨first⟩ := _root_.Integration9_9.TM2Composition.comp start.stock fold
obtain ⟨whole⟩ := _root_.Integration9_9.TM2Composition.comp first (PolyProgram.listReverse eb (f a0)).stock
exact ⟨_root_.Integration9_9.TM2StockLists.congrProgram whole _ (fun as => by
simp only [Function.comp_apply,id_eq,ListFold.result,ListAlgorithms.pushMap,List.append_nil,List.reverse_reverse])⟩
end Integration9_9.TM2StockLists
end
section
namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.PublicParameterProgram
end CurrentAFT.PublicParameterProgram
namespace CurrentAFT.PublicParameterProgram.checkedPower
end CurrentAFT.PublicParameterProgram.checkedPower
namespace CurrentAFT.PublicParameterProgram.checkedProduct
end CurrentAFT.PublicParameterProgram.checkedProduct
namespace CurrentAFT.PublicParameterProgram.checkedScan
end CurrentAFT.PublicParameterProgram.checkedScan
namespace CurrentAFT.PublicParameterProgram.primeTest
end CurrentAFT.PublicParameterProgram.primeTest
namespace CurrentAFT.PublicParameterProgram.testWork
end CurrentAFT.PublicParameterProgram.testWork
namespace CurrentAFT.PublicParameterProgram.workBound
end CurrentAFT.PublicParameterProgram.workBound
namespace CurrentAFT.PublicParameterProgram.workPolynomial
end CurrentAFT.PublicParameterProgram.workPolynomial
namespace Integration9_9
end Integration9_9
namespace Integration9_9.TM2NativePrime
end Integration9_9.TM2NativePrime
namespace Integration9_9.TM2NativePrime.candidateTest
end Integration9_9.TM2NativePrime.candidateTest
namespace Integration9_9.TM2NativePrime.doubleSlots
end Integration9_9.TM2NativePrime.doubleSlots
namespace Integration9_9.TM2NativePrime.powerSlots
end Integration9_9.TM2NativePrime.powerSlots
namespace Integration9_9.TM2NativePrime.powerSlots.match_1
end Integration9_9.TM2NativePrime.powerSlots.match_1
namespace Integration9_9.TM2NativePrime.primeTrial
end Integration9_9.TM2NativePrime.primeTrial
namespace Integration9_9.TM2NativePrime.thresholdSlots
end Integration9_9.TM2NativePrime.thresholdSlots
namespace Integration9_9.TM2NativePrime.upperSlots
end Integration9_9.TM2NativePrime.upperSlots
namespace Integration9_9.TM2PolynomialBudget
end Integration9_9.TM2PolynomialBudget
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false
namespace InfoLossLAR.WorstCase
open QAlgorithms.Complexity Turing Function Polynomial
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open OAI.MetricKMedian.Binary.Automatic.Poly
open Integration9_9 Integration9_9.TM2StockLists QMCNumericRuntime
/-- Unary requests are made by taking existing polynomially many slots. -/
def bundleRequestsFromSlots (slots : List Unit) : List Str :=
(List.range slots.length).map (fun index => (slots.take index).map (fun _ => true))
@[fun_prop] theorem bundleRequestsFromSlots_poly : Poly _root_.InfoLossLAR.WorstCase.bundleRequestsFromSlots := by
unfold _root_.InfoLossLAR.WorstCase.bundleRequestsFromSlots
fun_prop
def bundleRequests (budget : Polynomial ℕ) (input : Str) : List Str :=
_root_.InfoLossLAR.WorstCase.bundleRequestsFromSlots (List.replicate (budget.eval input.length+1) ())
@[fun_prop] theorem bundleRequests_poly (budget : Polynomial ℕ) : Poly (_root_.InfoLossLAR.WorstCase.bundleRequests budget) := by
unfold _root_.InfoLossLAR.WorstCase.bundleRequests
have hs : Poly (fun input : Str => List.replicate ((budget+1).eval input.length) ()) := by
have h := Poly.comp (_root_.Integration9_9.TM2PolynomialBudget.polynomialSlots_poly (budget+1))
(show Poly (fun input : Str => input.map (fun _ => ())) by fun_prop)
simpa only [List.length_map] using h
have h := Poly.comp _root_.InfoLossLAR.WorstCase.bundleRequestsFromSlots_poly hs
simpa only [eval_add,eval_one] using h
/-- Keep the input beside an actual opaque stock subroutine result. -/
theorem stock_pairWithInput {α β : Type} {ea : α → Str} {eb : β → Str}
{f : α → β} (P : TM2ComputableInPolyTime ea eb f) :
Nonempty (TM2ComputableInPolyTime ea (encodePair ea eb) (fun a => (a,f a))) := by
obtain ⟨thread⟩ := _root_.Integration9_9.TM2StockThread.thread_polynomial ea P
let duplicate := (PolyProgram.identity ea).fanout (PolyProgram.identity ea)
obtain ⟨first⟩ := _root_.Integration9_9.TM2Composition.comp duplicate.stock thread
obtain ⟨whole⟩ := _root_.Integration9_9.TM2Composition.comp first (PolyProgram.exchange eb ea).stock
exact ⟨_root_.Integration9_9.TM2StockLists.congrProgram whole _ (fun _ => rfl)⟩
/-- Quote/unquote are real native programs around the original raw stock machine. -/
theorem stock_quoted {f : Str → Str} (P : TM2ComputableInPolyTime id id f) :
Nonempty (TM2ComputableInPolyTime (encodeList encodeBool) (encodeList encodeBool) f) := by
obtain ⟨first⟩ := _root_.Integration9_9.TM2Composition.comp BooleanLists.unpackProgram.stock P
obtain ⟨whole⟩ := _root_.Integration9_9.TM2Composition.comp first BooleanLists.packProgram.stock
exact ⟨_root_.Integration9_9.TM2StockLists.congrProgram whole _ (fun _ => rfl)⟩
def generatedBundleDescriptions (generator : Str → Str) (budget : Polynomial ℕ) (input : Str) : List (Str × Str) :=
(_root_.InfoLossLAR.WorstCase.bundleRequests budget input).map (fun request => (request,generator request))
/-- Every original-platform uniform generator can be called on the whole
polynomial list of unary requests by a single genuine stock machine. -/
theorem generatedBundleDescriptions_stock (generator : Str → Str) (h : PolyTimeComputable generator)
(budget : Polynomial ℕ) :
Nonempty (TM2ComputableInPolyTime id (encodeList (encodePair (encodeList encodeBool) (encodeList encodeBool)))
(_root_.InfoLossLAR.WorstCase.generatedBundleDescriptions generator budget)) := by
obtain ⟨P⟩ := h
obtain ⟨quoted⟩ := _root_.InfoLossLAR.WorstCase.stock_quoted P
obtain ⟨paired⟩ := _root_.InfoLossLAR.WorstCase.stock_pairWithInput quoted
obtain ⟨mapped⟩ := _root_.Integration9_9.TM2StockLists.listMap paired []
obtain ⟨requests⟩ := _root_.Integration9_9.TM2Composition.comp BooleanLists.packProgram.stock (_root_.InfoLossLAR.WorstCase.bundleRequests_poly budget).program.stock
obtain ⟨whole⟩ := _root_.Integration9_9.TM2Composition.comp requests mapped
exact ⟨_root_.Integration9_9.TM2StockLists.congrProgram whole _ (fun _ => rfl)⟩
end InfoLossLAR.WorstCase
end
section
namespace AFT
end AFT
namespace AFT.FiniteDist
end AFT.FiniteDist
namespace InfoLossLAR
end InfoLossLAR
namespace InfoLossLAR.WorstCase
end InfoLossLAR.WorstCase
set_option autoImplicit false
namespace InfoLossLAR.WorstCase
open QAlgorithms.Complexity
open scoped Classical
/-- Real LAR acceptance with the secret fixed; all matrices remain fresh and uniform. -/
noncomputable def larSecretAcceptance (D : Family) (lam : ℕ) (pp : Str)
(q N d ℓ t : ℕ) [NeZero q]
(label : (Fin d → ZMod q) → Fin ℓ → ZMod q) (secret : Fin N → ZMod q) : ℝ :=
avg fun matrices : Fin t → Matrix (Fin d) (Fin N) (ZMod q) =>
acceptProb D (encInput lam pp (encTable
(fun i => (matrices i, label ((matrices i).mulVec secret)))))
/-- Game 1 of the actual reduction: replace only zero-secret labels by ideal labels. -/
noncomputable def prZeroSecretReplacedLAR (D : Family) (lam : ℕ) (pp : Str)
(q N d ℓ t : ℕ) [NeZero q]
(label : (Fin d → ZMod q) → Fin ℓ → ZMod q) : ℝ :=
avg fun secret : Fin N → ZMod q =>
if secret = 0 then prIdealLAR D lam pp q N d ℓ t
else _root_.InfoLossLAR.WorstCase.larSecretAcceptance D lam pp q N d ℓ t label secret
end InfoLossLAR.WorstCase
end
section
set_option autoImplicit false
set_option maxHeartbeats 1000000
namespace InfoLossLAR.WorstCase
open Matrix
open scoped BigOperators Classical
open QAlgorithms.Complexity
/-- Game 2: one shared uniform auxiliary vector selects real labels exactly on alignment;
otherwise all table labels are freshly uniform, including for the zero secret. -/
noncomputable def prAlignmentLAR (D : Family) (lam : ℕ) (pp : Str)
(q N d ℓ t : ℕ) [NeZero q]
(label : (Fin d → ZMod q) → Fin ℓ → ZMod q) : ℝ :=
avg fun secret : Fin N → ZMod q => avg fun auxiliary : Fin N → ZMod q =>
avg fun matrices : Fin t → Matrix (Fin d) (Fin N) (ZMod q) =>
if auxiliary ⬝ᵥ secret=1 then
acceptProb D (encInput lam pp (encTable
(fun i => (matrices i,label ((matrices i).mulVec secret)))))
else avg fun labels : Fin t → Fin ℓ → ZMod q =>
acceptProb D (encInput lam pp (encTable (fun i => (matrices i,labels i))))
end InfoLossLAR.WorstCase
end
section
namespace AFT
end AFT
namespace AFT.FiniteDist
end AFT.FiniteDist
namespace AFT.FiniteDist.mk
end AFT.FiniteDist.mk
namespace AFT.FiniteDist.uniform
end AFT.FiniteDist.uniform
set_option autoImplicit false
set_option maxHeartbeats 1000000
namespace InfoLossLAR.WorstCase
open Matrix AFT
open scoped BigOperators Classical
/-- The literal rank-one transformation of a real LWE block after writing
its response as `A * secret + x`, with the auxiliary vector fixed. -/
def rankOneMatrix {F : Type*} [CommRing F] {d N : ℕ}
(secret auxiliary : Fin N → F) (matrix : Matrix (Fin d) (Fin N) F)
(input : Fin d → F) : Matrix (Fin d) (Fin N) F :=
-matrix + vecMulVec (matrix.mulVec secret + input) auxiliary
/-- The transformed secret product identifies both alignment branches. -/
theorem rankOneMatrix_mulVec {F : Type*} [CommRing F] {d N : ℕ}
(secret auxiliary : Fin N → F) (matrix : Matrix (Fin d) (Fin N) F)
(input : Fin d → F) :
(_root_.InfoLossLAR.WorstCase.rankOneMatrix secret auxiliary matrix input).mulVec secret =
(auxiliary ⬝ᵥ secret - 1) • matrix.mulVec secret +
(auxiliary ⬝ᵥ secret) • input := by
ext i
simp only [_root_.InfoLossLAR.WorstCase.rankOneMatrix, Matrix.add_mulVec, Matrix.neg_mulVec,
Matrix.vecMulVec_mulVec, Pi.add_apply, Pi.neg_apply, Pi.smul_apply,
smul_eq_mul, op_smul_eq_mul]
ring
/-- On alignment, the transformed matrix encodes exactly the selected input. -/
theorem rankOneMatrix_aligned {F : Type*} [CommRing F] {d N : ℕ}
(secret auxiliary : Fin N → F) (halign : auxiliary ⬝ᵥ secret = 1)
(matrix : Matrix (Fin d) (Fin N) F) (input : Fin d → F) :
(_root_.InfoLossLAR.WorstCase.rankOneMatrix secret auxiliary matrix input).mulVec secret = input := by
rw [_root_.InfoLossLAR.WorstCase.rankOneMatrix_mulVec, halign]
simp
/-- Keeping the discarded secret product makes the aligned transformation
an involution on the full matrix/input pair. -/
theorem rankOneMatrix_aligned_involutive {F : Type*} [CommRing F] {d N : ℕ}
(secret auxiliary : Fin N → F) (halign : auxiliary ⬝ᵥ secret = 1) :
Function.Involutive (fun pair : Matrix (Fin d) (Fin N) F × (Fin d → F) =>
(_root_.InfoLossLAR.WorstCase.rankOneMatrix secret auxiliary pair.1 pair.2, pair.1.mulVec secret)) := by
rintro ⟨matrix, input⟩
apply Prod.ext
· dsimp only
change -_root_.InfoLossLAR.WorstCase.rankOneMatrix secret auxiliary matrix input +
vecMulVec ((_root_.InfoLossLAR.WorstCase.rankOneMatrix secret auxiliary matrix input).mulVec secret + matrix.mulVec secret) auxiliary = matrix
rw [_root_.InfoLossLAR.WorstCase.rankOneMatrix_aligned secret auxiliary halign]
unfold _root_.InfoLossLAR.WorstCase.rankOneMatrix
ext i j
simp only [Matrix.add_apply, Matrix.neg_apply, Matrix.vecMulVec_apply, Pi.add_apply]
ring
· exact _root_.InfoLossLAR.WorstCase.rankOneMatrix_aligned secret auxiliary halign matrix input
/-- Exact finite equivalence used to preserve the complete joint law. -/
def rankOneAlignedEquiv {F : Type*} [CommRing F] {d N : ℕ}
(secret auxiliary : Fin N → F) (halign : auxiliary ⬝ᵥ secret = 1) :
(Matrix (Fin d) (Fin N) F × (Fin d → F)) ≃
(Matrix (Fin d) (Fin N) F × (Fin d → F)) :=
Function.Involutive.toPerm _ (_root_.InfoLossLAR.WorstCase.rankOneMatrix_aligned_involutive secret auxiliary halign)
/-- In the complementary branch, the matrix transformation is injective for
every fixed selected input, so no independence is inferred from marginals. -/
theorem rankOneMatrix_injective {F : Type*} [Field F] {d N : ℕ}
(secret auxiliary : Fin N → F) (hmiss : auxiliary ⬝ᵥ secret ≠ 1)
(input : Fin d → F) : Function.Injective
(fun matrix : Matrix (Fin d) (Fin N) F => _root_.InfoLossLAR.WorstCase.rankOneMatrix secret auxiliary matrix input) := by
intro first second h
have hp := congrArg (fun matrix : Matrix (Fin d) (Fin N) F => matrix.mulVec secret) h
rw [_root_.InfoLossLAR.WorstCase.rankOneMatrix_mulVec, _root_.InfoLossLAR.WorstCase.rankOneMatrix_mulVec] at hp
have hproducts : first.mulVec secret = second.mulVec secret := by
have hscaled := add_right_cancel hp
exact (smul_right_injective _ (sub_ne_zero.mpr hmiss)) hscaled
change -first + vecMulVec (first.mulVec secret + input) auxiliary =
-second + vecMulVec (second.mulVec secret + input) auxiliary at h
rw [hproducts] at h
exact neg_injective (add_right_cancel h)
/-- Each nonaligned conditional matrix map is a genuine finite bijection. -/
noncomputable def rankOneUnalignedEquiv {F : Type*} [Field F] [Fintype F] {d N : ℕ}
(secret auxiliary : Fin N → F) (hmiss : auxiliary ⬝ᵥ secret ≠ 1)
(input : Fin d → F) : Matrix (Fin d) (Fin N) F ≃ Matrix (Fin d) (Fin N) F :=
Equiv.ofBijective _ ((Finite.injective_iff_bijective).mp
(_root_.InfoLossLAR.WorstCase.rankOneMatrix_injective secret auxiliary hmiss input))
end InfoLossLAR.WorstCase
end
section
namespace AFT
end AFT
namespace AFT.FiniteDist
end AFT.FiniteDist
namespace AFT.FiniteDist.mk
end AFT.FiniteDist.mk
namespace AFT.FiniteDist.uniform
end AFT.FiniteDist.uniform
namespace AFT.GaussianSource
end AFT.GaussianSource
namespace AFT.RepresentedPolynomial
end AFT.RepresentedPolynomial
namespace AFT.SafeConvolution
end AFT.SafeConvolution
namespace AFT.V7Calibration
end AFT.V7Calibration
namespace AFT.canonicalCarry
end AFT.canonicalCarry
namespace AFT.endpointIntegralPreimage
end AFT.endpointIntegralPreimage
namespace AFT.endpointLift
end AFT.endpointLift
namespace AFT.endpointProjection
end AFT.endpointProjection
namespace AFT.fiberLabel
end AFT.fiberLabel
namespace AFT.integerLabel
end AFT.integerLabel
namespace AFT.liftCoordinates
end AFT.liftCoordinates
namespace AFT.pathIncidence
end AFT.pathIncidence
namespace AFT.reduceCoordinates
end AFT.reduceCoordinates
namespace AFT.zeroFiberPullback
end AFT.zeroFiberPullback
namespace InfoLossLAR
end InfoLossLAR
namespace InfoLossLAR.WorstCase
end InfoLossLAR.WorstCase
namespace InfoLossLAR.WorstCase.Integration
end InfoLossLAR.WorstCase.Integration
namespace InfoLossLAR.WorstCase.TDef63
end InfoLossLAR.WorstCase.TDef63
namespace InfoLossLAR.WorstCase.unifOn
end InfoLossLAR.WorstCase.unifOn
namespace InfoLossLAR.WorstCase.zeroFiber63
end InfoLossLAR.WorstCase.zeroFiber63
set_option autoImplicit false
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 2000000
namespace InfoLossLAR.WorstCase
open AFT
open scoped BigOperators Classical
/-- Translation equivariance gives an explicit unique zero-fiber/label decomposition. -/
def zeroFiberCoordinates {V K : Type*} [AddCommGroup V] [AddCommGroup K]
(label : V → K) (direction : K →+ V)
(htranslate : ∀ x k, label (x + direction k) = label x + k) :
({x : V // label x = 0} × K) ≃ V where
toFun pair := pair.1.val + direction pair.2
invFun x := (⟨x + direction (-label x), by rw [htranslate]; simp⟩, label x)
left_inv pair := by
rcases pair with ⟨⟨x,hx⟩,k⟩
apply Prod.ext
· apply Subtype.ext
simp only [htranslate,hx,zero_add,map_neg]
abel
· simpa only [htranslate,hx,zero_add]
right_inv x := by
simp only [map_neg]
abel
/-- The integer preimage of a unit carry at the first endpoint. Its existence
comes from the proved integral image lattice of the actual rounding map. -/
noncomputable def roundingDirectionInteger (n q : ℕ) [NeZero q]
(column : Fin (n+1) → ℤ) (hcolumn : _root_.AFT.totalCharge column = (q : ℤ)) :
(Fin n → ℤ) × ℤ :=
(_root_.AFT.roundingCoordinates n (q : ℤ) (by exact_mod_cast NeZero.ne q) column hcolumn).symm
⟨(q : ℤ) • (Pi.single (0 : Fin (n+1)) (1 : ℤ)), by
change (q : ℤ) ∣ _root_.AFT.totalCharge ((q : ℤ) • (Pi.single (0 : Fin (n+1)) (1 : ℤ)))
rw [_root_.AFT.totalCharge_smul]
exact dvd_mul_right _ _⟩
/-- Reduction of the integer carry direction is an additive modular direction. -/
noncomputable def roundingDirection (n q : ℕ) [NeZero q]
(column : Fin (n+1) → ℤ) (hcolumn : _root_.AFT.totalCharge column = (q : ℤ)) :
ZMod q →+ ((Fin n → ZMod q) × ZMod q) where
toFun amount := amount • _root_.AFT.reduceCoordinates n q (_root_.InfoLossLAR.WorstCase.roundingDirectionInteger n q column hcolumn)
map_zero' := zero_smul _ _
map_add' a b := add_smul a b _
/-- The field direction in the platform's edge-then-last coordinate order. -/
noncomputable def fixedRoundingDirection (q n : ℕ) [NeZero q] (hq : q ≤ n+1) :
ZMod q →+ (Fin (n+1) → ZMod q) where
toFun amount := Fin.lastCases
(_root_.InfoLossLAR.WorstCase.roundingDirection n q (_root_.AFT.injectionColumn n q) (_root_.AFT.totalCharge_injectionColumn n q hq) amount).2
(_root_.InfoLossLAR.WorstCase.roundingDirection n q (_root_.AFT.injectionColumn n q) (_root_.AFT.totalCharge_injectionColumn n q hq) amount).1
map_zero' := by
funext i
refine Fin.lastCases ?_ (fun j => ?_) i <;> simp
map_add' a b := by
funext i
refine Fin.lastCases ?_ (fun j => ?_) i <;> simp
/-- The zero input has the zero platform label, providing a concrete
nonempty witness for the finite zero fiber. -/
theorem fT63_zero (q d : ℕ) : fT63 q d 0 = 0 := by
have hl : InfoLossLAR.WorstCase.lift (0 : Fin d → ZMod q) = 0 := by
funext i
simp [InfoLossLAR.WorstCase.lift]
unfold fT63 AR
rw [hl,Matrix.mulVec_zero]
simp [carry]
/-- A normalized finite distribution with exactly the platform zero-fiber density. -/
noncomputable def fixedZeroFiberLaw (q d : ℕ) [NeZero q] :
_root_.AFT.FiniteDist (Fin d → ZMod q) := by
letI : Nonempty {x : Fin d → ZMod q // fT63 q d x = 0} := ⟨⟨0,_root_.InfoLossLAR.WorstCase.fT63_zero q d⟩⟩
exact (_root_.AFT.FiniteDist.uniform {x : Fin d → ZMod q // fT63 q d x = 0}).map Subtype.val
end InfoLossLAR.WorstCase
end
section
set_option autoImplicit false
set_option maxHeartbeats 1000000
namespace InfoLossLAR.WorstCase
open AFT
open scoped BigOperators
/-- A direct integer prefix algorithm for the path-incidence preimage. -/
def pathPrefix : (n : ℕ) → (Fin (n+1) → ℤ) → (Fin n → ℤ)
| 0,_ => Fin.elim0
| n+1,load => Fin.cons (load 0)
(pathPrefix n (fun i => load i.succ + if i=0 then load 0 else 0))
/-- The public integer carry direction computed without choosing an inverse. -/
def computableRoundingDirectionInteger (n q : ℕ) (column : Fin (n+1) → ℤ) :
(Fin n → ℤ) × ℤ :=
(_root_.InfoLossLAR.WorstCase.pathPrefix n ((q : ℤ) • (Pi.single (0 : Fin (n+1)) (1 : ℤ))-column),1)
/-- The literal modular preprocessing direction, using the same edge-then-last
coordinate order as the actual platform matrix. -/
def computableFixedRoundingDirection (q n : ℕ) (amount : ZMod q) : Fin (n+1) → ZMod q :=
let integer := _root_.InfoLossLAR.WorstCase.computableRoundingDirectionInteger n q (_root_.AFT.injectionColumn n q)
Fin.lastCases (amount*(integer.2 : ZMod q)) (fun j => amount*(integer.1 j : ZMod q))
/-- The platform represents the scalar label as a vector with one coordinate. -/
def computableFixedVectorDirection (q n : ℕ) : (Fin 1 → ZMod q) → Fin (n+1) → ZMod q :=
fun label => _root_.InfoLossLAR.WorstCase.computableFixedRoundingDirection q n (label 0)
noncomputable def fixedVectorDirection (q n : ℕ) [NeZero q] (hq : q ≤ n+1) :
(Fin 1 → ZMod q) →+ (Fin (n+1) → ZMod q) where
toFun label := _root_.InfoLossLAR.WorstCase.fixedRoundingDirection q n hq (label 0)
map_zero' := by simp
map_add' first second := by simp
end InfoLossLAR.WorstCase
end
section
namespace AFT
end AFT
namespace AFT.FiniteDist
end AFT.FiniteDist
set_option autoImplicit false
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 1500000
namespace InfoLossLAR.WorstCase
open AFT Matrix QAlgorithms.Complexity
open scoped BigOperators Classical
/-- The actual classical rank-one preprocessing, using the observed LWE response. -/
def larRankOnePreprocess {F K : Type*} [CommRing F] {d N : ℕ}
(auxiliary : Fin N → F) (direction : K → (Fin d → F))
(matrix : Matrix (Fin d) (Fin N) F) (response : Fin d → F) (mark : K) :
Matrix (Fin d) (Fin N) F × K :=
(-matrix+vecMulVec (response+direction mark) auxiliary,mark)
/-- The real block experiment samples the zero-fiber error, its independent
uniform output label, and the uniform public matrix independently. -/
noncomputable def larRankOneRealBlock {F K : Type*} [Field F] [Fintype F]
[Fintype K] [Nonempty K] {d N : ℕ}
(source : _root_.AFT.FiniteDist (Fin d → F)) (direction : K → (Fin d → F))
(secret auxiliary : Fin N → F) : _root_.AFT.FiniteDist (Matrix (Fin d) (Fin N) F × K) :=
(source.prod (_root_.AFT.FiniteDist.uniform K)).mix fun draw =>
(_root_.AFT.FiniteDist.uniform (Matrix (Fin d) (Fin N) F)).map fun matrix =>
_root_.InfoLossLAR.WorstCase.larRankOnePreprocess auxiliary direction matrix (matrix.mulVec secret+draw.1) draw.2
/-- The ideal LWE block has a uniform response independent of the public
matrix; the reduction still samples its independent uniform output label. -/
noncomputable def larRankOneIdealBlock {F K : Type*} [Field F] [Fintype F]
[Fintype K] [Nonempty K] {d N : ℕ}
(direction : K → (Fin d → F)) (auxiliary : Fin N → F) :
_root_.AFT.FiniteDist (Matrix (Fin d) (Fin N) F × K) :=
((_root_.AFT.FiniteDist.uniform (Fin d → F)).prod (_root_.AFT.FiniteDist.uniform K)).mix fun draw =>
(_root_.AFT.FiniteDist.uniform (Matrix (Fin d) (Fin N) F)).map fun matrix =>
_root_.InfoLossLAR.WorstCase.larRankOnePreprocess auxiliary direction matrix draw.1 draw.2
/-- The literal uniform zero fiber, as a normalized law on the full input space. -/
noncomputable def larUniformZeroLaw {V K : Type*} [Fintype V] [Zero V] [Zero K]
(label : V → K) (hzero : label 0=0) : _root_.AFT.FiniteDist V := by
letI : Nonempty {x : V // label x=0} := ⟨⟨0,hzero⟩⟩
exact (_root_.AFT.FiniteDist.uniform {x : V // label x=0}).map Subtype.val
/-- Actual real-LWE preprocessing: one shared secret and independently
sampled errors/matrices/marks in every block, with one shared auxiliary vector. -/
noncomputable def prRankOneRealLAR (D : Family) (lam : ℕ) (pp : Str)
(q N d ℓ t : ℕ) [Fact q.Prime] [NeZero q]
(source : _root_.AFT.FiniteDist (Fin d → ZMod q))
(direction : (Fin ℓ → ZMod q) → (Fin d → ZMod q)) : ℝ :=
avg fun secret : Fin N → ZMod q => avg fun auxiliary : Fin N → ZMod q =>
(_root_.AFT.FiniteDist.independent (fun _ : Fin t => _root_.InfoLossLAR.WorstCase.larRankOneRealBlock source direction secret auxiliary)).expectation
(fun table => acceptProb D (encInput lam pp (encTable table)))
/-- Actual ideal-LWE preprocessing uses the same single shared auxiliary
vector and independently drawn uniform matrix/response/mark blocks. -/
noncomputable def prRankOneIdealLAR (D : Family) (lam : ℕ) (pp : Str)
(q N d ℓ t : ℕ) [Fact q.Prime] [NeZero q]
(direction : (Fin ℓ → ZMod q) → (Fin d → ZMod q)) : ℝ :=
avg fun auxiliary : Fin N → ZMod q =>
(_root_.AFT.FiniteDist.independent (fun _ : Fin t => _root_.InfoLossLAR.WorstCase.larRankOneIdealBlock direction auxiliary)).expectation
(fun table => acceptProb D (encInput lam pp (encTable table)))
end InfoLossLAR.WorstCase
end
section
set_option autoImplicit false
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 1500000
namespace InfoLossLAR.WorstCase
open AFT
open scoped BigOperators Classical
/-- The actual little-endian fair-bit ticket, with no enumeration of the output space. -/
def boundedBoolTicket (bits : ℕ) : (Fin bits → Bool) ≃ Fin (2^bits) :=
(Equiv.arrowCongr (Equiv.refl (Fin bits)) finTwoEquiv.symm).trans finFunctionFinEquiv
/-- One bounded rejection attempt: return the exact interval index or an explicit failure. -/
def boundedFinDraw (count : ℕ) (tape : Fin (Nat.size count) → Bool) : Option (Fin count) :=
let ticket := _root_.InfoLossLAR.WorstCase.boundedBoolTicket (Nat.size count) tape
if h : ticket.val<count then some ⟨ticket.val,h⟩ else none
/-- The success event is independent of every future LWE input. -/
noncomputable def boundedFinSuccess (count : ℕ) : ℝ := (count : ℝ)/(2 : ℝ)^Nat.size count
/-- The exact finite law of this actual Boolean program. -/
noncomputable def boundedFinLaw (count : ℕ) : _root_.AFT.FiniteDist (Option (Fin count)) :=
(_root_.AFT.FiniteDist.uniform (Fin (Nat.size count) → Bool)).map (_root_.InfoLossLAR.WorstCase.boundedFinDraw count)
/-- The literal successful decoder uses base-q quotient and remainder digits. -/
def boundedBaseQDecode (q coordinates : ℕ) (hq : 0<q) (ticket : Fin (q^coordinates)) : Fin coordinates → Fin q :=
fun index => ⟨ticket.val/q^index.val%q,Nat.mod_lt _ hq⟩
/-- The joint field-vector equivalence has an explicit modular digit implementation. -/
def boundedFieldEquiv (q coordinates : ℕ) [NeZero q] : Fin (q^coordinates) ≃ (Fin coordinates → ZMod q) :=
finFunctionFinEquiv.symm.trans (Equiv.piCongrRight fun _ => (ZMod.finEquiv q).toEquiv)
def boundedFieldDecode (q coordinates : ℕ) [NeZero q] (ticket : Fin (q^coordinates)) : Fin coordinates → ZMod q :=
fun index => ZMod.finEquiv q (_root_.InfoLossLAR.WorstCase.boundedBaseQDecode q coordinates (Nat.pos_of_ne_zero (NeZero.ne q)) ticket index)
/-- Split the sampled field coordinates into one shared auxiliary vector
and one independent field label at every position of the complete sample table. -/
def boundedSplitEquiv (F : Type*) (N samples labels : ℕ) :
(Fin (N+samples*labels) → F) ≃ (Fin N → F) × (Fin samples → Fin labels → F) :=
((Equiv.arrowCongr finSumFinEquiv.symm (Equiv.refl F)).trans
(Equiv.sumArrowEquivProdArrow (Fin N) (Fin (samples*labels)) F)).trans
((Equiv.refl (Fin N → F)).prodCongr
((Equiv.arrowCongr finProdFinEquiv.symm (Equiv.refl F)).trans
(Equiv.curry (Fin samples) (Fin labels) F)))
def boundedSplit (F : Type*) (N samples labels : ℕ) (word : Fin (N+samples*labels) → F) :
(Fin N → F) × (Fin samples → Fin labels → F) :=
(fun index => word (Fin.castAdd (samples*labels) index),
fun sample label => word (Fin.natAdd N (finProdFinEquiv (sample,label))))
/-- The semantic bijection corresponds exactly to the implemented quotient/remainder digits. -/
def boundedJointEquiv (q N samples labels : ℕ) [NeZero q] :
Fin (q^(N+samples*labels)) ≃ (Fin N → ZMod q) × (Fin samples → Fin labels → ZMod q) :=
(_root_.InfoLossLAR.WorstCase.boundedFieldEquiv q (N+samples*labels)).trans (_root_.InfoLossLAR.WorstCase.boundedSplitEquiv (ZMod q) N samples labels)
/-- The actual bounded Boolean sampler returns both all shared/table coins
or an explicit failure; its decoder uses integer division and remainder. -/
def boundedJointDraw (q N samples labels : ℕ) [NeZero q]
(tape : Fin (Nat.size (q^(N+samples*labels))) → Bool) :
Option ((Fin N → ZMod q) × (Fin samples → Fin labels → ZMod q)) :=
match _root_.InfoLossLAR.WorstCase.boundedFinDraw (q^(N+samples*labels)) tape with
| none => none
| some ticket => some (_root_.InfoLossLAR.WorstCase.boundedSplit (ZMod q) N samples labels (_root_.InfoLossLAR.WorstCase.boundedFieldDecode q (N+samples*labels) ticket))
end InfoLossLAR.WorstCase
end
Source
Companion Lean implementation for InfoLossLAR.WorstCase.fixed_family_gaussian_advantage_transfer. The definitions are extracted from the checked source modules listed in the publication manifest at /private/tmp/p2m_task4/first_bridge_extraction/publication_ready.json. Original generated-source SHA-256: 91a83fcb126438bf2f3facdb42f557514546fa3d17f16356833ae9c92489de09. Current submitted-source SHA-256: f71c0d06013f31e89765353a285ed259d00a84bdaff34a891aa8f46873405853. Source modules: Definitions.Def_InfoLossLAR_FirstBridge_Solutions_RegevBridgeBooleanNodeSerialization, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeMultiSelector, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeMultiSelectorEmitter, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeCircuitBundle, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeBundleEmitter, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeStockThread, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeStockLoop, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeStockLists, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeBundleUniform, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeLARZeroSecret, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeAlignment, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeRankOne, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeZeroFiberDecomposition, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeComputableDirection, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeLARToUZF, Definitions.Def_InfoLossLAR_FirstBridge_Solutions_AdvantageBridgeBoundedUniform. Current change: only replace the unpublished import of FirstBridgeBundle06 with imports of FirstBridgeBundle05 and FirstBridgeBundle06Optimized; all non-import source bytes are retained.