Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Local affine-response programs and finite draws

Definition
InfoLossLAR_RuntimeBundle_02

by BoomShaKaLaaaKa · Nov 14, 2026 · Mathlib 0df444a (Lean v4.33.1)

affine-transportinfo-loss-lar-runtimestoc-2027

These programs compute the finite profiles and response coefficients required by local affine calibration. They implement reference and inverse-response tables, tuple enumeration, root-group and background profiles, and finite probability draws. The data representations separate the finite encoded objects from their ideal rational or real interpretations.

Definition code

































import Definitions.Def_InfoLossLAR_RuntimeBundle_01




























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



























































namespace AFT
end AFT
namespace AFT.BinaryArithmetic
end AFT.BinaryArithmetic
namespace AFT.BinaryArithmetic.binaryAnchorSliceTerm
end AFT.BinaryArithmetic.binaryAnchorSliceTerm
namespace AFT.BinaryArithmetic.binaryAnchorSliceTermWork
end AFT.BinaryArithmetic.binaryAnchorSliceTermWork
namespace AFT.BinaryArithmetic.binaryAveragedSlice
end AFT.BinaryArithmetic.binaryAveragedSlice
namespace AFT.BinaryArithmetic.binaryAveragedSliceWork
end AFT.BinaryArithmetic.binaryAveragedSliceWork
namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryProfileKernel
end CurrentAFT.BinaryProfileKernel
namespace CurrentAFT.BinaryProfileKernel.anchorWorkPolynomial
end CurrentAFT.BinaryProfileKernel.anchorWorkPolynomial
namespace CurrentAFT.BinaryProfileKernel.averagedWorkPolynomial
end CurrentAFT.BinaryProfileKernel.averagedWorkPolynomial
namespace CurrentAFT.BinaryProfileKernel.currentHeight
end CurrentAFT.BinaryProfileKernel.currentHeight
namespace CurrentAFT.BinaryProfileKernel.currentWork
end CurrentAFT.BinaryProfileKernel.currentWork
namespace CurrentAFT.BinaryProfileKernel.heightPolynomial
end CurrentAFT.BinaryProfileKernel.heightPolynomial
namespace CurrentAFT.BinaryProfileKernel.integerBound
end CurrentAFT.BinaryProfileKernel.integerBound
namespace CurrentAFT.BinaryProfileKernel.integerPolynomial
end CurrentAFT.BinaryProfileKernel.integerPolynomial
namespace CurrentAFT.BinaryProfileKernel.sliceWorkPolynomial
end CurrentAFT.BinaryProfileKernel.sliceWorkPolynomial
namespace CurrentAFT.BinaryProfileKernel.start
end CurrentAFT.BinaryProfileKernel.start
namespace CurrentAFT.BinaryProfileKernel.startWork
end CurrentAFT.BinaryProfileKernel.startWork
namespace CurrentAFT.BinaryProfileKernel.startWorkPolynomial
end CurrentAFT.BinaryProfileKernel.startWorkPolynomial
namespace CurrentAFT.BinaryProfileKernel.workPolynomial
end CurrentAFT.BinaryProfileKernel.workPolynomial





set_option autoImplicit false
set_option maxHeartbeats 1000000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! Actual width-index enumeration and slice averaging for the native profile
kernel. The width is supplied by a real unary buffer, never expanded from an
arbitrary binary number. The signed endpoints and every term use actual TM2
integer/rational programs. -/
namespace Integration9_9.TM2NativeAveragedSlice
open AFT AFT.RationalNumerics AFT.BinaryArithmetic AFT.V7Calibration
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators

abbrev Request := (ℤ×ℤ)×((ℤ×ℤ)×(List Unit×ℤ))
abbrev requestCode : _root_.Integration9_9.TM2NativeAveragedSlice.Request → List Bool := Automatic.enc

def term (x : _root_.Integration9_9.TM2NativeAveragedSlice.Request×ℕ) : ℚ :=
  let shift := x.1.2.1.1+(x.2 : ℤ)
  _root_.Integration9_9.TM2NativeSliceProbability.interval ((x.1.2.1.1,x.1.2.2.1.length),shift)*
    _root_.Integration9_9.TM2NativeSliceProbability.slice ((x.1.1.1,x.1.1.2),(shift-x.1.2.1.2,x.1.2.2.2))

@[fun_prop] theorem term_poly : Poly _root_.Integration9_9.TM2NativeAveragedSlice.term := by unfold _root_.Integration9_9.TM2NativeAveragedSlice.term;fun_prop
noncomputable def termProgram : PolyProgram (encodePair _root_.Integration9_9.TM2NativeAveragedSlice.requestCode Nat.bits) Ratio.encode _root_.Integration9_9.TM2NativeAveragedSlice.term := _root_.Integration9_9.TM2NativeAveragedSlice.term_poly.program

def current (x : _root_.Integration9_9.TM2NativeAveragedSlice.Request) : ℚ :=
  ((List.range x.2.2.1.length).map (fun i => _root_.Integration9_9.TM2NativeAveragedSlice.term (x,i))).sum

noncomputable def currentProgram : PolyProgram _root_.Integration9_9.TM2NativeAveragedSlice.requestCode Ratio.encode _root_.Integration9_9.TM2NativeAveragedSlice.current := by
  let widths : PolyProgram _root_.Integration9_9.TM2NativeAveragedSlice.requestCode _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode (fun x : _root_.Integration9_9.TM2NativeAveragedSlice.Request => x.2.2.1) :=
    (show Poly (fun x : _root_.Integration9_9.TM2NativeAveragedSlice.Request => x.2.2.1) by fun_prop).program
  let indices := widths.comp (PolyProgram.listIndices _root_.Integration9_9.TM2NativeFiniteSeries.unitCode ())
  let terms := ((PolyProgram.identity _root_.Integration9_9.TM2NativeAveragedSlice.requestCode).fanout indices).comp (_root_.Integration9_9.TM2NativeAveragedSlice.termProgram.listMapWith 0 (0 : ℚ))
  exact terms.comp PolyProgram.ratSum

 theorem _root_.Integration9_9.TM2NativeAveragedSlice.sum_range (f : ℕ → ℚ) (n : ℕ) :
    ((List.range n).map f).sum=∑i : Fin n,f i := by
  rw [Fin.sum_univ_eq_sum_range]
  induction n with
  | zero => simp
  | succ n ih => simp only [List.range_succ,List.map_append,List.sum_append,ih,List.map_singleton,List.sum_cons,List.sum_nil,add_zero,Finset.sum_range_succ]

theorem current_eq (x : _root_.Integration9_9.TM2NativeAveragedSlice.Request) :
    _root_.Integration9_9.TM2NativeAveragedSlice.current x=_root_.AFT.V7Calibration.averagedSliceProgram x.1.1 x.1.2 x.2.1.1 x.2.1.2 x.2.2.1.length x.2.2.2 := by
  rw [_root_.Integration9_9.TM2NativeAveragedSlice.current,_root_.Integration9_9.TM2NativeAveragedSlice.sum_range]
  rfl

noncomputable def averagedSliceProgram : PolyProgram _root_.Integration9_9.TM2NativeAveragedSlice.requestCode Ratio.encode
    (fun x : _root_.Integration9_9.TM2NativeAveragedSlice.Request => _root_.AFT.V7Calibration.averagedSliceProgram x.1.1 x.1.2 x.2.1.1 x.2.1.2 x.2.2.1.length x.2.2.2) :=
  _root_.Integration9_9.TM2NativeAveragedSlice.currentProgram.congr _ _root_.Integration9_9.TM2NativeAveragedSlice.current_eq








/-- Colors, actual anchor-width ticks, sign, blur, scalar source and output. -/
abbrev ProfileRequest := ((ℕ×List Unit)×Bool)×((ℤ×ℤ)×ℕ)
abbrev profileCode : _root_.Integration9_9.TM2NativeAveragedSlice.ProfileRequest→List Bool := Automatic.enc

def profileValue (x : _root_.Integration9_9.TM2NativeAveragedSlice.ProfileRequest) : ℚ :=
  _root_.CurrentAFT.RationalFirstResponseProgram.profileKernel x.1.1.1 x.1.1.2.length x.1.2
    x.2.1.1 x.2.1.2 x.2.2

/-- The actual sign-selected profile kernel, including its full width loop. -/
noncomputable def profileKernelProgram : PolyProgram _root_.Integration9_9.TM2NativeAveragedSlice.profileCode Ratio.encode _root_.Integration9_9.TM2NativeAveragedSlice.profileValue := by
  let arrange : Poly (fun x : _root_.Integration9_9.TM2NativeAveragedSlice.ProfileRequest =>
      (((x.1.1.1 : ℤ),(1 : ℤ)),
       (((if x.1.2 then (x.1.1.2.length : ℤ) else -2*(x.1.1.2.length : ℤ)+1)+x.2.1.1,x.2.1.2),
        (x.1.1.2,(x.2.2 : ℤ))))) := by fun_prop
  exact (arrange.program.comp _root_.Integration9_9.TM2NativeAveragedSlice.averagedSliceProgram).congr _ (fun _ => rfl)

end Integration9_9.TM2NativeAveragedSlice

end

section




























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryProfileProgram
end CurrentAFT.BinaryProfileProgram
namespace CurrentAFT.BinaryProfileProgram.currentHeightPolynomial
end CurrentAFT.BinaryProfileProgram.currentHeightPolynomial
namespace CurrentAFT.BinaryProfileProgram.currentWorkPolynomial
end CurrentAFT.BinaryProfileProgram.currentWorkPolynomial
namespace CurrentAFT.BinaryProfileProgram.evaluate
end CurrentAFT.BinaryProfileProgram.evaluate





set_option autoImplicit false
set_option maxHeartbeats 1500000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! Full current diffuse profiles. The prime, anchor-width buffer, edge and
scalar Gaussian tables, and all three seed enumerations are actually generated.
All loops use real encoded lists. No numerical advice or work/time premise is
part of the certificate. -/
namespace Integration9_9.TM2NativeProfile
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators
attribute [local irreducible] CurrentAFT.BinaryProfileProgram.current
  CurrentAFT.BinaryProfileProgram.evaluate CurrentAFT.BinaryDiffuseCurrent.metadata

@[fun_prop] theorem nat_div_poly : Poly (fun x : ℕ×ℕ => x.1/x.2) := ⟨PolyProgram.natDiv⟩

/-- Stored generated colors/width/sign, Gaussian arrays, and retained output. -/
abbrev Context := (ℕ×(List Unit×Bool))×((List ℚ×List ℚ)×ℕ)
abbrev contextCode : _root_.Integration9_9.TM2NativeProfile.Context→List Bool := Automatic.enc
abbrev Seed := (ℕ×ℕ)×ℕ


def edgeIndices (c : _root_.Integration9_9.TM2NativeProfile.Context) : List ℕ := List.range c.2.1.1.length
def scalarIndices (c : _root_.Integration9_9.TM2NativeProfile.Context) : List ℕ := List.range c.2.1.2.length
@[fun_prop] theorem edgeIndices_poly : Poly _root_.Integration9_9.TM2NativeProfile.edgeIndices := by
  change Poly (fun c : _root_.Integration9_9.TM2NativeProfile.Context => List.range c.2.1.1.length)
  exact Poly.comp (f := fun xs : List ℚ => List.range xs.length) (g := fun c : _root_.Integration9_9.TM2NativeProfile.Context => c.2.1.1) (Poly.list_indices (α := ℚ)) (by fun_prop)
@[fun_prop] theorem scalarIndices_poly : Poly _root_.Integration9_9.TM2NativeProfile.scalarIndices := by
  change Poly (fun c : _root_.Integration9_9.TM2NativeProfile.Context => List.range c.2.1.2.length)
  exact Poly.comp (f := fun xs : List ℚ => List.range xs.length) (g := fun c : _root_.Integration9_9.TM2NativeProfile.Context => c.2.1.2) (Poly.list_indices (α := ℚ)) (by fun_prop)

def seeds (c : _root_.Integration9_9.TM2NativeProfile.Context) : List _root_.Integration9_9.TM2NativeProfile.Seed :=
  (_root_.Integration9_9.TM2NativeProfile.edgeIndices c).flatMap (fun left => (_root_.Integration9_9.TM2NativeProfile.edgeIndices c).flatMap (fun right =>
    (_root_.Integration9_9.TM2NativeProfile.scalarIndices c).map (fun scalar => ((left,right),scalar))))
@[fun_prop] theorem seeds_poly : Poly _root_.Integration9_9.TM2NativeProfile.seeds := by unfold _root_.Integration9_9.TM2NativeProfile.seeds;fun_prop

@[fun_prop] theorem profileValue_poly : Poly _root_.Integration9_9.TM2NativeAveragedSlice.profileValue :=
  ⟨_root_.Integration9_9.TM2NativeAveragedSlice.profileKernelProgram⟩

def kernelRequest (x : _root_.Integration9_9.TM2NativeProfile.Context×_root_.Integration9_9.TM2NativeProfile.Seed) : _root_.Integration9_9.TM2NativeAveragedSlice.ProfileRequest :=
  (((x.1.1.1,x.1.1.2.1),x.1.1.2.2),
    (((x.2.1.1 : ℤ)-x.2.1.2,(x.2.2 : ℤ)-(x.1.2.1.2.length/2 : ℕ)),x.1.2.2))
@[fun_prop] theorem kernelRequest_poly : Poly _root_.Integration9_9.TM2NativeProfile.kernelRequest := by unfold _root_.Integration9_9.TM2NativeProfile.kernelRequest;fun_prop

def term (x : _root_.Integration9_9.TM2NativeProfile.Context×_root_.Integration9_9.TM2NativeProfile.Seed) : ℚ :=
  x.1.2.1.1[x.2.1.1]?.getD 0 * x.1.2.1.1[x.2.1.2]?.getD 0 *
    x.1.2.1.2[x.2.2]?.getD 0 * _root_.Integration9_9.TM2NativeAveragedSlice.profileValue (_root_.Integration9_9.TM2NativeProfile.kernelRequest x)
@[fun_prop] theorem term_poly : Poly _root_.Integration9_9.TM2NativeProfile.term := by unfold _root_.Integration9_9.TM2NativeProfile.term;fun_prop

def evaluate (c : _root_.Integration9_9.TM2NativeProfile.Context) : ℚ := ((_root_.Integration9_9.TM2NativeProfile.seeds c).map (fun s => _root_.Integration9_9.TM2NativeProfile.term (c,s))).sum
noncomputable def evaluateProgram : PolyProgram _root_.Integration9_9.TM2NativeProfile.contextCode Ratio.encode _root_.Integration9_9.TM2NativeProfile.evaluate :=
  ((((PolyProgram.identity _root_.Integration9_9.TM2NativeProfile.contextCode).fanout _root_.Integration9_9.TM2NativeProfile.seeds_poly.program).comp
    (_root_.Integration9_9.TM2NativeProfile.term_poly.program.listMapWith ((0,0),0) (0 : ℚ))).comp PolyProgram.ratSum)
@[fun_prop] theorem evaluate_poly : Poly _root_.Integration9_9.TM2NativeProfile.evaluate := ⟨_root_.Integration9_9.TM2NativeProfile.evaluateProgram⟩

theorem sum_range (f : ℕ→ℚ) (n : ℕ) :
    ((List.range n).map f).sum=∑i : Fin n,f i := by
  rw [Fin.sum_univ_eq_sum_range]
  induction n with
  | zero => simp
  | succ n ih => simp only [List.range_succ,List.map_append,List.sum_append,ih,List.map_singleton,List.sum_cons,List.sum_nil,add_zero,Finset.sum_range_succ]

theorem sum_flatMap {α : Type} (f : α→List ℚ) (xs : List α) :
    (xs.flatMap f).sum=(xs.map (fun a => (f a).sum)).sum := by
  induction xs with
  | nil => rfl
  | cons a xs ih => simp only [List.flatMap_cons,List.sum_append,ih,List.map_cons,List.sum_cons]



/-- The scalar support and the half-sized edge support are generated as unary buffers. -/
def scalarTicks (xs : List Unit) : List Unit := (_root_.Integration9_9.TM2NativeGaussianWindow.squareTicks xs).tail
@[fun_prop] theorem scalarTicks_poly : Poly _root_.Integration9_9.TM2NativeProfile.scalarTicks := by unfold _root_.Integration9_9.TM2NativeProfile.scalarTicks;fun_prop

def edgeTicks (xs : List Unit) : List Unit := (_root_.Integration9_9.TM2NativeProfile.scalarTicks xs).take ((_root_.Integration9_9.TM2NativeProfile.scalarTicks xs).length/2)
noncomputable def edgeTicksProgram : PolyProgram _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode _root_.Integration9_9.TM2NativeProfile.edgeTicks := by
  let count := ((_root_.Integration9_9.TM2NativeProfile.scalarTicks_poly.program.comp (PolyProgram.listLength _root_.Integration9_9.TM2NativeFiniteSeries.unitCode ())).fanout
    (PolyProgram.constant _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode Nat.bits 2)).comp PolyProgram.natDiv
  exact (_root_.Integration9_9.TM2NativeProfile.scalarTicks_poly.program.fanout count).comp (PolyProgram.listTake _root_.Integration9_9.TM2NativeFiniteSeries.unitCode ())
@[fun_prop] theorem edgeTicks_poly : Poly _root_.Integration9_9.TM2NativeProfile.edgeTicks := ⟨_root_.Integration9_9.TM2NativeProfile.edgeTicksProgram⟩

def widthTicks (xs : List Unit) : List Unit := _root_.Integration9_9.TM2NativePrime.powerSlots 48 (_root_.Integration9_9.TM2NativeGaussianWindow.baseTicks xs)
@[fun_prop] theorem widthTicks_poly : Poly _root_.Integration9_9.TM2NativeProfile.widthTicks := by unfold _root_.Integration9_9.TM2NativeProfile.widthTicks;fun_prop

theorem scalarTicks_length (xs : List Unit) : (_root_.Integration9_9.TM2NativeProfile.scalarTicks xs).length=(xs.length+2)^2-1 := by
  simp only [_root_.Integration9_9.TM2NativeProfile.scalarTicks,List.length_tail,_root_.Integration9_9.TM2NativeGaussianWindow.squareTicks_length]
theorem edgeTicks_length (xs : List Unit) : (_root_.Integration9_9.TM2NativeProfile.edgeTicks xs).length=((xs.length+2)^2-1)/2 := by
  simp only [_root_.Integration9_9.TM2NativeProfile.edgeTicks,List.length_take,_root_.Integration9_9.TM2NativeProfile.scalarTicks_length,Nat.min_eq_left (Nat.div_le_self _ _)]
theorem widthTicks_length (xs : List Unit) : (_root_.Integration9_9.TM2NativeProfile.widthTicks xs).length=(xs.length+2)^48 := by
  simp only [_root_.Integration9_9.TM2NativeProfile.widthTicks,_root_.Integration9_9.TM2NativePrime.powerSlots_length,_root_.Integration9_9.TM2NativeGaussianWindow.baseTicks,List.length_cons]

abbrev Request := (List Unit×List Unit)×(Bool×ℕ)


def edgeRequest (x : _root_.Integration9_9.TM2NativeProfile.Request) : _root_.Integration9_9.TM2NativeGaussianWindow.Request := ((x.1.1,_root_.Integration9_9.TM2NativeProfile.edgeTicks x.1.1),x.1.2)
def scalarRequest (x : _root_.Integration9_9.TM2NativeProfile.Request) : _root_.Integration9_9.TM2NativeGaussianWindow.Request := ((x.1.1,_root_.Integration9_9.TM2NativeProfile.scalarTicks x.1.1),x.1.2)
@[fun_prop] theorem edgeRequest_poly : Poly _root_.Integration9_9.TM2NativeProfile.edgeRequest := by unfold _root_.Integration9_9.TM2NativeProfile.edgeRequest;fun_prop
@[fun_prop] theorem scalarRequest_poly : Poly _root_.Integration9_9.TM2NativeProfile.scalarRequest := by unfold _root_.Integration9_9.TM2NativeProfile.scalarRequest;fun_prop

def context (x : _root_.Integration9_9.TM2NativeProfile.Request) : _root_.Integration9_9.TM2NativeProfile.Context :=
  ((_root_.Integration9_9.TM2NativePrime.modulus x.1.1,(_root_.Integration9_9.TM2NativeProfile.widthTicks x.1.1,x.2.1)),
    ((_root_.Integration9_9.TM2NativeGaussianWindow.current (_root_.Integration9_9.TM2NativeProfile.edgeRequest x),_root_.Integration9_9.TM2NativeGaussianWindow.current (_root_.Integration9_9.TM2NativeProfile.scalarRequest x)),x.2.2))
@[fun_prop] theorem context_poly : Poly _root_.Integration9_9.TM2NativeProfile.context := by unfold _root_.Integration9_9.TM2NativeProfile.context;fun_prop

def current (x : _root_.Integration9_9.TM2NativeProfile.Request) : ℚ := _root_.Integration9_9.TM2NativeProfile.evaluate (_root_.Integration9_9.TM2NativeProfile.context x)
@[fun_prop] theorem current_poly : Poly _root_.Integration9_9.TM2NativeProfile.current := by unfold _root_.Integration9_9.TM2NativeProfile.current;fun_prop


theorem edgeCutoff (x : _root_.Integration9_9.TM2NativeProfile.Request) : _root_.Integration9_9.TM2NativeGaussianWindow.cutoff (_root_.Integration9_9.TM2NativeProfile.edgeRequest x)=((x.1.1.length+2)^2-1)/2 := by
  simp only [_root_.Integration9_9.TM2NativeGaussianWindow.cutoff,_root_.Integration9_9.TM2NativeProfile.edgeRequest,_root_.Integration9_9.TM2NativeProfile.edgeTicks_length]
  apply Nat.min_eq_left
  exact (Nat.div_le_self _ _).trans (Nat.sub_le _ _)
theorem scalarCutoff (x : _root_.Integration9_9.TM2NativeProfile.Request) : _root_.Integration9_9.TM2NativeGaussianWindow.cutoff (_root_.Integration9_9.TM2NativeProfile.scalarRequest x)=(x.1.1.length+2)^2-1 := by
  simp only [_root_.Integration9_9.TM2NativeGaussianWindow.cutoff,_root_.Integration9_9.TM2NativeProfile.scalarRequest,_root_.Integration9_9.TM2NativeProfile.scalarTicks_length]
  exact Nat.min_eq_left (Nat.sub_le _ _)

def gaussianList (security cutoff bits : ℕ) : List ℚ := List.ofFn
  (fun i : Fin (2*cutoff+1) => _root_.AFT.RationalNumerics.windowGaussianWeights (_root_.CurrentAFT.WindowGaussianSampler.squaredWidth security) cutoff bits i)

theorem window_semantics (x : _root_.Integration9_9.TM2NativeGaussianWindow.Request) :
    _root_.Integration9_9.TM2NativeGaussianWindow.current x=_root_.Integration9_9.TM2NativeProfile.gaussianList x.1.1.length (_root_.Integration9_9.TM2NativeGaussianWindow.cutoff x) x.2.length := by
  rw [_root_.Integration9_9.TM2NativeGaussianWindow.current_eq]
  apply congrArg List.ofFn
  funext i
  exact _root_.CurrentAFT.CurrentGaussianBits.table_value x.1.1.length (_root_.Integration9_9.TM2NativeGaussianWindow.cutoff x) x.2.length i

 theorem _root_.Integration9_9.TM2NativeProfile.generatedContext (x : _root_.Integration9_9.TM2NativeProfile.Request) : _root_.Integration9_9.TM2NativeProfile.context x=
  ((_root_.Integration9_9.TM2NativePrime.modulus x.1.1,(_root_.Integration9_9.TM2NativeProfile.widthTicks x.1.1,x.2.1)),
    ((_root_.Integration9_9.TM2NativeProfile.gaussianList x.1.1.length (((x.1.1.length+2)^2-1)/2) x.1.2.length,
      _root_.Integration9_9.TM2NativeProfile.gaussianList x.1.1.length ((x.1.1.length+2)^2-1) x.1.2.length),x.2.2)) := by
  simp only [_root_.Integration9_9.TM2NativeProfile.context,_root_.Integration9_9.TM2NativeProfile.window_semantics,_root_.Integration9_9.TM2NativeProfile.edgeCutoff,_root_.Integration9_9.TM2NativeProfile.scalarCutoff]
  rfl

 theorem _root_.Integration9_9.TM2NativeProfile.evaluate_gaussian (security edge scalar bits colors : ℕ) (width : List Unit) (positive : Bool) (output : ℕ) :
    _root_.Integration9_9.TM2NativeProfile.evaluate ((colors,(width,positive)),((_root_.Integration9_9.TM2NativeProfile.gaussianList security edge bits,_root_.Integration9_9.TM2NativeProfile.gaussianList security scalar bits),output)) =
    (_root_.CurrentAFT.BinaryProfileProgram.evaluate security colors width.length edge scalar bits positive (_root_.AFT.BinaryArithmetic.canonicalCounter output).digits).data.decode := by
  rw [_root_.CurrentAFT.BinaryProfileProgram.evaluate,_root_.CurrentAFT.BinarySeedAverage.evaluate_value]
  unfold _root_.Integration9_9.TM2NativeProfile.evaluate _root_.Integration9_9.TM2NativeProfile.seeds _root_.Integration9_9.TM2NativeProfile.edgeIndices _root_.Integration9_9.TM2NativeProfile.scalarIndices
  dsimp only [_root_.Integration9_9.TM2NativeProfile.gaussianList]
  simp only [List.length_ofFn,List.map_flatMap,_root_.Integration9_9.TM2NativeProfile.sum_flatMap,List.map_map,Function.comp_def]
  simp_rw [_root_.Integration9_9.TM2NativeProfile.sum_range]
  apply Finset.sum_congr rfl
  intro l _
  apply Finset.sum_congr rfl
  intro r _
  apply Finset.sum_congr rfl
  intro s _
  have hl := l.isLt
  have hr := r.isLt
  have hs := s.isLt
  simp only [_root_.Integration9_9.TM2NativeProfile.term,_root_.Integration9_9.TM2NativeProfile.kernelRequest,_root_.Integration9_9.TM2NativeAveragedSlice.profileValue,
    List.length_ofFn,List.getElem?_ofFn,hl,hr,hs,↓reduceDIte,Option.getD_some,
    _root_.CurrentAFT.BinaryProfileKernel.current_value,_root_.AFT.BinaryArithmetic.canonicalCounter_value]
  congr 3
  omega

theorem current_value (x : _root_.Integration9_9.TM2NativeProfile.Request) :
    _root_.Integration9_9.TM2NativeProfile.current x=(_root_.CurrentAFT.BinaryProfileProgram.current x.1.1.length x.1.2.length x.2.1 (_root_.AFT.BinaryArithmetic.canonicalCounter x.2.2).digits).data.decode := by
  rw [_root_.Integration9_9.TM2NativeProfile.current,_root_.Integration9_9.TM2NativeProfile.generatedContext,_root_.Integration9_9.TM2NativeProfile.evaluate_gaussian]
  rcases _root_.CurrentAFT.BinaryDiffuseCurrent.metadata_value x.1.1.length with ⟨hq,hw,he⟩
  rw [_root_.Integration9_9.TM2NativePrime.modulus_value,_root_.Integration9_9.TM2NativeProfile.widthTicks_length]
  conv_rhs => unfold _root_.CurrentAFT.BinaryProfileProgram.current
  change _ = (_root_.CurrentAFT.BinaryProfileProgram.evaluate x.1.1.length
    (_root_.CurrentAFT.BinaryDiffuseCurrent.metadata x.1.1.length).colors
    (_root_.CurrentAFT.BinaryDiffuseCurrent.metadata x.1.1.length).width
    (_root_.CurrentAFT.BinaryDiffuseCurrent.metadata x.1.1.length).cutoff
    (_root_.CurrentAFT.BinaryActivationProgram.cutoff x.1.1.length).count x.1.2.length x.2.1 (_root_.AFT.BinaryArithmetic.canonicalCounter x.2.2).digits).data.decode
  rw [hq,hw,he,_root_.CurrentAFT.BinaryActivationProgram.cutoff_value]








end Integration9_9.TM2NativeProfile

end

section


























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryMarkedKernel
end CurrentAFT.BinaryMarkedKernel
namespace CurrentAFT.BinaryMarkedKernel.average
end CurrentAFT.BinaryMarkedKernel.average
namespace CurrentAFT.BinaryMarkedKernel.coin
end CurrentAFT.BinaryMarkedKernel.coin
namespace CurrentAFT.BinaryMarkedKernel.point
end CurrentAFT.BinaryMarkedKernel.point



set_option autoImplicit false
set_option maxHeartbeats 1200000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! Full unary-width marked anchor kernels. The runtime direction coin, signed
companion coordinate, clipping to Nat, both endpoint tests, width sum and fair
coin average are compiled by actual verified Boolean-stack machines. -/
namespace Integration9_9.TM2NativeMarkedKernel
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators

/-- Colors/width buffer, primary/source, endpoints/blur. -/
abbrev Request := (ℕ×List Unit)×((ℕ×ℤ)×((ℕ×ℕ)×ℤ))
abbrev requestCode : _root_.Integration9_9.TM2NativeMarkedKernel.Request→List Bool := Automatic.enc
abbrev CoinRequest := _root_.Integration9_9.TM2NativeMarkedKernel.Request×Bool
abbrev coinCode : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest→List Bool := Automatic.enc

@[fun_prop] theorem direction_poly : Poly (fun x : (ℕ×ℕ)×Bool =>
    _root_.CurrentAFT.LocalDiffuseProgram.direction x.1.1 x.1.2 x.2) := by
  unfold _root_.CurrentAFT.LocalDiffuseProgram.direction
  fun_prop

def direction (x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest) : Bool := _root_.CurrentAFT.LocalDiffuseProgram.direction x.1.1.1 x.1.2.1.1 x.2
@[fun_prop] theorem direction_comp_poly : Poly _root_.Integration9_9.TM2NativeMarkedKernel.direction := by
  exact Poly.comp (f := fun x : (ℕ×ℕ)×Bool => _root_.CurrentAFT.LocalDiffuseProgram.direction x.1.1 x.1.2 x.2)
    (g := fun x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest => ((x.1.1.1,x.1.2.1.1),x.2)) _root_.Integration9_9.TM2NativeMarkedKernel.direction_poly (by fun_prop)

def companion (x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest×ℕ) : ℤ :=
  (x.1.1.1.1 : ℤ)-1-x.1.1.2.1.1+
    (if _root_.Integration9_9.TM2NativeMarkedKernel.direction x.1 then (x.1.1.1.2.length : ℤ)+x.2 else -((x.1.1.1.2.length : ℤ)+x.2))+
    x.1.1.2.2.2-x.1.1.2.1.2
@[fun_prop] theorem companion_poly : Poly _root_.Integration9_9.TM2NativeMarkedKernel.companion := by unfold _root_.Integration9_9.TM2NativeMarkedKernel.companion;fun_prop

def term (x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest×ℕ) : ℚ :=
  if x.1.1.2.1.1=x.1.1.2.2.1.1 ∧ (_root_.Integration9_9.TM2NativeMarkedKernel.companion x).toNat=x.1.1.2.2.1.2 then 1 else 0
@[fun_prop] theorem term_poly : Poly _root_.Integration9_9.TM2NativeMarkedKernel.term := by unfold _root_.Integration9_9.TM2NativeMarkedKernel.term;fun_prop

def total (x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest) : ℚ := ((List.range x.1.1.2.length).map (fun i => _root_.Integration9_9.TM2NativeMarkedKernel.term (x,i))).sum
noncomputable def totalProgram : PolyProgram _root_.Integration9_9.TM2NativeMarkedKernel.coinCode Ratio.encode _root_.Integration9_9.TM2NativeMarkedKernel.total := by
  let widths : PolyProgram _root_.Integration9_9.TM2NativeMarkedKernel.coinCode _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode (fun x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest => x.1.1.2) :=
    (show Poly (fun x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest => x.1.1.2) by fun_prop).program
  let indices := widths.comp (PolyProgram.listIndices _root_.Integration9_9.TM2NativeFiniteSeries.unitCode ())
  exact ((((PolyProgram.identity _root_.Integration9_9.TM2NativeMarkedKernel.coinCode).fanout indices).comp (_root_.Integration9_9.TM2NativeMarkedKernel.term_poly.program.listMapWith 0 (0 : ℚ))).comp PolyProgram.ratSum)
@[fun_prop] theorem total_poly : Poly _root_.Integration9_9.TM2NativeMarkedKernel.total := ⟨_root_.Integration9_9.TM2NativeMarkedKernel.totalProgram⟩

def coin (x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest) : ℚ := (x.1.1.2.length : ℚ)⁻¹*_root_.Integration9_9.TM2NativeMarkedKernel.total x
@[fun_prop] theorem coin_poly : Poly _root_.Integration9_9.TM2NativeMarkedKernel.coin := by unfold _root_.Integration9_9.TM2NativeMarkedKernel.coin;fun_prop


theorem coin_value (x : _root_.Integration9_9.TM2NativeMarkedKernel.CoinRequest) : _root_.Integration9_9.TM2NativeMarkedKernel.coin x=_root_.CurrentAFT.LocalMarkedProgram.coinEntry x.1.1.1 x.1.1.2.length
    x.1.2.1.1 x.1.2.1.2 x.1.2.2.2 x.2 x.1.2.2.1.1 x.1.2.2.1.2 := by
  rw [_root_.Integration9_9.TM2NativeMarkedKernel.coin,_root_.Integration9_9.TM2NativeMarkedKernel.total,_root_.Integration9_9.TM2NativeProfile.sum_range]
  rfl

def current (x : _root_.Integration9_9.TM2NativeMarkedKernel.Request) : ℚ := (_root_.Integration9_9.TM2NativeMarkedKernel.coin (x,true)+_root_.Integration9_9.TM2NativeMarkedKernel.coin (x,false))/2
@[fun_prop] theorem current_poly : Poly _root_.Integration9_9.TM2NativeMarkedKernel.current := by unfold _root_.Integration9_9.TM2NativeMarkedKernel.current;fun_prop
noncomputable def currentProgram : PolyProgram _root_.Integration9_9.TM2NativeMarkedKernel.requestCode Ratio.encode _root_.Integration9_9.TM2NativeMarkedKernel.current := _root_.Integration9_9.TM2NativeMarkedKernel.current_poly.program

theorem current_value (x : _root_.Integration9_9.TM2NativeMarkedKernel.Request) : _root_.Integration9_9.TM2NativeMarkedKernel.current x=_root_.CurrentAFT.LocalMarkedProgram.blurEntry x.1.1 x.1.2.length
    x.2.1.1 x.2.1.2 x.2.2.1.1 x.2.2.1.2 x.2.2.2 := by
  rw [_root_.Integration9_9.TM2NativeMarkedKernel.current,_root_.Integration9_9.TM2NativeMarkedKernel.coin_value,_root_.Integration9_9.TM2NativeMarkedKernel.coin_value]
  rfl






end Integration9_9.TM2NativeMarkedKernel

end

section



























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryAnchorTable
end CurrentAFT.BinaryAnchorTable
namespace CurrentAFT.BinaryAnchorTable.anchor_height
end CurrentAFT.BinaryAnchorTable.anchor_height
namespace CurrentAFT.BinaryAnchorTable.current
end CurrentAFT.BinaryAnchorTable.current
namespace CurrentAFT.BinaryAnchorTable.currentHeightPolynomial
end CurrentAFT.BinaryAnchorTable.currentHeightPolynomial
namespace CurrentAFT.BinaryAnchorTable.currentWorkPolynomial
end CurrentAFT.BinaryAnchorTable.currentWorkPolynomial
namespace CurrentAFT.BinaryAnchorTable.point
end CurrentAFT.BinaryAnchorTable.point
namespace CurrentAFT.BinaryAnchorTable.pointHeightPolynomial
end CurrentAFT.BinaryAnchorTable.pointHeightPolynomial
namespace CurrentAFT.BinaryWindowAverage
end CurrentAFT.BinaryWindowAverage
namespace CurrentAFT.BinaryWindowAverage.sumHeight
end CurrentAFT.BinaryWindowAverage.sumHeight




set_option autoImplicit false
set_option maxHeartbeats 1500000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! Complete current anchor entries and matrices. The prime, unary anchor
width, scalar Gaussian table, full marked-kernel width loops and all matrix
coordinates are generated by actual finite Boolean-stack programs. -/
namespace Integration9_9.TM2NativeAnchor
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators
attribute [local irreducible] CurrentAFT.BinaryAnchorProgram.current CurrentAFT.BinaryAnchorProgram.evaluate
  CurrentAFT.BinaryDiffuseCurrent.metadata TM2NativePrime.modulus TM2NativePrime.upperSlots

abbrev Context := (ℕ×(List Unit×ℕ))×(List ℚ×ℕ)
abbrev contextCode : _root_.Integration9_9.TM2NativeAnchor.Context→List Bool := Automatic.enc

@[fun_prop] theorem marked_poly : Poly _root_.Integration9_9.TM2NativeMarkedKernel.current := ⟨_root_.Integration9_9.TM2NativeMarkedKernel.currentProgram⟩

def kernelRequest (x : _root_.Integration9_9.TM2NativeAnchor.Context×ℕ) : _root_.Integration9_9.TM2NativeMarkedKernel.Request :=
  ((x.1.1.1,x.1.1.2.1),((x.1.1.2.2,-((x.2 : ℤ)-(x.1.2.1.length/2 : ℕ))),((x.1.1.2.2,x.1.2.2),(0 : ℤ))))
@[fun_prop] theorem kernelRequest_poly : Poly _root_.Integration9_9.TM2NativeAnchor.kernelRequest := by unfold _root_.Integration9_9.TM2NativeAnchor.kernelRequest;fun_prop

def term (x : _root_.Integration9_9.TM2NativeAnchor.Context×ℕ) : ℚ := x.1.2.1[x.2]?.getD 0 * _root_.Integration9_9.TM2NativeMarkedKernel.current (_root_.Integration9_9.TM2NativeAnchor.kernelRequest x)
@[fun_prop] theorem term_poly : Poly _root_.Integration9_9.TM2NativeAnchor.term := by unfold _root_.Integration9_9.TM2NativeAnchor.term;fun_prop

def evaluate (x : _root_.Integration9_9.TM2NativeAnchor.Context) : ℚ := ((List.range x.2.1.length).map (fun i => _root_.Integration9_9.TM2NativeAnchor.term (x,i))).sum
noncomputable def evaluateProgram : PolyProgram _root_.Integration9_9.TM2NativeAnchor.contextCode Ratio.encode _root_.Integration9_9.TM2NativeAnchor.evaluate := by
  let indices : PolyProgram _root_.Integration9_9.TM2NativeAnchor.contextCode (encodeList Nat.bits) (fun x : _root_.Integration9_9.TM2NativeAnchor.Context => List.range x.2.1.length) :=
    (show Poly (fun x : _root_.Integration9_9.TM2NativeAnchor.Context => List.range x.2.1.length) from Poly.comp
      (f := fun xs : List ℚ => List.range xs.length) (g := fun x : _root_.Integration9_9.TM2NativeAnchor.Context => x.2.1)
      (Poly.list_indices (α := ℚ)) (by fun_prop)).program
  exact ((((PolyProgram.identity _root_.Integration9_9.TM2NativeAnchor.contextCode).fanout indices).comp (_root_.Integration9_9.TM2NativeAnchor.term_poly.program.listMapWith 0 (0 : ℚ))).comp PolyProgram.ratSum)
@[fun_prop] theorem evaluate_poly : Poly _root_.Integration9_9.TM2NativeAnchor.evaluate := ⟨_root_.Integration9_9.TM2NativeAnchor.evaluateProgram⟩

abbrev Request := (List Unit×List Unit)×(ℕ×ℕ)
abbrev requestCode : _root_.Integration9_9.TM2NativeAnchor.Request→List Bool := Automatic.enc

def gaussianRequest (x : _root_.Integration9_9.TM2NativeAnchor.Request) : _root_.Integration9_9.TM2NativeGaussianWindow.Request := ((x.1.1,_root_.Integration9_9.TM2NativeProfile.scalarTicks x.1.1),x.1.2)
@[fun_prop] theorem gaussianRequest_poly : Poly _root_.Integration9_9.TM2NativeAnchor.gaussianRequest := by unfold _root_.Integration9_9.TM2NativeAnchor.gaussianRequest;fun_prop

def context (x : _root_.Integration9_9.TM2NativeAnchor.Request) : _root_.Integration9_9.TM2NativeAnchor.Context :=
  ((_root_.Integration9_9.TM2NativePrime.modulus x.1.1,(_root_.Integration9_9.TM2NativeProfile.widthTicks x.1.1,x.2.1)),
    (_root_.Integration9_9.TM2NativeGaussianWindow.current (_root_.Integration9_9.TM2NativeAnchor.gaussianRequest x),x.2.2))
@[fun_prop] theorem context_poly : Poly _root_.Integration9_9.TM2NativeAnchor.context := by unfold _root_.Integration9_9.TM2NativeAnchor.context;fun_prop

def current (x : _root_.Integration9_9.TM2NativeAnchor.Request) : ℚ := _root_.Integration9_9.TM2NativeAnchor.evaluate (_root_.Integration9_9.TM2NativeAnchor.context x)
@[fun_prop] theorem current_poly : Poly _root_.Integration9_9.TM2NativeAnchor.current := by unfold _root_.Integration9_9.TM2NativeAnchor.current;fun_prop
noncomputable def currentProgram : PolyProgram _root_.Integration9_9.TM2NativeAnchor.requestCode Ratio.encode _root_.Integration9_9.TM2NativeAnchor.current := _root_.Integration9_9.TM2NativeAnchor.current_poly.program

 theorem _root_.Integration9_9.TM2NativeAnchor.generatedContext (x : _root_.Integration9_9.TM2NativeAnchor.Request) : _root_.Integration9_9.TM2NativeAnchor.context x=
  ((_root_.Integration9_9.TM2NativePrime.modulus x.1.1,(_root_.Integration9_9.TM2NativeProfile.widthTicks x.1.1,x.2.1)),
    (_root_.Integration9_9.TM2NativeProfile.gaussianList x.1.1.length ((x.1.1.length+2)^2-1) x.1.2.length,x.2.2)) := by
  have hc : _root_.Integration9_9.TM2NativeGaussianWindow.cutoff (_root_.Integration9_9.TM2NativeAnchor.gaussianRequest x)=(x.1.1.length+2)^2-1 := by
    simp only [_root_.Integration9_9.TM2NativeGaussianWindow.cutoff,_root_.Integration9_9.TM2NativeAnchor.gaussianRequest,_root_.Integration9_9.TM2NativeProfile.scalarTicks_length]
    exact Nat.min_eq_left (Nat.sub_le _ _)
  simp only [_root_.Integration9_9.TM2NativeAnchor.context,_root_.Integration9_9.TM2NativeProfile.window_semantics,hc]
  rfl

 theorem _root_.Integration9_9.TM2NativeAnchor.evaluate_gaussian (security cutoff bits colors : ℕ) (width : List Unit) (primary output : ℕ) :
    _root_.Integration9_9.TM2NativeAnchor.evaluate ((colors,(width,primary)),(_root_.Integration9_9.TM2NativeProfile.gaussianList security cutoff bits,output)) =
    (_root_.CurrentAFT.BinaryAnchorProgram.evaluate security colors width.length cutoff bits primary (_root_.AFT.BinaryArithmetic.canonicalCounter output).digits).data.decode := by
  rw [_root_.CurrentAFT.BinaryAnchorProgram.evaluate,_root_.CurrentAFT.BinaryWindowAverage.evaluate_value]
  unfold _root_.Integration9_9.TM2NativeAnchor.evaluate
  dsimp only [_root_.Integration9_9.TM2NativeProfile.gaussianList]
  simp only [List.length_ofFn]
  rw [_root_.Integration9_9.TM2NativeProfile.sum_range]
  apply Finset.sum_congr rfl
  intro i _
  have hi:=i.isLt
  have hd : (2*cutoff+1)/2=cutoff := by omega
  simp only [_root_.Integration9_9.TM2NativeAnchor.term,_root_.Integration9_9.TM2NativeAnchor.kernelRequest,_root_.Integration9_9.TM2NativeMarkedKernel.current_value,List.length_ofFn,List.getElem?_ofFn,
    hi,↓reduceDIte,Option.getD_some,hd,_root_.CurrentAFT.BinaryAnchorProgram.atIndex_value,_root_.AFT.BinaryArithmetic.canonicalCounter_value,
    _root_.CurrentAFT.RationalProposalProgram.anchorKernel]

theorem current_value (x : _root_.Integration9_9.TM2NativeAnchor.Request) : _root_.Integration9_9.TM2NativeAnchor.current x=
    (_root_.CurrentAFT.BinaryAnchorProgram.current x.1.1.length x.1.2.length x.2.1 (_root_.AFT.BinaryArithmetic.canonicalCounter x.2.2).digits).data.decode := by
  rw [_root_.Integration9_9.TM2NativeAnchor.current,_root_.Integration9_9.TM2NativeAnchor.generatedContext,_root_.Integration9_9.TM2NativeAnchor.evaluate_gaussian,_root_.Integration9_9.TM2NativePrime.modulus_value,_root_.Integration9_9.TM2NativeProfile.widthTicks_length]
  rcases _root_.CurrentAFT.BinaryDiffuseCurrent.metadata_value x.1.1.length with ⟨hq,hw,he⟩
  conv_rhs => unfold _root_.CurrentAFT.BinaryAnchorProgram.current
  change _=(_root_.CurrentAFT.BinaryAnchorProgram.evaluate x.1.1.length
    (_root_.CurrentAFT.BinaryDiffuseCurrent.metadata x.1.1.length).colors
    (_root_.CurrentAFT.BinaryDiffuseCurrent.metadata x.1.1.length).width
    (_root_.CurrentAFT.BinaryActivationProgram.cutoff x.1.1.length).count x.1.2.length x.2.1 (_root_.AFT.BinaryArithmetic.canonicalCounter x.2.2).digits).data.decode
  rw [hq,hw,_root_.CurrentAFT.BinaryActivationProgram.cutoff_value]



abbrev TableRequest := List Unit×List Unit


def indices (x : _root_.Integration9_9.TM2NativeAnchor.TableRequest) : List ℕ := List.range (_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1).length
@[fun_prop] theorem indices_poly : Poly _root_.Integration9_9.TM2NativeAnchor.indices := by
  exact Poly.comp (f := fun xs : List Unit => List.range xs.length)
    (g := fun x : _root_.Integration9_9.TM2NativeAnchor.TableRequest => _root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1)
    (Poly.list_indices (α := Unit)) (by fun_prop)









end Integration9_9.TM2NativeAnchor

end

section



























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryBodyProgram
end CurrentAFT.BinaryBodyProgram
namespace CurrentAFT.BinaryBodyProgram.currentHeightPolynomial
end CurrentAFT.BinaryBodyProgram.currentHeightPolynomial
namespace CurrentAFT.BinaryBodyProgram.currentWorkPolynomial
end CurrentAFT.BinaryBodyProgram.currentWorkPolynomial
namespace CurrentAFT.BinaryBodyProgram.evaluate
end CurrentAFT.BinaryBodyProgram.evaluate
namespace CurrentAFT.BinaryBodyProgram.integerBound
end CurrentAFT.BinaryBodyProgram.integerBound
namespace CurrentAFT.BinaryBodyProgram.integerPolynomial
end CurrentAFT.BinaryBodyProgram.integerPolynomial
namespace CurrentAFT.BinaryBodyProgram.kernelHeight
end CurrentAFT.BinaryBodyProgram.kernelHeight
namespace CurrentAFT.BinaryBodyProgram.kernelHeightPolynomial
end CurrentAFT.BinaryBodyProgram.kernelHeightPolynomial
namespace CurrentAFT.BinaryBodyProgram.kernelWork
end CurrentAFT.BinaryBodyProgram.kernelWork
namespace CurrentAFT.BinaryBodyProgram.kernelWorkPolynomial
end CurrentAFT.BinaryBodyProgram.kernelWorkPolynomial
namespace CurrentAFT.BinaryBodyProgram.parameterPolynomial
end CurrentAFT.BinaryBodyProgram.parameterPolynomial
namespace CurrentAFT.BinaryBodyProgram.shiftWork
end CurrentAFT.BinaryBodyProgram.shiftWork
namespace CurrentAFT.BinaryBodyProgram.shiftWorkPolynomial
end CurrentAFT.BinaryBodyProgram.shiftWorkPolynomial




set_option autoImplicit false
set_option maxHeartbeats 1500000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! The full actual body reference law: generate the prime palette, margin,
edge/scalar Gaussian tables, then execute the three Gaussian seed loops and
the real finite palette residue kernel. -/
namespace Integration9_9.TM2NativeBody
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators
attribute [local irreducible] CurrentAFT.BinaryBodyProgram.current CurrentAFT.BinaryBodyProgram.evaluate
  CurrentAFT.BinaryDiffuseCurrent.metadata TM2NativePrime.modulus TM2NativePrime.upperSlots

abbrev Context := _root_.Integration9_9.TM2NativeProfile.Context
abbrev contextCode : _root_.Integration9_9.TM2NativeBody.Context→List Bool := Automatic.enc
abbrev Seed := _root_.Integration9_9.TM2NativeProfile.Seed

@[fun_prop] theorem bodyKernel_poly : Poly _root_.Integration9_9.TM2NativeBodyKernel.current := ⟨_root_.Integration9_9.TM2NativeBodyKernel.currentProgram⟩

def kernelRequest (x : _root_.Integration9_9.TM2NativeBody.Context×_root_.Integration9_9.TM2NativeBody.Seed) : _root_.Integration9_9.TM2NativeBodyKernel.Context :=
  ((x.1.1.2.1,x.1.1.1),
    (((x.2.1.1 : ℤ)-x.2.1.2 + if x.1.1.2.2 then
      (x.2.2 : ℤ)-(x.1.2.1.2.length/2 : ℕ) else 0),x.1.2.2))
@[fun_prop] theorem kernelRequest_poly : Poly _root_.Integration9_9.TM2NativeBody.kernelRequest := by unfold _root_.Integration9_9.TM2NativeBody.kernelRequest;fun_prop

def term (x : _root_.Integration9_9.TM2NativeBody.Context×_root_.Integration9_9.TM2NativeBody.Seed) : ℚ :=
  x.1.2.1.1[x.2.1.1]?.getD 0 * x.1.2.1.1[x.2.1.2]?.getD 0 *
    x.1.2.1.2[x.2.2]?.getD 0 * _root_.Integration9_9.TM2NativeBodyKernel.current (_root_.Integration9_9.TM2NativeBody.kernelRequest x)
@[fun_prop] theorem term_poly : Poly _root_.Integration9_9.TM2NativeBody.term := by unfold _root_.Integration9_9.TM2NativeBody.term;fun_prop

def evaluate (c : _root_.Integration9_9.TM2NativeBody.Context) : ℚ := ((_root_.Integration9_9.TM2NativeProfile.seeds c).map (fun s => _root_.Integration9_9.TM2NativeBody.term (c,s))).sum
noncomputable def evaluateProgram : PolyProgram _root_.Integration9_9.TM2NativeBody.contextCode Ratio.encode _root_.Integration9_9.TM2NativeBody.evaluate :=
  ((((PolyProgram.identity _root_.Integration9_9.TM2NativeBody.contextCode).fanout _root_.Integration9_9.TM2NativeProfile.seeds_poly.program).comp
    (_root_.Integration9_9.TM2NativeBody.term_poly.program.listMapWith ((0,0),0) (0 : ℚ))).comp PolyProgram.ratSum)
@[fun_prop] theorem evaluate_poly : Poly _root_.Integration9_9.TM2NativeBody.evaluate := ⟨_root_.Integration9_9.TM2NativeBody.evaluateProgram⟩

abbrev Request := _root_.Integration9_9.TM2NativeProfile.Request


def margin (xs : List Unit) : ℕ := 3*(xs.length+2)*(xs.length+2)
@[fun_prop] theorem margin_poly : Poly _root_.Integration9_9.TM2NativeBody.margin := by unfold _root_.Integration9_9.TM2NativeBody.margin;fun_prop

theorem margin_value (xs : List Unit) : _root_.Integration9_9.TM2NativeBody.margin xs=3*(xs.length+2)^2 := by unfold _root_.Integration9_9.TM2NativeBody.margin;ring

def context (x : _root_.Integration9_9.TM2NativeBody.Request) : _root_.Integration9_9.TM2NativeBody.Context :=
  ((_root_.Integration9_9.TM2NativeBody.margin x.1.1,(_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1.1,x.2.1)),
    ((_root_.Integration9_9.TM2NativeGaussianWindow.current (_root_.Integration9_9.TM2NativeProfile.edgeRequest x),
      _root_.Integration9_9.TM2NativeGaussianWindow.current (_root_.Integration9_9.TM2NativeProfile.scalarRequest x)),x.2.2))
@[fun_prop] theorem context_poly : Poly _root_.Integration9_9.TM2NativeBody.context := by unfold _root_.Integration9_9.TM2NativeBody.context;fun_prop

def current (x : _root_.Integration9_9.TM2NativeBody.Request) : ℚ := _root_.Integration9_9.TM2NativeBody.evaluate (_root_.Integration9_9.TM2NativeBody.context x)
@[fun_prop] theorem current_poly : Poly _root_.Integration9_9.TM2NativeBody.current := by unfold _root_.Integration9_9.TM2NativeBody.current;fun_prop


 theorem _root_.Integration9_9.TM2NativeBody.generatedContext (x : _root_.Integration9_9.TM2NativeBody.Request) : _root_.Integration9_9.TM2NativeBody.context x=
  ((_root_.Integration9_9.TM2NativeBody.margin x.1.1,(_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1.1,x.2.1)),
    ((_root_.Integration9_9.TM2NativeProfile.gaussianList x.1.1.length (((x.1.1.length+2)^2-1)/2) x.1.2.length,
      _root_.Integration9_9.TM2NativeProfile.gaussianList x.1.1.length ((x.1.1.length+2)^2-1) x.1.2.length),x.2.2)) := by
  simp only [_root_.Integration9_9.TM2NativeBody.context,_root_.Integration9_9.TM2NativeProfile.window_semantics,_root_.Integration9_9.TM2NativeProfile.edgeCutoff,_root_.Integration9_9.TM2NativeProfile.scalarCutoff]
  rfl

 theorem _root_.Integration9_9.TM2NativeBody.evaluate_gaussian (security edge scalar bits : ℕ) (palette : List Unit) (margin : ℕ)
    (includeScalar : Bool) (output : ℕ) (hq : 0<palette.length) :
    _root_.Integration9_9.TM2NativeBody.evaluate ((margin,(palette,includeScalar)),
      ((_root_.Integration9_9.TM2NativeProfile.gaussianList security edge bits,_root_.Integration9_9.TM2NativeProfile.gaussianList security scalar bits),output)) =
    (_root_.CurrentAFT.BinaryBodyProgram.evaluate security palette.length margin edge scalar bits includeScalar
      (_root_.AFT.BinaryArithmetic.canonicalCounter output).digits).data.decode := by
  rw [_root_.CurrentAFT.BinaryBodyProgram.evaluate,_root_.CurrentAFT.BinarySeedAverage.evaluate_value]
  unfold _root_.Integration9_9.TM2NativeBody.evaluate _root_.Integration9_9.TM2NativeProfile.seeds _root_.Integration9_9.TM2NativeProfile.edgeIndices _root_.Integration9_9.TM2NativeProfile.scalarIndices
  dsimp only [_root_.Integration9_9.TM2NativeProfile.gaussianList]
  simp only [List.length_ofFn,List.map_flatMap,_root_.Integration9_9.TM2NativeProfile.sum_flatMap,List.map_map,Function.comp_def]
  simp_rw [_root_.Integration9_9.TM2NativeProfile.sum_range]
  apply Finset.sum_congr rfl
  intro l _
  apply Finset.sum_congr rfl
  intro r _
  apply Finset.sum_congr rfl
  intro s _
  have hl:=l.isLt
  have hr:=r.isLt
  have hs:=s.isLt
  rw [_root_.CurrentAFT.BinaryBodyProgram.kernel_value palette.length margin edge scalar includeScalar
    (_root_.AFT.BinaryArithmetic.canonicalCounter output).digits l r s hq]
  have hd : (2*scalar+1)/2=scalar := by omega
  simp only [_root_.Integration9_9.TM2NativeBody.term,_root_.Integration9_9.TM2NativeBody.kernelRequest,_root_.Integration9_9.TM2NativeBodyKernel.current_value,List.length_ofFn,List.getElem?_ofFn,hd,
    hl,hr,hs,↓reduceDIte,Option.getD_some,_root_.AFT.BinaryArithmetic.canonicalCounter_value]


theorem current_value (x : _root_.Integration9_9.TM2NativeBody.Request) : _root_.Integration9_9.TM2NativeBody.current x=
    (_root_.CurrentAFT.BinaryBodyProgram.current x.1.1.length x.1.2.length x.2.1 (_root_.AFT.BinaryArithmetic.canonicalCounter x.2.2).digits).data.decode := by
  have hp : 0<(_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1.1).length := by
    rw [_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks_length]
    exact (_root_.CurrentAFT.Parameters.modulus_spec x.1.1.length).2.pos
  rw [_root_.Integration9_9.TM2NativeBody.current,_root_.Integration9_9.TM2NativeBody.generatedContext,_root_.Integration9_9.TM2NativeBody.evaluate_gaussian _ _ _ _ _ _ _ _ hp]
  rw [_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks_length,_root_.Integration9_9.TM2NativeBody.margin_value]
  rcases _root_.CurrentAFT.BinaryDiffuseCurrent.metadata_value x.1.1.length with ⟨hq,hw,he⟩
  conv_rhs => unfold _root_.CurrentAFT.BinaryBodyProgram.current
  change _=(_root_.CurrentAFT.BinaryBodyProgram.evaluate x.1.1.length
    (_root_.CurrentAFT.BinaryDiffuseCurrent.metadata x.1.1.length).colors
    (_root_.AFT.BinaryArithmetic.multiplyCounter 3 (_root_.AFT.BinaryArithmetic.addCounter (_root_.CurrentAFT.BinaryActivationProgram.cutoff x.1.1.length).count 1).count).count
    (_root_.CurrentAFT.BinaryDiffuseCurrent.metadata x.1.1.length).cutoff
    (_root_.CurrentAFT.BinaryActivationProgram.cutoff x.1.1.length).count x.1.2.length x.2.1 (_root_.AFT.BinaryArithmetic.canonicalCounter x.2.2).digits).data.decode
  rw [hq,he,_root_.CurrentAFT.BinaryBodyProgram.margin_value,_root_.CurrentAFT.BinaryActivationProgram.cutoff_value]







end Integration9_9.TM2NativeBody

end

section






























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryPrimaryTable
end CurrentAFT.BinaryPrimaryTable
namespace CurrentAFT.BinaryPrimaryTable.countPolynomial
end CurrentAFT.BinaryPrimaryTable.countPolynomial
namespace CurrentAFT.BinaryPrimaryTable.currentHeightPolynomial
end CurrentAFT.BinaryPrimaryTable.currentHeightPolynomial
namespace CurrentAFT.BinaryPrimaryTable.currentWorkPolynomial
end CurrentAFT.BinaryPrimaryTable.currentWorkPolynomial
namespace CurrentAFT.BinaryPrimaryTable.guardWorkPolynomial
end CurrentAFT.BinaryPrimaryTable.guardWorkPolynomial
namespace CurrentAFT.BinaryPrimaryTable.point
end CurrentAFT.BinaryPrimaryTable.point
namespace CurrentAFT.BinaryPrimaryTable.raw
end CurrentAFT.BinaryPrimaryTable.raw
namespace CurrentAFT.BinaryPrimaryTable.rawWorkPolynomial
end CurrentAFT.BinaryPrimaryTable.rawWorkPolynomial
namespace CurrentAFT.BinaryProfileTables
end CurrentAFT.BinaryProfileTables
namespace CurrentAFT.BinaryProfileTables.diffuse
end CurrentAFT.BinaryProfileTables.diffuse
namespace CurrentAFT.BinaryProfileTables.diffuseHeightPolynomial
end CurrentAFT.BinaryProfileTables.diffuseHeightPolynomial
namespace CurrentAFT.BinaryProfileTables.diffuseWorkPolynomial
end CurrentAFT.BinaryProfileTables.diffuseWorkPolynomial
namespace CurrentAFT.BinaryProfileTables.sign
end CurrentAFT.BinaryProfileTables.sign
namespace CurrentAFT.BinaryProfileTables.signHeightPolynomial
end CurrentAFT.BinaryProfileTables.signHeightPolynomial
namespace CurrentAFT.BinaryProfileTables.signWorkPolynomial
end CurrentAFT.BinaryProfileTables.signWorkPolynomial
namespace CurrentAFT.BinaryProposalGuard
end CurrentAFT.BinaryProposalGuard
namespace CurrentAFT.BinaryProposalGuard.lowerCheckWork
end CurrentAFT.BinaryProposalGuard.lowerCheckWork
namespace CurrentAFT.BinaryProposalGuard.uniformWork
end CurrentAFT.BinaryProposalGuard.uniformWork
namespace CurrentAFT.RationalFirstResponseProgram
end CurrentAFT.RationalFirstResponseProgram
namespace CurrentAFT.RationalFirstResponseProgram.profile
end CurrentAFT.RationalFirstResponseProgram.profile
namespace CurrentAFT.RationalFirstResponseProgram.signProfile
end CurrentAFT.RationalFirstResponseProgram.signProfile
namespace CurrentAFT.RationalProposalProgram
end CurrentAFT.RationalProposalProgram
namespace CurrentAFT.RationalProposalProgram.diffuse
end CurrentAFT.RationalProposalProgram.diffuse





set_option autoImplicit false
set_option maxHeartbeats 1800000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! Full current primary proposal. Every balancing input is generated from
the security/precision buffers. The entire palette is then checked against
its rational lower guard, with an actual uniform fallback on failure. -/
namespace Integration9_9.TM2NativePrimary
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators
attribute [local irreducible] TM2NativePrime.modulus TM2NativePrime.upperSlots

@[fun_prop] theorem nat_pow_poly (k : ℕ) : Poly (fun n : ℕ => n^k) := by
  induction k with
  | zero => simpa only [pow_zero] using (Automatic.Poly.const (α := ℕ) (1 : ℕ))
  | succ k ih =>
    change Poly (fun n : ℕ => n^k*n)
    fun_prop
@[fun_prop] theorem activation_poly : Poly _root_.Integration9_9.TM2NativeActivation.current := ⟨_root_.Integration9_9.TM2NativeActivation.currentProgram⟩

abbrev Request := (List Unit×List Unit)×ℕ


def colors (x : _root_.Integration9_9.TM2NativePrimary.Request) : ℕ := _root_.Integration9_9.TM2NativePrime.modulus x.1.1
def legs (x : _root_.Integration9_9.TM2NativePrimary.Request) : ℕ := (x.1.1.length+2)^128
def population (x : _root_.Integration9_9.TM2NativePrimary.Request) : ℕ := _root_.Integration9_9.TM2NativePrimary.colors x*(x.1.1.length+2)^96
@[fun_prop] theorem colors_poly : Poly _root_.Integration9_9.TM2NativePrimary.colors := by unfold _root_.Integration9_9.TM2NativePrimary.colors;fun_prop
@[fun_prop] theorem legs_poly : Poly _root_.Integration9_9.TM2NativePrimary.legs := by unfold _root_.Integration9_9.TM2NativePrimary.legs;fun_prop
@[fun_prop] theorem population_poly : Poly _root_.Integration9_9.TM2NativePrimary.population := by unfold _root_.Integration9_9.TM2NativePrimary.population;fun_prop

def rate (x : _root_.Integration9_9.TM2NativePrimary.Request) : ℚ := _root_.Integration9_9.TM2NativeActivation.current x.1
@[fun_prop] theorem rate_poly : Poly _root_.Integration9_9.TM2NativePrimary.rate := by unfold _root_.Integration9_9.TM2NativePrimary.rate;fun_prop

def body (x : _root_.Integration9_9.TM2NativePrimary.Request×Bool) : ℚ := _root_.Integration9_9.TM2NativeBody.current (x.1.1,(x.2,x.1.2))
@[fun_prop] theorem body_poly : Poly _root_.Integration9_9.TM2NativePrimary.body := by unfold _root_.Integration9_9.TM2NativePrimary.body;fun_prop

def diffuse (x : _root_.Integration9_9.TM2NativePrimary.Request) : ℚ :=
  (_root_.Integration9_9.TM2NativeProfile.current (x.1,(true,x.2))+_root_.Integration9_9.TM2NativeProfile.current (x.1,(false,x.2)))/2
@[fun_prop] theorem diffuse_poly : Poly _root_.Integration9_9.TM2NativePrimary.diffuse := by unfold _root_.Integration9_9.TM2NativePrimary.diffuse;fun_prop

def raw (x : _root_.Integration9_9.TM2NativePrimary.Request) : ℚ :=
  let free : ℚ := (_root_.Integration9_9.TM2NativePrimary.population x : ℚ)-_root_.Integration9_9.TM2NativePrimary.legs x-_root_.Integration9_9.TM2NativePrimary.colors x
  let marked : ℚ := (_root_.Integration9_9.TM2NativePrimary.legs x : ℚ)*_root_.Integration9_9.TM2NativePrimary.rate x
  (((_root_.Integration9_9.TM2NativePrimary.population x+2*_root_.Integration9_9.TM2NativePrimary.legs x : ℕ) : ℚ)/_root_.Integration9_9.TM2NativePrimary.colors x-(free+marked)*_root_.Integration9_9.TM2NativePrimary.body (x,false)-
    ((_root_.Integration9_9.TM2NativePrimary.legs x+_root_.Integration9_9.TM2NativePrimary.colors x : ℕ) : ℚ)*_root_.Integration9_9.TM2NativePrimary.body (x,true)-2*(_root_.Integration9_9.TM2NativePrimary.legs x : ℚ)*(1-_root_.Integration9_9.TM2NativePrimary.rate x)*_root_.Integration9_9.TM2NativePrimary.diffuse x)/marked
@[fun_prop] theorem raw_poly : Poly _root_.Integration9_9.TM2NativePrimary.raw := by unfold _root_.Integration9_9.TM2NativePrimary.raw;fun_prop


 theorem _root_.Integration9_9.TM2NativePrimary.body_value (x : _root_.Integration9_9.TM2NativePrimary.Request) (includeScalar : Bool) : _root_.Integration9_9.TM2NativePrimary.body (x,includeScalar)=
    _root_.CurrentAFT.RationalProposalProgram.body x.1.1.length x.1.2.length includeScalar x.2 := by
  simp only [_root_.Integration9_9.TM2NativePrimary.body,_root_.Integration9_9.TM2NativeBody.current_value,_root_.CurrentAFT.BinaryBodyProgram.current_value,_root_.AFT.BinaryArithmetic.canonicalCounter_value]
 theorem _root_.Integration9_9.TM2NativePrimary.rate_value (x : _root_.Integration9_9.TM2NativePrimary.Request) : _root_.Integration9_9.TM2NativePrimary.rate x=_root_.CurrentAFT.LocalPairProgram.activationApprox x.1.1.length x.1.2.length := by
  simp only [_root_.Integration9_9.TM2NativePrimary.rate,_root_.Integration9_9.TM2NativeActivation.current_value,_root_.CurrentAFT.BinaryActivationProgram.current_value]
 theorem _root_.Integration9_9.TM2NativePrimary.diffuse_value (x : _root_.Integration9_9.TM2NativePrimary.Request) : _root_.Integration9_9.TM2NativePrimary.diffuse x=_root_.CurrentAFT.RationalProposalProgram.diffuse x.1.1.length x.1.2.length x.2 := by
  simp only [_root_.Integration9_9.TM2NativePrimary.diffuse,_root_.Integration9_9.TM2NativeProfile.current_value,_root_.CurrentAFT.BinaryProfileProgram.current_value,_root_.AFT.BinaryArithmetic.canonicalCounter_value]
  exact (_root_.CurrentAFT.BinaryProfileTables.diffuse_formula x.1.1.length x.1.2.length x.2).symm

theorem raw_value (x : _root_.Integration9_9.TM2NativePrimary.Request) : _root_.Integration9_9.TM2NativePrimary.raw x=_root_.CurrentAFT.RationalProposalProgram.primaryRaw x.1.1.length x.1.2.length x.2 := by
  simp only [_root_.Integration9_9.TM2NativePrimary.raw,_root_.Integration9_9.TM2NativePrimary.body_value,_root_.Integration9_9.TM2NativePrimary.rate_value,_root_.Integration9_9.TM2NativePrimary.diffuse_value,_root_.Integration9_9.TM2NativePrimary.colors,_root_.Integration9_9.TM2NativePrimary.legs,_root_.Integration9_9.TM2NativePrimary.population,_root_.Integration9_9.TM2NativePrime.modulus_value,
    _root_.CurrentAFT.RationalProposalProgram.primaryRaw,_root_.CurrentAFT.PublicParameterProgram.modulus_value]

abbrev TableRequest := List Unit×List Unit


def rawTable (x : _root_.Integration9_9.TM2NativePrimary.TableRequest) : List ℚ := (_root_.Integration9_9.TM2NativeAnchor.indices x).map (fun i => _root_.Integration9_9.TM2NativePrimary.raw (x,i))
@[fun_prop] theorem rawTable_poly : Poly _root_.Integration9_9.TM2NativePrimary.rawTable := by unfold _root_.Integration9_9.TM2NativePrimary.rawTable;fun_prop


theorem rawTable_value (x : _root_.Integration9_9.TM2NativePrimary.TableRequest) : _root_.Integration9_9.TM2NativePrimary.rawTable x=List.ofFn (fun i : Fin (_root_.CurrentAFT.PublicParameterProgram.modulus x.1.length).count =>
    _root_.CurrentAFT.RationalProposalProgram.primaryRaw x.1.length x.2.length i.val) := by
  have hc : (_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1).length=(_root_.CurrentAFT.PublicParameterProgram.modulus x.1.length).count := by
    rw [_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks_length,_root_.CurrentAFT.PublicParameterProgram.modulus_value]
  apply List.ext_getElem
  · simp only [_root_.Integration9_9.TM2NativePrimary.rawTable,_root_.Integration9_9.TM2NativeAnchor.indices,List.length_map,List.length_range,List.length_ofFn,hc]
  · intro i hi1 hi2
    simp only [_root_.Integration9_9.TM2NativePrimary.rawTable,_root_.Integration9_9.TM2NativeAnchor.indices,List.getElem_map,List.getElem_range,List.getElem_ofFn,_root_.Integration9_9.TM2NativePrimary.raw_value]

def good (xs : List ℚ) : Bool := (xs.filter (fun q => decide (q<(1 : ℚ)/(4*xs.length)))).isEmpty
@[fun_prop] theorem good_poly : Poly _root_.Integration9_9.TM2NativePrimary.good := by unfold _root_.Integration9_9.TM2NativePrimary.good;fun_prop




theorem good_ofFn {n : ℕ} (f : Fin n→ℚ) : _root_.Integration9_9.TM2NativePrimary.good (List.ofFn f)=true ↔ ∀i,(1 : ℚ)/(4*n)≤f i := by
  simp [_root_.Integration9_9.TM2NativePrimary.good,List.filter_eq_nil_iff,not_lt]

theorem good_iff (x : _root_.Integration9_9.TM2NativePrimary.TableRequest) : _root_.Integration9_9.TM2NativePrimary.good (_root_.Integration9_9.TM2NativePrimary.rawTable x)=true ↔ _root_.CurrentAFT.RationalProposalProgram.primaryGood x.1.length x.2.length := by
  rw [_root_.Integration9_9.TM2NativePrimary.rawTable_value,_root_.Integration9_9.TM2NativePrimary.good_ofFn]
  rfl











end Integration9_9.TM2NativePrimary

end

section




















































set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2PolynomialBudget
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open Polynomial

 theorem unitList_eq (xs ys : List Unit) (h : xs.length = ys.length) : xs = ys := by
  apply List.ext_getElem h
  intro i hi hj
  exact Subsingleton.elim _ _

 

 @[fun_prop] theorem polynomialSlots_poly (p : Polynomial ℕ) :
    Poly (fun xs : List Unit => List.replicate (p.eval xs.length) ()) := by
  induction p using Polynomial.induction_on' with
  | add p q hp hq =>
    have h : Poly (fun xs : List Unit =>
        List.replicate (p.eval xs.length) () ++ List.replicate (q.eval xs.length) ()) := by fun_prop
    simpa only [eval_add, List.replicate_add] using h
  | monomial n c =>
    have hf : Poly (fun xs : List Unit =>
        (List.replicate c ()).flatMap (fun _ => _root_.Integration9_9.TM2NativePrime.powerSlots n xs)) := by
      fun_prop
    have he : (fun xs : List Unit => (List.replicate c ()).flatMap
        (fun _ => _root_.Integration9_9.TM2NativePrime.powerSlots n xs)) =
        (fun xs : List Unit => List.replicate ((monomial n c).eval xs.length) ()) := by
      funext xs
      apply _root_.Integration9_9.TM2PolynomialBudget.unitList_eq
      simp [List.length_flatMap, _root_.Integration9_9.TM2NativePrime.powerSlots_length, eval_monomial]
    rw [← he]
    exact hf

end Integration9_9.TM2PolynomialBudget

end

section






























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryFullResponseCounts
end CurrentAFT.BinaryFullResponseCounts
namespace CurrentAFT.BinaryFullResponseCounts.Counts
end CurrentAFT.BinaryFullResponseCounts.Counts
namespace CurrentAFT.BinaryFullResponseCounts.Counts.mk
end CurrentAFT.BinaryFullResponseCounts.Counts.mk
namespace CurrentAFT.BinaryFullResponseCounts.current
end CurrentAFT.BinaryFullResponseCounts.current
namespace CurrentAFT.BinaryFullResponseCounts.workPolynomial
end CurrentAFT.BinaryFullResponseCounts.workPolynomial




set_option autoImplicit false
set_option maxHeartbeats 400000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! The actual populations used by full-response choices and tags. Binary
counts are computed first; real unary buffers are clipped from an actually
generated fixed polynomial budget, with their exact lengths proved. -/
namespace Integration9_9.TM2NativeFullResponseCounts
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries
attribute [local irreducible] TM2NativePrime.modulus TM2NativePrime.upperSlots

def leg (xs : List Unit) : ℕ := _root_.Integration9_9.TM2NativePrimary.legs ((xs,[]),0)
def body (xs : List Unit) : ℕ := _root_.Integration9_9.TM2NativePrimary.population ((xs,[]),0)
def queue (xs : List Unit) : ℕ := _root_.Integration9_9.TM2NativePrimary.colors ((xs,[]),0)
def ordinary (xs : List Unit) : ℕ := (_root_.Integration9_9.TM2NativeFullResponseCounts.body xs-_root_.Integration9_9.TM2NativeFullResponseCounts.queue xs)-2*_root_.Integration9_9.TM2NativeFullResponseCounts.leg xs
@[fun_prop] theorem leg_poly : Poly _root_.Integration9_9.TM2NativeFullResponseCounts.leg := by unfold _root_.Integration9_9.TM2NativeFullResponseCounts.leg;fun_prop
@[fun_prop] theorem body_poly : Poly _root_.Integration9_9.TM2NativeFullResponseCounts.body := by unfold _root_.Integration9_9.TM2NativeFullResponseCounts.body;fun_prop
@[fun_prop] theorem queue_poly : Poly _root_.Integration9_9.TM2NativeFullResponseCounts.queue := by unfold _root_.Integration9_9.TM2NativeFullResponseCounts.queue;fun_prop
@[fun_prop] theorem ordinary_poly : Poly _root_.Integration9_9.TM2NativeFullResponseCounts.ordinary := by unfold _root_.Integration9_9.TM2NativeFullResponseCounts.ordinary;fun_prop

abbrev Counts := (ℕ×ℕ)×(ℕ×ℕ)


def current (xs : List Unit) : _root_.Integration9_9.TM2NativeFullResponseCounts.Counts := ((_root_.Integration9_9.TM2NativeFullResponseCounts.leg xs,_root_.Integration9_9.TM2NativeFullResponseCounts.ordinary xs),(_root_.Integration9_9.TM2NativeFullResponseCounts.queue xs,_root_.Integration9_9.TM2NativeFullResponseCounts.body xs))



theorem current_value (xs : List Unit) : _root_.Integration9_9.TM2NativeFullResponseCounts.current xs=
    (((_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).leg,(_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).ordinary),
      ((_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).queue,(_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).body)) := by
  rcases _root_.CurrentAFT.BinaryProposalMetadata.counts_value xs.length with ⟨hq,hl,hp⟩
  simp only [_root_.Integration9_9.TM2NativeFullResponseCounts.current,_root_.Integration9_9.TM2NativeFullResponseCounts.ordinary,_root_.Integration9_9.TM2NativeFullResponseCounts.leg,_root_.Integration9_9.TM2NativeFullResponseCounts.body,_root_.Integration9_9.TM2NativeFullResponseCounts.queue,_root_.Integration9_9.TM2NativePrimary.legs,_root_.Integration9_9.TM2NativePrimary.population,_root_.Integration9_9.TM2NativePrimary.colors,
    _root_.Integration9_9.TM2NativePrime.modulus_value,_root_.CurrentAFT.BinaryFullResponseCounts.current,_root_.AFT.BinaryArithmetic.differenceCounter_value,_root_.AFT.BinaryArithmetic.doubleCounter_value,hq,hl,hp]

inductive Kind where
  | leg | ordinary | queue | body
  deriving DecidableEq

def value (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) (xs : List Unit) : ℕ := match kind with
  | .leg => _root_.Integration9_9.TM2NativeFullResponseCounts.leg xs
  | .ordinary => _root_.Integration9_9.TM2NativeFullResponseCounts.ordinary xs
  | .queue => _root_.Integration9_9.TM2NativeFullResponseCounts.queue xs
  | .body => _root_.Integration9_9.TM2NativeFullResponseCounts.body xs
@[fun_prop] theorem value_poly (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) : Poly (_root_.Integration9_9.TM2NativeFullResponseCounts.value kind) := by cases kind <;> unfold _root_.Integration9_9.TM2NativeFullResponseCounts.value <;> fun_prop

def nativeValue (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) (xs : List Unit) : ℕ := match kind with
  | .leg => (_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).leg
  | .ordinary => (_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).ordinary
  | .queue => (_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).queue
  | .body => (_root_.CurrentAFT.BinaryFullResponseCounts.current xs.length).body

theorem value_native (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) (xs : List Unit) : _root_.Integration9_9.TM2NativeFullResponseCounts.value kind xs=_root_.Integration9_9.TM2NativeFullResponseCounts.nativeValue kind xs := by
  have h:=_root_.Integration9_9.TM2NativeFullResponseCounts.current_value xs
  cases kind
  · simpa only [_root_.Integration9_9.TM2NativeFullResponseCounts.current,_root_.Integration9_9.TM2NativeFullResponseCounts.value,_root_.Integration9_9.TM2NativeFullResponseCounts.nativeValue] using congrArg (fun c : _root_.Integration9_9.TM2NativeFullResponseCounts.Counts => c.1.1) h
  · simpa only [_root_.Integration9_9.TM2NativeFullResponseCounts.current,_root_.Integration9_9.TM2NativeFullResponseCounts.value,_root_.Integration9_9.TM2NativeFullResponseCounts.nativeValue] using congrArg (fun c : _root_.Integration9_9.TM2NativeFullResponseCounts.Counts => c.1.2) h
  · simpa only [_root_.Integration9_9.TM2NativeFullResponseCounts.current,_root_.Integration9_9.TM2NativeFullResponseCounts.value,_root_.Integration9_9.TM2NativeFullResponseCounts.nativeValue] using congrArg (fun c : _root_.Integration9_9.TM2NativeFullResponseCounts.Counts => c.2.1) h
  · simpa only [_root_.Integration9_9.TM2NativeFullResponseCounts.current,_root_.Integration9_9.TM2NativeFullResponseCounts.value,_root_.Integration9_9.TM2NativeFullResponseCounts.nativeValue] using congrArg (fun c : _root_.Integration9_9.TM2NativeFullResponseCounts.Counts => c.2.2) h

theorem value_bound (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) (xs : List Unit) : _root_.Integration9_9.TM2NativeFullResponseCounts.value kind xs≤_root_.CurrentAFT.BinaryProposalMetadata.sizeBound xs.length := by
  rw [_root_.Integration9_9.TM2NativeFullResponseCounts.value_native]
  have h:=_root_.InfoLossLARNativeSupplements.hf109288ce2bff41a.CurrentAFT.BinaryFullResponseCounts.current_sizes xs.length
  cases kind
  · exact h.1
  · exact h.2.1
  · exact h.2.2.1
  · exact h.2.2.2

def budget (xs : List Unit) : List Unit :=
  List.replicate (131072*(xs.length+2)^160) ()
@[fun_prop] theorem budget_poly : Poly _root_.Integration9_9.TM2NativeFullResponseCounts.budget := by
  change Poly (fun xs : List Unit => List.replicate (131072*(xs.length+2)^160) ())
  simpa only [_root_.CurrentAFT.BinaryProposalMetadata.sizePolynomial_eval,_root_.CurrentAFT.BinaryProposalMetadata.sizeBound] using
    _root_.Integration9_9.TM2PolynomialBudget.polynomialSlots_poly _root_.CurrentAFT.BinaryProposalMetadata.sizePolynomial

attribute [local irreducible] budget value

def slots (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) (xs : List Unit) : List Unit := (_root_.Integration9_9.TM2NativeFullResponseCounts.budget xs).take (_root_.Integration9_9.TM2NativeFullResponseCounts.value kind xs)
noncomputable def slotsProgram (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) : PolyProgram _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode (_root_.Integration9_9.TM2NativeFullResponseCounts.slots kind) := by
  change PolyProgram Automatic.enc Automatic.enc (fun xs : List Unit => (_root_.Integration9_9.TM2NativeFullResponseCounts.budget xs).take (_root_.Integration9_9.TM2NativeFullResponseCounts.value kind xs))
  have hi : Poly (fun xs : List Unit => (_root_.Integration9_9.TM2NativeFullResponseCounts.budget xs,_root_.Integration9_9.TM2NativeFullResponseCounts.value kind xs)) := Automatic.Poly.pair _root_.Integration9_9.TM2NativeFullResponseCounts.budget_poly (_root_.Integration9_9.TM2NativeFullResponseCounts.value_poly kind)
  have ht : Poly (fun x : List Unit×ℕ => x.1.take x.2) := ⟨PolyProgram.listTake _root_.Integration9_9.TM2NativeFiniteSeries.unitCode ()⟩
  exact (Poly.comp (f := fun x : List Unit×ℕ => x.1.take x.2)
    (g := fun xs : List Unit => (_root_.Integration9_9.TM2NativeFullResponseCounts.budget xs,_root_.Integration9_9.TM2NativeFullResponseCounts.value kind xs)) ht hi).program
@[fun_prop] theorem slots_poly (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) : Poly (_root_.Integration9_9.TM2NativeFullResponseCounts.slots kind) := ⟨_root_.Integration9_9.TM2NativeFullResponseCounts.slotsProgram kind⟩

theorem slots_length (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) (xs : List Unit) : (_root_.Integration9_9.TM2NativeFullResponseCounts.slots kind xs).length=_root_.Integration9_9.TM2NativeFullResponseCounts.value kind xs := by
  simp only [_root_.Integration9_9.TM2NativeFullResponseCounts.slots,List.length_take,_root_.Integration9_9.TM2NativeFullResponseCounts.budget,List.length_replicate]
  apply Nat.min_eq_left
  simpa only [_root_.CurrentAFT.BinaryProposalMetadata.sizeBound] using _root_.Integration9_9.TM2NativeFullResponseCounts.value_bound kind xs

theorem slots_native_length (kind : _root_.Integration9_9.TM2NativeFullResponseCounts.Kind) (xs : List Unit) : (_root_.Integration9_9.TM2NativeFullResponseCounts.slots kind xs).length=_root_.Integration9_9.TM2NativeFullResponseCounts.nativeValue kind xs :=
  (_root_.Integration9_9.TM2NativeFullResponseCounts.slots_length kind xs).trans (_root_.Integration9_9.TM2NativeFullResponseCounts.value_native kind xs)






end Integration9_9.TM2NativeFullResponseCounts

end

section





























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryReferenceTables
end CurrentAFT.BinaryReferenceTables
namespace CurrentAFT.BinaryReferenceTables.Result
end CurrentAFT.BinaryReferenceTables.Result
namespace CurrentAFT.BinaryReferenceTables.Result.mk
end CurrentAFT.BinaryReferenceTables.Result.mk
namespace CurrentAFT.BinaryReferenceTables.centerHeightPolynomial
end CurrentAFT.BinaryReferenceTables.centerHeightPolynomial
namespace CurrentAFT.BinaryReferenceTables.current
end CurrentAFT.BinaryReferenceTables.current
namespace CurrentAFT.BinaryReferenceTables.currentWorkPolynomial
end CurrentAFT.BinaryReferenceTables.currentWorkPolynomial
namespace CurrentAFT.BinaryReferenceTables.heightPolynomial
end CurrentAFT.BinaryReferenceTables.heightPolynomial
namespace CurrentAFT.BinaryReferenceTables.marginPolynomial
end CurrentAFT.BinaryReferenceTables.marginPolynomial
namespace CurrentAFT.BinaryReferenceTables.referenceHeightPolynomial
end CurrentAFT.BinaryReferenceTables.referenceHeightPolynomial



set_option autoImplicit false
set_option maxHeartbeats 1800000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! The entire current reference cache, with no reference data supplied as
advice. Primary and anchor arrays are generated, every weighted anchor column
is summed, the compensation and safe-slice formula are executed, and the same
activation is returned with the complete primary/center/anchor cache. -/
namespace Integration9_9.TM2NativeReferenceTables
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators
attribute [local irreducible] TM2NativePrime.modulus TM2NativePrime.upperSlots

















abbrev Request := List Unit×List Unit


def compensation (x : _root_.Integration9_9.TM2NativeReferenceTables.Request) : ℚ :=
  (_root_.Integration9_9.TM2NativePrimary.legs (x,0) : ℚ)*_root_.Integration9_9.TM2NativeActivation.current x /
    ((_root_.Integration9_9.TM2NativePrimary.population (x,0) : ℚ)-_root_.Integration9_9.TM2NativePrimary.legs (x,0)-_root_.Integration9_9.TM2NativePrimary.colors (x,0))
@[fun_prop] theorem compensation_poly : Poly _root_.Integration9_9.TM2NativeReferenceTables.compensation := by unfold _root_.Integration9_9.TM2NativeReferenceTables.compensation;fun_prop

































end Integration9_9.TM2NativeReferenceTables

end

section





























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryFirstInverseProgram
end CurrentAFT.BinaryFirstInverseProgram
namespace CurrentAFT.BinaryFirstInverseProgram.Cache
end CurrentAFT.BinaryFirstInverseProgram.Cache
namespace CurrentAFT.BinaryFirstInverseProgram.Cache.mk
end CurrentAFT.BinaryFirstInverseProgram.Cache.mk
namespace CurrentAFT.BinaryFirstInverseProgram.colors
end CurrentAFT.BinaryFirstInverseProgram.colors
namespace CurrentAFT.BinaryFirstInverseProgram.colorsPolynomial
end CurrentAFT.BinaryFirstInverseProgram.colorsPolynomial
namespace CurrentAFT.BinaryFirstInverseProgram.inputAt
end CurrentAFT.BinaryFirstInverseProgram.inputAt
namespace CurrentAFT.BinaryFirstInverseProgram.prepare
end CurrentAFT.BinaryFirstInverseProgram.prepare
namespace CurrentAFT.BinaryFirstInverseProgram.signPoint
end CurrentAFT.BinaryFirstInverseProgram.signPoint
namespace CurrentAFT.BinaryFirstInverseProgram.signWorkPolynomial
end CurrentAFT.BinaryFirstInverseProgram.signWorkPolynomial



set_option autoImplicit false
set_option maxHeartbeats 1800000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! The entire actual guarded rank-one first inverse and mass whitening.
Sign profiles, the guarded denominator, the primary law and activation are
computed internally; arbitrary stored input profiles are parsed and summed
by real palette-index and rational-arithmetic machines. -/
namespace Integration9_9.TM2NativeFirstInverse
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators
attribute [local irreducible] TM2NativePrime.modulus TM2NativePrime.upperSlots

def anchorSign (x : ℕ×ℕ) : ℚ := if 2*x.2<x.1-1 then -1 else if x.1-1<2*x.2 then 1 else 0
@[fun_prop] theorem anchorSign_poly : Poly _root_.Integration9_9.TM2NativeFirstInverse.anchorSign := by unfold _root_.Integration9_9.TM2NativeFirstInverse.anchorSign;fun_prop

abbrev FunctionalContext := List Unit×List ℚ
abbrev functionalCode : _root_.Integration9_9.TM2NativeFirstInverse.FunctionalContext→List Bool := Automatic.enc

def functionalTerm (x : _root_.Integration9_9.TM2NativeFirstInverse.FunctionalContext×ℕ) : ℚ := _root_.Integration9_9.TM2NativeFirstInverse.anchorSign (x.1.1.length,x.2)*x.1.2[x.2]?.getD 0
@[fun_prop] theorem functionalTerm_poly : Poly _root_.Integration9_9.TM2NativeFirstInverse.functionalTerm := by unfold _root_.Integration9_9.TM2NativeFirstInverse.functionalTerm;fun_prop

def functional (x : _root_.Integration9_9.TM2NativeFirstInverse.FunctionalContext) : ℚ := ((List.range x.1.length).map (fun i => _root_.Integration9_9.TM2NativeFirstInverse.functionalTerm (x,i))).sum
noncomputable def functionalProgram : PolyProgram _root_.Integration9_9.TM2NativeFirstInverse.functionalCode Ratio.encode _root_.Integration9_9.TM2NativeFirstInverse.functional := by
  let indices := (PolyProgram.fst _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode (encodeList Ratio.encode)).comp (PolyProgram.listIndices _root_.Integration9_9.TM2NativeFiniteSeries.unitCode ())
  exact ((((PolyProgram.identity _root_.Integration9_9.TM2NativeFirstInverse.functionalCode).fanout indices).comp
    (_root_.Integration9_9.TM2NativeFirstInverse.functionalTerm_poly.program.listMapWith 0 (0 : ℚ))).comp PolyProgram.ratSum)
@[fun_prop] theorem functional_poly : Poly _root_.Integration9_9.TM2NativeFirstInverse.functional := ⟨_root_.Integration9_9.TM2NativeFirstInverse.functionalProgram⟩

def maximum (x : ℚ×ℚ) : ℚ := if x.1≤x.2 then x.2 else x.1
@[fun_prop] theorem maximum_poly : Poly _root_.Integration9_9.TM2NativeFirstInverse.maximum := by unfold _root_.Integration9_9.TM2NativeFirstInverse.maximum;fun_prop

theorem maximum_eq (a b : ℚ) : _root_.Integration9_9.TM2NativeFirstInverse.maximum (a,b)=max a b := by
  by_cases h : a≤b
  · simp only [_root_.Integration9_9.TM2NativeFirstInverse.maximum,h,ite_true,max_eq_right h]
  · simp only [_root_.Integration9_9.TM2NativeFirstInverse.maximum,h,ite_false,max_eq_left (le_of_not_ge h)]

abbrev Meta := List Unit×List Unit

abbrev SignRequest := _root_.Integration9_9.TM2NativeFirstInverse.Meta×ℕ

def sign (x : _root_.Integration9_9.TM2NativeFirstInverse.SignRequest) : ℚ :=
  (1-_root_.Integration9_9.TM2NativeActivation.current x.1)*
    (_root_.Integration9_9.TM2NativeProfile.current (x.1,(true,x.2))-_root_.Integration9_9.TM2NativeProfile.current (x.1,(false,x.2)))
@[fun_prop] theorem sign_poly : Poly _root_.Integration9_9.TM2NativeFirstInverse.sign := by unfold _root_.Integration9_9.TM2NativeFirstInverse.sign;fun_prop

theorem sign_value (x : _root_.Integration9_9.TM2NativeFirstInverse.SignRequest) : _root_.Integration9_9.TM2NativeFirstInverse.sign x=_root_.CurrentAFT.RationalFirstResponseProgram.signProfile x.1.1.length x.1.2.length x.2 := by
  simp only [_root_.Integration9_9.TM2NativeFirstInverse.sign,_root_.Integration9_9.TM2NativeActivation.current_value,_root_.CurrentAFT.BinaryActivationProgram.current_value,
    _root_.Integration9_9.TM2NativeProfile.current_value,_root_.CurrentAFT.BinaryProfileProgram.current_value,_root_.AFT.BinaryArithmetic.canonicalCounter_value]
  rfl

def signTable (x : _root_.Integration9_9.TM2NativeFirstInverse.Meta) : List ℚ := (_root_.Integration9_9.TM2NativeAnchor.indices x).map (fun i => _root_.Integration9_9.TM2NativeFirstInverse.sign (x,i))
@[fun_prop] theorem signTable_poly : Poly _root_.Integration9_9.TM2NativeFirstInverse.signTable := by unfold _root_.Integration9_9.TM2NativeFirstInverse.signTable;fun_prop

theorem signTable_value (x : _root_.Integration9_9.TM2NativeFirstInverse.Meta) : _root_.Integration9_9.TM2NativeFirstInverse.signTable x=List.ofFn
    (fun i : Fin (_root_.CurrentAFT.PublicParameterProgram.modulus x.1.length).count =>
      _root_.CurrentAFT.RationalFirstResponseProgram.signProfile x.1.length x.2.length i.val) := by
  have hc : (_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1).length=(_root_.CurrentAFT.PublicParameterProgram.modulus x.1.length).count := by
    rw [_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks_length,_root_.CurrentAFT.PublicParameterProgram.modulus_value]
  apply List.ext_getElem
  · simp only [_root_.Integration9_9.TM2NativeFirstInverse.signTable,_root_.Integration9_9.TM2NativeAnchor.indices,List.length_map,List.length_range,List.length_ofFn,hc]
  · intro i hi1 hi2
    simp only [_root_.Integration9_9.TM2NativeFirstInverse.signTable,_root_.Integration9_9.TM2NativeAnchor.indices,List.getElem_map,List.getElem_range,List.getElem_ofFn,_root_.Integration9_9.TM2NativeFirstInverse.sign_value]

def denominator (x : _root_.Integration9_9.TM2NativeFirstInverse.Meta) : ℚ := _root_.Integration9_9.TM2NativeFirstInverse.maximum
  (_root_.Integration9_9.TM2NativeActivation.current x+_root_.Integration9_9.TM2NativeFirstInverse.functional (_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1,_root_.Integration9_9.TM2NativeFirstInverse.signTable x),_root_.Integration9_9.TM2NativeActivation.current x/4)
@[fun_prop] theorem denominator_poly : Poly _root_.Integration9_9.TM2NativeFirstInverse.denominator := by unfold _root_.Integration9_9.TM2NativeFirstInverse.denominator;fun_prop

 theorem _root_.Integration9_9.TM2NativeFirstInverse.getD_ofFn {α : Type} {n : ℕ} (f : Fin n→α) (i : Fin n) (a0 : α) :
    (List.ofFn f)[i.val]?.getD a0=f i := by simp

theorem functional_ofFn (xs : List Unit) (n : ℕ) (hn : xs.length=n) (f : Fin n→ℚ) :
    _root_.Integration9_9.TM2NativeFirstInverse.functional (xs,List.ofFn f)=∑i : Fin n,_root_.Integration9_9.TM2NativeFirstInverse.anchorSign (n,i.val)*f i := by
  unfold _root_.Integration9_9.TM2NativeFirstInverse.functional
  dsimp only
  rw [hn,_root_.Integration9_9.TM2NativeProfile.sum_range]
  apply Finset.sum_congr rfl
  intro i _
  simp only [_root_.Integration9_9.TM2NativeFirstInverse.functionalTerm,hn,_root_.Integration9_9.TM2NativeFirstInverse.getD_ofFn]

theorem denominator_value (x : _root_.Integration9_9.TM2NativeFirstInverse.Meta) : _root_.Integration9_9.TM2NativeFirstInverse.denominator x=_root_.CurrentAFT.RationalFirstResponseProgram.guardedDenominator x.1.length x.2.length := by
  have hc : (_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1).length=(_root_.CurrentAFT.PublicParameterProgram.modulus x.1.length).count := by
    rw [_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks_length,_root_.CurrentAFT.PublicParameterProgram.modulus_value]
  rw [_root_.Integration9_9.TM2NativeFirstInverse.denominator,_root_.Integration9_9.TM2NativeFirstInverse.maximum_eq,_root_.Integration9_9.TM2NativeFirstInverse.signTable_value,_root_.Integration9_9.TM2NativeFirstInverse.functional_ofFn _ _ hc]
  simp only [_root_.Integration9_9.TM2NativeActivation.current_value,_root_.CurrentAFT.BinaryActivationProgram.current_value,
    _root_.CurrentAFT.RationalFirstResponseProgram.guardedDenominator,_root_.CurrentAFT.RationalFirstResponseProgram.denominator,
    _root_.CurrentAFT.RationalFirstResponseProgram.functional,_root_.CurrentAFT.RationalFirstResponseProgram.anchorSign,_root_.Integration9_9.TM2NativeFirstInverse.anchorSign]














structure Context where
  security : List Unit
  precision : List Unit
  profile : Vector _root_.AFT.BinaryArithmetic.RationalBits (_root_.CurrentAFT.BinaryFirstInverseProgram.colors security.length)
  output : Fin (_root_.CurrentAFT.BinaryFirstInverseProgram.colors security.length)






end Integration9_9.TM2NativeFirstInverse

end

section





























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryDensityInverseColumn
end CurrentAFT.BinaryDensityInverseColumn
namespace CurrentAFT.BinaryDensityInverseColumn.workPolynomial
end CurrentAFT.BinaryDensityInverseColumn.workPolynomial



set_option autoImplicit false
set_option maxHeartbeats 1600000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! Actual density-inverse columns, on all natural source/output operands.
The finite delta functional is simplified exactly; full primary/profile point
programs preserve the mathematical output also outside the palette. -/
namespace Integration9_9.TM2NativeDensityInverseColumn
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries
open scoped BigOperators
attribute [local irreducible] TM2NativePrime.modulus TM2NativePrime.upperSlots

abbrev Meta := _root_.Integration9_9.TM2NativeFirstInverse.Meta
abbrev PointRequest := _root_.Integration9_9.TM2NativeDensityInverseColumn.Meta×ℕ

def primaryPoint (x : _root_.Integration9_9.TM2NativeDensityInverseColumn.PointRequest) : ℚ :=
  if _root_.Integration9_9.TM2NativePrimary.good (_root_.Integration9_9.TM2NativePrimary.rawTable x.1) then _root_.Integration9_9.TM2NativePrimary.raw x
  else (1 : ℚ)/_root_.Integration9_9.TM2NativePrime.modulus x.1.1
@[fun_prop] theorem primaryPoint_poly : Poly _root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint := by unfold _root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint;fun_prop

theorem primaryPoint_value (x : _root_.Integration9_9.TM2NativeDensityInverseColumn.PointRequest) : _root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint x=
    _root_.CurrentAFT.RationalProposalProgram.primary x.1.1.length x.1.2.length x.2 := by
  by_cases hp : _root_.CurrentAFT.RationalProposalProgram.primaryGood x.1.1.length x.1.2.length
  · have hg:= (_root_.Integration9_9.TM2NativePrimary.good_iff x.1).mpr hp
    simp only [_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint,hg,ite_true,_root_.Integration9_9.TM2NativePrimary.raw_value,_root_.CurrentAFT.RationalProposalProgram.primary,hp]
  · have hg : _root_.Integration9_9.TM2NativePrimary.good (_root_.Integration9_9.TM2NativePrimary.rawTable x.1)=false :=
      Bool.eq_false_iff.mpr (fun h => hp ((_root_.Integration9_9.TM2NativePrimary.good_iff x.1).mp h))
    simp only [_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint,hg,Bool.false_eq_true,ite_false,_root_.CurrentAFT.RationalProposalProgram.primary,hp,
      _root_.Integration9_9.TM2NativePrime.modulus_native]

abbrev Request := _root_.Integration9_9.TM2NativeDensityInverseColumn.Meta×(ℕ×ℕ)
abbrev requestCode : _root_.Integration9_9.TM2NativeDensityInverseColumn.Request→List Bool := Automatic.enc

def functionalDelta (x : _root_.Integration9_9.TM2NativeDensityInverseColumn.Request) : ℚ :=
  if x.2.1<_root_.Integration9_9.TM2NativePrime.modulus x.1.1 then
    _root_.Integration9_9.TM2NativeFirstInverse.anchorSign (_root_.Integration9_9.TM2NativePrime.modulus x.1.1,x.2.1)*_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint (x.1,x.2.1)
  else 0
@[fun_prop] theorem functionalDelta_poly : Poly _root_.Integration9_9.TM2NativeDensityInverseColumn.functionalDelta := by unfold _root_.Integration9_9.TM2NativeDensityInverseColumn.functionalDelta;fun_prop

def current (x : _root_.Integration9_9.TM2NativeDensityInverseColumn.Request) : ℚ :=
  ((if x.2.2=x.2.1 then _root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint (x.1,x.2.2) else 0)-
    _root_.Integration9_9.TM2NativeDensityInverseColumn.functionalDelta x/_root_.Integration9_9.TM2NativeFirstInverse.denominator x.1*_root_.Integration9_9.TM2NativeFirstInverse.sign (x.1,x.2.2)) /
    (_root_.Integration9_9.TM2NativeActivation.current x.1*_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint (x.1,x.2.2))
@[fun_prop] theorem current_poly : Poly _root_.Integration9_9.TM2NativeDensityInverseColumn.current := by unfold _root_.Integration9_9.TM2NativeDensityInverseColumn.current;fun_prop
noncomputable def currentProgram : PolyProgram _root_.Integration9_9.TM2NativeDensityInverseColumn.requestCode Ratio.encode _root_.Integration9_9.TM2NativeDensityInverseColumn.current := _root_.Integration9_9.TM2NativeDensityInverseColumn.current_poly.program

 theorem _root_.Integration9_9.TM2NativeDensityInverseColumn.functionalDelta_value (x : _root_.Integration9_9.TM2NativeDensityInverseColumn.Request) : _root_.Integration9_9.TM2NativeDensityInverseColumn.functionalDelta x=
    _root_.CurrentAFT.RationalFirstResponseProgram.functional x.1.1.length
      (fun color => _root_.CurrentAFT.RationalProposalProgram.primary x.1.1.length x.1.2.length color*
        (if color=x.2.1 then (1 : ℚ) else 0)) := by
  simp only [_root_.Integration9_9.TM2NativeDensityInverseColumn.functionalDelta,_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint_value,_root_.Integration9_9.TM2NativePrime.modulus_native]
  unfold _root_.CurrentAFT.RationalFirstResponseProgram.functional
  by_cases hsrc : x.2.1<(_root_.CurrentAFT.PublicParameterProgram.modulus x.1.1.length).count
  · let source : Fin (_root_.CurrentAFT.PublicParameterProgram.modulus x.1.1.length).count:=⟨x.2.1,hsrc⟩
    rw [if_pos hsrc,Finset.sum_eq_single source]
    · simp only [source,ite_true,mul_one,_root_.CurrentAFT.RationalFirstResponseProgram.anchorSign,_root_.Integration9_9.TM2NativeFirstInverse.anchorSign]
    · intro color _ hne
      have hn : color.val≠x.2.1 := fun h => hne (Fin.ext h)
      simp only [hn,ite_false,mul_zero]
    · simp
  · rw [if_neg hsrc]
    apply Eq.symm
    apply Finset.sum_eq_zero
    intro color _
    have hn : color.val≠x.2.1 := by intro h;have:=color.isLt;omega
    simp only [hn,ite_false,mul_zero]

theorem current_value (x : _root_.Integration9_9.TM2NativeDensityInverseColumn.Request) : _root_.Integration9_9.TM2NativeDensityInverseColumn.current x=_root_.CurrentAFT.RationalTensorInverseProgram.entry
    x.1.1.length x.1.2.length x.2.1 x.2.2 := by
  simp only [_root_.Integration9_9.TM2NativeDensityInverseColumn.current,_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint_value,_root_.Integration9_9.TM2NativeDensityInverseColumn.functionalDelta_value,_root_.Integration9_9.TM2NativeFirstInverse.denominator_value,
    _root_.Integration9_9.TM2NativeFirstInverse.sign_value,_root_.Integration9_9.TM2NativeActivation.current_value,_root_.CurrentAFT.BinaryActivationProgram.current_value,
    _root_.CurrentAFT.RationalTensorInverseProgram.entry,_root_.CurrentAFT.RationalDensityInverseProgram.current,
    _root_.CurrentAFT.RationalFirstResponseProgram.inverse]
  by_cases h : x.2.2=x.2.1 <;> simp only [h,ite_true,ite_false,mul_one,mul_zero]

/-- Every source/output pair, with no palette-bound premise. -/
noncomputable def entryProgram : PolyProgram _root_.Integration9_9.TM2NativeDensityInverseColumn.requestCode Ratio.encode
    (fun x : _root_.Integration9_9.TM2NativeDensityInverseColumn.Request => _root_.CurrentAFT.RationalTensorInverseProgram.entry x.1.1.length x.1.2.length x.2.1 x.2.2) :=
  _root_.Integration9_9.TM2NativeDensityInverseColumn.currentProgram.congr _ _root_.Integration9_9.TM2NativeDensityInverseColumn.current_value

structure Context where
  security : List Unit
  precision : List Unit
  source : Fin (_root_.CurrentAFT.BinaryFirstInverseProgram.colors security.length)
  output : Fin (_root_.CurrentAFT.BinaryFirstInverseProgram.colors security.length)





end Integration9_9.TM2NativeDensityInverseColumn

end

section



























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.BinaryPackedRootSum
end CurrentAFT.BinaryPackedRootSum
namespace CurrentAFT.BinaryPackedRootSum.heightPolynomial
end CurrentAFT.BinaryPackedRootSum.heightPolynomial
namespace CurrentAFT.BinaryPackedRootSum.workPolynomial
end CurrentAFT.BinaryPackedRootSum.workPolynomial



set_option autoImplicit false
set_option maxHeartbeats 1500000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

/-! Actual fixed-order joint source-word enumeration. The palette is a real
input list, and each tuple is materialized by real cons/map/flatMap machines.
The semantic proof reindexes exactly the finite tuple sum used by the native
packed-root response, without expanding a binary count into an unbounded loop. -/
namespace Integration9_9.TM2NativeTupleEnumeration
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries
open scoped BigOperators

def tuples : ℕ→List ℕ→List (List ℕ)
  | 0,_ => [[]]
  | k+1,xs => xs.flatMap (fun head => (tuples k xs).map (fun tail => head::tail))

@[fun_prop] theorem tuples_poly (k : ℕ) : Poly (_root_.Integration9_9.TM2NativeTupleEnumeration.tuples k) := by
  induction k with
  | zero => exact Automatic.Poly.const [[]]
  | succ k ih =>
    change Poly (fun xs : List ℕ => xs.flatMap (fun head => (_root_.Integration9_9.TM2NativeTupleEnumeration.tuples k xs).map (fun tail => head::tail)))
    fun_prop



theorem sum_tuples (k pool : ℕ) (f : List ℕ→ℚ) :
    ((_root_.Integration9_9.TM2NativeTupleEnumeration.tuples k (List.range pool)).map f).sum=
      ∑word : Fin k→Fin pool,f (List.ofFn (fun i => (word i).val)) := by
  induction k generalizing f with
  | zero => simp only [_root_.Integration9_9.TM2NativeTupleEnumeration.tuples,List.map_singleton,List.sum_cons,List.sum_nil,add_zero,Fintype.sum_unique,List.ofFn_zero]
  | succ k ih =>
    simp only [_root_.Integration9_9.TM2NativeTupleEnumeration.tuples,List.map_flatMap,_root_.Integration9_9.TM2NativeProfile.sum_flatMap,List.map_map,Function.comp_def]
    rw [_root_.Integration9_9.TM2NativeProfile.sum_range]
    simp_rw [ih]
    simpa only [Fintype.sum_prod_type,Fin.consEquiv,Equiv.coe_fn_mk,List.ofFn_succ,Fin.cons_zero,Fin.cons_succ] using
      (Equiv.sum_comp (Fin.consEquiv (fun _ : Fin (k+1) => Fin pool))
        (fun word => f (List.ofFn (fun i => (word i).val))))

/-- Real tuple materialization from a real unary palette. -/
noncomputable def enumerationProgram (k : ℕ) : PolyProgram _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode (encodeList (encodeList Nat.bits))
    (fun xs : List Unit => _root_.Integration9_9.TM2NativeTupleEnumeration.tuples k (List.range xs.length)) :=
  (PolyProgram.listIndices _root_.Integration9_9.TM2NativeFiniteSeries.unitCode ()).comp (_root_.Integration9_9.TM2NativeTupleEnumeration.tuples_poly k).program

/-- Compile a fixed-order joint sum from an already implemented strict leaf
subroutine. This constructs the actual whole machine and its time polynomial;
no abstract record cost is used. -/
noncomputable def sumProgram {α : Type} [Coding α] (k : ℕ) {f : α×List ℕ→ℚ}
    (leaf : PolyProgram Automatic.enc Ratio.encode f) :
    PolyProgram (encodePair Automatic.enc _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode) Ratio.encode
      (fun x : α×List Unit => ((_root_.Integration9_9.TM2NativeTupleEnumeration.tuples k (List.range x.2.length)).map (fun word => f (x.1,word))).sum) := by
  let context := PolyProgram.fst (Automatic.enc (α := α)) _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode
  let words := (PolyProgram.snd (Automatic.enc (α := α)) _root_.Integration9_9.TM2NativeFiniteSeries.ticksCode).comp (_root_.Integration9_9.TM2NativeTupleEnumeration.enumerationProgram k)
  exact (((context.fanout words).comp (leaf.listMapWith [] (0 : ℚ))).comp PolyProgram.ratSum)

end Integration9_9.TM2NativeTupleEnumeration

end

section



























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.RationalBackgroundTable
end CurrentAFT.RationalBackgroundTable
namespace CurrentAFT.RationalBackgroundTable.firstTable
end CurrentAFT.RationalBackgroundTable.firstTable
namespace CurrentAFT.RationalFamilyProductProgram
end CurrentAFT.RationalFamilyProductProgram
namespace CurrentAFT.RationalFamilyProductProgram.binomial
end CurrentAFT.RationalFamilyProductProgram.binomial
namespace CurrentAFT.RationalFamilyProductProgram.power
end CurrentAFT.RationalFamilyProductProgram.power
namespace CurrentAFT.RationalFamilyProductProgram.power.match_1
end CurrentAFT.RationalFamilyProductProgram.power.match_1
namespace CurrentAFT.RationalFamilyProductProgram.reciprocal
end CurrentAFT.RationalFamilyProductProgram.reciprocal
namespace CurrentAFT.RationalFamilyProductProgram.unit
end CurrentAFT.RationalFamilyProductProgram.unit




set_option autoImplicit false
set_option maxHeartbeats 3000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2NativeRootGroupAlgebra
open AFT CurrentAFT CurrentAFT.ControlCoordinates GradedControlAlgebra
open CurrentAFT.RationalFamilyProductProgram
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open scoped BigOperators

 theorem finite_sum_poly {α ι : Type} [Coding α] (s : Finset ι) (f : ι → α → ℚ)
    (hf : ∀ i ∈ s, Poly (f i)) : Poly (fun x => ∑ i ∈ s, f i x) := by
  classical
  induction s using Finset.induction_on with
  | empty => simpa using (Automatic.Poly.const (α := α) (0:ℚ))
  | @insert i s hi ih =>
    have hx := hf i (by simp)
    have hs := ih (fun j hj => hf j (by simp [hj]))
    simp only [Finset.sum_insert hi]
    fun_prop

 theorem tuple_poly {α β : Type} [Coding α] [Coding β] [Inhabited β]
    {n : ℕ} (f : Fin n → α → β) (hf : ∀ i, Poly (f i)) :
    Poly (fun x => List.ofFn (fun i => f i x)) := by
  induction n with
  | zero => simpa only [List.ofFn_zero] using (Automatic.Poly.const (α := α) ([] : List β))
  | succ n ih =>
    have h0 := hf 0
    have ht := ih (fun i x => f i.succ x) (fun i => hf i.succ)
    simp only [List.ofFn_succ]
    fun_prop

abbrev Query (α : Type) := α × (List ℕ × List ℕ)

def evaluate {α : Type} {order : ℕ} (F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order)
    (arity : _root_.CurrentAFT.GradedControlAlgebra.TruncatedArity order) (x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α) : ℚ :=
  F x.1 arity (fun i => (x.2.1[i.val]?).getD 0) (fun i => (x.2.2[i.val]?).getD 0)

def IsPoly {α : Type} [Coding α] (order : ℕ) (F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order) : Prop :=
  ∀ arity, Poly (_root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate F arity)

namespace IsPoly
variable {α : Type} [Coding α] {order : ℕ}

 theorem reindex {F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} (h : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (arity : _root_.CurrentAFT.GradedControlAlgebra.TruncatedArity order)
    (primary : Fin arity.val.1.val → ℕ) (body : Fin arity.val.2.val → ℕ) :
    Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α => F x.1 arity
      (fun i => (x.2.1[primary i]?).getD 0) (fun i => (x.2.2[body i]?).getD 0)) := by
  have hp := _root_.Integration9_9.TM2NativeRootGroupAlgebra.tuple_poly (fun i (x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α) => (x.2.1[primary i]?).getD 0) (by intro i; fun_prop)
  have hb := _root_.Integration9_9.TM2NativeRootGroupAlgebra.tuple_poly (fun i (x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α) => (x.2.2[body i]?).getD 0) (by intro i; fun_prop)
  have hq : Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α => (x.1,List.ofFn (fun i => (x.2.1[primary i]?).getD 0),
      List.ofFn (fun i => (x.2.2[body i]?).getD 0))) := by fun_prop
  have hh := Automatic.Poly.comp (f := _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate F arity) (g := fun x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α =>
    (x.1,List.ofFn (fun i => (x.2.1[primary i]?).getD 0), List.ofFn (fun i => (x.2.2[body i]?).getD 0))) (h arity) hq
  simpa only [_root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate, List.getElem?_ofFn, Fin.isLt, dif_pos, Option.getD_some] using hh

 theorem comp {β : Type} [Coding β] {F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} {g : β → α}
    (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (hg : Poly g) : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun b => F (g b)) := by
  intro arity
  have h := Automatic.Poly.comp (f := _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate F arity)
    (g := fun x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query β => (g x.1,x.2)) (hF arity) (by fun_prop)
  exact h

 theorem firstTable {f g : α × ℕ → ℚ} (hf : Poly f) (hg : Poly g) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun a => _root_.CurrentAFT.RationalBackgroundTable.firstTable order (fun i => f (a,i)) (fun i => g (a,i))) := by
  intro arity
  unfold _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate _root_.CurrentAFT.RationalBackgroundTable.firstTable
  by_cases hp : arity.val.1.val = 1 ∧ arity.val.2.val = 0
  · simp [hp]; fun_prop
  · by_cases hb : arity.val.1.val = 0 ∧ arity.val.2.val = 1
    · simp [hp,hb]; fun_prop
    · simp [hp,hb]; fun_prop

 

 theorem unit : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly (α := α) order (fun _ => _root_.CurrentAFT.RationalFamilyProductProgram.unit order) := by
  intro arity
  exact Automatic.Poly.const _

 theorem add {F G : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (hG : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order G) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun a => F a + G a) := by
  intro arity
  have hf := hF arity
  have hg := hG arity
  change Poly (fun x => _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate F arity x + _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate G arity x)
  fun_prop

 theorem sub {F G : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (hG : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order G) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun a => F a - G a) := by
  intro arity
  have hf := hF arity
  have hg := hG arity
  change Poly (fun x => _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate F arity x - _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate G arity x)
  fun_prop

 theorem scale {F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} {c : α → ℚ} (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (hc : Poly c) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun a arity colors centers => c a * F a arity colors centers) := by
  intro arity
  have hf := hF arity
  change Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α => c x.1 * _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate F arity x)
  fun_prop

 theorem sum {ι : Type} (s : Finset ι) (F : ι → α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order)
    (h : ∀ i ∈ s, _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (F i)) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun x arity colors centers => ∑ i ∈ s, F i x arity colors centers) := by
  intro arity
  exact _root_.Integration9_9.TM2NativeRootGroupAlgebra.finite_sum_poly s (fun i => _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate (F i) arity) (fun i hi => h i hi arity)

 theorem product {F G : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (hG : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order G) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun a => _root_.CurrentAFT.RationalFamilyProductProgram.product order (F a) (G a)) := by
  classical
  intro output
  unfold _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate _root_.CurrentAFT.RationalFamilyProductProgram.product
  apply _root_.Integration9_9.TM2NativeRootGroupAlgebra.finite_sum_poly
  intro left _
  apply _root_.Integration9_9.TM2NativeRootGroupAlgebra.finite_sum_poly
  intro right _
  by_cases hm : left.val.1.val+right.val.1.val=output.val.1.val ∧
      left.val.2.val+right.val.2.val=output.val.2.val
  · simp only [dif_pos hm]
    unfold _root_.CurrentAFT.RationalFamilyProductProgram.homogeneous _root_.CurrentAFT.RationalFamilyProductProgram.average
    have hs : Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupAlgebra.Query α => ∑ p : Equiv.Perm (Fin (left.val.1.val+right.val.1.val)),
        ∑ b : Equiv.Perm (Fin (left.val.2.val+right.val.2.val)),
          _root_.CurrentAFT.RationalFamilyProductProgram.tensor (F x.1 left) (G x.1 right)
            ((fun i => (x.2.1[i.val]?).getD 0) ∘ finCongr hm.1 ∘ p)
            ((fun i => (x.2.2[i.val]?).getD 0) ∘ finCongr hm.2 ∘ b)) := by
      apply _root_.Integration9_9.TM2NativeRootGroupAlgebra.finite_sum_poly
      intro p _
      apply _root_.Integration9_9.TM2NativeRootGroupAlgebra.finite_sum_poly
      intro b _
      have hf := hF.reindex left
        (fun i => (finCongr hm.1 (p (finSumFinEquiv (.inl i)))).val)
        (fun i => (finCongr hm.2 (b (finSumFinEquiv (.inl i)))).val)
      have hg := hG.reindex right
        (fun i => (finCongr hm.1 (p (finSumFinEquiv (.inr i)))).val)
        (fun i => (finCongr hm.2 (b (finSumFinEquiv (.inr i)))).val)
      unfold _root_.CurrentAFT.RationalFamilyProductProgram.tensor
      dsimp only [Function.comp_def]
      exact Automatic.Poly.comp (f := fun y : ℚ × ℚ => y.1*y.2)
        Automatic.Poly.rat_mul (Automatic.Poly.pair hf hg)
    fun_prop
  · simp only [dif_neg hm]
    exact Automatic.Poly.const 0

 theorem power {F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (n : ℕ) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun a => _root_.CurrentAFT.RationalFamilyProductProgram.power order (F a) n) := by
  induction n with
  | zero => exact _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly.unit
  | succ n ih => exact ih.product hF

 theorem reciprocal {F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun a => _root_.CurrentAFT.RationalFamilyProductProgram.reciprocal order (F a)) := by
  apply _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly.sum
  intro n hn
  exact (_root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly.unit.sub hF).power n

end IsPoly
end Integration9_9.TM2NativeRootGroupAlgebra

end

section































































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.CoefficientHilbert
end CurrentAFT.CoefficientHilbert
namespace CurrentAFT.CoefficientHilbert.centerLinear
end CurrentAFT.CoefficientHilbert.centerLinear
namespace CurrentAFT.RationalOrdinaryProfileProgram
end CurrentAFT.RationalOrdinaryProfileProgram
namespace CurrentAFT.RationalOrdinaryProfileProgram.preRoot
end CurrentAFT.RationalOrdinaryProfileProgram.preRoot
namespace CurrentAFT.RationalOrdinaryProfileProgram.shifted
end CurrentAFT.RationalOrdinaryProfileProgram.shifted
namespace CurrentAFT.RationalRootProfileProgram
end CurrentAFT.RationalRootProfileProgram
namespace CurrentAFT.RationalRootProfileProgram.approximatePreRoot
end CurrentAFT.RationalRootProfileProgram.approximatePreRoot
namespace CurrentAFT.RationalRootProfileProgram.deviation
end CurrentAFT.RationalRootProfileProgram.deviation
namespace CurrentAFT.RationalRootProfileProgram.mean
end CurrentAFT.RationalRootProfileProgram.mean
namespace CurrentAFT.RationalRootProfileProgram.meanDeviation
end CurrentAFT.RationalRootProfileProgram.meanDeviation
namespace CurrentAFT.RationalRootProfileProgram.preRoot
end CurrentAFT.RationalRootProfileProgram.preRoot
namespace CurrentAFT.RationalRootProfileProgram.preRoot.match_1
end CurrentAFT.RationalRootProfileProgram.preRoot.match_1
namespace CurrentAFT.RationalRootProfileProgram.shifted
end CurrentAFT.RationalRootProfileProgram.shifted





set_option autoImplicit false
set_option maxHeartbeats 3000000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2NativeRootGroupProfiles
open AFT AFT.RationalNumerics AFT.BinaryArithmetic CurrentAFT
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeSliceProbability
open scoped BigOperators
attribute [local irreducible] TM2NativePrime.modulus TM2NativePrime.upperSlots

abbrev Meta := _root_.Integration9_9.TM2NativeFirstInverse.Meta
abbrev Query (α : Type) := (_root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × α) × ℕ

theorem list_sum_poly {α : Type} [Coding α] {f : α → List ℚ} (hf : Poly f) :
    Poly (fun x => (f x).sum) := ⟨hf.program.comp PolyProgram.ratSum⟩

def paletteSum {α : Type} [Coding α] (f : (_root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × α) × ℕ → ℚ) (x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × α) : ℚ :=
  ∑ i : Fin (_root_.CurrentAFT.PublicParameterProgram.modulus x.1.1.length).count, f (x,i.val)

@[fun_prop] theorem palette_sum_poly {α : Type} [Coding α] {f : (_root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × α) × ℕ → ℚ} (hf : Poly f) :
    Poly (_root_.Integration9_9.TM2NativeRootGroupProfiles.paletteSum f) := by
  have hi : Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × α => _root_.Integration9_9.TM2NativeAnchor.indices x.1) := by fun_prop
  have hs := _root_.Integration9_9.TM2NativeRootGroupProfiles.list_sum_poly (show Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × α =>
    (_root_.Integration9_9.TM2NativeAnchor.indices x.1).map (fun i => f (x,i))) by fun_prop)
  refine ⟨hs.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeRootGroupProfiles.paletteSum,_root_.Integration9_9.TM2NativeAnchor.indices,_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks_length,
    ← _root_.CurrentAFT.PublicParameterProgram.modulus_value,_root_.Integration9_9.TM2NativeProfile.sum_range]

def primary (x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × ℕ) : ℚ := _root_.CurrentAFT.RationalProposalProgram.primary x.1.1.length x.1.2.length x.2
@[fun_prop] theorem primary_poly : Poly _root_.Integration9_9.TM2NativeRootGroupProfiles.primary :=
  ⟨_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint_poly.program.congr _ _root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint_value⟩

def anchor (x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × (ℕ × ℕ)) : ℚ := _root_.CurrentAFT.RationalProposalProgram.anchor x.1.1.length x.1.2.length x.2.1 x.2.2
@[fun_prop] theorem anchor_poly : Poly _root_.Integration9_9.TM2NativeRootGroupProfiles.anchor := by
  refine ⟨_root_.Integration9_9.TM2NativeAnchor.currentProgram.congr _ (fun x => ?_)⟩
  unfold _root_.Integration9_9.TM2NativeRootGroupProfiles.anchor
  rw [_root_.Integration9_9.TM2NativeAnchor.current_value, _root_.CurrentAFT.BinaryAnchorProgram.current_value, _root_.AFT.BinaryArithmetic.canonicalCounter_value]

def compensation (x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta) : ℚ := _root_.CurrentAFT.RationalProposalProgram.compensationApprox x.1.length x.2.length
@[fun_prop] theorem compensation_poly : Poly _root_.Integration9_9.TM2NativeRootGroupProfiles.compensation := by
  refine ⟨_root_.Integration9_9.TM2NativeReferenceTables.compensation_poly.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeRootGroupProfiles.compensation,_root_.Integration9_9.TM2NativeReferenceTables.compensation,_root_.Integration9_9.TM2NativePrimary.legs,_root_.Integration9_9.TM2NativePrimary.population,
    _root_.Integration9_9.TM2NativePrimary.colors,_root_.Integration9_9.TM2NativePrime.modulus_value,_root_.Integration9_9.TM2NativeActivation.current_value,
    _root_.CurrentAFT.BinaryActivationProgram.current_value,_root_.CurrentAFT.RationalProposalProgram.compensationApprox,_root_.CurrentAFT.PublicParameterProgram.modulus_value]

def safe (x : List Unit × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundProfiles.safe x.1.length x.2
@[fun_prop] theorem safe_poly : Poly _root_.Integration9_9.TM2NativeRootGroupProfiles.safe := by
  have h : Poly (fun x : List Unit × ℕ => _root_.Integration9_9.TM2NativeSliceProbability.slice
    (((_root_.Integration9_9.TM2NativePrime.modulus x.1 : ℤ),(_root_.Integration9_9.TM2NativeBody.margin x.1 : ℤ)),((0 : ℤ),(x.2 : ℤ)))) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeRootGroupProfiles.safe,_root_.Integration9_9.TM2NativeSliceProbability.slice,_root_.CurrentAFT.RationalBackgroundProfiles.safe,_root_.CurrentAFT.RationalProposalProgram.safeEntry,
    _root_.Integration9_9.TM2NativePrime.modulus_native,_root_.Integration9_9.TM2NativeBody.margin_value,_root_.CurrentAFT.RationalBackgroundProfiles.margin,
    _root_.CurrentAFT.RationalBackgroundProfiles.colors]

def center (x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × ℕ) : ℚ := _root_.CurrentAFT.RationalProposalProgram.center x.1.1.length x.1.2.length x.2
@[fun_prop] theorem center_poly : Poly _root_.Integration9_9.TM2NativeRootGroupProfiles.center := by
  have hl : Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × ℕ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupProfiles.primary (x.1.1,x.2)*_root_.Integration9_9.TM2NativeRootGroupProfiles.anchor (x.1.1,(x.2,x.1.2))) := by fun_prop
  have hs := _root_.Integration9_9.TM2NativeRootGroupProfiles.palette_sum_poly hl
  change Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × ℕ => (1+_root_.Integration9_9.TM2NativeRootGroupProfiles.compensation x.1)*_root_.Integration9_9.TM2NativeRootGroupProfiles.safe (x.1.1,x.2)-_root_.Integration9_9.TM2NativeRootGroupProfiles.compensation x.1*
    _root_.Integration9_9.TM2NativeRootGroupProfiles.paletteSum (fun y : (_root_.Integration9_9.TM2NativeRootGroupProfiles.Meta × ℕ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupProfiles.primary (y.1.1,y.2)*_root_.Integration9_9.TM2NativeRootGroupProfiles.anchor (y.1.1,(y.2,y.1.2))) x)
  fun_prop

def inverseShift (x : List Unit × (ℤ × ℕ)) : ℕ := _root_.CurrentAFT.RationalBackgroundProfiles.inverseShift x.1.length x.2.1 x.2.2
@[fun_prop] theorem inverseShift_poly : Poly _root_.Integration9_9.TM2NativeRootGroupProfiles.inverseShift := by
  have h : Poly (fun x : List Unit × (ℤ × ℕ) =>
    _root_.Integration9_9.TM2NativeBodyKernel.emodNatural ((x.2.2 : ℤ)-x.2.1,_root_.Integration9_9.TM2NativePrime.modulus x.1)) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeRootGroupProfiles.inverseShift,_root_.Integration9_9.TM2NativeBodyKernel.emodNatural_eq,_root_.Integration9_9.TM2NativePrime.modulus_native,
    _root_.CurrentAFT.RationalBackgroundProfiles.inverseShift,_root_.CurrentAFT.RationalBackgroundProfiles.colors]

def shifted (x : List Unit × (ℤ × ℕ)) : ℚ := _root_.CurrentAFT.RationalBackgroundProfiles.shifted x.1.length x.2.1 x.2.2
@[fun_prop] theorem shifted_poly : Poly _root_.Integration9_9.TM2NativeRootGroupProfiles.shifted := by
  have h : Poly (fun x : List Unit × (ℤ × ℕ) =>
    _root_.Integration9_9.TM2NativeBodyKernel.current ((_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks x.1,_root_.Integration9_9.TM2NativeBody.margin x.1),x.2)) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeRootGroupProfiles.shifted,_root_.Integration9_9.TM2NativeBodyKernel.current_value,_root_.Integration9_9.TM2NativeBodyKernel.paletteTicks_length,
    ← _root_.CurrentAFT.PublicParameterProgram.modulus_value,_root_.Integration9_9.TM2NativeBody.margin_value,_root_.CurrentAFT.RationalBackgroundProfiles.shifted,
    _root_.CurrentAFT.RationalBackgroundProfiles.colors,_root_.CurrentAFT.RationalBackgroundProfiles.margin]

/-- A total mass lift, including output coordinates outside the palette.
The profile is evaluated directly at the requested output; only the rank-one
functional enumerates the generated finite palette. -/
theorem massLift_poly {α : Type} [Coding α] {f : _root_.Integration9_9.TM2NativeRootGroupProfiles.Query α → ℚ} (hf : Poly f) :
    Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Query α => _root_.CurrentAFT.RationalMassLiftProgram.current x.1.1.1.length x.1.1.2.length
      (fun i => f (x.1,i)) x.2) := by
  have hl : Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Query α => _root_.Integration9_9.TM2NativeFirstInverse.anchorSign
    (_root_.Integration9_9.TM2NativePrime.modulus x.1.1.1,x.2)*f x) := by fun_prop
  have hs := _root_.Integration9_9.TM2NativeRootGroupProfiles.palette_sum_poly hl
  have h : Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupProfiles.Query α =>
      (f x-_root_.Integration9_9.TM2NativeRootGroupProfiles.paletteSum (fun y : _root_.Integration9_9.TM2NativeRootGroupProfiles.Query α => _root_.Integration9_9.TM2NativeFirstInverse.anchorSign
        (_root_.Integration9_9.TM2NativePrime.modulus y.1.1.1,y.2)*f y) x.1 /
        _root_.Integration9_9.TM2NativeFirstInverse.denominator x.1.1*_root_.Integration9_9.TM2NativeFirstInverse.sign (x.1.1,x.2)) /
      (_root_.Integration9_9.TM2NativeActivation.current x.1.1*_root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint (x.1.1,x.2))) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeRootGroupProfiles.paletteSum,_root_.Integration9_9.TM2NativeFirstInverse.denominator_value,_root_.Integration9_9.TM2NativeFirstInverse.sign_value,
    _root_.Integration9_9.TM2NativeDensityInverseColumn.primaryPoint_value,_root_.Integration9_9.TM2NativeActivation.current_value,_root_.CurrentAFT.BinaryActivationProgram.current_value,
    _root_.Integration9_9.TM2NativePrime.modulus_native,_root_.CurrentAFT.RationalMassLiftProgram.current,_root_.CurrentAFT.RationalFirstResponseProgram.inverse,
    _root_.CurrentAFT.RationalFirstResponseProgram.functional,_root_.CurrentAFT.RationalFirstResponseProgram.anchorSign,_root_.Integration9_9.TM2NativeFirstInverse.anchorSign]

end Integration9_9.TM2NativeRootGroupProfiles

end

section































































set_option autoImplicit false
set_option maxHeartbeats 3000000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2NativeRootGroupGaussian
open AFT AFT.RationalNumerics AFT.BinaryArithmetic CurrentAFT
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeRootGroupProfiles
open scoped BigOperators

abbrev Meta := _root_.Integration9_9.TM2NativeFirstInverse.Meta

def cutoff (edge : Bool) (security : ℕ) : ℕ :=
  if edge then _root_.CurrentAFT.DiffuseProfiles.edgeCutoff security else _root_.CurrentAFT.Parameters.sourceCutoff security-1

def gaussian (edge : Bool) (x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta) : List ℚ :=
  if edge then _root_.Integration9_9.TM2NativeGaussianWindow.current (_root_.Integration9_9.TM2NativeProfile.edgeRequest (x,(false,0)))
  else _root_.Integration9_9.TM2NativeGaussianWindow.current (_root_.Integration9_9.TM2NativeProfile.scalarRequest (x,(false,0)))
@[fun_prop] theorem gaussian_poly (edge : Bool) : Poly (_root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian edge) := by
  unfold _root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian
  cases edge <;> simp only [Bool.false_eq_true,ite_false,ite_true] <;> fun_prop

theorem gaussian_eq (edge : Bool) (x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta) : _root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian edge x=
    _root_.Integration9_9.TM2NativeProfile.gaussianList x.1.length (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.length) x.2.length := by
  cases edge <;> simp only [_root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian,Bool.false_eq_true,ite_false,ite_true,
    _root_.Integration9_9.TM2NativeProfile.window_semantics,_root_.Integration9_9.TM2NativeProfile.edgeCutoff,_root_.Integration9_9.TM2NativeProfile.scalarCutoff,
    _root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff,_root_.CurrentAFT.DiffuseProfiles.edgeCutoff,_root_.CurrentAFT.Parameters.sourceCutoff,_root_.CurrentAFT.Parameters.base] <;> rfl
  
def windowAverage {α : Type} (edge : Bool) (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × ℤ → ℚ) (x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) : ℚ :=
  ((List.range (_root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian edge x.1).length).map (fun i : ℕ =>
    (_root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian edge x.1)[i]?.getD 0*f (x,(i : ℤ)-((_root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian edge x.1).length/2 : ℕ)))).sum

@[fun_prop] theorem windowAverage_poly {α : Type} [Coding α] (edge : Bool)
    {f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × ℤ → ℚ} (hf : Poly f) : Poly (_root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage edge f) := by
  have hi : Poly (fun x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α => List.range (_root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian edge x.1).length) :=
    Poly.comp (f := fun xs : List ℚ => List.range xs.length) (Poly.list_indices (α := ℚ)) (by fun_prop)
  unfold _root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage
  apply _root_.Integration9_9.TM2NativeRootGroupProfiles.list_sum_poly
  fun_prop

theorem windowAverage_eq {α : Type} (edge : Bool) (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × ℤ → ℚ) (x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) :
    _root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage edge f x=∑i : Fin (2*_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length+1),
      _root_.CurrentAFT.RationalProposalProgram.gaussianWeight x.1.1.length (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length) x.1.2.length
        (_root_.AFT.FiniteConvolutionProgram.windowIndexEquiv _ i)*
      f (x,(_root_.AFT.FiniteConvolutionProgram.windowIndexEquiv (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length) i).val) := by
  simp only [_root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage,_root_.Integration9_9.TM2NativeRootGroupGaussian.gaussian_eq,_root_.Integration9_9.TM2NativeProfile.gaussianList,List.length_ofFn,_root_.Integration9_9.TM2NativeProfile.sum_range]
  apply Finset.sum_congr rfl
  intro i _
  have hi := i.isLt
  have hd : (2*_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length+1)/2=_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length := by omega
  simp only [List.getElem?_ofFn,hi,dif_pos,Option.getD_some,hd,
    _root_.CurrentAFT.RationalProposalProgram.gaussianWeight,_root_.CurrentAFT.CurrentGaussianBits.table_value,Equiv.symm_apply_apply]
  rfl

theorem windowAverage_eq_window {α : Type} (edge : Bool) (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × ℤ → ℚ) (x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) :
    _root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage edge f x=∑point : _root_.AFT.GaussianSource.Window (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length),
      _root_.CurrentAFT.RationalProposalProgram.gaussianWeight x.1.1.length (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length) x.1.2.length point*
      f (x,point.val) := by
  rw [_root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage_eq]
  exact (_root_.AFT.FiniteConvolutionProgram.windowIndexEquiv (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length)).sum_comp
    (fun point : _root_.AFT.GaussianSource.Window (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length) =>
      _root_.CurrentAFT.RationalProposalProgram.gaussianWeight x.1.1.length (_root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff edge x.1.1.length) x.1.2.length point*f (x,point.val))

/-- Compile a complete current scalar average, including generation of its
Gaussian table, from a genuine polynomial-time integer-argument leaf. -/
noncomputable def scalarProgram {α : Type} [Coding α] {f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × ℤ → ℚ}
    (leaf : PolyProgram Automatic.enc Ratio.encode f) :
    PolyProgram Automatic.enc Ratio.encode (fun x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α =>
      ∑i : Fin (2*((x.1.1.length+2)^2-1)+1),
        _root_.CurrentAFT.RationalProposalProgram.gaussianWeight x.1.1.length ((x.1.1.length+2)^2-1) x.1.2.length
          (_root_.AFT.FiniteConvolutionProgram.windowIndexEquiv _ i)*
        f (x,(_root_.AFT.FiniteConvolutionProgram.windowIndexEquiv ((x.1.1.length+2)^2-1) i).val)) :=
  (_root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage_poly false ⟨leaf⟩).program.congr _ (fun x => by exact _root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage_eq false f x)

abbrev Seed := (ℤ × ℤ) × ℤ

def scalarLeaf {α : Type} (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ) (x : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × (α × (ℤ × ℤ))) × ℤ) : ℚ :=
  f ((x.1.1,x.1.2.1),(x.1.2.2,x.2))
def rightLeaf {α : Type} (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ) (x : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × (α × ℤ)) × ℤ) : ℚ :=
  _root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage false (_root_.Integration9_9.TM2NativeRootGroupGaussian.scalarLeaf f) (x.1.1,(x.1.2.1,(x.1.2.2,x.2)))
def leftLeaf {α : Type} (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ) (x : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × ℤ) : ℚ :=
  _root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage true (_root_.Integration9_9.TM2NativeRootGroupGaussian.rightLeaf f) (x.1.1,(x.1.2,x.2))
def seedAverage {α : Type} (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ) : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α → ℚ := _root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage true (_root_.Integration9_9.TM2NativeRootGroupGaussian.leftLeaf f)

@[fun_prop] theorem scalarLeaf_poly {α : Type} [Coding α] {f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ} (hf : Poly f) :
    Poly (_root_.Integration9_9.TM2NativeRootGroupGaussian.scalarLeaf f) := by unfold _root_.Integration9_9.TM2NativeRootGroupGaussian.scalarLeaf;fun_prop
@[fun_prop] theorem rightLeaf_poly {α : Type} [Coding α] {f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ} (hf : Poly f) :
    Poly (_root_.Integration9_9.TM2NativeRootGroupGaussian.rightLeaf f) := by unfold _root_.Integration9_9.TM2NativeRootGroupGaussian.rightLeaf;fun_prop
@[fun_prop] theorem leftLeaf_poly {α : Type} [Coding α] {f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ} (hf : Poly f) :
    Poly (_root_.Integration9_9.TM2NativeRootGroupGaussian.leftLeaf f) := by unfold _root_.Integration9_9.TM2NativeRootGroupGaussian.leftLeaf;fun_prop
@[fun_prop] theorem seedAverage_poly {α : Type} [Coding α] {f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ} (hf : Poly f) :
    Poly (_root_.Integration9_9.TM2NativeRootGroupGaussian.seedAverage f) := by unfold _root_.Integration9_9.TM2NativeRootGroupGaussian.seedAverage;fun_prop

theorem seedAverage_eq {α : Type} (f : (_root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ) (x : _root_.Integration9_9.TM2NativeRootGroupGaussian.Meta × α) :
    _root_.Integration9_9.TM2NativeRootGroupGaussian.seedAverage f x=_root_.CurrentAFT.RationalProposalProgram.seedEvaluate x.1.1.length x.1.2.length
      (fun seed => f (x,((seed.1.1.val,seed.1.2.val),seed.2.val))) := by
  simp only [_root_.Integration9_9.TM2NativeRootGroupGaussian.seedAverage,_root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage_eq_window,_root_.Integration9_9.TM2NativeRootGroupGaussian.leftLeaf,_root_.Integration9_9.TM2NativeRootGroupGaussian.rightLeaf,_root_.Integration9_9.TM2NativeRootGroupGaussian.scalarLeaf,
    _root_.Integration9_9.TM2NativeRootGroupGaussian.cutoff,Bool.false_eq_true,ite_false,ite_true,_root_.CurrentAFT.RationalProposalProgram.seedEvaluate_eq_window_sum,
    Fintype.sum_prod_type,_root_.CurrentAFT.RationalProposalProgram.seedWeight,Finset.mul_sum]
  apply Finset.sum_congr rfl
  intro left _
  apply Finset.sum_congr rfl
  intro right _
  apply Finset.sum_congr rfl
  intro scalar _
  simp only [mul_assoc]
  rfl

end Integration9_9.TM2NativeRootGroupGaussian

end

section






























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.RationalActualFamilyApproximation
end CurrentAFT.RationalActualFamilyApproximation
namespace CurrentAFT.RationalActualFamilyApproximation.interpret
end CurrentAFT.RationalActualFamilyApproximation.interpret
namespace CurrentAFT.RationalFamilyProductProgram
end CurrentAFT.RationalFamilyProductProgram
namespace CurrentAFT.RationalFamilyProductProgram.pullback
end CurrentAFT.RationalFamilyProductProgram.pullback
namespace CurrentAFT.RationalMassLiftProgram
end CurrentAFT.RationalMassLiftProgram
namespace CurrentAFT.RationalMassLiftProgram.actual
end CurrentAFT.RationalMassLiftProgram.actual
namespace CurrentAFT.RationalOrdinaryFamilyProgram
end CurrentAFT.RationalOrdinaryFamilyProgram
namespace CurrentAFT.RationalOrdinaryFamilyProgram.bodyFirst
end CurrentAFT.RationalOrdinaryFamilyProgram.bodyFirst
namespace CurrentAFT.RationalOrdinaryFamilyProgram.first
end CurrentAFT.RationalOrdinaryFamilyProgram.first
namespace CurrentAFT.RationalOrdinaryFamilyProgram.firstActual
end CurrentAFT.RationalOrdinaryFamilyProgram.firstActual
namespace CurrentAFT.RationalSingletonProgram
end CurrentAFT.RationalSingletonProgram
namespace CurrentAFT.RationalSingletonProgram.first
end CurrentAFT.RationalSingletonProgram.first
namespace CurrentAFT.RationalSingletonProgram.positive
end CurrentAFT.RationalSingletonProgram.positive
namespace CurrentAFT.RootMeanPrimary
end CurrentAFT.RootMeanPrimary
namespace CurrentAFT.RootMeanPrimary.positiveAtom
end CurrentAFT.RootMeanPrimary.positiveAtom
namespace CurrentAFT.RootMeanPrimary.positiveFamily
end CurrentAFT.RootMeanPrimary.positiveFamily
namespace CurrentAFT.RootReferenceColumns
end CurrentAFT.RootReferenceColumns
namespace CurrentAFT.RootReferenceColumns.singletonFirstAt
end CurrentAFT.RootReferenceColumns.singletonFirstAt




set_option autoImplicit false
set_option maxHeartbeats 3000000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2NativeRootGroupRoles
open AFT AFT.RationalNumerics AFT.BinaryArithmetic CurrentAFT
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeRootGroupProfiles TM2NativeRootGroupGaussian
open UniformBodyProfiles (BodyRole)
open scoped BigOperators

abbrev Meta := _root_.Integration9_9.TM2NativeFirstInverse.Meta

def attachment (x : _root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℕ) : ℚ := _root_.CurrentAFT.RationalRootProfileProgram.attachment x.1.1.length x.1.2.length x.2
@[fun_prop] theorem attachment_poly : Poly _root_.Integration9_9.TM2NativeRootGroupRoles.attachment := by
  have h : Poly (fun y : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℕ) × ℤ => _root_.Integration9_9.TM2NativeRootGroupProfiles.shifted (y.1.1.1,(y.2,y.1.2))) := by fun_prop
  refine ⟨(_root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage_poly false h).program.congr _ (fun x => ?_)⟩
  rw [_root_.Integration9_9.TM2NativeRootGroupGaussian.windowAverage_eq]
  rfl

def preRoot (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalRootProfileProgram.preRoot x.1.1.1.length x.1.1.2.length role x.1.2 x.2
@[fun_prop] theorem preRoot_poly (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) : Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.preRoot role) := by
  cases role with
  | free => change Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupProfiles.center (x.1.1,x.2)); fun_prop
  | attachment => change Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupRoles.attachment (x.1.1,x.2)); fun_prop
  | queue => change Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupProfiles.shifted (x.1.1.1,(x.1.2,x.2))); fun_prop

def shifted (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℤ × ℤ)) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalRootProfileProgram.shifted x.1.1.1.length x.1.1.2.length role x.1.2.1 x.1.2.2 x.2
@[fun_prop] theorem shifted_poly (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) : Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.shifted role) := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℤ × ℤ)) × ℕ => _root_.Integration9_9.TM2NativeRootGroupRoles.preRoot role ((x.1.1,x.1.2.1),
    _root_.Integration9_9.TM2NativeRootGroupProfiles.inverseShift (x.1.1.1,(x.1.2.2,x.2))))
  fun_prop

def convolution {α : Type} (f : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × α) × ℕ → ℚ) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × α) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalBackgroundProfiles.convolution x.1.1.1.length x.1.1.2.length (fun i => f (x.1,i)) x.2
@[fun_prop] theorem convolution_poly {α : Type} [Coding α] {f : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × α) × ℕ → ℚ} (hf : Poly f) :
    Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.convolution f) := by
  let kernel : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (α × ℕ)) × _root_.Integration9_9.TM2NativeRootGroupGaussian.Seed → ℚ := fun y =>
    f ((y.1.1,y.1.2.1),_root_.Integration9_9.TM2NativeRootGroupProfiles.inverseShift (y.1.1.1,(y.2.1.1-y.2.1.2,y.1.2.2)))
  have hk : Poly kernel := by unfold kernel;fun_prop
  have h : Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × α) × ℕ => _root_.Integration9_9.TM2NativeRootGroupGaussian.seedAverage kernel (x.1.1,(x.1.2,x.2))) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  rw [_root_.Integration9_9.TM2NativeRootGroupGaussian.seedAverage_eq]
  rfl

def mean (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalRootProfileProgram.mean x.1.1.1.length x.1.1.2.length role x.1.2 x.2
@[fun_prop] theorem mean_poly (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) : Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.mean role) := _root_.Integration9_9.TM2NativeRootGroupRoles.convolution_poly (_root_.Integration9_9.TM2NativeRootGroupRoles.preRoot_poly role)

def deviation (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℤ × ℤ)) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalRootProfileProgram.deviation x.1.1.1.length x.1.1.2.length role x.1.2.1 x.1.2.2 x.2
@[fun_prop] theorem deviation_poly (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) : Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.deviation role) := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℤ × ℤ)) × ℕ => _root_.Integration9_9.TM2NativeRootGroupRoles.shifted role x - _root_.Integration9_9.TM2NativeRootGroupRoles.mean role ((x.1.1,x.1.2.1),x.2))
  fun_prop

def meanDeviation (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalRootProfileProgram.meanDeviation x.1.1.1.length x.1.1.2.length role x.1.2 x.2
@[fun_prop] theorem meanDeviation_poly (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) : Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.meanDeviation role) := by
  have h : Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupRoles.mean role x - 1/(_root_.Integration9_9.TM2NativePrime.modulus x.1.1.1 : ℚ)) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativePrime.modulus_native,_root_.Integration9_9.TM2NativeRootGroupRoles.mean,_root_.Integration9_9.TM2NativeRootGroupRoles.meanDeviation,_root_.CurrentAFT.RationalRootProfileProgram.meanDeviation]

def firstDensity (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℤ × ℤ)) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalRootProfileProgram.firstDensity x.1.1.1.length x.1.1.2.length role x.1.2.1 x.1.2.2 x.2
@[fun_prop] theorem firstDensity_poly (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) : Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.firstDensity role) := _root_.Integration9_9.TM2NativeRootGroupProfiles.massLift_poly (_root_.Integration9_9.TM2NativeRootGroupRoles.deviation_poly role)

def meanDensity (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℤ) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalRootProfileProgram.meanDensity x.1.1.1.length x.1.1.2.length role x.1.2 x.2
@[fun_prop] theorem meanDensity_poly (role : _root_.CurrentAFT.UniformBodyProfiles.BodyRole) : Poly (_root_.Integration9_9.TM2NativeRootGroupRoles.meanDensity role) := _root_.Integration9_9.TM2NativeRootGroupProfiles.massLift_poly (_root_.Integration9_9.TM2NativeRootGroupRoles.meanDeviation_poly role)

def ordinaryPreRoot (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℕ) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalOrdinaryProfileProgram.preRoot x.1.1.1.length x.1.1.2.length x.1.2 x.2
@[fun_prop] theorem ordinaryPreRoot_poly : Poly _root_.Integration9_9.TM2NativeRootGroupRoles.ordinaryPreRoot := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × ℕ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupProfiles.center x.1*((if x.2=x.1.2 then 1 else 0)-_root_.Integration9_9.TM2NativeRootGroupProfiles.center (x.1.1,x.2)))
  fun_prop

def ordinaryShifted (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℕ × ℤ)) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalOrdinaryProfileProgram.shifted x.1.1.1.length x.1.1.2.length x.1.2.1 x.1.2.2 x.2
@[fun_prop] theorem ordinaryShifted_poly : Poly _root_.Integration9_9.TM2NativeRootGroupRoles.ordinaryShifted := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℕ × ℤ)) × ℕ => _root_.Integration9_9.TM2NativeRootGroupRoles.ordinaryPreRoot ((x.1.1,x.1.2.1),
    _root_.Integration9_9.TM2NativeRootGroupProfiles.inverseShift (x.1.1.1,(x.1.2.2,x.2))))
  fun_prop

def ordinaryDensity (x : (_root_.Integration9_9.TM2NativeRootGroupRoles.Meta × (ℕ × ℤ)) × ℕ) : ℚ :=
  _root_.CurrentAFT.RationalOrdinaryProfileProgram.density x.1.1.1.length x.1.1.2.length x.1.2.1 x.1.2.2 x.2
@[fun_prop] theorem ordinaryDensity_poly : Poly _root_.Integration9_9.TM2NativeRootGroupRoles.ordinaryDensity := _root_.Integration9_9.TM2NativeRootGroupProfiles.massLift_poly _root_.Integration9_9.TM2NativeRootGroupRoles.ordinaryShifted_poly

end Integration9_9.TM2NativeRootGroupRoles

end

section






























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.RationalBackgroundDensities
end CurrentAFT.RationalBackgroundDensities
namespace CurrentAFT.RationalBackgroundDensities.bodyErrorConstant
end CurrentAFT.RationalBackgroundDensities.bodyErrorConstant
namespace CurrentAFT.RationalBackgroundDensities.primaryErrorConstant
end CurrentAFT.RationalBackgroundDensities.primaryErrorConstant
namespace CurrentAFT.RationalBackgroundDensities.residualErrorConstant
end CurrentAFT.RationalBackgroundDensities.residualErrorConstant
namespace CurrentAFT.RationalBackgroundProgram
end CurrentAFT.RationalBackgroundProgram
namespace CurrentAFT.RationalDensityInverseProgram
end CurrentAFT.RationalDensityInverseProgram
namespace CurrentAFT.RationalDensityInverseProgram.inverseBound
end CurrentAFT.RationalDensityInverseProgram.inverseBound
namespace CurrentAFT.RationalFirstResponseProgram
end CurrentAFT.RationalFirstResponseProgram
namespace CurrentAFT.RationalFirstResponseProgram.inverseErrorConstant
end CurrentAFT.RationalFirstResponseProgram.inverseErrorConstant
namespace CurrentAFT.RationalMassLiftProgram
end CurrentAFT.RationalMassLiftProgram
namespace CurrentAFT.RationalMassLiftProgram.errorConstant
end CurrentAFT.RationalMassLiftProgram.errorConstant
namespace CurrentAFT.RationalTensorInverseProgram
end CurrentAFT.RationalTensorInverseProgram
namespace CurrentAFT.RationalTensorInverseProgram.actualBound
end CurrentAFT.RationalTensorInverseProgram.actualBound



set_option autoImplicit false
set_option maxHeartbeats 3000000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2NativeBackgroundProfiles
open AFT AFT.RationalNumerics CurrentAFT
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeRootGroupAlgebra TM2NativeRootGroupProfiles TM2NativeRootGroupRoles
open scoped BigOperators
abbrev Meta := _root_.Integration9_9.TM2NativeFirstInverse.Meta

def colors (x : List Unit) : ℕ := (_root_.CurrentAFT.PublicParameterProgram.modulus x.length).count
@[fun_prop] theorem colors_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.colors :=
  ⟨_root_.Integration9_9.TM2NativePrime.modulus_poly.program.congr _ _root_.Integration9_9.TM2NativePrime.modulus_native⟩

def safeTest (x : List Unit × ℕ) : Bool := decide (_root_.CurrentAFT.RationalBackgroundProfiles.Safe x.1.length x.2)
@[fun_prop] theorem safeTest_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.safeTest := by
  have h : Poly (fun x : List Unit × ℕ => decide ((_root_.Integration9_9.TM2NativeBody.margin x.1 : ℤ) ≤ x.2 ∧
      (x.2 : ℤ) < (_root_.Integration9_9.TM2NativeBackgroundProfiles.colors x.1 : ℤ)-_root_.Integration9_9.TM2NativeBody.margin x.1)) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeBackgroundProfiles.safeTest,_root_.CurrentAFT.RationalBackgroundProfiles.Safe,_root_.CurrentAFT.RationalBackgroundProfiles.margin,_root_.Integration9_9.TM2NativeBody.margin_value,
    _root_.Integration9_9.TM2NativeBackgroundProfiles.colors,_root_.CurrentAFT.RationalBackgroundProfiles.colors]

def unsafeProfile (x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundProfiles.unsafeProfile x.1.1.1.length x.1.2 x.2
@[fun_prop] theorem unsafeProfile_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeProfile := by
  have h : Poly (fun x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ => if _root_.Integration9_9.TM2NativeBackgroundProfiles.safeTest (x.1.1.1,x.2) then (0 : ℚ)
      else _root_.Integration9_9.TM2NativeRootGroupProfiles.shifted (x.1.1.1,(x.1.2,x.2))) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  simp only [_root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeProfile,_root_.CurrentAFT.RationalBackgroundProfiles.unsafeProfile,_root_.Integration9_9.TM2NativeBackgroundProfiles.safeTest,decide_eq_true_eq,_root_.Integration9_9.TM2NativeRootGroupProfiles.shifted]

def unsafeTotal (x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) : ℚ := _root_.CurrentAFT.RationalBackgroundProfiles.unsafeTotal x.1.1.length x.2
@[fun_prop] theorem unsafeTotal_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeTotal := _root_.Integration9_9.TM2NativeRootGroupProfiles.palette_sum_poly _root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeProfile_poly

def seedProfile (x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundProfiles.seedProfile x.1.1.1.length x.1.2 x.2
@[fun_prop] theorem seedProfile_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.seedProfile := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupProfiles.shifted (x.1.1.1,(x.1.2,x.2))-
    _root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeProfile x+_root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeTotal x.1*_root_.Integration9_9.TM2NativeRootGroupProfiles.safe (x.1.1.1,x.2)-_root_.Integration9_9.TM2NativeRootGroupProfiles.safe (x.1.1.1,x.2))
  fun_prop

def body (x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℕ) : ℚ := _root_.CurrentAFT.RationalProposalProgram.body x.1.1.length x.1.2.length false x.2
@[fun_prop] theorem body_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.body := by
  have h : Poly (fun x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℕ => _root_.Integration9_9.TM2NativeBody.current (x.1,(false,x.2))) := by fun_prop
  refine ⟨h.program.congr _ (fun x => ?_)⟩
  rw [_root_.Integration9_9.TM2NativeBody.current_value, _root_.CurrentAFT.BinaryBodyProgram.current_value, _root_.AFT.BinaryArithmetic.canonicalCounter_value]
  rfl

def bodyDeviation (x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × Unit) × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundProfiles.bodyDeviation x.1.1.1.length x.1.1.2.length x.2
@[fun_prop] theorem bodyDeviation_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.bodyDeviation := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × Unit) × ℕ => _root_.Integration9_9.TM2NativeBackgroundProfiles.body (x.1.1,x.2)-1/(_root_.Integration9_9.TM2NativeBackgroundProfiles.colors x.1.1.1 : ℚ))
  fun_prop

def residual (x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundProfiles.residual x.1.1.1.length x.1.1.2.length x.1.2 x.2
@[fun_prop] theorem residual_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.residual := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeRootGroupRoles.convolution _root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeProfile x - _root_.Integration9_9.TM2NativeBackgroundProfiles.unsafeTotal x.1*_root_.Integration9_9.TM2NativeBackgroundProfiles.body (x.1.1,x.2))
  fun_prop

def primaryDensity (x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundDensities.primary x.1.1.length x.1.2.length x.2
@[fun_prop] theorem primaryDensity_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.primaryDensity := by
  have h := _root_.Integration9_9.TM2NativeRootGroupProfiles.massLift_poly _root_.Integration9_9.TM2NativeBackgroundProfiles.bodyDeviation_poly
  exact Automatic.Poly.comp (g := fun x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℕ => ((x.1,()),x.2)) h (by fun_prop)

def residualDensity (x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundDensities.residual x.1.1.1.length x.1.1.2.length x.1.2 x.2
@[fun_prop] theorem residualDensity_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.residualDensity := _root_.Integration9_9.TM2NativeRootGroupProfiles.massLift_poly _root_.Integration9_9.TM2NativeBackgroundProfiles.residual_poly

def bodyDensity (x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundDensities.body x.1.1.length x.1.2.length x.2
@[fun_prop] theorem bodyDensity_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.bodyDensity := by
  change Poly (fun x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℕ => 1-_root_.Integration9_9.TM2NativeRootGroupProfiles.safe (x.1.1,x.2)/_root_.Integration9_9.TM2NativeRootGroupProfiles.center x)
  fun_prop

def seedDensity (x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ) : ℚ := _root_.CurrentAFT.RationalBackgroundDensities.seed x.1.1.1.length x.1.1.2.length x.1.2 x.2
@[fun_prop] theorem seedDensity_poly : Poly _root_.Integration9_9.TM2NativeBackgroundProfiles.seedDensity := by
  change Poly (fun x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeBackgroundProfiles.seedProfile x / _root_.Integration9_9.TM2NativeRootGroupProfiles.center (x.1.1,x.2))
  fun_prop

theorem freeIsPoly (order : ℕ) : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta => _root_.CurrentAFT.RationalBackgroundProgram.free x.1.length x.2.length order) :=
  _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly.firstTable _root_.Integration9_9.TM2NativeBackgroundProfiles.primaryDensity_poly _root_.Integration9_9.TM2NativeBackgroundProfiles.bodyDensity_poly

theorem translationIsPoly (order : ℕ) : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ =>
    _root_.CurrentAFT.RationalBackgroundProgram.translation x.1.1.length x.1.2.length order x.2) := by
  change _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun x : _root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ => _root_.CurrentAFT.RationalBackgroundTable.firstTable order
    (fun i => _root_.Integration9_9.TM2NativeBackgroundProfiles.primaryDensity (x.1,i)+_root_.Integration9_9.TM2NativeBackgroundProfiles.residualDensity (x,i)) (fun i => _root_.Integration9_9.TM2NativeBackgroundProfiles.seedDensity (x,i)))
  apply _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly.firstTable (f := fun x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeBackgroundProfiles.primaryDensity (x.1.1,x.2)+_root_.Integration9_9.TM2NativeBackgroundProfiles.residualDensity x) (g := _root_.Integration9_9.TM2NativeBackgroundProfiles.seedDensity)
  · change Poly (fun x : (_root_.Integration9_9.TM2NativeBackgroundProfiles.Meta × ℤ) × ℕ => _root_.Integration9_9.TM2NativeBackgroundProfiles.primaryDensity (x.1.1,x.2)+_root_.Integration9_9.TM2NativeBackgroundProfiles.residualDensity x)
    fun_prop
  · exact _root_.Integration9_9.TM2NativeBackgroundProfiles.seedDensity_poly

end Integration9_9.TM2NativeBackgroundProfiles

end

section






























































namespace CurrentAFT
end CurrentAFT
namespace CurrentAFT.RationalActualFamilyApproximation
end CurrentAFT.RationalActualFamilyApproximation
namespace CurrentAFT.RationalActualFamilyApproximation.data
end CurrentAFT.RationalActualFamilyApproximation.data
namespace CurrentAFT.RationalScalarFamilyAverage
end CurrentAFT.RationalScalarFamilyAverage
namespace CurrentAFT.RationalScalarFamilyAverage.actual
end CurrentAFT.RationalScalarFamilyAverage.actual



set_option autoImplicit false
set_option maxHeartbeats 3000000
set_option maxRecDepth 10000
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2NativeBackgroundAlgebra
open AFT AFT.RationalNumerics CurrentAFT GradedControlAlgebra
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeRootGroupAlgebra TM2NativeRootGroupGaussian
open scoped BigOperators
abbrev Meta := _root_.Integration9_9.TM2NativeFirstInverse.Meta

@[fun_prop] theorem descFactorial_poly (k : ℕ) : Poly (fun n : ℕ => n.descFactorial k) := by
  induction k with
  | zero => simp only [Nat.descFactorial_zero];fun_prop
  | succ k ih => simp only [Nat.descFactorial_succ];fun_prop

@[fun_prop] theorem choose_poly (k : ℕ) : Poly (fun n : ℕ => n.choose k) := by
  simp only [Nat.choose_eq_descFactorial_div_factorial]
  fun_prop

theorem binomialIsPoly {α : Type} [Coding α] {order : ℕ}
    {F : α → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order} {n : α → ℕ}
    (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) (hn : Poly n) :
    _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun x => _root_.CurrentAFT.RationalFamilyProductProgram.binomial order (n x) (F x)) := by
  apply _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly.sum
  intro k _
  apply (hF.power k).scale
  have hk := _root_.Integration9_9.TM2NativeBackgroundAlgebra.choose_poly k
  fun_prop

theorem scalarAverageIsPoly {order : ℕ} {F : _root_.Integration9_9.TM2NativeBackgroundAlgebra.Meta × ℤ → _root_.CurrentAFT.RationalFamilyProductProgram.Table ℚ ℕ ℕ order}
    (hF : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order F) : _root_.Integration9_9.TM2NativeRootGroupAlgebra.IsPoly order (fun x : _root_.Integration9_9.TM2NativeBackgroundAlgebra.Meta =>
      _root_.CurrentAFT.RationalScalarFamilyAverage.current x.1.length x.2.length order (fun scalar => F (x,scalar))) := by
  intro arity
  have hleaf := hF arity
  let leaf : (_root_.Integration9_9.TM2NativeBackgroundAlgebra.Meta × (List ℕ × List ℕ)) × ℤ → ℚ := fun x => _root_.Integration9_9.TM2NativeRootGroupAlgebra.evaluate F arity ((x.1.1,x.2),x.1.2)
  have hl : Poly leaf := by unfold leaf;fun_prop
  refine ⟨(_root_.Integration9_9.TM2NativeRootGroupGaussian.scalarProgram hl.program).congr _ (fun x => ?_)⟩
  rfl

end Integration9_9.TM2NativeBackgroundAlgebra

end

section






























































namespace AFT
end AFT
namespace AFT.BinaryArithmetic
end AFT.BinaryArithmetic
namespace AFT.BinaryArithmetic.binaryAcceptance
end AFT.BinaryArithmetic.binaryAcceptance
namespace AFT.BinaryArithmetic.binaryAcceptanceWork
end AFT.BinaryArithmetic.binaryAcceptanceWork
namespace AFT.BinaryArithmetic.binaryRationalDraw
end AFT.BinaryArithmetic.binaryRationalDraw
namespace AFT.BinaryArithmetic.binaryRationalDrawWork
end AFT.BinaryArithmetic.binaryRationalDrawWork
namespace AFT.BinaryArithmetic.rationalAcceptance_threshold
end AFT.BinaryArithmetic.rationalAcceptance_threshold
namespace AFT.BinaryArithmetic.supplementFirst_ofFn
end AFT.BinaryArithmetic.supplementFirst_ofFn




set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 10000
set_option synthInstance.maxSize 1024
set_option backward.isDefEq.respectTransparency false

namespace Integration9_9.TM2NativeFiniteDraw
open AFT AFT.RationalNumerics AFT.BinaryArithmetic
open OAI.MetricKMedian.Binary OAI.MetricKMedian.Binary.Automatic
open TM2NativeFiniteSeries TM2NativeRootGroupProfiles
open scoped BigOperators

def floorValue (q : ℚ) : ℕ := if q<0 then 0 else q.num.natAbs/q.den







def dyadicPower (xs : List Unit) : ℕ := 2^xs.length


def dyadicFloor (x : ℚ × List Unit) : ℕ := ⌊(2 : ℚ)^x.2.length*x.1⌋₊


def natSum (xs : List ℕ) : ℕ := xs.sum


def clipped (q : ℚ) : ℚ := if q<0 then 0 else if q<1 then q else 1




def tapeValue (xs : List Bool) : ℕ := _root_.AFT.BinaryArithmetic.value xs


def ticks (xs : List Bool) : List Unit := xs.map (fun _ => ())


def acceptance (x : ℚ × List Bool) : ℕ := if _root_.Integration9_9.TM2NativeFiniteDraw.tapeValue x.2<_root_.Integration9_9.TM2NativeFiniteDraw.dyadicFloor (_root_.Integration9_9.TM2NativeFiniteDraw.clipped x.1,_root_.Integration9_9.TM2NativeFiniteDraw.ticks x.2) then 0 else 1








def bucket (x : List ℕ × ℕ) : ℕ :=
  (List.range x.1.length).findIdx (fun i => decide (x.2<(x.1.take (i+1)).sum))




end Integration9_9.TM2NativeFiniteDraw

end
Source
Companion Lean implementation for the fixed-family Gaussian affine transport theorem. The source modules and their SHA-256 hashes are recorded in the checked extraction manifest. This exact generated file has SHA-256 dd963e80a5b8529ba4d3d861c87a15dcb281d796f1031e23995720bf5593bf7a. Source modules: Integration9_9_TM2NativeAveragedSlice, Integration9_9_TM2NativeProfile, Integration9_9_TM2NativeMarkedKernel, Integration9_9_TM2NativeAnchor, Integration9_9_TM2NativeBody, Integration9_9_TM2NativePrimary, Integration9_9_TM2PolynomialBudget, Integration9_9_TM2NativeFullResponseCounts, Integration9_9_TM2NativeReferenceTables, Integration9_9_TM2NativeFirstInverse, Integration9_9_TM2NativeDensityInverseColumn, Integration9_9_TM2NativeTupleEnumeration, Integration9_9_TM2NativeRootGroupAlgebra, Integration9_9_TM2NativeRootGroupProfiles, Integration9_9_TM2NativeRootGroupGaussian, Integration9_9_TM2NativeRootGroupRoles, Integration9_9_TM2NativeBackgroundProfiles, Integration9_9_TM2NativeBackgroundAlgebra, Integration9_9_TM2NativeFiniteDraw. Alternate sparse native dependencies preserve the original non-import body bytes and all public types; this header-only packaging is recorded in sparse_live/manifest.json. Current source SHA256 0bff6efd0e607e3a9ff3d2b56bc1e0a039ffd51cfd2ea818144dace85af30ff6. Native10/11 split fallback keeps every original scope-closed data body unchanged and retains the canonical module names as import facades. Current source SHA256 0bff6efd0e607e3a9ff3d2b56bc1e0a039ffd51cfd2ea818144dace85af30ff6.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me